Skip to content

posix-cpu-timers: Fix bogus permission checks

Thomas Gleixner lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest6 patches 2 repliesIn review

Changes in v2 from the cover letter

- Address the review comments from Frederic

- Actually return -EPERM when the permission check fails. See patch 6/6 for rationale

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6posix-cpu-timers: Restrict timer_create() permissionskernel/time/posix-cpu-timers.c+15 -10 replies
2/6posix-cpu-timers: Restrict clock_gettime() permissionskernel/time/posix-cpu-timers.c+12 -10 replies
3/6posix-cpu-timers: Sanitize thread clock permissionskernel/time/posix-cpu-timers.c+32 -340 replies
4/6posix-cpu-timers: Make PID=0 and PID=self handling consistentkernel/time/posix-cpu-timers.c+8 -60 replies
5/6posix-cpu-timers: Return PTR_ERR() from lookup_task()kernel/time/posix-cpu-timers.c+12 -101 reply
6/6posix-cpu-timers: Return -EPERM if ptrace permission check failskernel/time/posix-cpu-timers.c+1 -11 reply

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchFrederic Weisbecker
1/6R-b
2/6R-b
3/6R-b
4/6R-b
5/6R-b
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [patch V2 0/6] posix-cpu-timers: Fix bogus permission checks

When cleaning up posix-cpu-timers I discovered that the permission checks for process clocks and process timers are completely bonkers. The only requirement is that the target PID is a group leader. Which means that any process can read the clocks and attach timers to any other process without priviledge restrictions.

That's just wrong because the clocks and timers can be used to observe behaviour and both reading the clocks and arming timers adds overhead and influences runtime performance of the target process.

Changes vs. V1:

- Address the review comments from Frederic

- Actually return -EPERM when the permission check fails. See patch 6/6 for rationale

V1 can be found here:

https://lore.kernel.org/r/[email protected]

I still did not come around to write self tests and won't do so in the next weeks as I'm traveling as of tomorrow and then going on vacation (finally) :)

Thanks,

tglx

---
 posix-cpu-timers.c |   71 ++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 49 insertions(+), 22 deletions(-)