Subject: bug#74220: invisible cursor

From: Jared Finder <[email-masked]>
Date: Thu, 28 Nov 2024 10:21:53 -0800

On 2024-11-27 19:13, Jared Finder wrote:
> On 2024-11-17 17:37, Jared Finder wrote:
>> On 2024-11-06 08:17, Stephen Berman wrote:
>>> On Wed, 06 Nov 2024 07:38:52 -0800 Jared Finder via "Bug reports for 
>>> GNU Emacs, the Swiss army knife of text editors" 
>>> <[email-masked]> wrote:
>>> 
>>>> I tested this locally at HEAD (b5845e) on Linux debian 
>>>> 6.1.0-13-amd64 and
>>>> everything is working fine.
>>>> 
>>>> Could you please describe what terminal (the output of "echo $TERM") 
>>>> and
>>>> kernel version (the output of "uname -a") you are using when you 
>>>> have this
>>>> issue? Can you try toggling M-x gpm-mouse-mode on and off and share 
>>>> if any
>>>> errors are reported?
>>> 
>>> I can reproduce the issue in the Linux terminal (echo $TERM => linux,
>>> uname -a => Linux strobelfssd 6.10.6 #1 SMP PREEMPT_DYNAMIC Mon Aug 
>>> 19
>>> 12:15:23 CEST 2024 x86_64 GNU/Linux).  When I start emacs there with 
>>> -Q,
>> 
>> Thank you, I am able to reproduce the issue locally on "Linux debian 
>> 6.11.5+bpo-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.11.5-1~bpo12+1 
>> (2024-11-11) x86_64 GNU=Linux". I will investigate.
> 
> This appears to be due to something happening at a lower level than 
> Emacs, though perhaps Emacs is not interfacing with GPM correctly.
> 
> This started happening in multiple Emacs versions with Linux 6.7. I 
> tested HEAD, 29.4, and 28.2 -- all three versions worked fine with 
> Linux 6.6.63 and then exhibit this bug starting with Linux 6.7. 
> GPM_DrawPointer is still being called, of course (since this works in 
> previous Linux versions), but is no longer having any effect.
> 
> I will keep investigating here.

AH HA!

This was an intentional change to Linux 6.7 to avoid a potential 
privilege escalation. Specifically, apps without the capability 
CAP_SYS_ADMIN are no longer able to set the kernel selection buffer. 
Across Emacs versions, granting the Emacs binary the CAP_SYS_ADMIN 
capability (sudo setcap cap_sys_admin+ep path/to/emacs) fixes the issue.

But is this the right fix? CAP_SYS_ADMIN grants many dangerous 
capabilities on Linux. An alternative fix would be to update redisplay 
on terminals to draw the mouse cursor. Perhaps this is what is done on 
other OSes? I would like guidance here on which path is recommended.

   -- MJF