From 283d98512272a12cb84e7798c23edbdf1adb287d Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Wed, 6 Jun 2018 14:07:34 -0300 Subject: posix: Fix posix_spawnp to not execute invalid binaries in non compat mode (BZ#23264) Current posix_spawnp implementation wrongly tries to execute invalid binaries (for instance script without shebang) as a shell script in non compat mode. It was a regression introduced by 9ff72da471a509a8c19791efe469f47fa6977410 when __spawni started to use __execvpe instead of __execve (glibc __execvpe try to execute ENOEXEC as shell script regardless). This patch fixes it by using an internal symbol (__execvpex) with the faulty semantic (since compat mode is handled by spawni.c itself). It was reported by Daniel Drake on libc-help [1]. Checked on x86_64-linux-gnu and i686-linux-gnu. [BZ #23264] * include/unistd.h (__execvpex): New prototype. * posix/Makefile (tests): Add tst-spawn4. (tests-internal): Add tst-spawn4-compat. * posix/execvpe.c (__execvpe_common, __execvpex): New functions. * posix/tst-spawn4-compat.c: New file. * posix/tst-spawn4.c: Likewise. * sysdeps/unix/sysv/linux/spawni.c (__spawni): Do not interpret invalid binaries as shell scripts. * sysdeps/posix/spawni.c (__spawni): Likewise. [1] https://sourceware.org/ml/libc-help/2018-06/msg00012.html --- posix/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'posix/Makefile') diff --git a/posix/Makefile b/posix/Makefile index e9730eedf0..4a9a1b57b8 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -95,10 +95,10 @@ tests := test-errno tstgetopt testfnm runtests runptests \ tst-posix_spawn-fd tst-posix_spawn-setsid \ tst-posix_fadvise tst-posix_fadvise64 \ tst-sysconf-empty-chroot tst-glob_symlinks tst-fexecve \ - tst-glob-tilde test-ssize-max + tst-glob-tilde test-ssize-max tst-spawn4 tests-internal := bug-regex5 bug-regex20 bug-regex33 \ tst-rfc3484 tst-rfc3484-2 tst-rfc3484-3 \ - tst-glob_lstat_compat + tst-glob_lstat_compat tst-spawn4-compat xtests := bug-ga2 tst-getaddrinfo4 tst-getaddrinfo5 ifeq (yes,$(build-shared)) test-srcs := globtest -- cgit 1.4.1