aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/exec/execveat.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-05-22selftests/exec: Verify execve of non-regular files failKees Cook1-0/+8
Add a named pipe as an exec target to make sure that non-regular files are rejected by execve() with EACCES. This can help verify commit 73601ea5b7b1 ("fs/open.c: allow opening only regular files during execve()"). Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 166Thomas Gleixner1-2/+1
Based on 1 normalized pattern(s): licensed under the terms of the gnu gpl license version 2 extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 62 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Richard Fontana <rfontana@redhat.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070033.929121379@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-30selftests: exec: return Kselftest Skip code for skipped testsShuah Khan (Samsung OSG)1-2/+4
When execveat test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error which is treated as a fail by the Kselftest framework. This leads to false negative result even when the test could not be run. Change it to return kselftest skip code when a test gets skipped to clearly report that the test could not be run. Change it to use ksft_exit_skip() when kernel doesn't support execveat. Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2017-11-15selftests/exec: include cwd in long path calculationSteve Muckle1-8/+19
When creating a pathname close to PATH_MAX to test execveat, factor in the current working directory path otherwise we end up with an absolute path that is longer than PATH_MAX. While execveat() may succeed, subsequent calls to the kernel from the runtime environment which are required to successfully execute the test binary/script may fail because of this. To keep the semantics of the test the same, rework the relative pathname part of the test to be relative to the root directory so it isn't decreased by the length of the current working directory path. Signed-off-by: Steve Muckle <smuckle.linux@gmail.com> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
2015-03-11selftests/exec: Check if the syscall exists and bail if notMichael Ellerman1-1/+9
On systems which don't implement sys_execveat(), this test produces a lot of output. Add a check at the beginning to see if the syscall is present, and if not just note one error and return. When we run on a system that doesn't implement the syscall we will get ENOSYS back from the kernel, so change the logic that handles __NR_execveat not being defined to also use ENOSYS rather than -ENOSYS. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Acked-by: David Drysdale <drysdale@google.com> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
2015-01-06selftests/exec: allow shell return code of 126David Drysdale1-6/+13
When the shell fails to invoke a script because its path name is too long (ENAMETOOLONG), most shells return 127 to indicate command not found. However, some systems report 126 (which POSIX suggests should indicate a non-executable file) for this case, so allow that too. Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: David Drysdale <drysdale@google.com> Tested-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
2014-12-22selftests/exec: Use %zu to format size_tGeert Uytterhoeven1-2/+2
On 32-bit: execveat.c: In function 'check_execveat_pathmax': execveat.c:183: warning: format '%lu' expects type 'long unsigned int', but argument 3 has type 'size_t' execveat.c:187: warning: format '%lu' expects type 'long unsigned int', but argument 2 has type 'size_t' Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
2014-12-13syscalls: add selftest for execveat(2)David Drysdale1-0/+397
Signed-off-by: David Drysdale <drysdale@google.com> Cc: Meredydd Luff <meredydd@senatehouse.org> Cc: Shuah Khan <shuah.kh@samsung.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Kees Cook <keescook@chromium.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Rich Felker <dalias@aerifal.cx> Cc: Christoph Hellwig <hch@infradead.org> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>