Jan Beulich
2010-Jun-29 15:34 UTC
[Xen-devel] [PATCH 3/6] 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@novell.com> --- 2010-06-15.orig/xen/common/trace.c 2010-06-28 11:58:37.000000000 +0200 +++ 2010-06-15/xen/common/trace.c 2010-06-28 11:58:37.000000000 +0200 @@ -77,11 +77,16 @@ static u32 tb_event_mask = TRC_ALL; /** * check_tbuf_size - check to make sure that the proposed size will fit - * in the currently sized struct t_info. + * in the currently sized struct t_info and allows prod and cons to + * reach double the value without overflow. */ -static inline int check_tbuf_size(int size) +static int check_tbuf_size(u32 pages) { - return (num_online_cpus() * size + T_INFO_FIRST_OFFSET) > (T_INFO_SIZE / sizeof(uint32_t)); + u32 size = 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-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
George Dunlap
2010-Jun-30 15:15 UTC
[Xen-devel] Re: [PATCH 3/6] trace: improve check_tbuf_size()
As long as we''re being anal, we should be sure to use the actual types from prod and cons to do the check. Patch attached. -George On Tue, Jun 29, 2010 at 4:34 PM, Jan Beulich <JBeulich@novell.com> wrote:> 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@novell.com> > > --- 2010-06-15.orig/xen/common/trace.c 2010-06-28 11:58:37.000000000 +0200 > +++ 2010-06-15/xen/common/trace.c 2010-06-28 11:58:37.000000000 +0200 > @@ -77,11 +77,16 @@ static u32 tb_event_mask = TRC_ALL; > > /** > * check_tbuf_size - check to make sure that the proposed size will fit > - * in the currently sized struct t_info. > + * in the currently sized struct t_info and allows prod and cons to > + * reach double the value without overflow. > */ > -static inline int check_tbuf_size(int size) > +static int check_tbuf_size(u32 pages) > { > - return (num_online_cpus() * size + T_INFO_FIRST_OFFSET) > (T_INFO_SIZE / sizeof(uint32_t)); > + u32 size = 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-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jan Beulich
2010-Jun-30 15:20 UTC
[Xen-devel] Re: [PATCH 3/6] trace: improve check_tbuf_size()
>>> On 30.06.10 at 17:15, George Dunlap <George.Dunlap@eu.citrix.com> wrote: > As long as we''re being anal, we should be sure to use the actual types > from prod and cons to do the check. Patch attached.Okay - I didn''t want to go that far, but it''s fine by me. Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel