From nobody Sat Jul 25 03:20:57 2026 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F1A32F3C3E for ; Sun, 19 Jul 2026 22:15:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784499335; cv=none; b=HjO9qbLIcMwkrHlI9yLndSUkijcNY+qQe8DMpRbsOZdWa1+Bg7i0sp5F4plaF1kT2DjUdujz/XX2ZqcYPilIuRVIs2DeZhk/85KV1d1GAxHBpEronoABdAo8JkKEjVzlU/nx/3RAyvHsoabw+mnNtoaYamlAnk6WWgw8UUOs9Lg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784499335; c=relaxed/simple; bh=phqWj/Y9V2U1q3g+xUxQmFCZQ+uhizVr+3ljUR4LdUk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NSElKm22ainXX8DI5brERvJPl0Qtvip3hS69YWvBQnLWaCkHlc3rHMCAHpGVU3IK86GC7e1shez6YTvhjIJh+Qkh0Izg0eIPiAXQLkeeMAqQzNhvv25FRM33ZmIBLRJkEVaULuYvgg2MDKVm6FLXK7SF1cRV+nGCOGrp+QDK57U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu; spf=pass smtp.mailfrom=asu.edu; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b=iQtrT/0k; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asu.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b="iQtrT/0k" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2ceed7018c8so39217845ad.1 for ; Sun, 19 Jul 2026 15:15:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu.edu; s=google; t=1784499334; x=1785104134; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=rBbMwui+/L0pgrSCs8qYX8BN/DRimeZ19odA05vUJ9o=; b=iQtrT/0kRWGXXzisfc131QpJKoAa4lVVmxVGW4ANgdNreHOHbuG17v1lPZ12rQvw5F llW7nImRLEfG0XhE73Fqu/K8+tTMYkg9v8fF9zVaexLafkCV2WzRhTtRhgk+rJ9lH2Ym DuZXEyuWJEWlLKYvPZsGeyztfUl62F5eshkFKHmAPxvIE2yioAG6+NXr8ZHgYHvC8BdH MO1MiSJDyN8u0ywxYtnsNW9w0i3NIS0Ck8KaeKaQZSei3zX9fgAYTFOpuU+PzcBcGlKf EV0n7UU80iWqOpIp0Vo69eoUai3DzpyR1u+r3IqM9eVbuASrcMLmiVC1MhD/H8KArPFi 7MvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784499334; x=1785104134; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rBbMwui+/L0pgrSCs8qYX8BN/DRimeZ19odA05vUJ9o=; b=iFLkpEfoHKW8N7Zt26RCQMmhr5PDTb352mYjtsZsgn9+cktw4WIUDH22yEMiQZCgNJ RXZIf912AkQk9iRNtKGvDT1r1pub1p6npsXgZ88zl+mDgJviNwZc/27xy42d2jE/IwFA sasseJhxL3c4lNXAsxF1JTVB8JTdn3kzyugSIZB1ESYyp7xLFtAyU2LFZn8tSocPBu9e C5KZ6PcA38lEz0FvM86G2XIIV4FsFyb1olxPMPDaZQJRsyHWqU7NtpOWRknDl/TiC10L Tr2F7moBevHpOEsctvFBZG0V21XmAJ1WfzOovLSkAsr4h46lle59oCHIs14GwmoSPwwF GWSw== X-Forwarded-Encrypted: i=1; AHgh+RpDErBzYZMHzpyLGv6ZSn/akri7A/LIrN+UYly16kg8p+NdzLlQljPJdBlI+iM5JOljLStgllkSqg2TjIM=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5cYZy7dVMPNp7R8bO7XFuWzVX9cAEj1JAUfZWoLiul3J2WBQN V7ovPApn5zHnEmkBqDEDCiCz81JGMfrFD59Vn6daIICngrKADh/DJqlVdkw7vlbIPg== X-Gm-Gg: AfdE7cldizLT53DwAwohj//yo6grnYOJ7XaKj9evQnSMoFqGkLeb8Fv2KonP2nEjt21 +aHe4M/6tworYJmixT87r7xv5TtcrGo026Xiqp+9zmBwkCKdNfOT0gmJSmVep/tVoqdTEGY68F9 8DJrS72+s8Z+TZYBy2JVrgNY5+IuvtBkJPHbt6GGct8BVpeE9yzfqYf4nId6QFmxmkWki5dBIjR XAVD4AXn++V7BmFmUtzZwsrHGiTtx5M8GXwSk+3iIlLXpkRbTeNvCyj0NriP6kjv/rHEBpWDnwi FENHKYg7vO0XrlOLHGDJKxpdPWJhfM0PFJlHzqyVflSCC0+UwawoK4hnVYmEjkTqclC5dwPpjSr qhdIxm6yqKpmCGszBZd6TSSYxH3xFzNXHoyaA36NIRCRJaT9RAShckned34Xa4bX2nA0fwYUXJB fNNGw9AXA= X-Received: by 2002:a05:6a20:c783:b0:3c3:90de:60e9 with SMTP id adf61e73a8af0-3c3adaa078amr12650690637.62.1784499333666; Sun, 19 Jul 2026 15:15:33 -0700 (PDT) Received: from xiang.tailc0aff1.ts.net ([20.171.14.70]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13ce2cd6e6esm24438644c88.13.2026.07.19.15.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jul 2026 15:15:25 -0700 (PDT) From: "Xiang Mei (Microsoft)" To: Pablo Neira Ayuso , Florian Westphal , Phil Sutter Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, AutonomousCodeSecurity@microsoft.com, tgopinath@linux.microsoft.com, kys@microsoft.com, "Xiang Mei (Microsoft)" Subject: [PATCH nf] netfilter: nft_payload: fix mask build for partial field offload Date: Sun, 19 Jul 2026 22:15:23 +0000 Message-ID: <20260719221523.1336739-1-xmei5@asu.edu> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" nft_payload_offload_mask() builds the offload match mask for a payload expression that covers only part of a header field. For a partial IPv6 address match (field_len =3D 16, priv_len =3D 1) that shift is 1 << 120, wh= ich is undefined on the 32-bit int operand. It also trims only one word, so the remaining words stay 0xffffffff (and when priv_len is a multiple of 4 the trim is skipped entirely), leaving the mask covering more bytes than the rule matches. UBSAN: shift-out-of-bounds in net/netfilter/nft_payload.c:278:20 shift exponent 120 is too large for 32-bit type 'int' ... The match is byte-granular and struct nft_data is zero-initialised, so the correct mask is simply the first priv_len bytes set to 0xff. Set those bytes directly and drop the word/shift trimming; this removes the undefined shift and no longer over-masks the trailing bytes. Fixes: a5d45bc0dc50 ("netfilter: nftables_offload: build mask based from th= e matching bytes") Reported-by: AutonomousCodeSecurity@microsoft.com Signed-off-by: Xiang Mei (Microsoft) --- net/netfilter/nft_payload.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c index 391539a1ceaa..8a4472fd77d9 100644 --- a/net/netfilter/nft_payload.c +++ b/net/netfilter/nft_payload.c @@ -259,9 +259,7 @@ static int nft_payload_dump(struct sk_buff *skb, static bool nft_payload_offload_mask(struct nft_offload_reg *reg, u32 priv_len, u32 field_len) { - unsigned int remainder, delta, k; struct nft_data mask =3D {}; - __be32 remainder_mask; =20 if (priv_len =3D=3D field_len) { memset(®->mask, 0xff, priv_len); @@ -270,15 +268,7 @@ static bool nft_payload_offload_mask(struct nft_offloa= d_reg *reg, return false; } =20 - memset(&mask, 0xff, field_len); - remainder =3D priv_len % sizeof(u32); - if (remainder) { - k =3D priv_len / sizeof(u32); - delta =3D field_len - priv_len; - remainder_mask =3D htonl(~((1 << (delta * BITS_PER_BYTE)) - 1)); - mask.data[k] =3D (__force u32)remainder_mask; - } - + memset(&mask, 0xff, priv_len); memcpy(®->mask, &mask, field_len); =20 return true; --=20 2.43.0