BPF List
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Tom Rix <trix@redhat.com>, Simon Horman <simon.horman@netronome.com>
Cc: kuba@kernel.org, davem@davemloft.net, ast@kernel.org,
	daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com,
	songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com,
	kpsingh@kernel.org, gustavoars@kernel.org,
	louis.peens@netronome.com, netdev@vger.kernel.org,
	bpf@vger.kernel.org, oss-drivers@netronome.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nfp: remove h from printk format specifier
Date: Fri, 25 Dec 2020 15:00:52 -0800	[thread overview]
Message-ID: <8401b60d35698e68bcf84e977b1b735c131d0b1e.camel@perches.com> (raw)
In-Reply-To: <65755252-96c3-a808-3e01-e377dd395ee7@redhat.com>

On Fri, 2020-12-25 at 14:13 -0800, Tom Rix wrote:
> On 12/25/20 9:06 AM, Joe Perches wrote:
> > On Fri, 2020-12-25 at 06:56 -0800, Tom Rix wrote:
> > > On 12/24/20 2:39 PM, Joe Perches wrote:
> > []
> > > > Kernel code doesn't use a signed char or short with %hx or %hu very often
> > > > but in case you didn't already know, any signed char/short emitted with
> > > > anything like %hx or %hu needs to be left alone as sign extension occurs so:
> > > Yes, this would also effect checkpatch.
> > Of course but checkpatch is stupid and doesn't know types
> > so it just assumes that the type argument is not signed.
> > 
> > In general, that's a reasonable but imperfect assumption.
> > 
> > coccinelle could probably do this properly as it's a much
> > better parser.  clang-tidy should be able to as well.
> > 
> Ok.
> 
> But types not matching the format string is a larger problem.
> 
> Has there been an effort to clean these up ?

Not really no.  __printf already does a reasonable job for that.

The biggest issue for format type mismatches is the %p<foo> extensions.

__printf can only verify that the argument is a pointer, not
necessarily the 'right' type of pointed to object.

There are overflow possibilities like '"%*ph", len, pointer'
where pointer may not have len bytes available and, for instance,
mismatched uses of %pI4 and %pI6 where %pI4 expects a pointer to
4 bytes and %pI6 expects a pointer to 16 bytes.

Anyway it's not that easy a problem to analyze.


  reply	other threads:[~2020-12-25 23:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23 20:20 [PATCH] nfp: remove h from printk format specifier trix
2020-12-24 20:21 ` Simon Horman
2020-12-24 22:14   ` Tom Rix
2020-12-24 22:39     ` Joe Perches
2020-12-25 14:56       ` Tom Rix
2020-12-25 17:06         ` Joe Perches
2020-12-25 22:13           ` Tom Rix
2020-12-25 23:00             ` Joe Perches [this message]
2020-12-26 20:40         ` David Laight

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=8401b60d35698e68bcf84e977b1b735c131d0b1e.camel@perches.com \
    --to=joe@perches.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=gustavoars@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=louis.peens@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    --cc=simon.horman@netronome.com \
    --cc=songliubraving@fb.com \
    --cc=trix@redhat.com \
    --cc=yhs@fb.com \
    /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