From: sashiko-bot@kernel.org
To: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH net v2 12/15] selftests: mptcp: lib: get counters for the right test
Date: Wed, 09 Sep 2026 14:15:05 +0000 [thread overview]
Message-ID: <20260909141506.384121F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260908-net-mptcp-misc-fixes-7-3-rc1-v2-12-df1de70348b6@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Insecure use of predictable temporary file paths in /tmp allows local privilege escalation via a symlink attack (TOCTOU).
--
commit 706f0812739080817c63b8f13d5f3a60fbeddf0a
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>
selftests: mptcp: lib: get counters for the right test
This commit updates the mptcp_lib_get_counter function to use nstat history
instead of absolute counters when extracting MIB values. It renames the
previous variable to cache and introduces a new history file variable.
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> index da1da414c30f2..b9d14647f4019 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
[ ... ]
> @@ -416,19 +416,21 @@ mptcp_lib_nstat_get() {
> }
>
> # $1: ns, $2: MIB counter
> -# Get the counter from the history (mptcp_lib_nstat_{init,get}()) if available.
> -# If not, get the counter from nstat ignoring any history.
> +# Get the counter from the cache (mptcp_lib_nstat_{init,get}()) if available.
> +# If not, get the counter from nstat ignoring any cache, but using the history.
> mptcp_lib_get_counter() {
> local ns="${1}"
> local counter="${2}"
> - local hist="/tmp/${ns}.out"
> + local cache="/tmp/${ns}.out"
> + local hist="/tmp/${ns}.nstat"
[Severity: High]
This isn't a bug introduced by this patch, but was already present in the
script for .out and .nstat files. Is there a risk of a local privilege
escalation via a symlink attack here?
Because the file path is constructed in mptcp_lib_get_counter() using the
globally visible namespace name, an unprivileged attacker could monitor
/var/run/netns/ for new network namespace names and preemptively create a
symlink at /tmp/${ns}.nstat pointing to a sensitive file like /etc/shadow.
> local count
>
> - if [[ -s "${hist}" && "${counter}" == *"Tcp"* ]]; then
> - count=$(awk "/^${counter} / {print \$2; exit}" "${hist}")
> + if [[ -s "${cache}" && "${counter}" == *"Tcp"* ]]; then
> + count=$(awk "/^${counter} / {print \$2; exit}" "${cache}")
> else
> - count=$(ip netns exec "${ns}" nstat -asz "${counter}" |
> - awk 'NR==1 {next} {print $2}')
> + count=$(NSTAT_HISTORY="${hist}" ip netns exec "${ns}" \
> + nstat -sz "${counter}" |
> + awk 'NR==1 {next} {print $2}')
[Severity: High]
When nstat is executed here as root with NSTAT_HISTORY pointing to the
predictable /tmp/ path, could it follow the attacker's symlink and
overwrite the target file?
> fi
> if [ -z "${count}" ]; then
> mptcp_lib_fail_if_expected_feature "${counter} counter"
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908-net-mptcp-misc-fixes-7-3-rc1-v2-0-df1de70348b6@kernel.org?part=12
next prev parent reply other threads:[~2026-09-09 14:15 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 14:07 [PATCH net v2 00/15] mptcp: misc fixes for v7.3-rc1 Matthieu Baerts (NGI0)
2026-09-08 14:07 ` [PATCH net v2 01/15] mptcp: do not reschedule the RTX timer for fallback sockets Matthieu Baerts (NGI0)
2026-09-09 14:49 ` netdev-bot+sashiko
2026-09-09 15:32 ` Paolo Abeni
2026-09-08 14:07 ` [PATCH net v2 02/15] mptcp: subflow: no need to copy thmac during ulp_clone Matthieu Baerts (NGI0)
2026-09-08 14:07 ` [PATCH net v2 03/15] mptcp: syncookies: remember the request backup flag Matthieu Baerts (NGI0)
2026-09-08 14:07 ` [PATCH net v2 04/15] mptcp: pm: kernel: drop pending ADD_ADDR when removing ID0 Matthieu Baerts (NGI0)
2026-09-09 14:49 ` netdev-bot+sashiko
2026-09-09 17:57 ` Matthieu Baerts
2026-09-08 14:07 ` [PATCH net v2 05/15] mptcp: options: handle MPC data + csum reqd + no csum Matthieu Baerts (NGI0)
2026-09-09 14:49 ` netdev-bot+sashiko
2026-09-09 18:03 ` Matthieu Baerts
2026-09-08 14:07 ` [PATCH net v2 06/15] mptcp: prevent race between disconnect() and rtx Matthieu Baerts (NGI0)
2026-09-09 14:49 ` netdev-bot+sashiko
2026-09-09 15:54 ` Paolo Abeni
2026-09-09 18:05 ` Matthieu Baerts
2026-09-08 14:07 ` [PATCH net v2 07/15] selftests: mptcp: fix an UAF in mptcp_connect.c Matthieu Baerts (NGI0)
2026-09-08 14:07 ` [PATCH net v2 08/15] mptcp: pm: userspace: fix address ID overflow Matthieu Baerts (NGI0)
2026-09-09 14:15 ` sashiko-bot
2026-09-08 14:07 ` [PATCH net v2 09/15] mptcp: pm: reset retrans_time when ADD_ADDR entry is reused Matthieu Baerts (NGI0)
2026-09-08 14:07 ` [PATCH net v2 10/15] mptcp: remove unneeded READ_ONCE() annotation Matthieu Baerts (NGI0)
2026-09-08 14:07 ` [PATCH net v2 11/15] selftests: mptcp: lib: dump nstat for the right test Matthieu Baerts (NGI0)
2026-09-08 14:07 ` [PATCH net v2 12/15] selftests: mptcp: lib: get counters " Matthieu Baerts (NGI0)
2026-09-09 14:15 ` sashiko-bot [this message]
2026-09-09 16:17 ` Matthieu Baerts
2026-09-08 14:07 ` [PATCH net v2 13/15] mptcp: options: fix uninit-value in mptcp_write_data_fin Matthieu Baerts (NGI0)
2026-09-08 14:07 ` [PATCH net v2 14/15] mptcp: being below memory limit is a likely() condition Matthieu Baerts (NGI0)
2026-09-08 14:07 ` [PATCH net v2 15/15] mptcp: avoid pruning for OoW data Matthieu Baerts (NGI0)
2026-09-09 14:49 ` netdev-bot+sashiko
2026-09-09 15:50 ` Paolo Abeni
2026-09-09 18:07 ` Matthieu Baerts
2026-09-09 18:09 ` [PATCH net v2 00/15] mptcp: misc fixes for v7.3-rc1 Matthieu Baerts
2026-09-09 20:40 ` patchwork-bot+netdevbpf
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=20260909141506.384121F00A3E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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