Clipboard is not cleared when screen locked
Affected version
- OS: Fedora 40 and Arch
- Mutter: 46.0
- Windowing system: XOrg and Wayland
Bug summary
In js/ui/screenShield.js
:
// Clear the clipboard - otherwise, its contents may be leaked
// to unauthorized parties by pasting into the unlock dialog's
// password entry and unmasking the entry
St.Clipboard.get_default().set_text(St.ClipboardType.CLIPBOARD, '');
St.Clipboard.get_default().set_text(St.ClipboardType.PRIMARY, '');
However, when locking screen, this error shows in journal:
Mar 26 21:56:21 hostname gnome-shell[3620882]: Failed to create new MetaSelectionSourceMemory: Failed to create MetaAnonymousFile
Mar 26 21:56:21 hostname gnome-shell[3620882]: Failed to create new MetaSelectionSourceMemory: Failed to create MetaAnonymousFile
The error is triggered in src/st/st-clipboard.c
, st_clipboard_set_content()
:
source = meta_selection_source_memory_new (mimetype, bytes, &error);
if (!source)
{
g_warning ("Failed to create new MetaSelectionSourceMemory: %s",
error->message);
return;
}
With GDB attached, the root cause of error is inside mutter src/core/meta-anonymous-file.c
, create_anonymous_file()
:
(gdb) l
141 {
142 ret = posix_fallocate (fd, 0, size);
143 }
144 while (ret == EINTR);
145
146 if (ret != 0)
147 {
148 close (fd);
149 errno = ret;
150 return -1;
(gdb) print ret
$7 = 22
(gdb) print fd
$8 = 36
(gdb) print size
$9 = 0
Where errno 22 means "EINVAL", man page of posix_fallocate
:
EINVAL offset was less than 0, or len was less than or equal to 0, or the underlying filesystem does not support the operation.
Well, len here is 0. I'm not familiar with the anonymous files stuff, seems like it could be fixed by skipping posix_fallocate
when size == 0
.
Steps to reproduce
- Copy some text
- Lock screen
- Paste to password box
What happened
The paste succeeds.
What did you expect to happen
Nothing shall be pasted.
Relevant logs, screenshots, screencasts etc.
N/A