public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* event tracing, ringbuffer and RB_MAX_SMALL_DATA
@ 2009-07-14 17:18 Johannes Berg
  2009-07-15  1:08 ` Li Zefan
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2009-07-14 17:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Frederic Weisbecker, Steven Rostedt

[-- Attachment #1: Type: text/plain, Size: 528 bytes --]

Hi,

By code inspection, I think there's a bug if your event contains only

	__dynamic_array(u8, buf, buflen)

and your buflen is only, say, 3. Then the event size will be the common
event size (12 bytes) plus this, so 15, which is well below
RB_MAX_SMALL_DATA (4*28 = 112), so it'll be divided by four to be stored
into type_len. At this point, however, you've lost the information that
your dynamic array was only three bytes, and it'll be considered _four_
bytes long by parsers as far as I can tell?

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: event tracing, ringbuffer and RB_MAX_SMALL_DATA
  2009-07-14 17:18 event tracing, ringbuffer and RB_MAX_SMALL_DATA Johannes Berg
@ 2009-07-15  1:08 ` Li Zefan
  2009-07-15  9:48   ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Li Zefan @ 2009-07-15  1:08 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-kernel, Ingo Molnar, Frederic Weisbecker, Steven Rostedt

Johannes Berg wrote:
> Hi,
> 
> By code inspection, I think there's a bug if your event contains only
> 
> 	__dynamic_array(u8, buf, buflen)
> 
> and your buflen is only, say, 3. Then the event size will be the common
> event size (12 bytes) plus this, so 15, which is well below
> RB_MAX_SMALL_DATA (4*28 = 112), so it'll be divided by four to be stored
> into type_len. At this point, however, you've lost the information that
> your dynamic array was only three bytes, and it'll be considered _four_
> bytes long by parsers as far as I can tell?
> 

Right, the length of a dynamic array is not recorded, and this
causes 2 problems:

- the event filter is not working properly for dynamic strings
- userspace parsers can't figure out the length of those arrays

I had an idea some time ago, and hopefully will send out a
patch today or tomorrow. 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: event tracing, ringbuffer and RB_MAX_SMALL_DATA
  2009-07-15  1:08 ` Li Zefan
@ 2009-07-15  9:48   ` Johannes Berg
  2009-07-16  0:48     ` Li Zefan
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2009-07-15  9:48 UTC (permalink / raw)
  To: Li Zefan; +Cc: linux-kernel, Ingo Molnar, Frederic Weisbecker, Steven Rostedt

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

On Wed, 2009-07-15 at 09:08 +0800, Li Zefan wrote:

> Right, the length of a dynamic array is not recorded, and this
> causes 2 problems:
> 
> - the event filter is not working properly for dynamic strings
> - userspace parsers can't figure out the length of those arrays
> 
> I had an idea some time ago, and hopefully will send out a
> patch today or tomorrow. 

Well except for the corner case I pointed out, you can determine the
length of dynamic arrays by either
 - the next dynamic array's offset or
 - the length of the item.

So, afaict, the simplest solution would be to not embed the length of
the item in type_len if it's not divisible by four and contains dynamic
members, though the latter condition might be hard to check.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: event tracing, ringbuffer and RB_MAX_SMALL_DATA
  2009-07-15  9:48   ` Johannes Berg
@ 2009-07-16  0:48     ` Li Zefan
  2009-07-21  1:25       ` Steven Rostedt
  0 siblings, 1 reply; 7+ messages in thread
From: Li Zefan @ 2009-07-16  0:48 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-kernel, Ingo Molnar, Frederic Weisbecker, Steven Rostedt

Johannes Berg wrote:
> On Wed, 2009-07-15 at 09:08 +0800, Li Zefan wrote:
> 
>> Right, the length of a dynamic array is not recorded, and this
>> causes 2 problems:
>>
>> - the event filter is not working properly for dynamic strings
>> - userspace parsers can't figure out the length of those arrays
>>
>> I had an idea some time ago, and hopefully will send out a
>> patch today or tomorrow. 
> 
> Well except for the corner case I pointed out, you can determine the
> length of dynamic arrays by either
>  - the next dynamic array's offset or
>  - the length of the item.
> 
> So, afaict, the simplest solution would be to not embed the length of
> the item in type_len if it's not divisible by four and contains dynamic
> members, though the latter condition might be hard to check.
> 

Actually I'm going to encode the size of a dynamic array
in it's @offset, so the lower 16bits is offset and the
higher 16bits is size.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: event tracing, ringbuffer and RB_MAX_SMALL_DATA
  2009-07-16  0:48     ` Li Zefan
@ 2009-07-21  1:25       ` Steven Rostedt
  2009-07-21  1:30         ` Li Zefan
  0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2009-07-21  1:25 UTC (permalink / raw)
  To: Li Zefan; +Cc: Johannes Berg, linux-kernel, Ingo Molnar, Frederic Weisbecker


On Thu, 16 Jul 2009, Li Zefan wrote:

> Johannes Berg wrote:
> > On Wed, 2009-07-15 at 09:08 +0800, Li Zefan wrote:
> > 
> >> Right, the length of a dynamic array is not recorded, and this
> >> causes 2 problems:
> >>
> >> - the event filter is not working properly for dynamic strings
> >> - userspace parsers can't figure out the length of those arrays
> >>
> >> I had an idea some time ago, and hopefully will send out a
> >> patch today or tomorrow. 
> > 
> > Well except for the corner case I pointed out, you can determine the
> > length of dynamic arrays by either
> >  - the next dynamic array's offset or
> >  - the length of the item.
> > 
> > So, afaict, the simplest solution would be to not embed the length of
> > the item in type_len if it's not divisible by four and contains dynamic
> > members, though the latter condition might be hard to check.
> > 
> 
> Actually I'm going to encode the size of a dynamic array
> in it's @offset, so the lower 16bits is offset and the
> higher 16bits is size.

Was there a patch sent out to do this yet, or is this still something 
being worked on?

Thanks,

-- Steve


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: event tracing, ringbuffer and RB_MAX_SMALL_DATA
  2009-07-21  1:25       ` Steven Rostedt
@ 2009-07-21  1:30         ` Li Zefan
  2009-07-21  1:42           ` Steven Rostedt
  0 siblings, 1 reply; 7+ messages in thread
From: Li Zefan @ 2009-07-21  1:30 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Johannes Berg, linux-kernel, Ingo Molnar, Frederic Weisbecker

Steven Rostedt wrote:
> On Thu, 16 Jul 2009, Li Zefan wrote:
> 
>> Johannes Berg wrote:
>>> On Wed, 2009-07-15 at 09:08 +0800, Li Zefan wrote:
>>>
>>>> Right, the length of a dynamic array is not recorded, and this
>>>> causes 2 problems:
>>>>
>>>> - the event filter is not working properly for dynamic strings
>>>> - userspace parsers can't figure out the length of those arrays
>>>>
>>>> I had an idea some time ago, and hopefully will send out a
>>>> patch today or tomorrow. 
>>> Well except for the corner case I pointed out, you can determine the
>>> length of dynamic arrays by either
>>>  - the next dynamic array's offset or
>>>  - the length of the item.
>>>
>>> So, afaict, the simplest solution would be to not embed the length of
>>> the item in type_len if it's not divisible by four and contains dynamic
>>> members, though the latter condition might be hard to check.
>>>
>> Actually I'm going to encode the size of a dynamic array
>> in it's @offset, so the lower 16bits is offset and the
>> higher 16bits is size.
> 
> Was there a patch sent out to do this yet, or is this still something 
> being worked on?
> 

Haven't you pulled it as you said. ;)

http://lkml.org/lkml/2009/7/20/155


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: event tracing, ringbuffer and RB_MAX_SMALL_DATA
  2009-07-21  1:30         ` Li Zefan
@ 2009-07-21  1:42           ` Steven Rostedt
  0 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2009-07-21  1:42 UTC (permalink / raw)
  To: Li Zefan; +Cc: Johannes Berg, linux-kernel, Ingo Molnar, Frederic Weisbecker


On Tue, 21 Jul 2009, Li Zefan wrote:
> > 
> > Was there a patch sent out to do this yet, or is this still something 
> > being worked on?
> > 
> 
> Haven't you pulled it as you said. ;)
> 
> http://lkml.org/lkml/2009/7/20/155

Ah, in deed, I have them queued.

So many patches, so little time ;-)

Thanks!

-- Steve




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-07-21  1:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-14 17:18 event tracing, ringbuffer and RB_MAX_SMALL_DATA Johannes Berg
2009-07-15  1:08 ` Li Zefan
2009-07-15  9:48   ` Johannes Berg
2009-07-16  0:48     ` Li Zefan
2009-07-21  1:25       ` Steven Rostedt
2009-07-21  1:30         ` Li Zefan
2009-07-21  1:42           ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox