From: Christoph Hellwig <hch@infradead.org>
To: Kees Cook <keescook@chromium.org>
Cc: Song Liu <song@kernel.org>,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] md/raid5: Convert stripe_head's "dev" to flexible array member
Date: Wed, 17 May 2023 21:27:24 -0700 [thread overview]
Message-ID: <ZGWpLClY7vz+xl5A@infradead.org> (raw)
In-Reply-To: <20230517233313.never.130-kees@kernel.org>
On Wed, May 17, 2023 at 04:33:14PM -0700, Kees Cook wrote:
> sc = kmem_cache_create(conf->cache_name[conf->active_name],
> - sizeof(struct stripe_head)+(devs-1)*sizeof(struct r5dev),
> + struct_size((struct stripe_head *)0, dev, devs),
> 0, 0, NULL);
> if (!sc)
> return 1;
> @@ -2559,7 +2559,7 @@ static int resize_stripes(struct r5conf *conf, int newsize)
>
> /* Step 1 */
> sc = kmem_cache_create(conf->cache_name[1-conf->active_name],
> - sizeof(struct stripe_head)+(newsize-1)*sizeof(struct r5dev),
> + struct_size((struct stripe_head *)0, dev, newsize),
The constant you're casting here should be NULL, not 0.
Also given that this expression is duplicated, I'd suggest a little
helper for it…
> - } dev[1]; /* allocated with extra space depending of RAID geometry */
> + } dev[]; /* allocated with extra space depending of RAID geometry */
And this isn't extra space over the single entry anymore, so I'd
change this to:
/* allocated depending of RAID geometry */
next prev parent reply other threads:[~2023-05-18 4:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-17 23:33 Kees Cook
2023-05-18 4:27 ` Christoph Hellwig [this message]
2023-05-22 11:49 ` Yu Kuai
2023-05-23 5:54 ` Christoph Hellwig
2023-05-23 13:46 ` Yu Kuai
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=ZGWpLClY7vz+xl5A@infradead.org \
--to=hch@infradead.org \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.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
all inboxes | Powered by JetHome®