Re: [PATCH v2] tty: Permit some TIOCL_SETSEL modes without CAP_SYS_ADMIN

From: Jared Finder
Date: Sat Feb 22 2025 - 16:15:01 EST


On 2025-02-20 16:10, Günther Noack wrote:

Jared, can you please confirm whether Emacs works now with this patch
in the kernel?

I am asking this because I realized that the patch had a bug. We are
erring in the "secure" direction, but not all TIOCL_SELMOUSEREPORT
invocations work without CAP_SYS_ADMIN.

I confirmed that Emacs worked fine with 6.14-rc1. My understanding is that the Emacs process relies only on TIOCL_SELPOINTER which it needs to do to draw the mouse pointer after Emacs' redisplay. It's fine for TIOCL_SELMOUSEREPORT to not work in an unpriviliged Emacs.

If this specific selection mode is not needed by Emacs, I think *the
best thing would be to keep it guarded by CAP_SYS_ADMIN, after all*.

This sounds good to me.

Reading over a documentation proposal for TIOCL_SELMOUSEREPORT (https://lkml.org/lkml/2020/7/6/249), I can not imagine how a userspace program that was not acting as the mouse daemon could successfully use SELMOUSEREPORT as the mouse daemon will be fighting with it. Any legitimate setting of mouse state (for example, setting the mouse x/y coordinate) would need to be done with the mouse daemon in the loop, in which case the mouse daemon might as well send the message itself.

-- MJF