Skip to content

Commit f5d7c08

Browse files
committed
runcon: revert "disable use of the TIOCSTI ioctl"
This reverts commit v8.27-97-g8cb06d4 because the setsid() fallback was not implemented correctly and disabling the ioctl was not a complete solution to the security issue of the child being passed the tty of the parent. Given runcon is not really a sandbox command, the advice is to use `runcon ... setsid ...` to avoid this particular issue.
1 parent f169345 commit f5d7c08

File tree

6 files changed

+0
-78
lines changed

6 files changed

+0
-78
lines changed

NEWS

-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ GNU coreutils NEWS -*- outline -*-
7272
non regular files are specified, as inotify is ineffective with these.
7373
[bug introduced with inotify support added in coreutils-7.5]
7474

75-
runcon now disables use of the TIOCSTI ioctl in its children, which could
76-
be used to inject commands to the terminal and run at the original context.
77-
[the issue dates back to the initial implementation]
78-
7975
uptime no longer outputs the AM/PM component of the current time,
8076
as that's inconsistent with the 24 hour time format used.
8177
[bug introduced in coreutils-7.0]

m4/jm-macros.m4

-13
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,6 @@ AC_DEFUN([coreutils_MACROS],
6363
esac
6464
fi
6565
])
66-
67-
# Used by runcon.c
68-
LIB_SECCOMP=
69-
AC_SUBST([LIB_SECCOMP])
70-
if test "$with_selinux" != no; then
71-
AC_SEARCH_LIBS([seccomp_init], [seccomp],
72-
[test "$ac_cv_search_seccomp_init" = "none required" ||
73-
LIB_SECCOMP=$ac_cv_search_seccomp_init
74-
AC_DEFINE([HAVE_SECCOMP], [1], [libseccomp usability])],
75-
[test "$ac_cv_header_selinux_selinux_h" = yes &&
76-
AC_MSG_WARN([libseccomp library was not found or not usable])
77-
AC_MSG_WARN([runcon will be vulnerable to tty injection])])
78-
fi
7966
LIBS=$coreutils_saved_libs
8067
8168
# Used by sort.c.

src/local.mk

-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ src_mkfifo_LDADD += $(LIB_SMACK)
243243
src_mknod_LDADD += $(LIB_SELINUX)
244244
src_mknod_LDADD += $(LIB_SMACK)
245245
src_runcon_LDADD += $(LIB_SELINUX)
246-
src_runcon_LDADD += $(LIB_SECCOMP)
247246
src_stat_LDADD += $(LIB_SELINUX)
248247

249248
# for nvlist_lookup_uint64_array

src/runcon.c

-28
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@
4545
#include <getopt.h>
4646
#include <selinux/selinux.h>
4747
#include <selinux/context.h>
48-
#ifdef HAVE_SECCOMP
49-
# include <seccomp.h>
50-
# include <sys/ioctl.h>
51-
#endif
5248
#include <sys/types.h>
5349
#include "system.h"
5450
#include "die.h"
@@ -106,28 +102,6 @@ With neither CONTEXT nor COMMAND, print the current security context.\n\
106102
exit (status);
107103
}
108104

109-
static void
110-
disable_tty_inject (void)
111-
{
112-
#ifdef HAVE_SECCOMP
113-
scmp_filter_ctx ctx = seccomp_init (SCMP_ACT_ALLOW);
114-
if (! ctx)
115-
die (EXIT_FAILURE, 0, _("failed to initialize seccomp context"));
116-
if (seccomp_rule_add (ctx, SCMP_ACT_ERRNO (EPERM), SCMP_SYS (ioctl), 1,
117-
SCMP_A1 (SCMP_CMP_EQ, (int) TIOCSTI)) < 0)
118-
die (EXIT_FAILURE, 0, _("failed to add seccomp rule"));
119-
if (seccomp_load (ctx) < 0)
120-
die (EXIT_FAILURE, 0, _("failed to load seccomp rule"));
121-
seccomp_release (ctx);
122-
#else
123-
/* This may have unwanted side effects, but is a fallback
124-
on older systems without libseccomp. */
125-
if (setsid () != 0)
126-
die (EXIT_FAILURE, errno, _("cannot create session"));
127-
#endif /* HAVE_SECCOMP */
128-
}
129-
130-
131105
int
132106
main (int argc, char **argv)
133107
{
@@ -221,8 +195,6 @@ main (int argc, char **argv)
221195
die (EXIT_FAILURE, 0, _("%s may be used only on a SELinux kernel"),
222196
program_name);
223197

224-
disable_tty_inject ();
225-
226198
if (context)
227199
{
228200
con = context_new (context);

tests/local.mk

-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ all_tests = \
333333
tests/misc/readlink-root.sh \
334334
tests/misc/realpath.sh \
335335
tests/misc/runcon-no-reorder.sh \
336-
tests/misc/runcon-no-inject.sh \
337336
tests/misc/sha1sum.pl \
338337
tests/misc/sha1sum-vec.pl \
339338
tests/misc/sha224sum.pl \

tests/misc/runcon-no-inject.sh

-31
This file was deleted.

0 commit comments

Comments
 (0)