Article View: linux.kernel.netdev
Article #6180Re: [PATCH net-next] net/sched: em_text: pad the text pattern in the ematch dump
From: Victor Nogueira
Date: Wed, 21 Oct 2026 20:44
Date: Wed, 21 Oct 2026 20:44
90 lines
15356 bytes
15356 bytes
On Wed, Oct 21, 2026 at 10:42 AM Paolo Abeni <pabeni@redhat.com> wrote:
>
> On 10/16/26 17:01, Victor Nogueira wrote:
> > This is a follow-up to commit 9c572a83037a ("net/sched: fix potential
> > stack infoleak in em_text_dump()"), which zero-initialised the dump-side
> > struct. Sashiko separately pointed at the unaligned pattern tail on the
> > same dump path.
> >
> > em_text_dump() appends the text pattern with nla_append(), which is a bare
> > skb_put_data() and does not pad the attribute to a 4-byte boundary. When
> > pattern_len is not a multiple of four the skb tail is left unaligned.
> >
> > tcf_em_tree_dump() records the raw span as the ematch entry's nla_len and
> > then writes the next ematch's nlattr header at that unaligned tail.
> > Userspace walks the list with RTA_NEXT()/NLA_NEXT(), which rounds each
> > attribute length up to four bytes, so it looks for the next entry at an
> > aligned offset the kernel did not write. The ematch list is therefore
> > misparsed as soon as a text ematch has a pattern length that is not a
> > multiple of four.
> >
> > Append the pattern with nla_put_nohdr(), which reserves NLA_ALIGN(attrlen)
> > bytes and zero-fills the padding, so the following ematch stays aligned.
> > The emitted ematch entry then carries the padding in its nla_len, which is
> > what NLA_NEXT() already assumes. em_text_change() only checks that len
> > covers the struct and the pattern, so a dump replayed as a request is still
> > accepted. This also removes the last variable-length nla_append() caller
> > (sch_gred's is a fixed-size, already aligned struct).
> >
> > Conditions to recreate the bug:
> > - CAP_NET_ADMIN on the target netns (namespace-local via unshare -Urn is
> > enough)
> > - add a basic filter with two text ematches whose pattern_len is not a
> > multiple of 4 (e.g. 1 and 2), then dump it with RTM_GETTFILTER
> > - the first ematch entry comes back with an unaligned nla_len and the next
> > entry's nlattr header is written at that raw offset, while RTA_NEXT()
> > reads an aligned offset three bytes later
> >
> > Reported-by: Sashiko (gemini) <sashiko-bot@kernel.org>
> > Closes: https://sashiko.dev/#/patchset/20260918133953.12494-1-bernard.ladenthin%40gmail.com
> > Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
> > Signed-off-by: Victor Nogueira <victor@mojatatu.com>
> > ---
> > net/sched/em_text.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/sched/em_text.c b/net/sched/em_text.c
> > index 4132f8c3c5fc..fbf78d61f109 100644
> > --- a/net/sched/em_text.c
> > +++ b/net/sched/em_text.c
> > @@ -125,8 +125,8 @@ static int em_text_dump(struct sk_buff *skb, struct tcf_ematch *m)
> >
> > if (nla_put_nohdr(skb, sizeof(conf), &conf) < 0)
> > goto nla_put_failure;
> > - if (nla_append(skb, conf.pattern_len,
> > - textsearch_get_pattern(tm->config)) < 0)
> > + if (nla_put_nohdr(skb, conf.pattern_len,
> > + textsearch_get_pattern(tm->config)) < 0)
> > goto nla_put_failure;
> > return 0;
> Sashiko suspects this can introduce another issue:
>
> https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-7SHE.v1.r0.20261016101330-1@mojatatu.com
>
> (the 2nd concern)
>
> I think it should be addressed in the same patch.
Ok, also think it merits a respin.
Will do once net-next reopens.
cheers,
Victor
Technical Details
Message-ID:
<CA+NMeC8wOuvc9RNCsro1vYqkEhJLKZhL6PW1jLBpPDqps-LC2Q@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350242-linux-kernel-netdev=dewy.ruReferences:
<QDISC-7SHE.v1.r0.20261016101330-1@mojatatu.com> <e0f4776a-0457-4069-9f79-3c97de2a54d0@redhat.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350242-linux-kernel-netdev=dewy.ru
From: victor@mojatatu.com (Victor Nogueira)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next] net/sched: em_text: pad the text pattern in the
ematch dump
Date: Wed, 21 Oct 2026 17:44:24 -0300
Organization: Usenet Network
Message-ID: <CA+NMeC8wOuvc9RNCsro1vYqkEhJLKZhL6PW1jLBpPDqps-LC2Q@mail.gmail.com>
References: <QDISC-7SHE.v1.r0.20261016101330-1@mojatatu.com> <e0f4776a-0457-4069-9f79-3c97de2a54d0@redhat.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="58410"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:kZ/Z9iPDCze02ufMdCBu2RrfKnI= sha256:mhfBWGlwHVD/W5hyBXwuS0+JZl7HTCX/fAsmu/dwPSY=
sha1:/eKDfwoYqjVq8Ffgb5sqVdtAu6g= sha256:UrjYDHjTDWu9WU2jH+LnhFwPgfRXlqtGBT9cg7rcYQg=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 342F8111107; Wed, 21 Oct 2026 23:45:08 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
header.d=mojatatu.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id DXxK03RkXfpD;
Wed, 21 Oct 2026 23:45:04 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-350242-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 6DA8C110FD0; Wed, 21 Oct 2026 23:44:56 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id 1D6432BF8A; Wed, 21 Oct 2026 20:44:39 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1792615478;
b=NZmUq0H2MLuFmDeiDmXumlOB9dY8sdwPoHaxDYg1PvPsuQv41ULznaH7KZZCAeV5iPqs
uD1dgYc/OaP8dU9h69YoM67b1VBWwopUIKwFBIaxwrKROfGU6Cavf49cDttULSVQRLDPc
Mqnrp1EdghVEEL/op+i+kg72yuedoxrNk+j6XaPtV/nbkpG0vjRpacJuYqh4Am2qvCtAS
4uUSswHwPjw6K4Sx2r2wNf1hxIJ1CiDslop64UH2cuxs+CGZSBAfmx5AJ2Ek53sc/RDoF
0BIyZA/SLCWQ0XXBFYv11xxhb1+h7wNTOzsQ9ZfrLKzNRWyU8egN1yFpndGZtq73YKA==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792615478;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
References:In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:
Cc:Content-Type:Content-Transfer-Encoding;
bh=ptFg/AwFxTH5f4L+o+63VUa962mRQD30O48qGbT4Brc=;
b=4Xd48FY7Gy5IcoMgiX3gzRlXpde8IE6ikgZZKQIAzdpk2dJYLqoYaarIM4I0OF1mXRxr
qFsv2I57DXnfDdXwszG0AxB498Ex7yBTNcJ/umsI8YEKQjEUYavNzntfyCLucNlEH5C6e
nYDp+EeKrS7hiL20LCHV2VomQKszqCUEEYe9U95mVpq1kk8e+Fer+kwfAMrdKzLEh5Lby
pxnGvKJpI2MLXW0dhykHR/3upzzwyI3CPGacRmwXevPJBMz4vmrf+rfjJvdAXeAUYeWz/
PUycn6uPyGQzljFCDMz/ww3vhcr5g2PH3MYVPb7U4/sjZcfWbd/tnBgnyzKrl11BBRg==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org;
dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=jbLWr4TJ;
dmarc=none header.from=mojatatu.com;
spf=none smtp.mailfrom=mojatatu.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C8A4606A321;
Wed, 21 Oct 2026 20:44:38 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (1024-bit key, unprotected) header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=jbLWr4TJ
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=74.125.224.44
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1792615477;
b=yTiV5XoKMIbW+E/uBwmhXM/z0CyFK/ov8pHeEGk7uJJ8ePYZZXvB8a2IxHhXE3EpglKQ
3nlU11aY67Qc11gzaAEvy3mKEto/DdRYR6Z6Pp6oFa85mq8VYOU7nf+9KAHGhTE/oedDT
W7IOYwWJ7791ZWnvFjWR3+r7zavRa8AkQDV+n8L83joxQQhzikdhDeE6c4fqCc3Dn9vw+
IjSTBWtBlfuLTWeXWhSphpOMa24O/ISEdko5cs582P2VnQpeCnRLRYLIRIURJ/ODAp4LM
O2NfrzRetwLPIFkNOKCQn9VzDOqax9+LT0uobGSEeT6AWMJrEcqJzn/6z+ptwsI+PSw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792615477;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:
MIME-Version:References:In-Reply-To:From:Date:X-Gm-Features:
Message-ID:Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
bh=ptFg/AwFxTH5f4L+o+63VUa962mRQD30O48qGbT4Brc=;
b=g3mA0yu1YLmgmvUZYwREA6mNlEGr2xSDONn35ajdE8l3v9Lk/eZGQWxBvvmz/hA+sXrO
A2WOgUT6aXVkEmbTf5qJCPoDrTHun7PLmFoPHwIXplrJNTthVN5pzYr0PirwggHrwBdOv
I5vyCtDETwZNNyZVQR5sQBnDAl+EJ5UjaFmybF5/byV+4yxCHBmTMgyOjtAkXESv30c5A
J8KzoDErzPsFnJhqHEAH9otC8GdrP07WFwW5uk1UHpJV36bkTP6NSjDqAqRsCzidvol0Q
1qJZ5iQSYde+lv16X3KYoxqrd5iO+dSd7B2lD7oz9UGPOU/J/jZJTcCkR2tnJflRRWQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dmarc=none header.from=mojatatu.com;
spf=none smtp.mailfrom=mojatatu.com;
dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=jbLWr4TJ;
arc=pass header.oldest-pass=0 smtp.remote-ip=74.125.224.44
X-Received: from mail-yx1-f44.google.com (mail-yx1-f44.google.com [74.125.224.44])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EF4E606A31A
for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 20:44:37 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2EF4E606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=mojatatu.com
X-Received: by mail-yx1-f44.google.com with SMTP id 956f58d0204a3-67921b515a7so1123960d50.2
for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 13:44:36 -0700 (PDT)
X-ARC-Seal: i=1; a=rsa-sha256; t=1792615476; cv=none;
d=google.com; s=arc-20260327;
b=mDWL0nZdkn4eItYVV2VU6spqZT5H8/hgJzV2OQJ8Zu28fQZQize37IY8ZHwyBwz8Vq
yXa+K/d4KGSqpNY9yHbxxdUrDGj5Wck2T7G3oY3genBRTpcA4+X5EOOn8yE91TQB/dLc
RbuxLtdzvXaaIHU3Yju08y5X25UgpHWykP0/UlRJoa0wwh5fx2LSrOc/TejiE+8xu28b
12r2W2U2IjNivUIlx4ZwRDxIpNUY5Hk2WFeZ3ZHuDDClilGgtRZNbPesm4mQKxvRYlG7
lx9jAoHe9NRl72DVqEupENC6STp2z47R6scb6rTxefoKR0Tig1vnylQN4xEfRafBGEFr
SWwg==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:dkim-signature;
bh=ptFg/AwFxTH5f4L+o+63VUa962mRQD30O48qGbT4Brc=;
fh=I94r6SN/+9n+53MDbG1a3oA09SuXdPBkVULaK1hSl/Y=;
b=AqrD9Hhhv0npBmddd3T6XETaPOBRuSy3eQRcewUno800Ss5Hum8yNUlMMmjrf/hWFG
Eg6kiZtM+rGSKy0no+PmAR7KBZhvn8Py9khXmix7KKp3LP0S7wGgChkwDgKuj8gGLVc1
Ekwu3wwuwc6xvi5kpjhQuFQ8LXdIxRy/5ST/Dh5NluLqF3PowJverIl8u/Ok1KmSntim
Lwq8CNJtQ73VXqiCZcd7uSGN/upAxHdpb+WxIjV+SY4mFg07fSiLoRRSUiWEK10NjytD
x1HFfMQI7Ll20hiYg28yYGZyO+u0pO4OBHz87pLfWqx7nWR8/yHyEGMRkoFw+OUgWVvR
IsXg==;
darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=mojatatu.com; s=google; t=1792615476; x=1793220276; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=ptFg/AwFxTH5f4L+o+63VUa962mRQD30O48qGbT4Brc=;
b=jbLWr4TJVuNMXdyXLBgaZpbib4opRvjX3jKGFSgRfBk+Cu0YRHMfBxjM7c744i5S6Y
naQNBLFymsMWaY3SW1uVPLHm2/mPRdStegE9E2OwThyTE9LxQgoC4+duq9QBs0UFF2BW
CEn1rOznnxbqTHWUw/olW7UQCyf4crkM0d1lQ=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792615476; x=1793220276;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=ptFg/AwFxTH5f4L+o+63VUa962mR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v8yzovMFurmI0VCkbrNUXOXUzCZA9yuuNVz+e4Q
X-Received: by 2002:a05:690e:458a:20b0:679:bb35:96ae with SMTP id
956f58d0204a3-67a0e57febdmr1116875d50.74.1792615476200; Wed, 21 Oct 2026
13:44:36 -0700 (PDT)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <e0f4776a-0457-4069-9f79-3c97de2a54d0@redhat.com>
X-Gm-Features: AclHuK_iJwtn4T9BOcwwmqz_vgKPGYOJxCDP35uTHuQAq1jQv2i6iwQyVeKUy3c
X-Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
jhs@mojatatu.com, jiri@resnulli.us, netdev@vger.kernel.org, horms@kernel.org,
Sashiko <sashiko-bot@kernel.org>