[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y1ku+jfRAyezq6Nz@zx2c4.com>
Date: Wed, 26 Oct 2022 14:58:34 +0200
From: "Jason A. Donenfeld" <Jason@...c4.com>
To: Kees Cook <keescook@...omium.org>, cocci@...ia.fr
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Alexey Dobriyan <adobriyan@...il.com>,
akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
mm-commits@...r.kernel.org, masahiroy@...nel.org,
gregkh@...uxfoundation.org, andriy.shevchenko@...ux.intel.com,
Stephen Rothwell <sfr@...b.auug.org.au>
Subject: Re: [PATCH -mm] -funsigned-char, x86: make struct
p4_event_bind::cntr signed array
On Wed, Oct 26, 2022 at 03:50:25AM +0200, Jason A. Donenfeld wrote:
> The traditional objdump comparison does work, though. It produces a good
Another thing that appears to work well is just using Coccinelle
scripts. I've had some success just scrolling through the results of:
@@
char c;
expression E;
@@
(
* E > c
|
* E >= c
|
* E < c
|
* E <= c
)
That also triggers on explicitly signed chars, and examining those
reveals that quite a bit of code in the tree already does do the right
thing, which is good.
>From looking at this and objdump output, it looks like most naked-char
usage that isn't for strings is actually already assuming it's unsigned,
using it as a byte. I'll continue to churn, and I'm sure I'll miss a few
things here and there, but all and all, I don't think this is looking as
terrible as I initially feared.
I'm CC'ing the Coccinelle people to see if they have any nice ideas on
improvements. Specifically, the thing we're trying to identify is:
- Usage of vanilla `char`, without a `signed` or `unsigned` qualifier,
where:
- It's not being used for characters; and
- It's doing something that assumes it is signed, such as various
types of comparisons or decrements.
LWN wrote a summary of the general problem, in case that helps describe
what would be useful: https://lwn.net/SubscriberLink/911914/f90c2ed1af23cbc4/
Any nice Cocci tricks for this?
Jason
Powered by blists - more mailing lists