From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f49.google.com (mail-yx1-f49.google.com [74.125.224.49]) (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 29B53322C83 for ; Wed, 10 Dec 2025 13:55:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765374921; cv=none; b=TIlL2zTFnCDT6xGfljzmYogAvsOvQcNaxV9tU7nYQdt0ic/Htbj2DpQUCH9T2l0NVNt/sJaXb6+ES7PlgrYMLADWMBN1S+4LGvOw9URwHOOXby8NYhB+9eCjrSmhERE5zKfO4sXUWelb2iUaiAeSjY3vchA4TNhE8VUZKGMS2FE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765374921; c=relaxed/simple; bh=rUs9TrsVVSrRHKY3G9FtQ8C8glXBWJ1UxJYOpoCCD5A=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: Mime-Version:Content-Type; b=ECfPUZUwFC3mKjelP8JPDnePAYBDYoVLHzIp6CBTODyq7aeQX9dyyWR02+XgNmgp+WTBeCsfWCB7/GovmoWmw7OhQ7doUxsF/p4+wOOLlA6X25G2BecRKUSavY5qZNZS0TD7Fws4dH3vXvUWQu4ZbRrPFZAuhrFynnPiMHzw5r0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PSE5+JeS; arc=none smtp.client-ip=74.125.224.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PSE5+JeS" Received: by mail-yx1-f49.google.com with SMTP id 956f58d0204a3-6446fcddf2fso639258d50.0 for ; Wed, 10 Dec 2025 05:55:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765374919; x=1765979719; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=VTifI29dWJ/cAF0/szoDrGzc4h9LSBx4IloVQSNjGSI=; b=PSE5+JeSRkt4ObelTKlhbRjtCmplxv4orKB58yBgc/rEmE3Dx24/6INtUZ28RCK+zU zS1xZXCfQLCYuONIkdoR7Y+tGSuvzTC71LGLDikK/aVfcj5H58pk5pvOUhcDCfWFtDIR IgjDRR236OytPjmtLZedwGvgGfVXZJiCsCFgs26aDdkIEQOQBMmh5RUGnwEjJQoH4Vgj eKVdbNETchlx4CaC7lG/LYsLbyTY3LHvxS9C4Pt9Uk7tj7idpjzlf3H7Ezw0D1mm6q8S /Y7q9RPh6oK8NBJ7SZZ0x54hZJDyCJW6htJMKhwHwpl8v+PEqQ77uNukiQo6OX+9D+3S QEmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765374919; x=1765979719; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=VTifI29dWJ/cAF0/szoDrGzc4h9LSBx4IloVQSNjGSI=; b=NxxysILCnbAtgXXMX8+YJUBgTjGCsl/IFxBC7saxhLPfpzmGJxblzrRP+oIqbhoT3W fvlcnupe+9UUUvD6hChgPTR/CdEHuEm1Bxz5Orcj+NWE+aa5bIzNsbkshtlZ1z759zcv suU49JEirtgSW2xHmbmPRTgV0X/GDIOM4D92KLss3a7CqTUwjt9K9pxeDm+gobZVRf5O yKDzPkCSegOTVnLP7xZPOxFHe57Hka1Closgd7f4hvbY7QNwoOMbTkLnJgiPbpxKEEj4 26NI9Wdriqpg0yl9ijETtImxDk/xAwocbOUdd3PaUTHm7lfotqUOTZu4ErHBWWjDVr98 N90w== X-Forwarded-Encrypted: i=1; AJvYcCUZd5wM2lqABGjWfUZzEbCTW8nE6sFrnpcM/gs+HUdkc8WONagZ0y5cSStquSOJRHeqgLlbE5yDIcZ+dbM=@vger.kernel.org X-Gm-Message-State: AOJu0Yxw8LPrBtOshGYCW7b40D3Vvy5HCxzGXkcn0fxTChZyeiNdTVuu XIX4GODTSgVhvkTCFC+em/iwXaSb5UAEXB/dBd55BFGNY1q8yX1Lz+0E X-Gm-Gg: AY/fxX6KUpnUzD1Q03jg04qUTyyqKHu/Z9hao4tYaOLSBN01rLqI1+8TJPcuRoWV5mC 8lHjZdl25eNsiSOmXElUQ0/3WCy0IQqUe23U91pinyPrOdEqg8TijVV/zOX+DoRMgPzMwZgMNyQ DFTMTUOb5FcfRg+eSg9UVv2D56Pezj88+7xPXJQpBdwvAU/IPi0UvYLV31pErWz+oBsPKbkFc5y zbMmNEiY/Uv5MjDr8SLt7CILZ9pnz91ak9sVLX9i/pG2Cl60JEgD4MS7UwnLvlFIG9UZJIyFW7E TH9XPLmHqhlkm9SObZpVcmEJ1Tcg0JOVTRRwOuy1E/K+H/KJWzFGRkWTE4f7FJaz3dMUswin1ro wfg4ZVBVbB98OmWwp1UpYWBo/tCC68Jitt1Eu7Q27L66m9LiepBLuJ6gT6j4AlO9/uR7+4EhI4w 1u1yXZzmk8c2NqtDk4nG2Xb9XdVyqr82G5hXyuaP8HI4M08QjvJuip6R2uIvS4RgEOmlk= X-Google-Smtp-Source: AGHT+IEGWR6SFUkSdSC8NDvIrcTrtp5wIqCeacqwZUJzSb2kOZ9UYdlatQzYHUWCxDGmeNEZBanRJQ== X-Received: by 2002:a05:690e:128c:b0:644:49be:4b8a with SMTP id 956f58d0204a3-6446e85ca12mr2008217d50.0.1765374919157; Wed, 10 Dec 2025 05:55:19 -0800 (PST) Received: from gmail.com (141.139.145.34.bc.googleusercontent.com. [34.145.139.141]) by smtp.gmail.com with UTF8SMTPSA id 956f58d0204a3-6443f5a3ca0sm7613991d50.12.2025.12.10.05.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Dec 2025 05:55:18 -0800 (PST) Date: Wed, 10 Dec 2025 08:55:17 -0500 From: Willem de Bruijn To: Junrui Luo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Herbert Xu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yuhao Jiang , Junrui Luo Message-ID: In-Reply-To: References: Subject: Re: [PATCH net] skb_checksum_help: fix out-of-bounds access Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Junrui Luo wrote: > The skb_checksum_help() function does not validate negative offset > values returned by skb_checksum_start_offset(). This can occur when > __skb_pull() is called on a packet, increasing the headroom while > leaving csum_start unchanged. Do you have a specific example where this happens? > A negative offset causes out-of-bounds memory access: > - skb_checksum() reads before skb->data when computing the checksum > - skb_checksum_help() writes before skb->data I don't think this is true out-of-bounds as long as the data access starts greater than or equal to skb->head, which it will. There are known cases where such negative skb offsets are intentional. I don't think this is one of them, but needs a careful analysis. The use in skb_checksum does seem to indicate that this is not intentional indeed. Checksumming a packet where the L4 header would lie outside the data. csum = skb_checksum(skb, offset, skb->len - offset, 0); > Add validation to detect and reject negative offsets. > > Reported-by: Yuhao Jiang > Reported-by: Junrui Luo > Fixes: 663ead3bb8d5 ("[NET]: Use csum_start offset instead of skb_transport_header") > Signed-off-by: Junrui Luo > --- > net/core/dev.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/net/core/dev.c b/net/core/dev.c > index 9094c0fb8c68..30161b9240a2 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -3574,6 +3574,11 @@ int skb_checksum_help(struct sk_buff *skb) > > offset = skb_checksum_start_offset(skb); > ret = -EINVAL; > + if (unlikely(offset < 0)) { > + DO_ONCE_LITE(skb_dump, KERN_ERR, skb, false); > + WARN_ONCE(true, "offset (%d) < 0\n", offset); > + goto out; > + } > if (unlikely(offset >= skb_headlen(skb))) { > DO_ONCE_LITE(skb_dump, KERN_ERR, skb, false); > WARN_ONCE(true, "offset (%d) >= skb_headlen() (%u)\n", > > --- > base-commit: cfd4039213e7b5a828c5b78e1b5235cac91af53d > change-id: 20251210-fixes-ef9fa1c91916 > > Best regards, > -- > Junrui Luo >