|
|
e63663 |
From 53c6b01e8e3fd338d7f53e5ff817ef86f9efa852 Mon Sep 17 00:00:00 2001
|
|
|
e63663 |
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
|
|
|
e63663 |
Date: Wed, 11 Nov 2020 17:22:33 +0000
|
|
|
e63663 |
Subject: [PATCH] ls: fix crash printing SELinux context for unstatable files
|
|
|
e63663 |
|
|
|
e63663 |
This crash was identified by Cyber Independent Testing Lab:
|
|
|
e63663 |
https://cyber-itl.org/2020/10/28/citl-7000-defects.html
|
|
|
e63663 |
and was introduced with commit v6.9.90-11-g4245876e2
|
|
|
e63663 |
|
|
|
e63663 |
* src/ls.c (gobble_file): Ensure scontext is initialized
|
|
|
e63663 |
in the case where files are not statable.
|
|
|
e63663 |
* tests/ls/selinux-segfault.sh: Renamed from proc-selinux-segfault.sh,
|
|
|
e63663 |
and added test case for broken symlinks.
|
|
|
e63663 |
* tests/local.mk: Adjust for the renamed test.
|
|
|
e63663 |
|
|
|
e63663 |
Upstream-commit: 6fc695cb4a26f09dfeef8b1c24895a707055334e
|
|
|
e63663 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
e63663 |
---
|
|
|
e63663 |
src/ls.c | 3 +++
|
|
|
e63663 |
tests/local.mk | 2 +-
|
|
|
e63663 |
.../{proc-selinux-segfault.sh => selinux-segfault.sh} | 10 ++++++++--
|
|
|
e63663 |
3 files changed, 12 insertions(+), 3 deletions(-)
|
|
|
e63663 |
rename tests/ls/{proc-selinux-segfault.sh => selinux-segfault.sh} (77%)
|
|
|
e63663 |
|
|
|
e63663 |
diff --git a/src/ls.c b/src/ls.c
|
|
|
e63663 |
index 4acf5f4..8eb483d 100644
|
|
|
e63663 |
--- a/src/ls.c
|
|
|
e63663 |
+++ b/src/ls.c
|
|
|
e63663 |
@@ -3412,6 +3412,9 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
|
|
|
e63663 |
provokes an exit status of 1. */
|
|
|
e63663 |
file_failure (command_line_arg,
|
|
|
e63663 |
_("cannot access %s"), full_name);
|
|
|
e63663 |
+
|
|
|
e63663 |
+ f->scontext = UNKNOWN_SECURITY_CONTEXT;
|
|
|
e63663 |
+
|
|
|
e63663 |
if (command_line_arg)
|
|
|
e63663 |
return 0;
|
|
|
e63663 |
|
|
|
e63663 |
diff --git a/tests/local.mk b/tests/local.mk
|
|
|
e63663 |
index 2aeff2b..2441fdc 100644
|
|
|
e63663 |
--- a/tests/local.mk
|
|
|
e63663 |
+++ b/tests/local.mk
|
|
|
e63663 |
@@ -616,7 +616,7 @@ all_tests = \
|
|
|
e63663 |
tests/ls/multihardlink.sh \
|
|
|
e63663 |
tests/ls/no-arg.sh \
|
|
|
e63663 |
tests/ls/no-cap.sh \
|
|
|
e63663 |
- tests/ls/proc-selinux-segfault.sh \
|
|
|
e63663 |
+ tests/ls/selinux-segfault.sh \
|
|
|
e63663 |
tests/ls/quote-align.sh \
|
|
|
e63663 |
tests/ls/readdir-mountpoint-inode.sh \
|
|
|
e63663 |
tests/ls/recursive.sh \
|
|
|
e63663 |
diff --git a/tests/ls/proc-selinux-segfault.sh b/tests/ls/selinux-segfault.sh
|
|
|
e63663 |
similarity index 77%
|
|
|
e63663 |
rename from tests/ls/proc-selinux-segfault.sh
|
|
|
e63663 |
rename to tests/ls/selinux-segfault.sh
|
|
|
e63663 |
index 831a00e..e2b7ef6 100755
|
|
|
e63663 |
--- a/tests/ls/proc-selinux-segfault.sh
|
|
|
e63663 |
+++ b/tests/ls/selinux-segfault.sh
|
|
|
e63663 |
@@ -1,5 +1,5 @@
|
|
|
e63663 |
#!/bin/sh
|
|
|
e63663 |
-# ls -l /proc/sys would segfault when built against libselinux1 2.0.15-2+b1
|
|
|
e63663 |
+# Ensure we don't segfault in selinux handling
|
|
|
e63663 |
|
|
|
e63663 |
# Copyright (C) 2008-2020 Free Software Foundation, Inc.
|
|
|
e63663 |
|
|
|
e63663 |
@@ -19,9 +19,15 @@
|
|
|
e63663 |
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
|
|
|
e63663 |
print_ver_ ls
|
|
|
e63663 |
|
|
|
e63663 |
+# ls -l /proc/sys would segfault when built against libselinux1 2.0.15-2+b1
|
|
|
e63663 |
f=/proc/sys
|
|
|
e63663 |
test -r $f || f=.
|
|
|
e63663 |
-
|
|
|
e63663 |
ls -l $f > out || fail=1
|
|
|
e63663 |
|
|
|
e63663 |
+# ls <= 8.32 would segfault when printing
|
|
|
e63663 |
+# the security context of broken symlink targets
|
|
|
e63663 |
+mkdir sedir || framework_failure_
|
|
|
e63663 |
+ln -sf missing sedir/broken || framework_failure_
|
|
|
e63663 |
+returns_ 1 ls -L -R -Z -m sedir > out || fail=1
|
|
|
e63663 |
+
|
|
|
e63663 |
Exit $fail
|
|
|
e63663 |
--
|
|
|
e63663 |
2.26.2
|
|
|
e63663 |
|