From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: unknownbbqrx <dev@unknownbbqr.xyz>
Cc: srinivas.pandruvada@linux.intel.com,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] tools/power/x86/intel-speed-select: Harden daemon pidfile open
Date: Fri, 24 Apr 2026 14:49:23 +0300 (EEST) [thread overview]
Message-ID: <252a30ef-197f-1097-1754-5f8058dcd62e@linux.intel.com> (raw)
In-Reply-To: <360cfdd8-c97c-4772-bc1e-85a6ee42a2a2@smtp-relay.sendinblue.com>
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.
next parent reply other threads:[~2026-04-24 11:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <360cfdd8-c97c-4772-bc1e-85a6ee42a2a2@smtp-relay.sendinblue.com>
2026-04-24 11:49 ` Ilpo Järvinen [this message]
2026-04-26 15:09 [PATCH v2] tools/power/x86/intel-speed-select: Harden daemon pidfile open 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=252a30ef-197f-1097-1754-5f8058dcd62e@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=dev@unknownbbqr.xyz \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox