Fix leaking of FDs requested from logind
ClosedPublic

Authored by fvogt on Nov 18 2017, 10:27 PM.

Details

Summary

The takeDevice method calls dup, but that syscall removes the O_CLOEXEC flag
as a side-effect. This resulted in all child processes of kwin_wayland having
an open file descriptor for those devices.

Test Plan

Looked at the open FDs of the startplasma script. Before, all
/dev/input/eventX files and /dev/dri/card0 were open. Now, none of those
are part of /proc/PID/fd/

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
fvogt created this revision.Nov 18 2017, 10:27 PM
Restricted Application added a project: KWin. · View Herald TranscriptNov 18 2017, 10:27 PM
Restricted Application added subscribers: KWin, kwin. · View Herald Transcript
graesslin added inline comments.Nov 19 2017, 8:07 AM
logind.cpp
387

Which systems wouldn't have it?

fvogt added inline comments.Nov 19 2017, 10:50 AM
logind.cpp
387

FD_DUPFD_CLOEXEC is Linux specific. I don't know whether this code path could get used on BSDs.

Should this go into Plasma/5.11 (probably even 5.8) as well?

In D8887#169520, @fvogt wrote:

Should this go into Plasma/5.11 (probably even 5.8) as well?

5.11 yes! Wayland support is not covered by LTS, so I don't see a need to fix in 5.8.

logind.cpp
387

AFAIK libinput is Linux specific, so this code path can be Linux specific as well.

fvogt updated this revision to Diff 22592.Nov 19 2017, 11:30 AM

Remove non-linux codepath

Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptNov 19 2017, 11:30 AM
graesslin accepted this revision.Nov 19 2017, 1:22 PM
This revision is now accepted and ready to land.Nov 19 2017, 1:22 PM
This revision was automatically updated to reflect the committed changes.