lkml.org 
[lkml]   [2023]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] ELF: use __builtin_mul_overflow() more
__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:
\
 
 \ /
  Last update: 2023-04-21 20:55    [W:0.084 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site