diff mbox series

[bug#61462,v2,01/10] system: Disallow file-like setuid-programs.

Message ID 129e8d298556f6a159fcb704ed3df4bf0709ddd3.1689465600.git.me@tobias.gr
State New
Headers show
Series [bug#61462,v2,01/10] system: Disallow file-like setuid-programs. | expand

Commit Message

Tobias Geerinckx-Rice July 15, 2023, 11:59 p.m. UTC
It has been a warning for well over a year now.  Now, with
privileged-programs coming, don't let's support nested deprecation
hacks.

* gnu/system.scm (<operating-system>):
Don't ‘sanitize’ the setuid-programs field.
(ensure-setuid-program-list): Delete syntax.
(%ensure-setuid-program-list): Delete variable.
---

This is a quick snapshot of my rebased tree at the request of vagrantc.

There shouldn't be any functional changes.  If there are, that's cool too.

 gnu/system.scm | 28 +---------------------------
 1 file changed, 1 insertion(+), 27 deletions(-)


base-commit: 21b718f4d6c3ded8ef50d12f6e9ae6474f74620f
prerequisite-patch-id: efc79914a4e3e994a8786e02774237de36f6b105
prerequisite-patch-id: 1986dc849c15ae6c1502df25f9c17b53a02df83d
prerequisite-patch-id: bb189cbd1346b0d00e9b79189155c9916731788b
prerequisite-patch-id: 062a02ed88acf0f11c5895b67065faa55d71fae8
prerequisite-patch-id: 2eea585e7940a16c24baeed3b65a123b1b10fd6b
prerequisite-patch-id: 31a3407b0c583d01cc2664168ec6cf499f10cb53
prerequisite-patch-id: a0566799f4aef296a3efcd228c3a223202662f86
prerequisite-patch-id: cd50cb9494a47433c7fd167729e239178c78d7f1
prerequisite-patch-id: e86e94b9a40613e3ce534ce778d027210b93b05a
prerequisite-patch-id: c7068d2079b3d2f0f172cc4cf9e0791ff5e84da3
prerequisite-patch-id: b52b35693094914ea1962ac2f186a52617d38c8a
prerequisite-patch-id: b2bdf5541825c9cd57d2fe3e3e9a90e5fc8ffbe6
prerequisite-patch-id: f085c8ee7c7f1d0250b0ed8a548a72d397d96056
prerequisite-patch-id: 49c8f3f912d24147362a3a874c2b2c0b4b182d5d
prerequisite-patch-id: 1f0fc1ca1a40444f4831beaf3183d7d4f866fd6d
prerequisite-patch-id: 8c69acfe3cb01ff3c0a46a2efe04b53ad063002d
prerequisite-patch-id: 10f972ac75020ce096d83b53a68a3b2f1eba1c8c
prerequisite-patch-id: 74586b82a25b775527adc7e8cf09b15bdb4850f7
prerequisite-patch-id: 7388ac8d395ef16830105026230e47d903026335
prerequisite-patch-id: 2c7df330bf50663218016e01b9c0922a6b3a001f
prerequisite-patch-id: f45ec5e6d6023fc5538e1578bbb4e270d7b23baf
prerequisite-patch-id: 0083d0b8d60fd0e526449cd192f153d0bd1bde0b
prerequisite-patch-id: 7e6e4ab87b52996e9bb6cd8595889f21ba87e9fe

Comments

Vagrant Cascadian July 21, 2023, 6:53 p.m. UTC | #1
Thanks for the refreshed v2 patches! I gave them a quick spin...

As noted on IRC, apparently it lacks actual calls to setcap, so that
part still needs another patch at least!

Otherwise, it did seem to more-or-less work...

There are compatibility symlinks from /run/setuid-programs to
/run/privledged/bin and it sets setuid on requested files.

I was a little curious about why /run/privlidged/bin as opposed to
without /bin ... keeping the door open for other privlidged things? What
about things that come from /gnu/store/*/sbin ? are those handled any
differently?

My only concern is... wow is it hard, even for a native speaker, to
spell privileged!

live well,
  vagrant
Vagrant Cascadian July 21, 2023, 7:11 p.m. UTC | #2
On 2023-07-21, Vagrant Cascadian wrote:
> Thanks for the refreshed v2 patches! I gave them a quick spin...
>
> As noted on IRC, apparently it lacks actual calls to setcap, so that
> part still needs another patch at least!
>
> Otherwise, it did seem to more-or-less work...
>
> There are compatibility symlinks from /run/setuid-programs to
> /run/privledged/bin and it sets setuid on requested files.

Oh, I noticed on reconfiguring back to a system without the patches to
support /run/privileged configurations ... the /run/privileged directory
is still present, with all those files sitting there in their previous
state.

This is why I think at least by default, many other distros implement
/run as a tmpfs or similar, so that it at least gets thrown out at
reboot. Though this is obviously a deeper problem than just this patch
series... I will file a separate bug about that.

live well,
  vagrant
Ludovic Courtès Aug. 8, 2023, 3:40 p.m. UTC | #3
Hey!

Vagrant Cascadian <vagrant@debian.org> skribis:

> Oh, I noticed on reconfiguring back to a system without the patches to
> support /run/privileged configurations ... the /run/privileged directory
> is still present, with all those files sitting there in their previous
> state.
>
> This is why I think at least by default, many other distros implement
> /run as a tmpfs or similar, so that it at least gets thrown out at
> reboot. Though this is obviously a deeper problem than just this patch
> series... I will file a separate bug about that.

We could try to make that change: /run as tmpfs, or wiped by
‘cleanup-service-type’.

Ludo’.
Vagrant Cascadian Aug. 29, 2023, 8:29 p.m. UTC | #4
On 2023-08-08, Ludovic Courtès wrote:
> Vagrant Cascadian <vagrant@debian.org> skribis:
>> Oh, I noticed on reconfiguring back to a system without the patches to
>> support /run/privileged configurations ... the /run/privileged directory
>> is still present, with all those files sitting there in their previous
>> state.
>>
>> This is why I think at least by default, many other distros implement
>> /run as a tmpfs or similar, so that it at least gets thrown out at
>> reboot. Though this is obviously a deeper problem than just this patch
>> series... I will file a separate bug about that.
>
> We could try to make that change: /run as tmpfs, or wiped by
> ‘cleanup-service-type’.

Or both, really!

Filed:

  https://issues.guix.gnu.org/64775

live well,
  vagrant
Brian Cully Aug. 29, 2023, 9:21 p.m. UTC | #5
Vagrant Cascadian <vagrant@debian.org> writes:

> On 2023-08-08, Ludovic Courtès wrote:
>> We could try to make that change: /run as tmpfs, or wiped by
>> ‘cleanup-service-type’.
>
> Or both, really!
>
> Filed:
>
>   https://issues.guix.gnu.org/64775

I tried this a while ago, and the trivial case of mounting /run as tmpfs
in the operating-system definition causes errors during activation. It
turns out that the /run/current-system symlink is activated before all
non-root mounts, so mounting /run afterwards causes everything to break.

I don't have a solution, and haven't even looked at it past this, but
maybe this report will help.

-bjc
Vagrant Cascadian Nov. 15, 2023, 9:37 p.m. UTC | #6
On 2023-07-21, Vagrant Cascadian wrote:
> Thanks for the refreshed v2 patches! I gave them a quick spin...
>
> As noted on IRC, apparently it lacks actual calls to setcap, so that
> part still needs another patch at least!
>
> Otherwise, it did seem to more-or-less work...

I did eventually get some updated patches that even followed through on
the promise of calling out to setcap, and from what I recall they even
worked! I liked them a lot.


> There are compatibility symlinks from /run/setuid-programs to
> /run/privledged/bin and it sets setuid on requested files.
>
> I was a little curious about why /run/privlidged/bin as opposed to
> without /bin ... keeping the door open for other privlidged things? What
> about things that come from /gnu/store/*/sbin ? are those handled any
> differently?

Working patches aside, that is my only outstanding question, and I would
hate to see that be a blocker. :)


In short, "ping" :)


live well,
  vagrant
Vagrant Cascadian Dec. 24, 2023, 12:34 a.m. UTC | #7
On 2023-11-15, Vagrant Cascadian wrote:
> On 2023-07-21, Vagrant Cascadian wrote:
>> Thanks for the refreshed v2 patches! I gave them a quick spin...
>>
>> As noted on IRC, apparently it lacks actual calls to setcap, so that
>> part still needs another patch at least!
>>
>> Otherwise, it did seem to more-or-less work...
>
> I did eventually get some updated patches that even followed through on
> the promise of calling out to setcap, and from what I recall they even
> worked! I liked them a lot.
>
>
>> There are compatibility symlinks from /run/setuid-programs to
>> /run/privledged/bin and it sets setuid on requested files.
>>
>> I was a little curious about why /run/privlidged/bin as opposed to
>> without /bin ... keeping the door open for other privlidged things? What
>> about things that come from /gnu/store/*/sbin ? are those handled any
>> differently?
>
> Working patches aside, that is my only outstanding question, and I would
> hate to see that be a blocker. :)

I just noticed I pushed a branch with the working patches to a public
branch last month:

  https://salsa.debian.org/debian/guix/-/tree/capabilities-61462-20231115?ref_type=heads

They are even still cherry-pickable from current master! Yay!

These patches were started over a year ago(well, probably before that,
even), and had a working implementation about 6 months ago...

My guess is the main blocker is nervousness about renaming
setuid-programs to privilidged-programs (I know I am a bit nervous to do
so!)?


This would make it possible to properly fix several bugs:

  https://issues.guix.gnu.org/27415
  https://issues.guix.gnu.org/39136
  https://issues.guix.gnu.org/39136
  https://issues.guix.gnu.org/55683

And have been mentioned indirectly in several others over the years:

  https://issues.guix.gnu.org/search?query=setcap


live well,
  vagrant
Ludovic Courtès Jan. 8, 2024, 4:45 p.m. UTC | #8
Hello!

Vagrant Cascadian <vagrant@debian.org> skribis:

> I just noticed I pushed a branch with the working patches to a public
> branch last month:
>
>   https://salsa.debian.org/debian/guix/-/tree/capabilities-61462-20231115?ref_type=heads
>
> They are even still cherry-pickable from current master! Yay!

Wo0t!

> These patches were started over a year ago(well, probably before that,
> even), and had a working implementation about 6 months ago...
>
> My guess is the main blocker is nervousness about renaming
> setuid-programs to privilidged-programs (I know I am a bit nervous to do
> so!)?

It shouldn’t be an issue as /run/setuid-programs is populated with
symlinks for backward compatibility.

AIUI, we can still use good’ol setuid programs on the Hurd until a
better solution is found, so we should be fine (meaning
“make check-system TESTS=childhurd” should pass).

We could emit a deprecation warning when someone uses the
‘setuid-programs’ field of <operating-system>.  Not a blocker though.

Tobias, ready to push? :-)

Cheers,
Ludo’.
diff mbox series

Patch

diff --git a/gnu/system.scm b/gnu/system.scm
index 23addf41e9..e32879b240 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -296,8 +296,7 @@  (define-record-type* <operating-system> operating-system
   (pam-services operating-system-pam-services     ; list of PAM services
                 (default (base-pam-services)))
   (setuid-programs operating-system-setuid-programs
-                   (default %setuid-programs)     ; list of <setuid-program>
-                   (sanitize ensure-setuid-program-list))
+                   (default %setuid-programs))    ; list of <setuid-program>
 
   (sudoers-file operating-system-sudoers-file     ; file-like
                 (default %sudoers-specification))
@@ -1203,31 +1202,6 @@  (define (operating-system-environment-variables os)
     ;; when /etc/machine-id is missing.  Make sure these warnings are non-fatal.
     ("DBUS_FATAL_WARNINGS" . "0")))
 
-;; Ensure LST is a list of <setuid-program> records and warn otherwise.
-(define-with-syntax-properties (ensure-setuid-program-list (lst properties))
-  (%ensure-setuid-program-list lst properties))
-
-;; We want to be able to use defines, so define a procedure.
-(define (%ensure-setuid-program-list lst properties)
-  (define warned? #f)
-
-  (define (warn-once)
-    (unless warned?
-      (warning (source-properties->location properties)
-               (G_ "representing setuid programs with file-like objects is \
-deprecated; use 'setuid-program' instead~%"))
-      (set! warned? #t)))
-
-  (map (match-lambda
-         ((? setuid-program? program)
-          program)
-         (program
-          ;; PROGRAM is a file-like or a gexp like #~(string-append #$foo
-          ;; "/bin/bar").
-          (warn-once)
-          (setuid-program (program program))))
-       lst))
-
 (define %setuid-programs
   ;; Default set of setuid-root programs.
   (let ((shadow (@ (gnu packages admin) shadow)))