Re: [PATCH] Fix computations with (potentially) NULL pointer

2023-11-14 Thread Mark Wielaard
Hi Paul, On Tue, Nov 14, 2023 at 10:56:50AM -0800, Paul Pluzhnikov wrote: > On Tue, Nov 14, 2023 at 9:55 AM Mark Wielaard wrote: > > > Unfortunately our 32bit buildbots were also very quick to point out an > > issue: https://builder.sourceware.org/buildbot/#/changes/35202 > > Sorry about the br

Re: [PATCH] Fix computations with (potentially) NULL pointer

2023-11-14 Thread Paul Pluzhnikov
On Tue, Nov 14, 2023 at 9:55 AM Mark Wielaard wrote: > Unfortunately our 32bit buildbots were also very quick to point out an > issue: https://builder.sourceware.org/buildbot/#/changes/35202 Sorry about the break. I just tried "./configure "CC=gcc -m32" "CXX=g++ -m32" and that didn't reproduce

Re: [PATCH] Fix computations with (potentially) NULL pointer

2023-11-14 Thread Mark Wielaard
Hi Paul, On Tue, 2023-11-14 at 09:04 -0800, Paul Pluzhnikov wrote: > On Tue, Nov 14, 2023 at 8:57 AM Mark Wielaard wrote: > > Looks good. Applied. > > Thanks! > > Appreciate the speedy reviews. Unfortunately our 32bit buildbots were also very quick to point out an issue: https://builder.source

Re: [PATCH] Fix computations with (potentially) NULL pointer

2023-11-14 Thread Paul Pluzhnikov
Mark, On Tue, Nov 14, 2023 at 8:57 AM Mark Wielaard wrote: > I am slightly surprised our testsuite didn't catch this. We do have -- > enable-sanitize-undefined which does build everything with -- > sanitize=undefined. Which should enable -fsanitize=pointer-overflow. > But I just tried (with gcc)

Re: [PATCH] Fix computations with (potentially) NULL pointer

2023-11-14 Thread Mark Wielaard
Hi Paul, On Tue, 2023-11-14 at 08:12 -0800, Paul Pluzhnikov wrote: > On Tue, Nov 14, 2023 at 4:57 AM Mark Wielaard wrote: > > > Urgh, I had no idea NULL + ... was technically undefined behavior. > > ISO/IEC 9899:201x > 6.5.6p8 > > When an expression that has integer type is added to or subtrac

Re: [PATCH] Fix computations with (potentially) NULL pointer

2023-11-14 Thread Paul Pluzhnikov
Mark, On Tue, Nov 14, 2023 at 4:57 AM Mark Wielaard wrote: > Urgh, I had no idea NULL + ... was technically undefined behavior. ISO/IEC 9899:201x 6.5.6p8 When an expression that has integer type is added to or subtracted from a pointer, the result has the type of the pointer operand. If the po

Re: [PATCH] Fix computations with (potentially) NULL pointer

2023-11-14 Thread Mark Wielaard
Hi Paul, Hi Nafi, On Mon, 2023-11-13 at 22:58 +, Paul Pluzhnikov wrote: > When map_address is NULL, computing map_address+offset is technically > undefined behavior, and triggers Clang/LLVM warning when using > -fsanitize=pointer-overflow. Urgh, I had no idea NULL + ... was technically undefi

[PATCH] Fix computations with (potentially) NULL pointer

2023-11-13 Thread Paul Pluzhnikov
When map_address is NULL, computing map_address+offset is technically undefined behavior, and triggers Clang/LLVM warning when using -fsanitize=pointer-overflow. Fix this by using uintptr_t to perform computations. Signed-off-by: Shahriar "Nafi" Rouf --- libelf/elf_begin.c | 10 +- 1 fi