Thread (5 messages) 5 messages, 4 authors, 2019-07-04

Re: [RFC PATCH] binfmt_elf: Extract .note.gnu.property from an ELF file

From: Pavel Machek <hidden>
Date: 2019-07-04 19:50:29
Also in: linux-arch, linux-doc, linux-mm, lkml

Hi!

quoted
+static int scan(u8 *buf, u32 buf_size, int item_size, test_item_fn test_item,
+               next_item_fn next_item, u32 *arg, u32 type, u32 *pos)
+{
+       int found = 0;
+       u8 *p, *max;
+
+       max = buf + buf_size;
+       if (max < buf)
+               return 0;
How can this ever legitimately happen? If it can't, perhaps you meant
to put a WARN_ON_ONCE() or something like that here?
Also, computing out-of-bounds pointers is UB (section 6.5.6 of C99:
"If both the pointer operand and the result point to elements of the
same array object, or one past the last element of the array object,
the evaluation shall not produce an overflow; otherwise, the behavior
is undefined."), and if the addition makes the pointer wrap, that's
certainly out of bounds; so I don't think this condition can trigger
without UB.
Kernel assumes sane compiler. We pass flags to get it... C99 does not
quite apply here.
								Pavel
								
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help