Bug 485085 - On X11, unlocked desktop with apps flashes before kscreenlocker obscures the locked screen after wake-up from sleep
Summary: On X11, unlocked desktop with apps flashes before kscreenlocker obscures the ...
Status: CONFIRMED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Screen locking (show other bugs)
Version: 6.2.4
Platform: Neon Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: X11-only
: 492735 498003 500498 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-04-05 14:53 UTC by Daniel Duris
Modified: 2025-03-05 09:02 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Duris 2024-04-05 14:53:51 UTC
SUMMARY
Unlocked screen flashes showing potentially private info before kscreenlocker kicks in and obscures the screen

STEPS TO REPRODUCE
1. Sleep KDE
2. Wake up computer
3. Flash of unlocked screen before kscreenlocker locks the screen

OBSERVED RESULT
Flash of unlocked screen before kscreenlocker locks the screen

EXPECTED RESULT
Kscreenlocker launched immediately, unlocked screen not visible

SOFTWARE/OS VERSIONS
Operating System: KDE neon 6.0
KDE Plasma Version: 6.0.3
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.3
Kernel Version: 6.5.0-26-generic (64-bit)
Graphics Platform: X11
Comment 1 TraceyC 2024-04-11 20:11:00 UTC
I can reproduce this.

Operating System: Solus 4.5
KDE Plasma Version: 6.0.3
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.3
Kernel Version: 6.6.22-281.current (64-bit)
Graphics Platform: X11
Processors: 16 × 11th Gen Intel® Core™ i7-11800H @ 2.30GHz
Memory: 62.5 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2
Manufacturer: Dell Inc.
Product Name: XPS 17 9710
Comment 2 Daniel Duris 2024-04-13 18:12:52 UTC
Another thing that seems related - once on a locked screen, if I press Esc key, it goes to blank/black screen, where nothing is shown, not even a cursor. Pressing Esc once more goes back to lockscreen. Esc used to defocus out of the "enter password" dialog, now it does this. Definitely not a feature as not even a background is shown.
Comment 3 popov895 2024-05-20 17:53:10 UTC
(In reply to Daniel Duris from comment #2)
> Another thing that seems related - once on a locked screen, if I press Esc
> key, it goes to blank/black screen, where nothing is shown, not even a
> cursor. Pressing Esc once more goes back to lockscreen. Esc used to defocus
> out of the "enter password" dialog, now it does this. Definitely not a
> feature as not even a background is shown.

It's not a bug. Pressing Esc when the screen is locked simply turns it off/on.
Comment 4 Daniel Duris 2024-08-19 18:15:36 UTC
This seems to be fixed in the latest KDE.

Operating System: KDE neon 6.0
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Comment 5 Daniel Duris 2024-08-20 07:34:24 UTC
Nope, unfortunately, the flash of unlocked content has happened again.
Comment 6 MrAndersen 2024-08-22 11:23:49 UTC
I can also confirm this bug. It happens every time I wake the computer from sleep.
Has been like this for the last couple of months now. 
However, if I invoke the lock screen (Meta-L) before putting the computer to sleep, it does not happen.

Operating System: Manjaro Linux 
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Kernel Version: 6.6.46-1-MANJARO (64-bit)
Graphics Platform: X11
Processors: 4 × Intel® Core™ i7-3520M CPU @ 2.90GHz
Graphics Processor: Mesa Intel® HD Graphics 4000
Manufacturer: LENOVO
Product Name: 2356FE6
System Version: ThinkPad T430s
Comment 7 TraceyC 2024-09-04 14:14:54 UTC
I've noticed that on my system, I don't see this bug with Wayland. I only see it with X11.
Comment 8 cwo 2024-09-12 19:09:48 UTC
*** Bug 492735 has been marked as a duplicate of this bug. ***
Comment 9 kdebugs 2024-09-12 20:10:09 UTC
(In reply to cwo from comment #8)
> *** Bug 492735 has been marked as a duplicate of this bug. ***

Thanks!  I did look for duplicates, but apparently my method was flawed. Looking back at my url history, it seems that by default, https://bugs.kde.org/query.cgi adds my email address in the "Search By People" section, which isn't even expanded unless I happen to click on it, so I had no idea I was only looking for bugs I already had some involvement with.

But one thing this bug hasn't mentioned, which my duplicate bug did, is the wording of the settings.  If indeed the desired behavior is for it to lock before sleeping, then why does it say lock after waking up?

According to MrAnderson in comment 6, it doesn't happen when he manually locks the screen before sleeping, which would seem to indicate it's only locking after waking up.  But that seems contrary to what Martin Flöser said in bug 388384: "The screen is supposed to be locked before going to suspend. In fact the lock screen ensures that suspending gets delayed till the screen is locked."
Comment 10 cwo 2024-12-30 14:00:10 UTC
*** Bug 498003 has been marked as a duplicate of this bug. ***
Comment 11 Steve Vialle 2024-12-31 08:09:34 UTC
It's a race. The screenlocker is supposed to start before suspend, but it gets frozen before it has time to draw over the desktop. This has been going on for over a decade (https://bugs.kde.org/show_bug.cgi?id=316734), and apparently nobody is interested in fixing it because "it works on wayland".

The easiest workaround is to add a short sleep during the suspend/hibernate process (e.g. in /etc/[e]logind/system-sleep/foo) so that the screenlocker has time to actually draw a frame before PM freezes tasks.
Comment 12 TraceyC 2025-02-27 01:53:38 UTC
*** Bug 500498 has been marked as a duplicate of this bug. ***
Comment 13 kbtr.buffer098 2025-03-04 15:57:01 UTC
Well, the "works on Wayland" is relative. I did notice it happening also there, just way quicker than in Xorg and not always, therefore probably not looking as bad an issue, but still existing.

I found on the settings an option called "Lock after waking from sleep". I don't know if it's related, but this makes me thing that the locking is happening, as the option says, after waking up, and during the time between waking up and locking, the desktop is shown.

If I lock the screen first, and then put the computer to sleep, when I wake it up, it behaves 100% correctly, both on Xorg and Wayland. Which makes me think the screen locking should happen **before** going to sleep.

I'd like to remark that this can represent a major privacy and security issue for some people when using computers in shared environments and should be addressed, even if we're moving on to Wayland. Unfortunately I don't have the technical ability to fix this myself, otherwise I'd volunteer. Hope to see somebody step up soon, as this seems to have been a problem for quite a few releases already.
Comment 14 TraceyC 2025-03-04 18:17:26 UTC
I tested this on Wayland on git-master, as well as Plasma 6.3.2 and was unable to reproduce
"Lock after waking from sleep" was enabled

1. Put the system to sleep
2. Wake the system

I saw nothing but the login screen, no flash of anything on the desktop
Comment 15 kdebugs 2025-03-05 08:05:33 UTC
If it's really a race, as Steve Vialle indicates, then one's inability to reproduce is of no consequence; only one's ability to reproduce would be of consequence.  The only indication that it has indeed been fixed is to point to code that was changed.  While Steve Vialle's workaround is a help to those who experience the problem the most, it isn't ultimately a way of fixing things.  What we need is a guarantee that the screen has in fact been redrawn/repainted, and only then sleep the system.

per comment 13:
> I did notice it happening also there, just way quicker than in Xorg and not always, therefore probably not looking as bad an issue, but still existing.

That's consistent with a race condition.   As for "not looking as bad" on Wayland, that is of course relative.  Anyone actively exploiting this security/privacy bug could use a camera and then take as much time as he likes to read the screen.  And, given this report, the bug's current title "On X11, ..." and keyword "X11-only" are wrong and should be changed.

And of course, once fixed, the wording of the settings should be changed from "Lock after waking" to "Lock before sleeping".
Comment 16 Steve Vialle 2025-03-05 09:02:22 UTC
(In reply to kbtr.buffer098 from comment #13)
> the screen locking should happen **before** going to sleep.
Of course it should, that's the only way to ensure that, in the (very likely) event GPU memory is restored before the relevant KDE process(es) are thawed, said memory doesn't contain an image of the unlocked desktop.


(In reply to kdebugs from comment #15)
> The only indication that it has indeed been fixed is to point
> to code that was changed.
AIUI, the "indication" is a callback from kwaylandserver to say the screenlocker window has been mapped... Not that the framebuffer has actually been updated mind, just that the screenlocker has a window. If that is indeed how it (currently) works, then it's still going to be racy, just less so. 
On X11 we don't even have that much, as far as I can see it's just "fire and hope".

Personally I doubt this will ever be fixed, Nate's comment from the bug I linked (which, IMO, should never have been closed as this was never *properly* addressed) kinda says it all WRT interest:
"if you want a better experience here, use Wayland."

Why there is so much resistance to implementing even the bare-minimum workaround I don't know. While certainly not ideal, surely a sub-second delay before calling suspend is still preferable to this rather obvious security flaw.