Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: remove /dev/input/ based idle detection #2463

Merged
merged 1 commit into from
Jun 12, 2018
Merged

client: remove /dev/input/ based idle detection #2463

merged 1 commit into from
Jun 12, 2018

Conversation

JuhaSointusalo
Copy link
Contributor

The code tries to open /dev/input/mice as if it was a directory. If
there are no input devices, like in a headless machine, the code
repeatedly tries to make a list of input devices. On Debian, these bugs,
together with Debian's patches to BOINC, result in useless error
messages in client's log.

On SELinux systems, services can access device nodes in /dev/input/ only
if given that right in SELinux configuration. On some Fedora versions
BOINC client doesn't have that right and the code results in numerous
SELinux warnings. These warnings in turn result in high CPU usage when
the system analyzes the warnings.

Furthermore, the code doesn't work at all. The code expects that input
drivers update timestamps on device nodes when the drivers receive input
from devices. The input drivers however have no such code. Checking
driver commit logs suggest that if such code ever existed it was so long
time ago that we don't need to care about it and testing distros of
various ages confirms that.

Since the code doesn't and can't work solve the problems on Debian and
Fedora by just removing the code altogether. The code was only used on
Linux and /dev/input/ seems to be Linux only thing anyway.

Note that the client has similar code for checking terminal devices.
Contrary to the input device code that code does work correctly. This is
because programs running on a terminal have their inputs and outputs
connected to the terminal device node. Input to or output from a program
results in a read from or write to device node and terminal drivers do
have code that updates timestamps on reads and writes.

Closes #2335.
See #1187.

The code tries to open /dev/input/mice as if it was a directory. If
there are no input devices, like in a headless machine, the code
repeatedly tries to make a list of input devices. On Debian, these bugs,
together with Debian's patches to BOINC, result in useless error
messages in client's log.

On SELinux systems, services can access device nodes in /dev/input/ only
if given that right in SELinux configuration. On some Fedora versions
BOINC client doesn't have that right and the code results in numerous
SELinux warnings. These warnings in turn result in high CPU usage when
the system analyzes the warnings.

Furthermore, the code doesn't work at all. The code expects that input
drivers update timestamps on device nodes when the drivers receive input
from devices. The input drivers however have no such code. Checking
driver commit logs suggest that if such code ever existed it was so long
time ago that we don't need to care about it and testing distros of
various ages confirms that.

Since the code doesn't and can't work solve the problems on Debian and
Fedora by just removing the code altogether. The code was only used on
Linux and /dev/input/ seems to be Linux only thing anyway.

Note that the client has similar code for checking terminal devices.
Contrary to the input device code that code does work correctly. This is
because programs running on a terminal have their inputs and outputs
connected to the terminal device node. Input to or output from a program
results in a read from or write to device node and terminal drivers do
have code that updates timestamps on reads and writes.

Closes #2335.
See #1187.
@JuhaSointusalo
Copy link
Contributor Author

@Germano0 @lfield

Fedora has allowed BOINC client to access input devices for some time. boinc.te

You might want to have that access right removed from the policy at same point, after this change is in a released BOINC version and once you are sure that no-one running an older BOINC version is going to receive a policy update.

You might also want have the change made to the upstream repo as well. I don't normally run SELinux distros and I don't know much about SELinux anyway so I'd rather not request it myself. I wouldn't see any problems that change might create.

@Germano0
Copy link
Contributor

You might want to have that access right removed from the policy at same point, after this change is in a released BOINC version and once you are sure that no-one running an older BOINC version is going to receive a policy update.

You might also want have the change made to the upstream repo as well. I don't normally run SELinux distros and I don't know much about SELinux anyway so I'd rather not request it myself. I wouldn't see any problems that change might create.

Thank you @JuhaSointusalo, I will take care of updating both Fedora and upstream SELinux rules

Germano0 added a commit to thetra0/refpolicy-contrib that referenced this pull request Apr 11, 2018
boinc no longer needs permissions to run stat command on /dev/input/*
BOINC/boinc#2463

Signed-off-by: Germano Massullo <[email protected]>
Germano0 added a commit to thetra0/selinux-policy-contrib that referenced this pull request Apr 11, 2018
boinc no longer needs permissions to run stat command on /dev/input/*
BOINC/boinc#2463

Note: the affected boinc code never worked
BOINC/boinc#1187
BOINC/boinc#2335

Upstream pull request
OwlCyberDefense/refpolicy-contrib#68

Signed-off-by: Germano Massullo <[email protected]>
wrabcak pushed a commit to fedora-selinux/selinux-policy-contrib that referenced this pull request Apr 15, 2018
boinc no longer needs permissions to run stat command on /dev/input/*
BOINC/boinc#2463

Note: the affected boinc code never worked
BOINC/boinc#1187
BOINC/boinc#2335

Upstream pull request
OwlCyberDefense/refpolicy-contrib#68

Signed-off-by: Germano Massullo <[email protected]>
wrabcak pushed a commit to fedora-selinux/selinux-policy-contrib that referenced this pull request Apr 15, 2018
boinc no longer needs permissions to run stat command on /dev/input/*
BOINC/boinc#2463

Note: the affected boinc code never worked
BOINC/boinc#1187
BOINC/boinc#2335

Upstream pull request
OwlCyberDefense/refpolicy-contrib#68

Signed-off-by: Germano Massullo <[email protected]>
@TheAspens
Copy link
Member

@davidpanderson or @CharlieFenton or @lfield - can one of you review this code and confirm it is good to merge? I'm not familiar enough with this level of linux to make the call.

@lfield
Copy link
Contributor

lfield commented May 3, 2018

I think is is ok. AFAIK looking at /dev/input doesn't work. It only makes sense to get the idle time from the xserver.

@SETIguy
Copy link
Contributor

SETIguy commented May 3, 2018 via email

@JuhaSointusalo
Copy link
Contributor Author

I had checked CentOS 4.8 and 5.11; Debian 5 and 9; Fedora 27; Mandrake 10.1; Mint 10 (=Ubuntu 10.10), 11, 14, 16 and 17 (=Ubuntu 14.04) and Scientific Linux 6.3. The oldest kernel was 2.6.8 from around 2004.

I didn't think to check Android. Android has more security features enabled than average desktop Linux so I would be surprised if the code worked on Android even if the Android/Linux kernel somehow otherwise was updating /dev/input timestamps.

I also checked FreeBSD 11.1; NetBSD 7.1.2; OpenBSD 6.3 and Solaris 11.3. None had /dev/input.

I didn't check AIX or HP-UX because they don't run on x86. Haiku is open-source clone of BeOS which I think was it's own kind of OS and probably didn't have /dev at all. DragonflyBSD is a fork of some other BSD and probably doesn't have /dev/input either. There is some OS that runs on Raspberry PI, maybe called RiscOS or something. I didn't check it and don't really know if BOINC even runs on it. I forgot about OS/2 / eComStation and I don't know if it's still alive or freely available.

Anything else?

The interesting kernel files are evdev.c, input.c and mousedev.c and for comparison tty_io.c which does update timestamps on PTY/TTY device nodes. The kernel history on GitHub goes back to 2005 and 2.6.12-rc2 which is IMHO old enough.

@CharlieFenton
Copy link
Contributor

I also am not familiar with this level of Linux.

@Germano0
Copy link
Contributor

Germano0 commented May 3, 2018

The interesting kernel files are evdev.c, input.c and mousedev.c and for comparison tty_io.c which does update timestamps on PTY/TTY device nodes. The kernel history on GitHub goes back to 2005 and 2.6.12-rc2 which is IMHO old enough.

IMHO the best solution for Linux idle detection is using logind features. Read: #1187 (comment)

@JuhaSointusalo
Copy link
Contributor Author

One way to look at this is to run stat /dev/input/* (which is basically what the client does), note the times, type something on keyboard and move mouse and use other input devices, wait a few moments, run the command again and observe that the times have not changed. Repeat the test on a selection of different distros and come to the conclusion that the code doesn't work at all.

The rest is just that I wasn't satisfied with "doesn't work at all" and needed to explain to myself why the code doesn't work when the similar code for TTYs does work.

@TheAspens
Copy link
Member

@JuhaSointusalo - can you let me know the status of this? Is there anything pending that you need to do and if it is ready - who do you think the most suitable reviewers are? Thanks!

@JuhaSointusalo
Copy link
Contributor Author

can you let me know the status of this

It's ready.

who do you think the most suitable reviewers are

Anyone who can check that the code doesn't work anywhere.

@TheAspens
Copy link
Member

@lfield - would you be willing to review and merge if you are ok with it? I don't know linux at this level well enough to feel comfortable doing the review and merge.

@lfield
Copy link
Contributor

lfield commented Jun 11, 2018

I am fine with this change. We can only test on a limited set of machines this will be merged for wider testing.

@lfield lfield closed this Jun 11, 2018
@RichardHaselgrove
Copy link
Contributor

This is an example of the sort of change which should be tested from master, long before the next release branch is forked.

Otherwise, we fall foul of "Too early to test, too late to change".

@TheAspens
Copy link
Member

@lfield - did you mean to merge the pull request or close it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants