The quilt patch titled Subject: selftests/capabilities: fix possible file leak in copy_fromat_to has been removed from the -mm tree. Its filename was selftests-capabilities-fix-possible-file-leak-in-copy_fromat_to.patch This patch was dropped because it was nacked ------------------------------------------------------ From: Ma Ke <make24@xxxxxxxxxxx> Subject: selftests/capabilities: fix possible file leak in copy_fromat_to Date: Sun, 30 Jun 2024 21:00:38 +0800 open() returns -1 on error. openat() and open() initialize 'from' and 'to', and only 'from' validated with 'if' statement. If the initialization of variable 'to' fails, we should better check the value of 'to' and close 'from' to avoid possible file leak. Improve the checking of 'from' additionally. Link: https://lkml.kernel.org/r/20240630130038.3671507-1-make24@xxxxxxxxxxx Fixes: 32ae976ed3b5 ("selftests/capabilities: Add tests for capability evolution") Signed-off-by: Ma Ke <make24@xxxxxxxxxxx> Reviewed-by: Muhammad Usama Anjum <usama.anjum@xxxxxxxxxxxxx> Cc: Amer Al Shanawany <amer.shanawany@xxxxxxxxx> Cc: Andy Lutomirski <luto@xxxxxxxxxx> Cc: Kees Cook <kees@xxxxxxxxxx> Cc: Shuah Khan <shuah@xxxxxxxxxx> Cc: Swarup Laxman Kotiaklapudi <swarupkotikalapudi@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- tools/testing/selftests/capabilities/test_execve.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/tools/testing/selftests/capabilities/test_execve.c~selftests-capabilities-fix-possible-file-leak-in-copy_fromat_to +++ a/tools/testing/selftests/capabilities/test_execve.c @@ -145,10 +145,14 @@ static void chdir_to_tmpfs(void) static void copy_fromat_to(int fromfd, const char *fromname, const char *toname) { int from = openat(fromfd, fromname, O_RDONLY); - if (from == -1) + if (from < 0) ksft_exit_fail_msg("open copy source - %s\n", strerror(errno)); int to = open(toname, O_CREAT | O_WRONLY | O_EXCL, 0700); + if (to < 0) { + close(from); + ksft_exit_fail_msg("open copy destination - %s\n", strerror(errno)); + } while (true) { char buf[4096]; _ Patches currently in -mm which might be from make24@xxxxxxxxxxx are