Skip to content

tools/thermal/tmon: Fix predictable temporary path /var/log/tmon.log

Thomas Renninger linux-pm 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3tools/thermal/tmon: Prevent symlink attack on log filetools/thermal/tmon/tmon.c tools/thermal/tmon/tmon.h+37 -160 replies
2/3tools/thermal/tmon: Make sure ctrl_cdev is a Null terminated stringtools/thermal/tmon/tmon.c+1 -00 replies
3/3tools/thermal/tmon: Cleanup only: Use LOG_FILE varstools/thermal/tmon/tmon.c+4 -20 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchThomas Renninger
1/3R-b
2/3
3/3

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

Read the v1 thread

Cover letter [PATCH 0/3] tools/thermal/tmon: Fix predictable temporary path /var/log/tmon.log

Wolfgang Frisch identified and reported:
tmon only runs as root and logs event to /var/tmp/tmon.log. If fs.protected_symlinks=0, an unprivileged user can overwrite arbitrary files on the system.

nobody@localhost:/var/tmp> ln -s /test/shadow tmon.log root@localhost:/> tmon -l

I could reproduce the issue and after some discussion we came to 3 possible solutions:
1. Use /var/log/tmon.log instead of world-readable /var/tmp
2. Add randomness to the file name, e.g. /var/log/tmon.log.QipZjI
3. Make /var/tmp/tmon.log safe (TM), or say more robust.

Wolfgang came up with a patch which is part of this submission. His intention is to keep /var/tmp/tmon.log, in case other tools/scripts or docs rely on it.

If 3. is a suitable solution, it would be great if someone could pile these patches for next submission round.

Thanks,

Thomas

Thomas Renninger (3):
tools/thermal/tmon: Prevent symlink attack on log file tools/thermal/tmon: Make sure ctrl_cdev is a Null terminated string tools/thermal/tmon: Cleanup only: Use LOG_FILE vars

 tools/thermal/tmon/tmon.c | 57 +++++++++++++++++++++++++++------------
 tools/thermal/tmon/tmon.h |  3 ++-
 2 files changed, 42 insertions(+), 18 deletions(-)
Signature · 1 line
2.49.0