public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Bagas Sanjaya <bagasdotme@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: David Woodhouse <dwmw2@infradead.org>,
	Richard Weinberger <richard@nod.at>,
	David Howells <dhowells@redhat.com>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Baokun Li <libaokun1@huawei.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Kyeong Yoo <kyeong.yoo@alliedtelesis.co.nz>,
	hongnanli <hongnan.li@linux.alibaba.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: partly outside array bounds warning on fs/jffs2/summary.c, GCC 12.1.0
Date: Mon, 6 Jun 2022 10:59:40 +0700	[thread overview]
Message-ID: <Yp17rHxRb6d5JrHd@debian.me> (raw)

Hi everyone,

When I build arm64 kernel with GCC 12.1.0 (bcm2711_defconfig), I get
partly outside array bounds warning on fs/jffs2/summary.c:

  CC [M]  fs/jffs2/summary.o
In file included from fs/jffs2/summary.c:23:
In function 'jffs2_sum_add_mem',
    inlined from 'jffs2_sum_add_inode_mem' at fs/jffs2/summary.c:130:9:
fs/jffs2/nodelist.h:43:28: warning: array subscript 'union jffs2_sum_mem[0]' is partly outside array bounds of 'unsigned char[26]' [-Warray-bounds]
   43 | #define je16_to_cpu(x) ((x).v16)
      |                        ~~~~^~~~~
fs/jffs2/summary.c:71:17: note: in expansion of macro 'je16_to_cpu'
   71 |         switch (je16_to_cpu(item->u.nodetype)) {
      |                 ^~~~~~~~~~~
In file included from fs/jffs2/summary.c:17:
In function 'kmalloc',
    inlined from 'jffs2_sum_add_inode_mem' at fs/jffs2/summary.c:118:37:
./include/linux/slab.h:600:24: note: object of size 26 allocated by 'kmem_cache_alloc_trace'
  600 |                 return kmem_cache_alloc_trace(
      |                        ^~~~~~~~~~~~~~~~~~~~~~~
  601 |                                 kmalloc_caches[kmalloc_type(flags)][index],
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  602 |                                 flags, size);
      |                                 ~~~~~~~~~~~~
In file included from fs/jffs2/nodelist.h:22:
In function 'jffs2_sum_add_mem',
    inlined from 'jffs2_sum_add_inode_mem' at fs/jffs2/summary.c:130:9:
fs/jffs2/summary.c:79:73: warning: array subscript 'union jffs2_sum_mem[0]' is partly outside array bounds of 'unsigned char[26]' [-Warray-bounds]
   79 |                         s->sum_size += JFFS2_SUMMARY_DIRENT_SIZE(item->d.nsize);
fs/jffs2/summary.h:34:80: note: in definition of macro 'JFFS2_SUMMARY_DIRENT_SIZE'
   34 | #define JFFS2_SUMMARY_DIRENT_SIZE(x) (sizeof(struct jffs2_sum_dirent_flash) + (x))
      |                                                                                ^
In function 'kmalloc',
    inlined from 'jffs2_sum_add_inode_mem' at fs/jffs2/summary.c:118:37:
./include/linux/slab.h:600:24: note: object of size 26 allocated by 'kmem_cache_alloc_trace'
  600 |                 return kmem_cache_alloc_trace(
      |                        ^~~~~~~~~~~~~~~~~~~~~~~
  601 |                                 kmalloc_caches[kmalloc_type(flags)][index],
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  602 |                                 flags, size);
      |                                 ~~~~~~~~~~~~

I first found these warnings when reviewing linux-5.18.y stable rc [1],
for which Greg recommends me to contact JFFS subsystem developers.

Thanks.

[1]: https://lore.kernel.org/stable/YpxU%2FbVogip64iQF@debian.me/ 

-- 
An old man doll... just what I always wanted! - Clara

                 reply	other threads:[~2022-06-06  3:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=Yp17rHxRb6d5JrHd@debian.me \
    --to=bagasdotme@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hongnan.li@linux.alibaba.com \
    --cc=kyeong.yoo@alliedtelesis.co.nz \
    --cc=libaokun1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    --cc=willy@infradead.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