]> git.ipfire.org Git - thirdparty/glibc.git/commit
Fix SXID_ERASE behavior in setuid programs (BZ #27471)
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Tue, 16 Mar 2021 07:07:55 +0000 (12:37 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Wed, 14 Apr 2021 05:38:02 +0000 (11:08 +0530)
commit2c9083f93ded1b9754d0ad302a05e0c5c1a57dbc
treebb3399c0622cea38a78abed5fe75a9e20b79763d
parentdcfcb1b208cd94847807492eee74059f0943b975
Fix SXID_ERASE behavior in setuid programs (BZ #27471)

When parse_tunables tries to erase a tunable marked as SXID_ERASE for
setuid programs, it ends up setting the envvar string iterator
incorrectly, because of which it may parse the next tunable
incorrectly.  Given that currently the implementation allows malformed
and unrecognized tunables pass through, it may even allow SXID_ERASE
tunables to go through.

This change revamps the SXID_ERASE implementation so that:

- Only valid tunables are written back to the tunestr string, because
  of which children of SXID programs will only inherit a clean list of
  identified tunables that are not SXID_ERASE.

- Unrecognized tunables get scrubbed off from the environment and
  subsequently from the child environment.

- This has the side-effect that a tunable that is not identified by
  the setxid binary, will not be passed on to a non-setxid child even
  if the child could have identified that tunable.  This may break
  applications that expect this behaviour but expecting such tunables
  to cross the SXID boundary is wrong.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 2ed18c5b534d9e92fc006202a5af0df6b72e7aca)
elf/dl-tunables.c
elf/tst-env-setuid-tunables.c