From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E09847DD47; Thu, 2 Jul 2026 16:23:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783009437; cv=none; b=Ro6pq9LOQGOh41IGfv35LYEOUsEi79Xyv5uEhLOoVdsU8LJiTw1Z6xFPPB49krQJbGdr60ot1pVlMnSzxl5lp8u+6CgL5PeryahsqqQ7AKHQjBzx7XlOwxK2Ety3Xom45A/MtBFJfmDZYd1oYQ6qMPSJj9Xy/vrICFWAKE/ufe8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783009437; c=relaxed/simple; bh=kyI6kHftdjm2xpwz9HUfyqNAB90L6e2i2JL8blJ+730=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cXm/VttjXI42kqJTHj7sbkFKdNDhJR6Bpn+qgbJwdDJ3ttm9ZvugcHMqtBDnCYdJPkZP3PjHD0EcZIN3L/py6221SWeiWd1Knth7SrqXypddnMAupi9jGuwGJDVGWixIwBplHBswCZ7nlDSA2v9YRuU0yqvaY2sq6B91Wq1bvOY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=X140wjGw; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="X140wjGw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C72D01F00A3D; Thu, 2 Jul 2026 16:23:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783009429; bh=3zQGbw81Y3hxcScC6tPqk9v3HsknPe/HdCtE5wMCw1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=X140wjGwvT+WjcvC0jSMdE2N9jCOcu2nApx8/GzGPUPdLZXiSkV4MfohuMTglIDQC X1IWDOTXFuZ7/aiVOn8G2vYSCJxTCJVICt39lAy1VSgVTjjepawNUb2npnpk1z7ipu jkHIjabV6dQ6qNvTRmrLg4sN5qBR6avCt9sYning= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jamal Hadi Salim , Simon Horman , Pedro Tammela , "David S. Miller" , Wentao Guan , Sasha Levin Subject: [PATCH 5.10 05/96] net/sched: act_pedit: check static offsets a priori Date: Thu, 2 Jul 2026 18:18:57 +0200 Message-ID: <20260702155109.079134995@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155108.949633242@linuxfoundation.org> References: <20260702155108.949633242@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pedro Tammela [ Upstream commit e1201bc781c28766720e78a5e099ffa568be4d74 ] Static key offsets should always be on 32 bit boundaries. Validate them on create/update time for static offsets and move the datapath validation for runtime offsets only. iproute2 already errors out if a given offset and data size cannot be packed to a 32 bit boundary. This change will make sure users which create/update pedit instances directly via netlink also error out, instead of finding out when packets are traversing. Reviewed-by: Jamal Hadi Salim Reviewed-by: Simon Horman Signed-off-by: Pedro Tammela Signed-off-by: David S. Miller Signed-off-by: Wentao Guan Signed-off-by: Sasha Levin --- net/sched/act_pedit.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index 957ce9017c3f73..95ae885ecba168 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -239,8 +239,16 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, memcpy(nparms->tcfp_keys, parm->keys, ksize); for (i = 0; i < nparms->tcfp_nkeys; ++i) { + u32 offmask = nparms->tcfp_keys[i].offmask; u32 cur = nparms->tcfp_keys[i].off; + /* The AT option can be added to static offsets in the datapath */ + if (!offmask && cur % 4) { + NL_SET_ERR_MSG_MOD(extack, "Offsets must be on 32bit boundaries"); + ret = -EINVAL; + goto put_chain; + } + /* sanitize the shift value for any later use */ nparms->tcfp_keys[i].shift = min_t(size_t, BITS_PER_TYPE(int) - 1, @@ -249,7 +257,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, /* The AT option can read a single byte, we can bound the actual * value with uchar max. */ - cur += (0xff & nparms->tcfp_keys[i].offmask) >> nparms->tcfp_keys[i].shift; + cur += (0xff & offmask) >> nparms->tcfp_keys[i].shift; /* Each key touches 4 bytes starting from the computed offset */ nparms->tcfp_off_max_hint = @@ -383,12 +391,12 @@ static int tcf_pedit_act(struct sk_buff *skb, const struct tc_action *a, sizeof(_d), &_d); if (!d) goto bad; - offset += (*d & tkey->offmask) >> tkey->shift; - } - if (offset % 4) { - pr_info("tc action pedit offset must be on 32 bit boundaries\n"); - goto bad; + offset += (*d & tkey->offmask) >> tkey->shift; + if (offset % 4) { + pr_info("tc action pedit offset must be on 32 bit boundaries\n"); + goto bad; + } } if (!offset_valid(skb, hoffset + offset)) { -- 2.53.0