* Re: [PATCH] cap_syslog: remove CAP_SYS_ADMIN when dmesg_restrict
2024-01-05 6:20 ` [PATCH] cap_syslog: remove CAP_SYS_ADMIN when dmesg_restrict Jingzi Meng
@ 2024-01-05 14:49 ` Theodore Ts'o
2024-01-05 15:23 ` Petr Mladek
2024-01-08 6:32 ` 孟敬姿
2024-01-08 17:57 ` Kees Cook
2024-02-01 18:05 ` Kees Cook
2 siblings, 2 replies; 11+ messages in thread
From: Theodore Ts'o @ 2024-01-05 14:49 UTC (permalink / raw)
To: Jingzi Meng
Cc: gregkh, gpiccoli, john.ogness, keescook, linux-hardening,
linux-kernel, pmladek, rostedt, senozhatsky, tony.luck
On Fri, Jan 05, 2024 at 02:20:07PM +0800, Jingzi Meng wrote:
> CAP_SYSLOG was separated from CAP_SYS_ADMIN and introduced in Linux
> 2.6.37 (2010-11). For a long time, certain syslog actions required
> CAP_SYS_ADMIN or CAP_SYSLOG. Maybe it’s time to officially remove
> CAP_SYS_ADMIN for more fine-grained control.
>
> CAP_SYS_ADMIN was once removed but added back for backwards
> compatibility reasons. In commit 38ef4c2e437d ("syslog: check cap_syslog
> when dmesg_restrict") (2010-12), CAP_SYS_ADMIN was no longer needed. And
> in commit ee24aebffb75 ("cap_syslog: accept CAP_SYS_ADMIN for now")
> (2011-02), it was accepted again. Since then, CAP_SYS_ADMIN has been
> preserved.
>
> Now that almost 13 years have passed, the legacy application may have
> had enough time to be updated.
What testing have you done to make sure that this is OK? "May have
had enough time"? That's not very reassuring?
Also, note that we can't actually reuse the bit position of
CAP_SYS_ADMIN since it's likely that there may be pre-existing
capability masks that are still using that position. So there isn't
all that much upside in trying to retire CAP_SYS_ADMIN --- if you as a
system administrator think it's not too course, then just don't use
it.
It's unclear to me what goal you have in trying to mess with the
capability definitions? Perhaps it might be useful if you were to
explicitly state your goals in these proposals?
Thanks,
- Ted
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] cap_syslog: remove CAP_SYS_ADMIN when dmesg_restrict
2024-01-05 14:49 ` Theodore Ts'o
@ 2024-01-05 15:23 ` Petr Mladek
2024-01-08 6:32 ` 孟敬姿
1 sibling, 0 replies; 11+ messages in thread
From: Petr Mladek @ 2024-01-05 15:23 UTC (permalink / raw)
To: Theodore Ts'o
Cc: Jingzi Meng, gregkh, gpiccoli, john.ogness, keescook,
linux-hardening, linux-kernel, rostedt, senozhatsky, tony.luck
On Fri 2024-01-05 09:49:44, Theodore Ts'o wrote:
> On Fri, Jan 05, 2024 at 02:20:07PM +0800, Jingzi Meng wrote:
> > CAP_SYSLOG was separated from CAP_SYS_ADMIN and introduced in Linux
> > 2.6.37 (2010-11). For a long time, certain syslog actions required
> > CAP_SYS_ADMIN or CAP_SYSLOG. Maybe it’s time to officially remove
> > CAP_SYS_ADMIN for more fine-grained control.
> >
> > CAP_SYS_ADMIN was once removed but added back for backwards
> > compatibility reasons. In commit 38ef4c2e437d ("syslog: check cap_syslog
> > when dmesg_restrict") (2010-12), CAP_SYS_ADMIN was no longer needed. And
> > in commit ee24aebffb75 ("cap_syslog: accept CAP_SYS_ADMIN for now")
> > (2011-02), it was accepted again. Since then, CAP_SYS_ADMIN has been
> > preserved.
> >
> > Now that almost 13 years have passed, the legacy application may have
> > had enough time to be updated.
>
> What testing have you done to make sure that this is OK? "May have
> had enough time"? That's not very reassuring?
>
> Also, note that we can't actually reuse the bit position of
> CAP_SYS_ADMIN since it's likely that there may be pre-existing
> capability masks that are still using that position. So there isn't
> all that much upside in trying to retire CAP_SYS_ADMIN --- if you as a
> system administrator think it's not too course, then just don't use
> it.
>
> It's unclear to me what goal you have in trying to mess with the
> capability definitions? Perhaps it might be useful if you were to
> explicitly state your goals in these proposals?
My understanding is that this patch is about reducing overlap of
capabilities.
Allowing the same thing with more capabilities seems to go against
the idea of separate capabilities.
Kernel has printed the warning for 13 years. It is a long
time to fix configuration for newly installed systems. And I doubt
that anyone is installing a new kernel on 13 year's old system.
IMHO, this fits into the category that it should be OK until
anyone complains. But I might miss something.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] cap_syslog: remove CAP_SYS_ADMIN when dmesg_restrict
2024-01-05 14:49 ` Theodore Ts'o
2024-01-05 15:23 ` Petr Mladek
@ 2024-01-08 6:32 ` 孟敬姿
1 sibling, 0 replies; 11+ messages in thread
From: 孟敬姿 @ 2024-01-08 6:32 UTC (permalink / raw)
To: Theodore Ts'o
Cc: gregkh, gpiccoli, john.ogness, keescook, linux-hardening,
linux-kernel, pmladek, rostedt, senozhatsky, tony.luck
On Fri 2024-01-05 09:49:44, Theodore Ts'o wrote:
> It's unclear to me what goal you have in trying to mess with the
> capability definitions? Perhaps it might be useful if you were to
> explicitly state your goals in these proposals?
Petr is right, we are trying to resolve the overlap problem of capability.
Capability is about to separate superuser privileges into distinct units for
finer-grained access control. It’s effective work requires the kernel to use
proper capability for sensitive resources and the user programs to choose the
right capability instead of ROOT to execute. And we want to promote the
standardized use of capability.
> So there isn't all that much upside in trying to retire CAP_SYS_ADMIN
We are not going to retire CAP_SYS_ADMIN, but saying that CAP_SYSLOG is the
more appropriate capability when it comes to protecting syslog functionality.
CAP_SYS_ADMIN is already overloaded, check out the link[1], narrowing down its
definitions will facilitate the implementation of least privilege. This adjustment
makes it clearer for a user program requiring syslog access to specify only the
necessary capability, CAP_SYSLOG, instead of relying on the broader CAP_SYS_ADMIN.
> What testing have you done to make sure that this is OK?
We booted the modified kernel and confirmed that CAP_SYS_ADMIN no longer has access
to syslog when dmesg is set.
While certain user programs relying on CAP_SYS_ADMIN for syslog access might be impacted,
they can adjust their capability configuration using the ‘setcap’ command. Decreasing the
reliance on CAP_SYS_ADMIN across applications contributes to minimizing security risks in
the system. Currently, it's uncertain if any such programs exist.
Best regrads,
Jingzi
[1]: https://lwn.net/Articles/486306/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] cap_syslog: remove CAP_SYS_ADMIN when dmesg_restrict
2024-01-05 6:20 ` [PATCH] cap_syslog: remove CAP_SYS_ADMIN when dmesg_restrict Jingzi Meng
2024-01-05 14:49 ` Theodore Ts'o
@ 2024-01-08 17:57 ` Kees Cook
2024-01-15 1:24 ` 孟敬姿
2024-02-01 18:05 ` Kees Cook
2 siblings, 1 reply; 11+ messages in thread
From: Kees Cook @ 2024-01-08 17:57 UTC (permalink / raw)
To: Jingzi Meng
Cc: gregkh, gpiccoli, john.ogness, linux-hardening, linux-kernel,
pmladek, rostedt, senozhatsky, tony.luck
On Fri, Jan 05, 2024 at 02:20:07PM +0800, Jingzi Meng wrote:
> CAP_SYSLOG was separated from CAP_SYS_ADMIN and introduced in Linux
> 2.6.37 (2010-11). For a long time, certain syslog actions required
> CAP_SYS_ADMIN or CAP_SYSLOG. Maybe it’s time to officially remove
> CAP_SYS_ADMIN for more fine-grained control.
>
> CAP_SYS_ADMIN was once removed but added back for backwards
> compatibility reasons. In commit 38ef4c2e437d ("syslog: check cap_syslog
> when dmesg_restrict") (2010-12), CAP_SYS_ADMIN was no longer needed. And
> in commit ee24aebffb75 ("cap_syslog: accept CAP_SYS_ADMIN for now")
> (2011-02), it was accepted again. Since then, CAP_SYS_ADMIN has been
> preserved.
>
> Now that almost 13 years have passed, the legacy application may have
> had enough time to be updated.
I can't find anything mention this warning in recent times except this:
https://sysdig.com/blog/container-escape-capabilities-falco-detection/
which is mainly an example about how to apply Capabilities, not a
software failure.
> Signed-off-by: Jingzi Meng <mengjingzi@iie.ac.cn>
Reviewed-by: Kees Cook <keescook@chromium.org>
If you can boot a few stock modern distros and verify nothing emits this
warning any more should be sufficient evidence that this can be dropped.
-Kees
--
Kees Cook
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] cap_syslog: remove CAP_SYS_ADMIN when dmesg_restrict
2024-01-08 17:57 ` Kees Cook
@ 2024-01-15 1:24 ` 孟敬姿
0 siblings, 0 replies; 11+ messages in thread
From: 孟敬姿 @ 2024-01-15 1:24 UTC (permalink / raw)
To: Kees Cook
Cc: gregkh, gpiccoli, john.ogness, linux-hardening, linux-kernel,
pmladek, rostedt, senozhatsky, tony.luck
I tested on ubuntu 22.04.3 LTS kernel 6.2.16 and Fedora 39 kernel 6.6.11,
the warning is gone, and CAP_SYS_ADMIN is no longer authorized to bypass
check_syslog_permissions().
Best regards,
Jingzi
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] cap_syslog: remove CAP_SYS_ADMIN when dmesg_restrict
2024-01-05 6:20 ` [PATCH] cap_syslog: remove CAP_SYS_ADMIN when dmesg_restrict Jingzi Meng
2024-01-05 14:49 ` Theodore Ts'o
2024-01-08 17:57 ` Kees Cook
@ 2024-02-01 18:05 ` Kees Cook
2 siblings, 0 replies; 11+ messages in thread
From: Kees Cook @ 2024-02-01 18:05 UTC (permalink / raw)
To: gregkh, Jingzi Meng
Cc: Kees Cook, gpiccoli, john.ogness, linux-hardening, linux-kernel,
pmladek, rostedt, senozhatsky, tony.luck
On Fri, 05 Jan 2024 14:20:07 +0800, Jingzi Meng wrote:
> CAP_SYSLOG was separated from CAP_SYS_ADMIN and introduced in Linux
> 2.6.37 (2010-11). For a long time, certain syslog actions required
> CAP_SYS_ADMIN or CAP_SYSLOG. Maybe it’s time to officially remove
> CAP_SYS_ADMIN for more fine-grained control.
>
> CAP_SYS_ADMIN was once removed but added back for backwards
> compatibility reasons. In commit 38ef4c2e437d ("syslog: check cap_syslog
> when dmesg_restrict") (2010-12), CAP_SYS_ADMIN was no longer needed. And
> in commit ee24aebffb75 ("cap_syslog: accept CAP_SYS_ADMIN for now")
> (2011-02), it was accepted again. Since then, CAP_SYS_ADMIN has been
> preserved.
>
> [...]
Applied to for-next/hardening, thanks!
[1/1] cap_syslog: remove CAP_SYS_ADMIN when dmesg_restrict
https://git.kernel.org/kees/c/09ce61e27db8
Take care,
--
Kees Cook
^ permalink raw reply [flat|nested] 11+ messages in thread