Skip to content

Commit 4695d66

Browse files
committed
2 parents c97409f + 4ecbbd3 commit 4695d66

File tree

3 files changed

+110
-11
lines changed

3 files changed

+110
-11
lines changed

coreutils-selinux/.SRCINFO

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pkgbase = coreutils-selinux
22
pkgdesc = The basic file, shell and text manipulation utilities of the GNU operating system with SELinux support
3-
pkgver = 9.5
3+
pkgver = 9.6
44
pkgrel = 2
55
url = https://www.gnu.org/software/coreutils/
66
arch = x86_64
@@ -18,14 +18,14 @@ pkgbase = coreutils-selinux
1818
depends = libcap
1919
depends = libselinux
2020
depends = openssl
21-
provides = coreutils=9.5-2
22-
provides = selinux-coreutils=9.5-2
21+
provides = coreutils=9.6-2
22+
provides = selinux-coreutils=9.6-2
2323
conflicts = coreutils
2424
conflicts = selinux-coreutils
25-
source = git+https://git.savannah.gnu.org/git/coreutils.git?signed#tag=v9.5
26-
source = gcc14-gnulib-lto.patch
25+
source = git+https://git.savannah.gnu.org/git/coreutils.git?signed#tag=v9.6
26+
source = 915004f403cb25fadb207ddfdbe6a2f43bd44fac.patch
2727
validpgpkeys = 6C37DC12121A5006BC1DB804DF6FD971306037D9
28-
b2sums = 7b48eaa372037f1162335dacbc6460a1455e7b6c73badefd631b1a47cfab6072db938a25ce9bdba68c2b3ac13e9c64df06fef6f135d2979199cb09f41f83454a
29-
b2sums = 1264b815101ebf98ce846ac96a649cc7964624ae0c140f23d41f2d2e8292f67b0c0cad3d66f6329a2d21c530b1cfbff65ef378abd8e49f3a1ac972a1cf88366d
28+
b2sums = 8d8ee559af5401564314c87e6b2affb670d6de59546b23dab3fa5235d6d3c71f841f91dcb6daf9bf38db25ebc3c21db4f9a536568744fabe3d02bcf9430c90ca
29+
b2sums = d365086f33ffd770c8f457348561ed4120919c84f1bd4126495cd339f85a1fbf99845e1b17032a4ea579a93986f45ad71add1cd997e6a43235852087eac1279d
3030

3131
pkgname = coreutils-selinux
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
From 915004f403cb25fadb207ddfdbe6a2f43bd44fac Mon Sep 17 00:00:00 2001
2+
From: =?utf8?q?P=C3=A1draig=20Brady?= <[email protected]>
3+
Date: Fri, 17 Jan 2025 17:29:34 +0000
4+
Subject: [PATCH] ls: fix crash with --context
5+
6+
* src/ls.c (main): Flag that we need to stat()
7+
if we're going to get security context (call file_has_aclinfo_cache).
8+
(file_has_aclinfo_cache): Be defensive and only lookup the device
9+
for the file if the stat has been performed.
10+
(has_capability_cache): Likewise.
11+
* tests/ls/selinux-segfault.sh: Add a test case.
12+
* NEWS: Mention the bug fix.
13+
Reported by Bruno Haible.
14+
---
15+
NEWS | 5 +++++
16+
src/ls.c | 10 +++++-----
17+
tests/ls/selinux-segfault.sh | 3 +++
18+
3 files changed, 13 insertions(+), 5 deletions(-)
19+
20+
diff --git a/NEWS b/NEWS
21+
index 9be61e4c4..c9ba5f196 100644
22+
--- a/NEWS
23+
+++ b/NEWS
24+
@@ -2,6 +2,11 @@ GNU coreutils NEWS -*- outline -*-
25+
26+
* Noteworthy changes in release ?.? (????-??-??) [?]
27+
28+
+** Bug fixes
29+
+
30+
+ `ls -Z dir` would crash.
31+
+ [bug introduced in coreutils-9.6]
32+
+
33+
34+
* Noteworthy changes in release 9.6 (2025-01-17) [stable]
35+
36+
diff --git a/src/ls.c b/src/ls.c
37+
index 321536021..f67167f16 100644
38+
--- a/src/ls.c
39+
+++ b/src/ls.c
40+
@@ -1768,7 +1768,7 @@ main (int argc, char **argv)
41+
42+
format_needs_stat = ((sort_type == sort_time) | (sort_type == sort_size)
43+
| (format == long_format)
44+
- | print_block_size | print_hyperlink);
45+
+ | print_block_size | print_hyperlink | print_scontext);
46+
format_needs_type = ((! format_needs_stat)
47+
& (recursive | print_with_color | print_scontext
48+
| directories_first
49+
@@ -3309,7 +3309,7 @@ file_has_aclinfo_cache (char const *file, struct fileinfo *f,
50+
static int unsupported_scontext_err;
51+
static dev_t unsupported_device;
52+
53+
- if (f->stat.st_dev == unsupported_device)
54+
+ if (f->stat_ok && f->stat.st_dev == unsupported_device)
55+
{
56+
ai->buf = ai->u.__gl_acl_ch;
57+
ai->size = 0;
58+
@@ -3322,7 +3322,7 @@ file_has_aclinfo_cache (char const *file, struct fileinfo *f,
59+
errno = 0;
60+
int n = file_has_aclinfo (file, ai, flags);
61+
int err = errno;
62+
- if (n <= 0 && !acl_errno_valid (err))
63+
+ if (f->stat_ok && n <= 0 && !acl_errno_valid (err))
64+
{
65+
unsupported_return = n;
66+
unsupported_scontext = ai->scontext;
67+
@@ -3342,14 +3342,14 @@ has_capability_cache (char const *file, struct fileinfo *f)
68+
found that has_capability fails indicating lack of support. */
69+
static dev_t unsupported_device;
70+
71+
- if (f->stat.st_dev == unsupported_device)
72+
+ if (f->stat_ok && f->stat.st_dev == unsupported_device)
73+
{
74+
errno = ENOTSUP;
75+
return 0;
76+
}
77+
78+
bool b = has_capability (file);
79+
- if ( !b && !acl_errno_valid (errno))
80+
+ if (f->stat_ok && !b && !acl_errno_valid (errno))
81+
unsupported_device = f->stat.st_dev;
82+
return b;
83+
}
84+
diff --git a/tests/ls/selinux-segfault.sh b/tests/ls/selinux-segfault.sh
85+
index 11623acb3..1cac2b5fc 100755
86+
--- a/tests/ls/selinux-segfault.sh
87+
+++ b/tests/ls/selinux-segfault.sh
88+
@@ -30,4 +30,7 @@ mkdir sedir || framework_failure_
89+
ln -sf missing sedir/broken || framework_failure_
90+
returns_ 1 ls -L -R -Z -m sedir > out || fail=1
91+
92+
+# ls 9.6 would segfault with the following
93+
+ls -Z . > out || fail=1
94+
+
95+
Exit $fail
96+
--
97+
2.17.1
98+

coreutils-selinux/PKGBUILD

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# If you want to help keep it up to date, please open a Pull Request there.
1212

1313
pkgname=coreutils-selinux
14-
pkgver=9.5
14+
pkgver=9.6
1515
pkgrel=2
1616
pkgdesc='The basic file, shell and text manipulation utilities of the GNU operating system with SELinux support'
1717
arch=('x86_64' 'aarch64')
@@ -41,13 +41,14 @@ provides=("${pkgname/-selinux}=${pkgver}-${pkgrel}"
4141
"selinux-${pkgname/-selinux}=${pkgver}-${pkgrel}")
4242
source=(
4343
git+https://git.savannah.gnu.org/git/coreutils.git?signed#tag=v${pkgver}
44-
gcc14-gnulib-lto.patch
44+
# 915004f403cb25fadb207ddfdbe6a2f43bd44fac.patch::https://git.savannah.gnu.org/gitweb/"?p=coreutils.git;a=patch;h=915004f403cb25fadb207ddfdbe6a2f43bd44fac"
45+
915004f403cb25fadb207ddfdbe6a2f43bd44fac.patch
4546
)
4647
validpgpkeys=(
4748
6C37DC12121A5006BC1DB804DF6FD971306037D9 # Pádraig Brady
4849
)
49-
b2sums=('7b48eaa372037f1162335dacbc6460a1455e7b6c73badefd631b1a47cfab6072db938a25ce9bdba68c2b3ac13e9c64df06fef6f135d2979199cb09f41f83454a'
50-
'1264b815101ebf98ce846ac96a649cc7964624ae0c140f23d41f2d2e8292f67b0c0cad3d66f6329a2d21c530b1cfbff65ef378abd8e49f3a1ac972a1cf88366d')
50+
b2sums=('8d8ee559af5401564314c87e6b2affb670d6de59546b23dab3fa5235d6d3c71f841f91dcb6daf9bf38db25ebc3c21db4f9a536568744fabe3d02bcf9430c90ca'
51+
'd365086f33ffd770c8f457348561ed4120919c84f1bd4126495cd339f85a1fbf99845e1b17032a4ea579a93986f45ad71add1cd997e6a43235852087eac1279d')
5152

5253
prepare() {
5354
cd "${pkgname/-selinux}"

0 commit comments

Comments
 (0)