Re: [PATCH v3 2/2] tty: Allow TIOCSTI to be disabled
From: Kees Cook
Date: Wed Jun 28 2023 - 12:33:07 EST
On Wed, Jun 28, 2023 at 08:07:16AM +0200, Samuel Thibault wrote:
> Kees Cook, le mar. 27 juin 2023 19:48:45 -0700, a ecrit:
> > On Sun, Jun 25, 2023 at 05:56:25PM +0200, Samuel Thibault wrote:
> > > > Can we perhaps just introduce a CAP_TIOCSTI that the brltty daemon would
> > > > be able to use? We could even make it only allow TIOCSTI on the linux
> > > > console (tty->ops == con_ops).
> >
> > Does brltty run with CAP_SYS_ADMIN?
>
> ATM most often, yes, though we are trying to reduce the CAP_* privileges
> to what it actually needs.
>
> > > *Please* comment on this so we can progress. ATM people are
> > > advising each other to set dev.tty.legacy_tiocsti=1, which is just
> > > counter-productive in terms of security...
> >
> > So is there really no solution for brltty and TIOCSTI being disabled?
>
> No, there is no way to simulate characters on the Linux console. The
> alternative would be to use uinput, but that simulates keycodes, not
> characters, thus requiring backtranslating first, which is very fragile.
>
> > What is FreeBSD doing? I imagine it's the same situation there too,
> > though maybe there is just no support?
>
> There is just no support in the kernel, only a patch against "screen".
>
> > > Really, this a serious regression for the people affected by this.
> >
> > Can you send a patch adding a CAP_SYS_ADMIN exception?
>
> Sure!
Thanks! (And be sure to use file->f_cred for the check[1], not "current",
that way brltty can open the tty and drop caps and still do the ioctl.)
-Kees
https://docs.kernel.org/security/credentials.html?highlight=confused+deputy#open-file-credentials
--
Kees Cook