From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Kees Cook <keescook@chromium.org>, cocci@inria.fr
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Alexey Dobriyan <adobriyan@gmail.com>,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
mm-commits@vger.kernel.org, masahiroy@kernel.org,
gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com,
Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: [cocci] [PATCH -mm] -funsigned-char, x86: make struct p4_event_bind::cntr signed array
Date: Wed, 26 Oct 2022 14:58:34 +0200 [thread overview]
Message-ID: <Y1ku+jfRAyezq6Nz@zx2c4.com> (raw)
In-Reply-To: <Y1iSYddi3BpP8gvf@zx2c4.com>
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
next parent reply other threads:[~2022-11-02 17:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20221020000356.177CDC433C1@smtp.kernel.org>
[not found] ` <Y1EZuQcO8UoN91cX@localhost.localdomain>
[not found] ` <CAHmME9prEhkHqQmtDGCSFunNnxiKdE_8FHKiksyqebUN63U81Q@mail.gmail.com>
[not found] ` <CAHk-=whFow9Wd6C8htoRUt5wXbwf1i_qbuArBbhXOPqYsTFvtw@mail.gmail.com>
[not found] ` <CAHmME9qBZqTd0D_gr8nE+DUzCrC0fxZNZK=7u+21jbgtFgAJBg@mail.gmail.com>
[not found] ` <CAHk-=wjZDC9o8iwF+bU91Hx40HjGOpMui+VoFCDJkaGCu=rG4A@mail.gmail.com>
[not found] ` <202210201151.ECC19BC97A@keescook>
[not found] ` <Y1iSYddi3BpP8gvf@zx2c4.com>
2022-10-26 12:58 ` Jason A. Donenfeld [this message]
2022-10-26 13:17 ` [cocci] [PATCH -mm] -funsigned-char, x86: make struct p4_event_bind::cntr signed array Andy Shevchenko
2022-11-02 17:17 ` Julia Lawall
2022-11-03 0:08 ` Jason A. Donenfeld
2022-11-03 6:31 ` Julia Lawall
2022-11-03 12:45 ` Julia Lawall
2022-11-03 12:47 ` Jason A. Donenfeld
2022-11-03 12:57 ` Julia Lawall
2022-11-03 14:07 ` Jason A. Donenfeld
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y1ku+jfRAyezq6Nz@zx2c4.com \
--to=jason@zx2c4.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=cocci@inria.fr \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).