Re: Correct way of calling prctl(2) (was: Sashimi of prctl(2))

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2024-05-28 at 11:24 +0200, Alejandro Colomar wrote:
> From what I can see, glibc does no magic to set unspecified parameters
> to 0, so this means passing '0' results in Undefined Behavior.

On most targets where Glibc implements prctl in assembly (not C), the C
standard does not apply at all so there's no Undefined Behavior. 
There's just "expected" and "unexpected" behaviors.

So on 32-bit targets (both long and int are 32-bit) there's no problem.

On targets like riscv64 and loongarch64 the ABI mandates a sign-
extension on parameters narrower than a GPR, so there's no problem as
well.

x86_64 does not have such a guarantee (as said
in https://gcc.gnu.org/PR46942) so yes passing '0' may leave the high 32
bits of the parameter uninitialized and cause problems (at least in
theory).

-- 
Xi Ruoyao <xry111@xxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University





[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux