From: Alexey Dobriyan <adobriyan@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] ELF: use __builtin_mul_overflow() more
Date: Fri, 21 Apr 2023 21:54:36 +0300 [thread overview]
Message-ID: <dd85c092-379e-4d14-88f0-8f3910de9f7f@p183> (raw)
__builtin_mul_overflow() can do multiplication and overflow check
in one line.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
fs/binfmt_elf.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1651,9 +1651,8 @@ static int fill_files_note(struct memelfnote *note, struct coredump_params *cprm
/* *Estimated* file count and total data size needed */
count = cprm->vma_count;
- if (count > UINT_MAX / 64)
+ if (__builtin_mul_overflow(count, 64, &size))
return -EINVAL;
- size = count * 64;
names_ofs = (2 + 3 * count) * sizeof(data[0]);
alloc:
next reply other threads:[~2023-04-21 18:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-21 18:54 Alexey Dobriyan [this message]
2023-04-21 19:39 ` Andrew Morton
2023-04-22 9:45 ` Alexey Dobriyan
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=dd85c092-379e-4d14-88f0-8f3910de9f7f@p183 \
--to=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.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®