lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1239949360.23397.4065.camel@laptop>
Date:	Fri, 17 Apr 2009 08:22:40 +0200
From:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
To:	Frédéric Weisbecker <fweisbec@...il.com>
Cc:	Ingo Molnar <mingo@...e.hu>, Steven Rostedt <rostedt@...dmis.org>,
	Zhaolei <zhaolei@...fujitsu.com>,
	Tom Zanussi <tzanussi@...il.com>,
	Li Zefan <lizf@...fujitsu.com>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2 v2] tracing/events: provide string with undefined
 size  support

On Thu, 2009-04-16 at 22:28 +0200, Frédéric Weisbecker wrote:
> 2009/4/16 Peter Zijlstra <a.p.zijlstra@...llo.nl>:
> > On Thu, 2009-04-16 at 22:00 +0200, Frederic Weisbecker wrote:
> >> Impact: less memory usage for tracing
> >>
> >> This patch provides the support for dynamic size strings on
> >> event tracing.
> >>
> >> The key concept is to use a structure with an ending char array field of
> >> undefined size and use such ability to allocate the minimal size on the ring
> >> buffer to make the entry fit inside as opposite to a fixed length strings with
> >> upper bound.
> >>
> >> This patch provides one new macro:
> >>
> >> -__ending_string(name, src)
> >>
> >> This one declares the string to the structure inside TP_STRUCT__entry.
> >> You need to provide the name of the string field and the source that will be
> >> copied inside.
> >> Two constraints: only one __ending_string() per TRACE_EVENT can be added and
> >> it must be the last field to be declared. Hence the __ending prefix.
> >>
> >> This macro will declare the necessary field and will also add the dynamic
> >> size of the string needed for the ring buffer entry allocation.
> >>
> >> It also support filtering because these strings behave essentially
> >> like usual fixed length string.
> >
> > can't we simply do __string(name, src) and output something like:
> >
> >  struct {
> >   u16 size;
> >   char str[0];
> >  } name;
> >
> > That would get rid of this __ending_ wart.
> >
> >
> 
> Hmm, I don't understand.
> Such a thing doesn't seem to work. Once we fill the string it would
> override the fields that
> follow it if it's not at the end.

Just grow the thing to fit whatever string length -- rather common
pattern:

struct foo {
  int length;
  char data[0];
};

struct foo *bar = kmalloc(sizeof(struct foo) + data_size);

and bob's your uncle.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ