public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* inappropriate capability checks in tty_ioctl()
@ 2024-01-02 11:38 孟敬姿
  2024-01-02 11:51 ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: 孟敬姿 @ 2024-01-02 11:38 UTC (permalink / raw)
  To: gregkh, jirislaby; +Cc: linux-kernel, linux-serial

Hi!

We would like to propose an adjustment to the capability checks in the tty_ioctl() function. Currently, the function uses CAP_SYS_ADMIN to protect three subcommands: TIOCCONS, TIOCSTI and TIOCVHANGUP. We propose updating this to use CAP_SYS_TTY_CONFIG instead for the following reasons:

(1) CAP_SYS_TTY_CONFIG is more relevant to the functions: The three subcommands are responsible for tty-related functions: redirecting console output (TIOCCONS), faking input to a terminal (TIOCSTI), and making the terminal be hung up (TIOCVHANGUP). As the definitions in the capability manual page[1], CAP_SYS_TTY_CONFIG is specifically designed for "employing various privileged ioctl(2) operations on virtual terminals." This aligns more closely with the intended usage scenario compared to CAP_SYS_ADMIN.

(2) Consistency: CAP_SYS_TTY_CONFIG is already employed in other parts of the kernel to protect TIOCVHANGUP-like functionality. For instance, in tty_ioctl() CAP_SYS_ADMIN is used before tty_vhangup(), while in SYSCALL_DEFINE0(vhangup), which located in fs/open.c, the check is done with CAP_SYS_TTY_CONFIG before tty_vhangup().

(3) Maintaining Least Privilege: CAP_SYS_ASMIN is already overloaded and known as the new "root"[2]. According to the manual page[1] “don't choose CAP_SYS_ADMIN if you can possibly avoid it”, switching to CAP_SYS_TTY_CONFIG could be helpful for standardizing the use of capabilities and implementing least privileges. 

This issue exists in several kernel versions and we have checked it on the latest stable release(Linux 6.6.9). We would appreciate your thoughts and feedback on this proposal. Thank you for your time and consideration.

Best regards,
Jingzi

reference:
[1] https://www.man7.org/linux/man-pages/man7/capabilities.7.html
[2] https://lwn.net/Articles/486306/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-01-15 15:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-02 11:38 inappropriate capability checks in tty_ioctl() 孟敬姿
2024-01-02 11:51 ` Greg KH
2024-01-15  8:24   ` [PATCH] tty: change the privilege required for tty operarions Jingzi Meng
2024-01-15  8:35     ` Greg KH
2024-01-15  9:55       ` 孟敬姿
2024-01-15 12:04         ` Greg KH
     [not found]       ` <a47cd6e2-571f-4146-961f-758a51c52550@iie.ac.cn>
2024-01-15 15:34         ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox