Linux-Sparse Archive on lore.kernel.org
 help / color / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Sparse Mailing-list <linux-sparse@vger.kernel.org>
Subject: Re: [PATCH 13/13] flex-array: warn when a flexible array member has some padding
Date: Thu, 1 Oct 2020 21:51:20 +0200
Message-ID: <20201001195120.yhnrsq54ojfuy7lr@ltop.local> (raw)
In-Reply-To: <20201001194121.2lk6e66zycgtoqkw@ltop.local>

On Thu, Oct 01, 2020 at 09:41:21PM +0200, Luc Van Oostenryck wrote:
> On Thu, Oct 01, 2020 at 12:27:56PM -0700, Linus Torvalds wrote:
> > On Thu, Oct 1, 2020 at 12:17 PM Luc Van Oostenryck
> > <luc.vanoostenryck@gmail.com> wrote:
> > >
> > > > So in the kernel, we would
> > > >
> > > >  - start warning about 'sizeof(flex_struct)'
> > >
> > > Adding this warning by default annoys me slightly because it will
> > > add 5700+ warnings to the 18000 already present and I think sparse
> > > is already underused because it is very/too noisy. But I guess that
> > > most occurrences come from a few macros and thus should be easy to
> > > get rid off.
> > 
> > Hopefully. I'll try to take a look. Do you have the sparse changes in
> > a git branch already so that I can just try that directly?
> 
> What I posted yesterday is on
> 	git://git.kernel.org/pub/scm/devel/sparse/sparse-dev.git flex-array
> 
> > Or if you send me a couple of examples, maybe it's just the same
> > pattern over and over,..
> 
> Well, the 888 occurences I see are already 'unique' occurences
> (in the sense that the warning is from a distinct file+position).
> I'm adding in attachment the extract of my test logs (but it is
> on v5.9-rc1 so it's maybe not much usefull). I ddn't investigated
> anything, just checked a few case to see that it was a genuine
> occurrence.

Sorry, I was thinking about the nested ones and sent the wrong.
Here are the top entries for sizeof():
     66 ./include/linux/filter.h:752:16: warning: using sizeof on a flexible structure
     48 crypto/gcm.c:547:17: warning: using sizeof on a flexible structure
     48 crypto/authencesn.c:357:17: warning: using sizeof on a flexible structure
     48 crypto/authenc.c:339:17: warning: using sizeof on a flexible structure
     44 ./include/linux/ihex.h:26:38: warning: using sizeof on a flexible structure
     30 drivers/crypto/chelsio/chcr_algo.c:793:32: warning: using sizeof on a flexible structure
     29 ./include/crypto/skcipher.h:518:31: warning: using sizeof on a flexible structure
     27 ./include/linux/can/dev.h:100:13: warning: using sizeof on a flexible structure
     24 net/mac80211/tdls.c:874:32: warning: using sizeof on a flexible structure
     24 net/ipv6/ndisc.c:1662:18: warning: using sizeof on a flexible structure
     24 drivers/tty/tty_buffer.c:352:28: warning: using sizeof on a flexible structure
     24 drivers/tty/tty_buffer.c:316:28: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:972:25: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:968:32: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:961:29: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:905:25: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:897:29: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:760:49: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:756:55: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:747:62: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:738:49: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:729:53: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:577:33: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:559:39: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:554:41: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:404:29: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:1134:33: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:1118:55: warning: using sizeof on a flexible structure
     23 net/netfilter/ipset/ip_set_hash_gen.h:1114:51: warning: using sizeof on a flexible structure
     20 fs/proc/inode.c:110:9: warning: using sizeof on a flexible structure
     20 fs/proc/inode.c:109:17: warning: using sizeof on a flexible structure
     20 fs/proc/generic.c:425:29: warning: using sizeof on a flexible structure
     18 net/ipv4/tcp_output.c:1241:28: warning: using sizeof on a flexible structure
     18 net/core/net-sysfs.c:769:23: warning: using sizeof on a flexible structure
     17 ./include/linux/ihex.h:52:50: warning: using sizeof on a flexible structure
     16 fs/proc/inode.c:107:35: warning: using sizeof on a flexible structure
     16 ./include/crypto/skcipher.h:496:23: warning: using sizeof on a flexible structure
     15 mm/percpu.c:2259:21: warning: using sizeof on a flexible structure
     14 drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.h:281:27: warning: using sizeof on a flexible structure
     13 drivers/net/wireguard/messages.h:117:34: warning: using sizeof on a flexible structure
     13 ./include/crypto/hash.h:594:23: warning: using sizeof on a flexible structure
     12 net/netfilter/x_tables.c:780:21: warning: using sizeof on a flexible structure
     12 net/netfilter/x_tables.c:1157:21: warning: using sizeof on a flexible structure
     12 net/netfilter/ipset/ip_set_hash_gen.h:143:51: warning: using sizeof on a flexible structure
     12 net/netfilter/ipset/ip_set_hash_gen.h:139:29: warning: using sizeof on a flexible structure
     12 net/mac80211/iface.c:1829:28: warning: using sizeof on a flexible structure
     12 net/core/skbuff.c:6188:26: warning: using sizeof on a flexible structure
     12 net/core/skbuff.c:6146:39: warning: using sizeof on a flexible structure
     12 net/core/skbuff.c:4214:16: warning: using sizeof on a flexible structure
     12 net/core/bpf_sk_storage.c:666:32: warning: using sizeof on a flexible structure
     12 net/core/bpf_sk_storage.c:1081:9: warning: using sizeof on a flexible structure
     12 kernel/module.c:1601:19: warning: using sizeof on a flexible structure
     12 kernel/bpf/core.c:881:16: warning: using sizeof on a flexible structure
     12 drivers/staging/greybus/sdio.c:136:20: warning: using sizeof on a flexible structure
     12 drivers/infiniband/hw/cxgb4/provider.c:278:31: warning: using sizeof on a flexible structure
     12 drivers/gpu/drm/drm_managed.c:92:13: warning: using sizeof on a flexible structure
     12 drivers/crypto/picoxcell_crypto.c:711:17: warning: using sizeof on a flexible structure
     12 crypto/cmac.c:271:17: warning: using sizeof on a flexible structure
     12 crypto/cmac.c:266:17: warning: using sizeof on a flexible structure
     12 crypto/chacha20poly1305.c:528:17: warning: using sizeof on a flexible structure
     12 crypto/adiantum.c:429:23: warning: using sizeof on a flexible structure
     11 ./include/uapi/linux/bcache.h:101:17: warning: using sizeof on a flexible structure
     11 ./include/crypto/aead.h:414:23: warning: using sizeof on a flexible structure
     10 drivers/infiniband/sw/rxe/rxe.h:76:9: warning: using sizeof on a flexible structure
     10 drivers/base/devres.c:95:13: warning: using sizeof on a flexible structure
     10 ./include/rdma/rdmavt_qp.h:535:39: warning: using sizeof on a flexible structure
     10 ./include/rdma/ib_verbs.h:583:25: warning: using sizeof on a flexible structure
     10 ./include/crypto/hash.h:990:26: warning: using sizeof on a flexible structure
     10 ./include/crypto/akcipher.h:196:23: warning: using sizeof on a flexible structure

Less frequent ones removed. There is a lot with a single occurence
mostly in drivers/.


-- Luc


  reply index

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-30 23:18 [PATCH 00/13] add warnings for flexible arrays Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 01/13] flex-array: add testcases Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 02/13] flex-array: factor out common part of lay_out_{struct,union}() Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 03/13] flex-array: do not lay out invalid struct members Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 04/13] flex-array: flexible array members have zero size and alignment is OK Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 05/13] flex-array: detect structures with a flexible array member Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 06/13] flex-array: warn on flexible arrays in unions Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 07/13] flex-array: warn if flexible array is not last Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 08/13] flex-array: identify structures with a flexible array member Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 09/13] flex-array: add helper has_flexible_array() Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 10/13] flex-array: warn when using sizeof() on a flexible array Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 11/13] flex-array: warn an arrays containing " Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 12/13] flex-array: warn on flexible array in nested aggregate types Luc Van Oostenryck
2020-09-30 23:18 ` [PATCH 13/13] flex-array: warn when a flexible array member has some padding Luc Van Oostenryck
2020-10-01 16:34   ` Linus Torvalds
2020-10-01 19:17     ` Luc Van Oostenryck
2020-10-01 19:27       ` Linus Torvalds
2020-10-01 19:41         ` Luc Van Oostenryck
2020-10-01 19:51           ` Luc Van Oostenryck [this message]
2020-10-01 16:36 ` [PATCH 00/13] add warnings for flexible arrays Linus Torvalds

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=20201001195120.yhnrsq54ojfuy7lr@ltop.local \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --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

Linux-Sparse Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-sparse/0 linux-sparse/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-sparse linux-sparse/ https://lore.kernel.org/linux-sparse \
		linux-sparse@vger.kernel.org
	public-inbox-index linux-sparse

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-sparse


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git