From: "Eric W. Biederman" <ebiederm@xmission.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
Kees Cook <keescook@chromium.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 1/2] binfmt: Use struct_size()
Date: Sun, 28 May 2023 11:32:52 -0500 [thread overview]
Message-ID: <871qj0l8ln.fsf@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <53150beae5dc04dac513dba391a2e4ae8696a7f3.1685290790.git.christophe.jaillet@wanadoo.fr> (Christophe JAILLET's message of "Sun, 28 May 2023 18:20:24 +0200")
Christophe JAILLET <christophe.jaillet@wanadoo.fr> writes:
> Use struct_size() instead of hand-writing it. It is less verbose, more
> robust and more informative.
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Obviously correct transform.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested on arm
> ---
> fs/binfmt_elf_fdpic.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
> index d76ad3d4f676..237ce388d06d 100644
> --- a/fs/binfmt_elf_fdpic.c
> +++ b/fs/binfmt_elf_fdpic.c
> @@ -748,7 +748,6 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
> struct elf32_phdr *phdr;
> unsigned long load_addr, stop;
> unsigned nloads, tmp;
> - size_t size;
> int loop, ret;
>
> /* allocate a load map table */
> @@ -760,8 +759,7 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
> if (nloads == 0)
> return -ELIBBAD;
>
> - size = sizeof(*loadmap) + nloads * sizeof(*seg);
> - loadmap = kzalloc(size, GFP_KERNEL);
> + loadmap = kzalloc(struct_size(loadmap, segs, nloads), GFP_KERNEL);
> if (!loadmap)
> return -ENOMEM;
next prev parent reply other threads:[~2023-05-28 16:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-28 16:20 Christophe JAILLET
2023-05-28 16:20 ` [PATCH 2/2] binfmt: Slightly simplify elf_fdpic_map_file() Christophe JAILLET
2023-05-28 16:34 ` Eric W. Biederman
2023-05-28 16:32 ` Eric W. Biederman [this message]
2023-05-30 22:52 ` [PATCH 1/2] binfmt: Use struct_size() Kees Cook
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=871qj0l8ln.fsf@email.froward.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=brauner@kernel.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=keescook@chromium.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=viro@zeniv.linux.org.uk \
/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