From 442b4b6f385258cf2b3d4687da46731bf62b2dad Mon Sep 17 00:00:00 2001 From: hunt Date: Thu, 20 Sep 2007 17:03:45 +0000 Subject: [PATCH] 2007-09-20 Martin Hunt * transport.h: Increase default buffer size. * control.c (_stp_ctl_read_cmd): Check buffer size. --- runtime/transport/ChangeLog | 5 +++++ runtime/transport/control.c | 5 ++--- runtime/transport/transport.h | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/runtime/transport/ChangeLog b/runtime/transport/ChangeLog index b720b1129..b03b4b0ae 100644 --- a/runtime/transport/ChangeLog +++ b/runtime/transport/ChangeLog @@ -1,3 +1,8 @@ +2007-09-20 Martin Hunt + + * transport.h: Increase default buffer size. + * control.c (_stp_ctl_read_cmd): Check buffer size. + 2007-09-10 Martin Hunt * procfs.c (_stp_register_ctl_channel): Call diff --git a/runtime/transport/control.c b/runtime/transport/control.c index 5242af495..6df9a8af8 100644 --- a/runtime/transport/control.c +++ b/runtime/transport/control.c @@ -195,8 +195,6 @@ _stp_ctl_read_cmd (struct file *file, char __user *buf, size_t count, loff_t *pp int len; unsigned long flags; - /* FIXME FIXME FIXME. assuming count is large enough to hold buffer!! */ - /* wait for nonempty ready queue */ spin_lock_irqsave(&_stp_ready_lock, flags); while (list_empty(&_stp_ready_q)) { @@ -215,11 +213,12 @@ _stp_ctl_read_cmd (struct file *file, char __user *buf, size_t count, loff_t *pp /* write it out */ len = bptr->len + 4; - if (copy_to_user(buf, &bptr->type, len)) { + if (len > count || copy_to_user(buf, &bptr->type, len)) { /* now what? We took it off the queue then failed to send it */ /* we can't put it back on the queue because it will likely be out-of-order */ /* fortunately this should never happen */ /* FIXME need to mark this as a transport failure */ + errk("Supplied buffer too small. count:%d len:%d\n", count, len); return -EFAULT; } diff --git a/runtime/transport/transport.h b/runtime/transport/transport.h index 78b011810..0a83001e7 100644 --- a/runtime/transport/transport.h +++ b/runtime/transport/transport.h @@ -14,8 +14,8 @@ void _stp_warn (const char *fmt, ...); /* how often the work queue wakes up and checks buffers */ #define STP_WORK_TIMER (HZ/100) -static unsigned _stp_nsubbufs = 4; -static unsigned _stp_subbuf_size = 65536*2; +static unsigned _stp_nsubbufs = 8; +static unsigned _stp_subbuf_size = 65536*4; extern void _stp_transport_close(void); extern int _stp_print_init(void); extern void _stp_print_cleanup(void); -- 2.43.5