[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <90E2BBA5-8A2D-42DE-B36A-CD37BABBB433@kernel.org>
Date: Sun, 01 Oct 2023 08:26:56 -0700
From: Kees Cook <kees@...nel.org>
To: Julia Lawall <julia.lawall@...ia.fr>,
Kees Cook <keescook@...omium.org>
CC: Christophe JAILLET <christophe.jaillet@...adoo.fr>,
Ian Abbott <abbotti@....co.uk>,
H Hartley Sweeten <hsweeten@...ionengravers.com>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Tom Rix <trix@...hat.com>, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org, linux-hardening@...r.kernel.org,
llvm@...ts.linux.dev
Subject: Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by
On October 1, 2023 12:45:41 AM PDT, Julia Lawall <julia.lawall@...ia.fr> 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 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
>> > functions).
>> >
>> > Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
>> > ---
>> > This patch is part of a work done in parallel of what is currently worked
>> > on by Kees Cook.
>> >
>> > My patches are only related to corner cases that do NOT match the
>> > semantic of his Coccinelle script[1].
>>
>> Nice!
>>
>> struct comedi_lrange {
>> int length;
>> struct comedi_krange range[];
>> };
>> ...
>> static const struct comedi_lrange range_rti800_ai_10_bipolar = {
>> 4, {
>> BIP_RANGE(10),
>> BIP_RANGE(1),
>> BIP_RANGE(0.1),
>> BIP_RANGE(0.02)
>> }
>> };
>>
>> I'm struggling to come up with a way for Coccinelle to find this kind of
>> thing in other places...
>
>Kees, what exactly are you trying to match? Static allocations?
I need to count the number of initialized elements in the flexible array that is the last member and see if it matches a value set in another member.
E.g. the above sets 4 values for the last array member and then sets another member to 4.
-Kees
--
Kees Cook
Powered by blists - more mailing lists