public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Johan Hovold <johan@kernel.org>
Cc: Zhang Jianhua <chris.zjh@huawei.com>,
	tytso@mit.edu, linux-fscrypt@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next v2] fs-verity: Use struct_size() helper in enable_verity()
Date: Thu, 19 May 2022 09:57:12 -0700	[thread overview]
Message-ID: <YoZ26O3XCK0+7h2Y@sol.localdomain> (raw)
In-Reply-To: <YoYo/XBmqn6KGz5k@hovoldconsulting.com>

On Thu, May 19, 2022 at 01:24:45PM +0200, Johan Hovold wrote:
> On Wed, May 18, 2022 at 08:17:59PM -0700, Eric Biggers wrote:
> > On Wed, May 18, 2022 at 08:06:04PM -0700, Eric Biggers wrote:
> > > On Thu, May 19, 2022 at 10:24:50AM +0800, Zhang Jianhua wrote:
> > > > Also, address the following sparse warning:
> > > > fs/verity/enable.c:205:28: warning: using sizeof on a flexible structure
> > > 
> > > How can I reproduce this warning?  I am using the latest version of sparse, and
> > > I don't see any of these warnings you're reporting.
> > > 
> > > $ sparse --version
> > > v0.6.4
> > > $ make C=2 fs/verity/
> > >   CHECK   scripts/mod/empty.c
> > >   CALL    scripts/checksyscalls.sh
> > >   CALL    scripts/atomic/check-atomics.sh
> > >   DESCEND objtool
> > >   CHECK   fs/verity/enable.c
> > >   CHECK   fs/verity/hash_algs.c
> > >   CHECK   fs/verity/init.c
> > >   CHECK   fs/verity/measure.c
> > >   CHECK   fs/verity/open.c
> > >   CHECK   fs/verity/read_metadata.c
> > >   CHECK   fs/verity/verify.c
> > >   CHECK   fs/verity/signature.c
> > > 
> > 
> > 'make C=2 CHECK="sparse -Wflexible-array-sizeof"' does the trick.  However, it
> > produces a *lot* of warnings all over the place.
> > 
> > Unless there is an effort to actually address all of these so that this warning
> > can be enabled by default, I don't see the poinnt in addressing these just for
> > the warnings sake.  The change to fsverity_ioctl_measure() is definitely just
> > for the warning's sake, so I don't really want to do that one.  The change to
> > enable_verity() is a bit less useless, so I could still take that one.
> 
> Importantly, struct_size() still relies on sizeof() so this has zero
> effect on those sparse warnings.
> 

Yeah, you're right.  In fact struct_size() generates two warnings, whereas
directly writing sizeof only generates 1!  So clearly sparse's
-Wflexible-array-sizeof warning is useless as-is.

I'm still keeping this patch, but I updated the commit message to not claim that
it addresses a sparse warning.  Now it's just:

    fs-verity: Use struct_size() helper in enable_verity()

    Follow the best practice for allocating a variable-sized structure.

- Eric

      reply	other threads:[~2022-05-19 16:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19  2:24 [PATCH -next v2] fs-verity: Use struct_size() helper in enable_verity() Zhang Jianhua
2022-05-19  3:06 ` Eric Biggers
2022-05-19  3:17   ` Eric Biggers
     [not found]     ` <e030eaf6-0b6b-7685-c5b6-fd0b57aea600@huawei.com>
2022-05-19  4:22       ` Eric Biggers
2022-05-19  6:22         ` zhangjianhua (E)
2022-05-19 11:24     ` Johan Hovold
2022-05-19 16:57       ` Eric Biggers [this message]

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=YoZ26O3XCK0+7h2Y@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=chris.zjh@huawei.com \
    --cc=johan@kernel.org \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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