[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-4.0-testing] trace: improve check_tbuf_size()
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1278104623 -3600 # Node ID 1972b4e9f34f2144f18e22cb783f4940b0b901b7 # Parent e26d53eb32df6227d5e893edea9cb5a2bfa5818f trace: improve check_tbuf_size() It didn't consider the case of the incoming size not allowing for the 2*data_size range for t_buf->{prod,cons} Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx> Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx> xen-unstable changeset: 21704:1390e2ab45c7 xen-unstable date: Fri Jul 02 18:53:10 2010 +0100 --- xen/common/trace.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) diff -r e26d53eb32df -r 1972b4e9f34f xen/common/trace.c --- a/xen/common/trace.c Fri Jul 02 22:02:31 2010 +0100 +++ b/xen/common/trace.c Fri Jul 02 22:03:43 2010 +0100 @@ -91,11 +91,19 @@ static void calc_tinfo_first_offset(void /** * check_tbuf_size - check to make sure that the proposed size will fit - * in the currently sized struct t_info. - */ -static inline int check_tbuf_size(int size) -{ - return (num_online_cpus() * size + t_info_first_offset) > (T_INFO_SIZE / sizeof(uint32_t)); + * in the currently sized struct t_info and allows prod and cons to + * reach double the value without overflow. + */ +static int check_tbuf_size(u32 pages) +{ + struct t_buf dummy; + typeof(dummy.prod) size; + + size = ((typeof(dummy.prod))pages) * PAGE_SIZE; + + return (size / PAGE_SIZE != pages) + || (size + size < size) + || (num_online_cpus() * pages + t_info_first_offset > T_INFO_SIZE / sizeof(uint32_t)); } /** _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |