Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-11-05 Thread Christophe JAILLET
Le 01/10/2023 à 23:22, Kees Cook a écrit : On Sun, Oct 01, 2023 at 02:05:46PM -0700, Kees Cook wrote: On Sun, Oct 01, 2023 at 09:14:02PM +0200, Julia Lawall wrote: Kees, You can try the following. Cool! Yeah, this finds the example: drivers/comedi/drivers/rti800.c:74: struct comedi_lrange:

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-10-02 Thread Kees Cook
On Mon, Oct 02, 2023 at 07:38:42AM +0200, Julia Lawall wrote: > The sizeof with an expression argument is treated differently than the > sizeof with a type argument. So you need to write: > > @allocated@ > identifier STRUCT, ARRAY; > expression COUNT; > struct STRUCT *PTR; > identifier ALLOC; > t

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-10-01 Thread Julia Lawall
On Sun, 1 Oct 2023, Kees Cook wrote: > On Sun, Oct 01, 2023 at 02:22:17PM -0700, Kees Cook wrote: > > On Sun, Oct 01, 2023 at 02:05:46PM -0700, Kees Cook wrote: > > > On Sun, Oct 01, 2023 at 09:14:02PM +0200, Julia Lawall wrote: > > > > Kees, > > > > > > > > You can try the following. > > > > >

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-10-01 Thread Kees Cook
On Sun, Oct 01, 2023 at 02:22:17PM -0700, Kees Cook wrote: > On Sun, Oct 01, 2023 at 02:05:46PM -0700, Kees Cook wrote: > > On Sun, Oct 01, 2023 at 09:14:02PM +0200, Julia Lawall wrote: > > > Kees, > > > > > > You can try the following. > > > > Cool! Yeah, this finds the example: > > > > drivers

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-10-01 Thread Kees Cook
On Sun, Oct 01, 2023 at 02:05:46PM -0700, Kees Cook wrote: > On Sun, Oct 01, 2023 at 09:14:02PM +0200, Julia Lawall wrote: > > Kees, > > > > You can try the following. > > Cool! Yeah, this finds the example: > > drivers/comedi/drivers/rti800.c:74: struct comedi_lrange: field at offset 0 > is th

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-10-01 Thread Kees Cook
On Sun, Oct 01, 2023 at 09:14:02PM +0200, Julia Lawall wrote: > Kees, > > You can try the following. Cool! Yeah, this finds the example: drivers/comedi/drivers/rti800.c:74: struct comedi_lrange: field at offset 0 is the counter for the flex array drivers/comedi/drivers/rti800.c:83: struct comed

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-10-01 Thread Julia Lawall
Kees, You can try the following. julia #spatch --all-includes @r@ identifier i,j; type T; @@ struct i { ... T j[]; } @s@ identifier r.i; constant ini; identifier j; initializer list [n] is2; position p; identifier x; @@ struct i@p x = { ..., .j = ini, ..., { is2 } } ; @scrip

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-10-01 Thread Kees Cook
On October 1, 2023 12:45:41 AM PDT, Julia Lawall wrote: > > >On Sat, 30 Sep 2023, Kees Cook wrote: > >> On Sat, Sep 30, 2023 at 11:14:47AM +0200, Christophe JAILLET wrote: >> > Prepare for the coming implementation by GCC and Clang of the __counted_by >> > attribute. Flexible array members annotat

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-10-01 Thread Christophe JAILLET
Le 01/10/2023 à 09:25, Julia Lawall a écrit : This is not found due to the regular expression used for the name of the alloc function. Maybe you could drop it entirely? Maybe you could just check for alloc somewhere in the string? That's how I found it. I simplified a lot Kees's script and l

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-10-01 Thread Julia Lawall
On Sat, 30 Sep 2023, Kees Cook wrote: > On Sat, Sep 30, 2023 at 11:14:47AM +0200, Christophe JAILLET wrote: > > Prepare for the coming implementation by GCC and Clang of the __counted_by > > attribute. Flexible array members annotated with __counted_by can have > > their accesses bounds-checked

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-10-01 Thread Julia Lawall
On Sat, 30 Sep 2023, Kees Cook wrote: > On Sat, Sep 30, 2023 at 11:14:47AM +0200, Christophe JAILLET wrote: > > Prepare for the coming implementation by GCC and Clang of the __counted_by > > attribute. Flexible array members annotated with __counted_by can have > > their accesses bounds-checked

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-09-30 Thread Gustavo A. R. Silva
On 9/30/23 11:14, Christophe JAILLET wrote: Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONF

Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-09-30 Thread Kees Cook
On Sat, Sep 30, 2023 at 11:14:47AM +0200, Christophe JAILLET wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (f

[PATCH] comedi: Annotate struct comedi_lrange with __counted_by

2023-09-30 Thread Christophe JAILLET
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family funct