Article View: linux.kernel.netdev
Article #6781Re: [PATCH net] net/sched: etf: initialise the sock_exterr_skb before filling it
From: Simon Horman
Date: Fri, 23 Oct 2026 11:03
Date: Fri, 23 Oct 2026 11:03
84 lines
11410 bytes
11410 bytes
On Wed, Oct 21, 2026 at 11:54:01PM +0800, Dudu Lu wrote:
> report_sock_error() clones the transmitted skb, overlays a
> struct sock_exterr_skb on its control block and fills in the seven
> struct sock_extended_err fields, but never clears addr_offset and port.
> skb_clone() copies cb[] verbatim, so the errqueue entry carries the TX
> skb's stale control block to the receive side, and the ipv4 error-queue
> reader trusts those bytes:
>
> net/ipv4/ip_sockglue.c:556
> sin->sin_addr.s_addr = *(__be32 *)(skb_network_header(skb) +
> serr->addr_offset);
> sin->sin_port = serr->port;
>
> The gate that is supposed to guard that read only asks whether an
> address was requested at all:
>
> net/ipv4/ip_sockglue.c:484
> return serr->ee.ee_origin == SO_EE_ORIGIN_ICMP ||
> serr->ee.ee_origin == SO_EE_ORIGIN_LOCAL || serr->port;
>
> SO_EE_ORIGIN_TXTIME is neither ICMP nor LOCAL, so for sch_etf the gate is
> decided by serr->port alone -- by the stale byte pair. When it is
> non-zero the reader dereferences skb_network_header() + addr_offset with
> an arbitrary offset. On the TCP path cb[40..44) is not zero: the
> transmit path stored delivered_mstamp there (tcp_rate_skb_sent()), which
> is exactly where addr_offset/port sit in the arm64 struct layout.
>
> Reached with an unmodified 7.3-rc4 (arm64, KASAN, in-tree modules): a TCP
> socket enables TX-timestamp error reporting (SO_TXTIME with
> SOF_TXTIME_REPORT_ERRORS), a sch_etf qdisc drops the packet, and a
> recvmsg() reaches ip_recv_error():
>
> BUG: KASAN: slab-out-of-bounds in ip_recv_error+0x970/0xa0c
> Read of size 4 at addr ffff0000158ffdd5 by task A-227-A227-1_S2/113
> ip_recv_error+0x970/0xa0c
> inet_recv_error+0x94/0xdc
> tcp_recvmsg+0x378/0x408
> ...
> The buggy address is located 149 bytes to the right of
> allocated 704-byte region
>
> Zero the whole overlay rather than the two fields individually: the
> errqueue entry is handed to the receive side as a self-contained record,
> which is what every other producer in the tree already does (sch_etf was
> the only error-queue producer that cleared neither field). This does not
> change what the in-tree selftest observes -- so_txtime.c reads only
> ee_origin/ee_errno/ee_code/ee_data/ee_info, never msg_name or sin_port.
>
> Fixes: 4b15c7075352 ("net/sched: Make etf report drops on error_queue")
> Assisted-by: LLM
> Signed-off-by: Dudu Lu <phx0fer@gmail.com>
> ---
> Tested base
> -----------
> Detected on Linux 7.3-rc4 (commit 93f51579e7df), arm64 QEMU guest.
> Re-checked against mainline f47d223627f8 (v7.3-341): the affected code
> is unchanged between the two, so the bug is still present there.
> Checked against linux-next next-20261021 (commit 9a482184d910): the
> affected code is unchanged there as well, so the bug is still present in
> linux-next too.
>
> Reproducer status
> -----------------
> A reproducer was written and executed on an arm64 QEMU guest (dummy-virt,
> KASAN kernel) against unmodified 7.3-rc4 in-tree modules; KASAN fired at the
> claimed sink. The reproducer source is not posted here per
> Documentation/process/security-bugs.rst ("do not publicly share a reproducer");
> it is available on request.
>
> Triggering conditions
> ---------------------
> CAP_NET_ADMIN to install the etf qdisc; the socket must opt into TX
> timestamp error reporting (SO_TXTIME + SOF_TXTIME_REPORT_ERRORS); a TCP flow
> with a non-empty retransmit queue. No out-of-tree module is needed.
>
> Notes
> -----
> Built and checkpatch-clean: this patch was applied on top of 7.3-rc4
> (commit 93f51579e7df) and a full arm64 kernel (defconfig) was built with
> it -- no new warnings or errors. scripts/checkpatch.pl reports 0 errors,
> 0 warnings.
Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID:
<20261023110328.GL708417@horms.kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351026-linux-kernel-netdev=dewy.ruReferences:
<20261021155401.65997-1-phx0fer@gmail.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-351026-linux-kernel-netdev=dewy.ru From: horms@kernel.org (Simon Horman) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net/sched: etf: initialise the sock_exterr_skb before filling it Date: Fri, 23 Oct 2026 12:03:28 +0100 Organization: Usenet Network Message-ID: <20261023110328.GL708417@horms.kernel.org> References: <20261021155401.65997-1-phx0fer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="482578"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Zd+NdIZCnnPccrv6xuqH4LSzJW8= sha256:/i8bOdgIn3cYLadExEwB5yckAkb+56orZ+GTf4PrJwI= sha1:F/vGMvxqLbw7CUkZec0yO43b+/M= sha256:GcLgFLzAXHDvqWxckLAST924AfjJSBgIROGK2l5DhTc= Content-Disposition: inline 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 B04A6111476; Fri, 23 Oct 2026 14:09:26 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.738 X-Spam-Status: No, score=-3.738 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 (2048-bit key) header.d=kernel.org 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 CjX94n_5xcNw; Fri, 23 Oct 2026 14:09:24 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-351026-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id E13E5111402; Fri, 23 Oct 2026 14:09:13 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 17ABC297CE; Fri, 23 Oct 2026 11:03:34 +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=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792753413; b=bdQQHQxECZ0PK1PQGFQfMNI3yw6MkB7VxVnICAtQEK8TfT90I4WJA4oREmB0nu1z3WqO TGO8xL9AFUc+rmGCcsxu8yHD4hcD8/g4euFkGr2+vpbNCKhFbv4HHW8s3oerJj9FoW5F1 s0m6LfbenAh+uc62UsiCsONZV03xHTCnmGAgjQdI/Wd0u6w/K7/gq6HcJXUb9HIDHuoRr zxa/V/fDnNOjtBxCxu1I9/pjoaGebajS/i/X5ngi1WFKGaX6rOpgELbbQy1sp6ksYgW/h YPROA1nHXnxI6td1Fjo/OcfJFyzwnhGNaKnk0UMMQxeBlRlBt3tjOQ1AdhKeiLIf9zw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792753413; h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=7YRX/enVQAzytukMCM6+WSBuOlJEKJvpnpxugZ2I9TQ=; b=bEGWUHjHFi12fHBxJCvhYz6WbmecGD6dQjQbbw2Vew6g2ButHfuTQSue4SsXqFLz2UxH KYiM0tfHvVte0mJbnMMbMTOx2DBhZkBveYe4Z3A8X6RjEAY+DvhpG7cRzCiUnZrDrym/9 f75aA/PylQLLVOaslbeZfIV6PFR4Z2UDEqCcNdoQQHkJxr+dyQ/q5KMBsBUXR0PvsXaT9 71trYECvbD+ID0W4NC4LW4KOj4AUkUfSsQPXRxndpZvx7hNpJw7mlPX/g//mrWqHSBVMr LSGgDRNZJJmVg+PdzsItUX8MjowmyNZKa+Qpd2t6ZgUkEeZ8dwEfp7Zvfo61zVWLfSQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YcNu7rMa; 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 2A406606A324; Fri, 23 Oct 2026 11:03:33 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YcNu7rMa X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792753412; b=HnTG+tf89e1sAEHN/lRMMpSRi3VeB1t/sTK8PVggfk+UKZ6GszS8Xd6RrXDi5JhtkCZN 6pKQHnBs+7TNr8s9sGM1++dMaK6/GwnsJz6SKEKCXX035yMElgBnPRLOZQphh9k6mo+Vk /vsgUuW7UlcBCgBo63E6Dg/7BxQ1Ov0u19goagRJPNl968mxBBbfpdDWnvs4XH+tnkA4G Tc8pvN9MDtdohENeu5E3XxKMgdpMfGpfl+4e9pk9sQG3eoPaLP3siwC5ANTAxjjeKvzKN PjGli/TnS6bX+kX4Fd/bxc4AJUwKeZthQCOZ0ZgJIWvkmK88XedPN/Y/+8NfqDZu3eA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792753412; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=7YRX/enVQAzytukMCM6+WSBuOlJEKJvpnpxugZ2I9TQ=; b=LbyG4r9HGw54j4yaXnOvHfCKu7TD/T9Wa+yX4vTLXpA78yEpLM2lqlIe41tRkpoynls9 iVqQnmXqwPHiWrnbb51FPPGqncatLBWDux9WG793ZLjZ7eAVYGi7l/v7bCHaxkTJ0rijv et92khZ/45Qa7F4QYY7GfUyMXrLty/cyN7AXfcKowzi3hqZqLExF8ssP39xH5H6DRBaRl IhqaMCRho7QVTGfLfE+5PT/RSc59Ci17qXF/g/fO5bgNu33JjbfuT9qXsYwFsGJZ0FjB8 4GpyLrCG8b4i/9uuliHqIj0Eac3YpvaeVgfGnuYQ9Ha2jvyRBXEQExNFphCHD5nDcIw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YcNu7rMa; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C130606A31B for <netdev@vger.kernel.org>; Fri, 23 Oct 2026 11:03:31 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72EFA1F01825; Fri, 23 Oct 2026 11:03:30 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792753411; bh=7YRX/enVQAzytukMCM6+WSBuOlJEKJvpnpxugZ2I9TQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=YcNu7rMaHhRKzOuX9bm6hR0e10LK1rzV6U19WMN1z5m4+jqHtQQjxALQ3GkhwiZBj YA5gkHtOyGv3pvvwhwM+NP+h160x3hU2VdCz1JGkuvrqDxxY/E362kRmskaCWW9EKN C+9trwNwMDfQ/kvFyKbvBifR9ArubCNaOgCrqisrnDSCARD2pWegkK3ZZz+nRPytIp MhXZWNTjC67TsZh9Fr0Z+BPWVFJWMlwlTEF9vbXgvxtLCtK000YMIC4iRoNeIBFK8b DuO6HoH2lyTLC21c5YuaUgQELdtplAfgATRc2UvgJjWO5Ldyf9ybx8O+I9sX+7IrcH 3kzxiIXx37M0A== X-Cc: vinicius.gomes@intel.com, jhs@mojatatu.com, jiri@resnulli.us, netdev@vger.kernel.org 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: <20261021155401.65997-1-phx0fer@gmail.com>