[PATCH 1/3] elf: load the main program from AT_EXECFD when run as a binfmt interpreter

Andreas Schwab schwab@suse.de
Wed Jul 15 10:38:32 GMT 2026


On Jul 15 2026, Christian Brauner wrote:

> +      /* Move the descriptor out of the standard range: it is closed
> +	 once the program is mapped, and a secure process must not
> +	 start with a silently closed standard descriptor.  The
> +	 standard descriptor check at startup ran while the descriptor
> +	 still occupied the slot, so run it again once the slot is
> +	 free.  */
> +      if (execfd >= 0 && execfd <= STDERR_FILENO)
> +	{
> +	  int movedfd = __fcntl64_nocancel (execfd, F_DUPFD,
> +					    STDERR_FILENO + 1);
> +	  if (movedfd >= 0)

If F_DUPFD failed here in a __libc_enable_secure program, it will be run
with a closed std desc, defeating __libc_check_standard_fds.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


More information about the Libc-alpha mailing list