* Re: [PATCH v2] tools/power/x86/intel-speed-select: Harden daemon pidfile open
[not found] <360cfdd8-c97c-4772-bc1e-85a6ee42a2a2@smtp-relay.sendinblue.com>
@ 2026-04-24 11:49 ` Ilpo Järvinen
0 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2026-04-24 11:49 UTC (permalink / raw)
To: unknownbbqrx; +Cc: srinivas.pandruvada, platform-driver-x86, LKML
On Thu, 23 Apr 2026, unknownbbqrx wrote:
>
> From: ali <dev@unknownbbqr.xyz>
>
> Avoid symlink-based pidfile clobbering by opening the pidfile with
> O_NOFOLLOW and validating it with fstat() before locking/writing.
>
> The daemon currently uses a fixed pidfile path under /tmp. A local
> unprivileged user can pre-create a symlink at that path and cause a
> root-run daemon instance to write into an attacker-chosen file.
>
Shouldn't this change have a Fixes tag?
> Signed-off-by: ali <dev@unknownbbqr.xyz>
Please use your full name for signing off changes (see
Documentation/process/submitting-patches.rst).
> ---
> tools/power/x86/intel-speed-select/isst-daemon.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/tools/power/x86/intel-speed-select/isst-daemon.c b/tools/power/x86/intel-speed-select/isst-daemon.c
> index 66df21b2b..4346b049d 100644
> --- a/tools/power/x86/intel-speed-select/isst-daemon.c
> +++ b/tools/power/x86/intel-speed-select/isst-daemon.c
> @@ -200,11 +200,21 @@ static void daemonize(char *rundir, char *pidfile)
> if (ret == -1)
> exit(EXIT_FAILURE);
>
> - pid_file_handle = open(pidfile, O_RDWR | O_CREAT, 0600);
> + pid_file_handle = open(pidfile, O_RDWR | O_CREAT | O_NOFOLLOW, 0600);
> if (pid_file_handle == -1) {
> /* Couldn't open lock file */
> exit(1);
> }
> +
> + {
> + struct stat st;
> +
> + if (fstat(pid_file_handle, &st) == -1)
> + exit(1);
> +
> + if (!S_ISREG(st.st_mode))
> + exit(1);
> + }
> /* Try to lock file */
> #ifdef LOCKF_SUPPORT
> if (lockf(pid_file_handle, F_TLOCK, 0) == -1) {
>
> base-commit: 2e68039281932e6dc37718a1ea7cbb8e2cda42e6
>
--
i.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] tools/power/x86/intel-speed-select: Harden daemon pidfile open
@ 2026-04-26 15:09 Srinivas Pandruvada
0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2026-04-26 15:09 UTC (permalink / raw)
To: hansg, ilpo.jarvinen
Cc: platform-driver-x86, linux-kernel, Ali Ahmet MEMIS,
Srinivas Pandruvada, stable
From: Ali Ahmet MEMIS <dev@unknownbbqr.xyz>
Avoid symlink-based pidfile clobbering by opening the pidfile with
O_NOFOLLOW and validating it with fstat() before locking/writing.
The daemon currently uses a fixed pidfile path under /tmp. A local
unprivileged user can pre-create a symlink at that path and cause a
root-run daemon instance to write into an attacker-chosen file.
Fixes: 7fd786dfbd2c ("tools/power/x86/intel-speed-select: OOB daemon mode")
Signed-off-by: Ali Ahmet MEMIS <dev@unknownbbqr.xyz>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: stable@kernel.org
---
[Fixed commit message for long lines]
v2
- Added CC to stable
tools/power/x86/intel-speed-select/isst-daemon.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/power/x86/intel-speed-select/isst-daemon.c b/tools/power/x86/intel-speed-select/isst-daemon.c
index 66df21b2b573..acedb7432849 100644
--- a/tools/power/x86/intel-speed-select/isst-daemon.c
+++ b/tools/power/x86/intel-speed-select/isst-daemon.c
@@ -148,6 +148,7 @@ static void daemonize(char *rundir, char *pidfile)
{
int pid, sid, i;
char str[10];
+ struct stat st;
struct sigaction sig_actions;
sigset_t sig_set;
int ret;
@@ -200,11 +201,17 @@ static void daemonize(char *rundir, char *pidfile)
if (ret == -1)
exit(EXIT_FAILURE);
- pid_file_handle = open(pidfile, O_RDWR | O_CREAT, 0600);
+ pid_file_handle = open(pidfile, O_RDWR | O_CREAT | O_NOFOLLOW, 0600);
if (pid_file_handle == -1) {
/* Couldn't open lock file */
exit(1);
}
+
+ if (fstat(pid_file_handle, &st) == -1)
+ exit(1);
+
+ if (!S_ISREG(st.st_mode))
+ exit(1);
/* Try to lock file */
#ifdef LOCKF_SUPPORT
if (lockf(pid_file_handle, F_TLOCK, 0) == -1) {
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread[parent not found: <a34faaab-459a-4247-9df2-447948a7af9b@smtp-relay.sendinblue.com>]
* Re: [PATCH v2] tools/power/x86/intel-speed-select: Harden daemon pidfile open
[not found] <a34faaab-459a-4247-9df2-447948a7af9b@smtp-relay.sendinblue.com>
@ 2026-04-23 20:51 ` srinivas pandruvada
0 siblings, 0 replies; 4+ messages in thread
From: srinivas pandruvada @ 2026-04-23 20:51 UTC (permalink / raw)
To: unknownbbqrx; +Cc: platform-driver-x86, linux-kernel
On Thu, 2026-04-23 at 22:32 +0300, unknownbbqrx wrote:
>
> From: ali <dev@unknownbbqr.xyz>
>
> Avoid symlink-based pidfile clobbering by opening the pidfile with
> O_NOFOLLOW and validating it with fstat() before locking/writing.
>
> The daemon currently uses a fixed pidfile path under /tmp. A local
> unprivileged user can pre-create a symlink at that path and cause a
> root-run daemon instance to write into an attacker-chosen file.
>
> Signed-off-by: ali <dev@unknownbbqr.xyz>
Thanks for the patch, I am sorry, but I still can't take it in this
state. It's still an anonymous contribution, which is against policy.
> ---
> tools/power/x86/intel-speed-select/isst-daemon.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/tools/power/x86/intel-speed-select/isst-daemon.c
> b/tools/power/x86/intel-speed-select/isst-daemon.c
> index 66df21b2b..4346b049d 100644
> --- a/tools/power/x86/intel-speed-select/isst-daemon.c
> +++ b/tools/power/x86/intel-speed-select/isst-daemon.c
> @@ -200,11 +200,21 @@ static void daemonize(char *rundir, char
> *pidfile)
> if (ret == -1)
> exit(EXIT_FAILURE);
>
> - pid_file_handle = open(pidfile, O_RDWR | O_CREAT, 0600);
> + pid_file_handle = open(pidfile, O_RDWR | O_CREAT |
> O_NOFOLLOW, 0600);
> if (pid_file_handle == -1) {
> /* Couldn't open lock file */
> exit(1);
> }
> +
> + {
> + struct stat st;
> +
> + if (fstat(pid_file_handle, &st) == -1)
> + exit(1);
> +
> + if (!S_ISREG(st.st_mode))
> + exit(1);
> + }
Also move struct stat st out at the top of function. So we don't do
unnecessary indentation with { }.
> /* Try to lock file */
> #ifdef LOCKF_SUPPORT
> if (lockf(pid_file_handle, F_TLOCK, 0) == -1) {
>
> base-commit: 2e68039281932e6dc37718a1ea7cbb8e2cda42e6
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] tools/power/x86/intel-speed-select: Harden daemon pidfile open
@ 2026-04-23 19:32 unknownbbqrx
0 siblings, 0 replies; 4+ messages in thread
From: unknownbbqrx @ 2026-04-23 19:32 UTC (permalink / raw)
To: srinivas.pandruvada; +Cc: platform-driver-x86, linux-kernel, ali
From: ali <dev@unknownbbqr.xyz>
Avoid symlink-based pidfile clobbering by opening the pidfile with
O_NOFOLLOW and validating it with fstat() before locking/writing.
The daemon currently uses a fixed pidfile path under /tmp. A local
unprivileged user can pre-create a symlink at that path and cause a
root-run daemon instance to write into an attacker-chosen file.
Signed-off-by: ali <dev@unknownbbqr.xyz>
---
tools/power/x86/intel-speed-select/isst-daemon.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/power/x86/intel-speed-select/isst-daemon.c b/tools/power/x86/intel-speed-select/isst-daemon.c
index 66df21b2b..4346b049d 100644
--- a/tools/power/x86/intel-speed-select/isst-daemon.c
+++ b/tools/power/x86/intel-speed-select/isst-daemon.c
@@ -200,11 +200,21 @@ static void daemonize(char *rundir, char *pidfile)
if (ret == -1)
exit(EXIT_FAILURE);
- pid_file_handle = open(pidfile, O_RDWR | O_CREAT, 0600);
+ pid_file_handle = open(pidfile, O_RDWR | O_CREAT | O_NOFOLLOW, 0600);
if (pid_file_handle == -1) {
/* Couldn't open lock file */
exit(1);
}
+
+ {
+ struct stat st;
+
+ if (fstat(pid_file_handle, &st) == -1)
+ exit(1);
+
+ if (!S_ISREG(st.st_mode))
+ exit(1);
+ }
/* Try to lock file */
#ifdef LOCKF_SUPPORT
if (lockf(pid_file_handle, F_TLOCK, 0) == -1) {
base-commit: 2e68039281932e6dc37718a1ea7cbb8e2cda42e6
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-26 15:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <360cfdd8-c97c-4772-bc1e-85a6ee42a2a2@smtp-relay.sendinblue.com>
2026-04-24 11:49 ` [PATCH v2] tools/power/x86/intel-speed-select: Harden daemon pidfile open Ilpo Järvinen
2026-04-26 15:09 Srinivas Pandruvada
[not found] <a34faaab-459a-4247-9df2-447948a7af9b@smtp-relay.sendinblue.com>
2026-04-23 20:51 ` srinivas pandruvada
-- strict thread matches above, loose matches on Subject: below --
2026-04-23 19:32 unknownbbqrx
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox