From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f49.google.com (mail-dl1-f49.google.com [74.125.82.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 B330D273816 for ; Sat, 2 May 2026 01:24:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777685086; cv=none; b=TfqA2p+KdScwFufyKon9AL5JlqmBP/rrA0R485qGSiJiTPTRc9Xlf9H0+d6iMrUFMVx7fVFnLzvk1B7anE3PK8JN+fyvgqC6Z80nVDQkol71KuiTECJGrN+CWNHbfc7kznliID3gyHeLqFHH8PLCvimrXenR+0RZKjg9+pMA4zU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777685086; c=relaxed/simple; bh=IFeLGt15QdddHrJsvE3HvXPhtFz5rcwT0S8R0UJdSFI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W2JZf3PPEwoLab0MnY/1VUmuO208J7oOznZMrLfKxTnx507yYpkxQfBxi0WBDfr+v3KD+ERSQ5z+YLxlNWQagWfXJ9iZAZIwnZEmv2gkvW+HDgLMTFPZkC8i66cHkAIojxTEUfiW9TOmnK6u3i6V0g+YiapVBSFHNoSnc4AReGQ= 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=DRQmHrH9; arc=none smtp.client-ip=74.125.82.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="DRQmHrH9" Received: by mail-dl1-f49.google.com with SMTP id a92af1059eb24-12dbd0f8063so3925014c88.0 for ; Fri, 01 May 2026 18:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777685085; x=1778289885; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rl2ZTF35NbwbP1Q+Ln2/raLrxAm4iCnVRc4K6GIJe4o=; b=DRQmHrH9ZX2zg9RetvHASKpUc6FTtq8i/O0hqghSzGqAiUkurjooYZ4WcO6RoMJ5yz 9XNx4K2yoJ7Y3b80pTDUmjZKKWDCh9KZvQlI9/lTVLGR6svTIiDDSeapA+/Fkq1ySM1Y ZaHCPGLLA7dAgzLwiC5kAKGsky4EVCDRfI1/TVY7NVGzqFbm5Q8ejliFKgSNZkWGyB6U VnU5RJdgQEg8HSgUBJitekK4QxGZuFg1dFS0G8Iw4J+jYhdYK3TAxx0bNzbYASk7plHl xWrvOSLfKYuzLKyQakj/VOIijHMFHaC6VXrDnzdYlGnKQ21g7TMek6DEnKJYrDZ1K2Mb YqyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777685085; x=1778289885; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rl2ZTF35NbwbP1Q+Ln2/raLrxAm4iCnVRc4K6GIJe4o=; b=T20pdkQDn7n0IoR3mYYKZ7uCyEBL0lnl3zTh2gsgLqPz55JAM+4OMVR75pz1TL6Ozu FTIPAXD/9UpF7Bp862cWo+c5ykKtIFqhdF+4Iur19TY6AHdTLs0vwUldbRTluYzG9mlG ZgklM6GuXFqyKp5PG8nmnKnyouXty5VIvMph4mWacTgboD3oKaHUGE77vkdaxAiyM3bC nubx/rnOe1DfTp5S//2AWrseFRL9/crLTKd0mO1A+6q64gmLaQGuH/mfUYBbdLNzMafQ VDsgCa494vrlWj4r35WTOPfOJSokUNxeQee/3ghU3/yA2sn+xZfCK7J+Novt0/ovYKTF 0bCw== X-Forwarded-Encrypted: i=1; AFNElJ/OTluA8kwFyAEPeUzlJOrSLbpnmdnCZ26SZFsshjWMRDHfvn8S/5atmUwz/2A9GieOPJ6cTwghD5r8Rsc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2l+yO+RtIZFap1QoFhnV/rqI1kfEULQEzX4xmasn606wpw3/0 wHNM9XLUNH/OIbFzEv3xPBmcHFRVuJL5oFzGuu+E5p8OuxJaVxho+26g X-Gm-Gg: AeBDieu3udx8y9itaGQOjNO4Z65IBW3UN7NTaQ6Xuq1ntt9LCWJYuPq8rYSw8T2+Tod DhVj7rSEhztQ5nhBEZJeYeLYkKQs0P0lT/jssGRJTmgNlXRroJn0N8I6C3WTQFMon0Vo0slLJhi hEot8DMId5Z3EaCEa8yMxLSzXGenMkXa+fNq4/tcvzaHL7wllbGjotpqSAYQe9EVlCKppG8JEeX dnzRNj7U7DCgLAwr+az8pszOQPSRlB1lNIxwj39SQNuB7GBAsT+nS27nCE0U6tY5AzgsH21bN7f jxsqCZXqh+5yj7+e2B18LbbeBcgYBY3CJ8Eu8kueyhq1ABtaxPPfX7mCYNzdKAwp6qhJeyHpd/E y9tqOS+cofcOuGZx5ZBNW3MP/kiuf95dk7+y/6xpXK9it8EC9sLBq+WaTG26JhVHXBuIQWuP+JI x9edp/8igDh5pxvUTTP+oXasw+AnO9XTZJjytsz/bnA6XXpWUXhMYU X-Received: by 2002:a05:7022:660c:b0:12d:ce36:8930 with SMTP id a92af1059eb24-12dfd7a15d1mr854409c88.3.1777685084825; Fri, 01 May 2026 18:24:44 -0700 (PDT) Received: from teatimelab.tailcd024.ts.net ([148.135.103.3]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12df84252c0sm6663448c88.10.2026.05.01.18.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2026 18:24:44 -0700 (PDT) From: Qi Tang To: Paolo Abeni Cc: "David S . Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Qi Tang Subject: Re: [PATCH net v3] ipv6: validate extension header length before copying to cmsg Date: Sat, 2 May 2026 09:24:38 +0800 Message-ID: <20260502012438.3685742-1-tpluszz77@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Tue, Apr 28, 2026, Paolo Abeni wrote: > > +static u16 ipv6_get_exthdr_len(const struct sk_buff *skb, const u8 *ptr) > > +{ > > + u16 len = (ptr[1] + 1) << 3; > > Sashiko notes that you should validate even this offset (1) before > accessing it. Good catch. I will add a "ptr + 2 > skb_tail_pointer(skb)" check before reading ptr[1], in both the helper and the inline AH path. > You may also consider switching to pskb_may_pull(). I considered this but would prefer to keep skb_tail_pointer(). Two reasons: 1. ipv6_parse_hopopts() / dst_opts_rcv() / ipv6_rthdr_rcv() already pskb_may_pull() the full extension header during input parsing, so by the time ip6_datagram_recv_specific_ctl() runs the headers are guaranteed to be in the linear area; another pskb_may_pull() would be a no-op. 2. When pskb_may_pull() does have work to do, __pskb_pull_tail() can call pskb_expand_head() and reallocate skb->head, which would invalidate the caller's `ptr` (computed as nh + offset). WDYT? Happy to switch if I'm missing something. Thanks, Qi