Article View: linux.kernel.netdev
Article #9371Re: [PATCH net] net: qualcomm: rmnet: avoid stale VND access on TX drop
From: Jérémy Jean
Date: Sun, 01 Nov 2026 22:59
Date: Sun, 01 Nov 2026 22:59
185 lines
16184 bytes
16184 bytes
On 2026-11-01 23:11, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 1 (1) · Medium: 0 · Low: 0
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let
> patchwork
> know by including "pw-bot: cr" as a separate line at the end of your
> reply
> (one such reply per series is enough).
>
> - [High] The fix is incomplete: the stale port->rmnet_dev UAF described
> in the commit message can still be reached.
>
> Pre-existing issues:
> - [High] Teardown race: rmnet_port can be freed while its hrtimer is
> still armed.
>
> --
>
> net: qualcomm: rmnet: avoid stale VND access on TX drop
>
> This commit changes rmnet_send_skb() so that a TX drop after a failed
> __skb_linearize() is counted on the lower device with
> dev_core_stats_tx_dropped_inc(). Before, the drop was counted through
> port->rmnet_dev, which can still point at a VND that has been deleted.
>
>> diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
>> b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
>> index 39d6d084e73f0..bd68d60b50d35 100644
>> --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
>> +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
>> @@ -543,10 +543,7 @@ static void rmnet_send_skb(struct rmnet_port
>> *port, struct sk_buff *skb)
>> {
>> if (skb_needs_linearize(skb, port->dev->features)) {
>> if (unlikely(__skb_linearize(skb))) {
>> - struct rmnet_priv *priv;
>> -
>> - priv = netdev_priv(port->rmnet_dev);
>> - this_cpu_inc(priv->pcpu_stats->stats.tx_drops);
>
> [Severity: High]
> This removes one reader of the stale port->rmnet_dev. Can the stale
> pointer still be reached another way?
>
> rmnet_newlink() is the only function that writes port->rmnet_dev.
> rmnet_dellink() does not clear or reassign it when the VND it points to
> is deleted. rmnet_unregister_bridge() still uses it on the real-device
> branch:
>
> drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c:rmnet_unregister_bridge()
> {
> ...
> rmnet_dev = port->rmnet_dev;
> if (!port->nr_rmnet_devs) {
> ...
> } else {
> /* real device */
> bridge_dev = port->bridge_ep;
> ...
> }
>
> netdev_upper_dev_unlink(bridge_dev, rmnet_dev);
> ...
> }
>
> This sequence seems to reach it without any race:
>
> 1. Create VNDs A and B on real device R, so port->rmnet_dev = B.
>
> 2. Delete B. nr_rmnet_devs drops to 1 and B is unregistered and freed
> (needs_free_netdev), but port->rmnet_dev still points at B.
>
> 3. Run "ip link set S master A". rmnet_add_bridge() only rejects
> nr_rmnet_devs > 1, so the call succeeds. It puts R's port into
> bridge mode but does not update R's port->rmnet_dev.
>
> 4. Unregister R:
>
> rmnet_config_notify_cb(NETDEV_UNREGISTER)
> rmnet_force_unassociate_device(R)
> rmnet_unregister_bridge(port)
> netdev_upper_dev_unlink(S, B) <- B already freed
> __netdev_upper_dev_unlink()
>
> __netdev_upper_dev_unlink() passes B to the PRECHANGEUPPER and
> CHANGEUPPER notifiers. It then calls __netdev_update_lower_level(B),
> which writes to B, and __netdev_walk_all_upper_dev(B), which walks B's
> adjacency lists.
>
> The real S->A adjacency is also never removed. Does that leak the
> reference on A, so that unregistering A later hangs in
> netdev_wait_allrefs()?
>
> Should port->rmnet_dev be kept valid in rmnet_dellink() instead? The
> other option is to stop using it in rmnet_unregister_bridge() as well,
> for example by using the slave port's rmnet_dev or
> netdev_master_upper_dev_get(bridge_ep).
>
>> + dev_core_stats_tx_dropped_inc(port->dev);
>
> [Severity: High]
> This is a pre-existing issue and was not introduced by this patch. Can
> rmnet_send_skb() run on an rmnet_port that has already been freed? If
> so, both port->dev->features and the new
> dev_core_stats_tx_dropped_inc(port->dev) read freed memory.
>
> When the last VND is deleted, rmnet_dellink() tears down the port
> before
> it unregisters the VND:
>
> netdev_upper_dev_unlink(real_dev, dev);
> rmnet_unregister_real_device(real_dev);
> unregister_netdevice_queue(dev, head);
>
> rmnet_unregister_real_device() then does:
>
> rmnet_map_tx_aggregate_exit(port);
>
> netdev_rx_handler_unregister(real_dev);
>
> kfree(port);
>
> Nothing marks the port as shutting down. With TX aggregation enabled
> (egress_agg_params.count > 1, set through ethtool coalesce), a transmit
> on another CPU at the same time could go like this:
>
> CPU1
> rmnet_vnd_start_xmit()
> rmnet_egress_handler()
> port = rmnet_get_port_rcu(skb->dev); <- before rx_handler is NULL
> rmnet_map_egress_handler()
> rmnet_map_tx_aggregate()
> spin_lock_bh(&port->agg_lock); <- waits for CPU2
>
> CPU2
> rmnet_unregister_real_device()
> rmnet_map_tx_aggregate_exit()
> hrtimer_cancel(&port->hrtimer);
> cancel_work_sync(&port->agg_wq);
> spin_lock_bh(&port->agg_lock);
> ... frees skbagg_head ...
> spin_unlock_bh(&port->agg_lock);
>
> CPU1 then takes agg_lock, sets port->skbagg_head with skb_copy_expand()
> and re-arms the timer:
>
> hrtimer_start(&port->hrtimer,
> ns_to_ktime(port->egress_agg_params.time_nsec),
> HRTIMER_MODE_REL);
>
> CPU2 continues:
>
> netdev_rx_handler_unregister() <- synchronize_net() waits for CPU1
> kfree(port); <- hrtimer still queued
>
> When the timer fires, rmnet_map_flush_tx_packet_queue() calls
> schedule_work(&port->agg_wq) on the freed port. The work then reaches
> rmnet_send_skb() through rmnet_map_flush_tx_packet_work(). The
> aggregated skb also seems to leak.
>
> synchronize_net() waits for the reader to finish, but nothing cancels
> the timer that the reader armed. Would a shutdown flag checked under
> agg_lock work here, or a second cancel after
> netdev_rx_handler_unregister()?
>
> This looks like it comes from the TX aggregation code added by the
> commit in the Fixes: tag.
>
>> dev_kfree_skb_any(skb);
>> return;
>> }
Both comments from Sashiko seem valid, thanks.
I will make a v2 for the first one, and create a dedicated patch for
the second one.
Jérémy
pw-bot: cr
Technical Details
Message-ID:
<1916da9d261bf0094fb5295f10ec6db3@oss.cyber.gouv.fr>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354357-linux-kernel-netdev=dewy.ruReferences:
<20261031221052.1642262-1-Jeremy.Jean@oss.cyber.gouv.fr> <179357109791.3131.6434747837427266534@kernel.org>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-354357-linux-kernel-netdev=dewy.ru From: jeremy.jean@oss.cyber.gouv.fr (Jérémy Jean) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net: qualcomm: rmnet: avoid stale VND access on TX drop Date: Sun, 01 Nov 2026 23:59:19 +0100 Organization: Usenet Network Message-ID: <1916da9d261bf0094fb5295f10ec6db3@oss.cyber.gouv.fr> References: <20261031221052.1642262-1-Jeremy.Jean@oss.cyber.gouv.fr> <179357109791.3131.6434747837427266534@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2791134"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:qBLjTKXlmv2UD6jpOEVRQUvuBmA= sha256:IWwRftcWyAbDCNJC7BJCjy1zrbgkznjqozPVpuQUrQo= sha1:gaGV0mOqZXJ2isvd1+CWK1GL1ZI= sha256:zwHCmsUW6+BcTX+dx6nlZExAZv6FJMD0/1XcXgW0PsY= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Source X-Source-Args X-Source-Dir X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 9A3101123A0; Mon, 2 Nov 2026 02:00:27 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=oss.cyber.gouv.fr 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 dap_9Ziy4pQl; Mon, 2 Nov 2026 02:00:20 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-354357-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=oss.cyber.gouv.fr X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id ECB5E11201F; Mon, 2 Nov 2026 02:00:11 +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 D96E62829F; Sun, 1 Nov 2026 22:59:43 +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=1793573983; b=ZOPiqDB7qOw4uuEd5pGFxuu5NEcaXsYshdZTU6tbn+mW8pu1x4DlBd5QG71YTSaV2xLD 5SKsA9mOlq7HfWDLunHTteVl9/tmkzdTYytXvVqYsQgipByRdBI633mJyFe826KgyVxeU 3ZBt4Y2pRIFjHDMYqnFaO1TX1n7doMhoCQmGDN3fiW17ZP87mk044eXSAYir2Xb4UPz9E MzOi89xuh9PFHGQq0o+Z6lGLcXtvyTfJZVW9hvwoYkxpSmu5/Tdt0uLKyPcRH6Q9w7AL6 N6ZllDDu/PZMmNLI8TSaQuchA6ShXmIs2ew6kqQqMT36gIwKu0Z/t3n8rjlvS9mPxYg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793573983; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Date:From:To:Cc: Subject:In-Reply-To:References:User-Agent:Message-ID:X-Sender: Content-Type:Content-Transfer-Encoding:X-AntiAbuse:X-AntiAbuse: X-AntiAbuse:X-AntiAbuse:X-AntiAbuse:X-Get-Message-Sender-Via: X-Authenticated-Sender:X-Source:X-Source-Args:X-Source-Dir; bh=UfWjHWL7Sf5149fxouKPsSV+//DCptgJPgsPxN+aK+8=; b=J2wcZ5qOl0YKGxRuYXqgeGqMtVp0ZUdUjFUoO16OtQo5S5tcNBq5S8S/SC6VsGR9FrfA v4EgHnOF2eNrvAO8BkHbQ5hTmM1MOM7UJFW7D8vWGUXcN+osBzLgZjdSQ9p8QGe8QIYDd ovqkO6d0QLdRCVHEYKemMTiC66Cg9Dcft6mz9isAiviWbW/4kjFnMz0Rq34YlFay+ss/a 6992Tor0deF4hpZ0Blzmj4HS+mMtOk0gnTU6fFdWvEV4hj55DI/AumR0UyQ3kiyj/jg4O kyfsJ2WE7WtbBHxJVYPyI0xpxm0mPUTJfKghdeS70WnbAW8ZTA5IOUe2ATsAG5w6bWw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=oss.cyber.gouv.fr header.i=@oss.cyber.gouv.fr header.a=rsa-sha256 header.s=default header.b=qXhfjLJN; dmarc=pass header.from=oss.cyber.gouv.fr; spf=pass smtp.mailfrom=oss.cyber.gouv.fr; 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 B037F606A32D; Sun, 1 Nov 2026 22:59:43 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=oss.cyber.gouv.fr header.i=@oss.cyber.gouv.fr header.a=rsa-sha256 header.s=default header.b=qXhfjLJN X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=51.159.188.251 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793573967; b=GkFLj7LSME2Js7QYkn1CogM9NKA2kt+2hZr/Q5CXJBgag+RFHSUFRsxDzbYKE3aD5SuG 5nClRVSxn+R2tjJGIZI99SrjO1AmlCvNi5U6nLXIAMMFD2jHw+m+MASh+pBu+0b67ZlnZ +QTn3Dsukv+nK6yhz0EG4I1Rpag1nrwhpl+g/wqmAipOt3ZfYaMGBsU+Umsg1NaYCTCYC oM5PccGMWg3tMFT4G4WP7PB5LsHxLNcFyVw4DWmAzIokbQUJ27NlpR6ScUeW10V/if4Yq iWTtNy4eRgCPsLkzKO94B1LD5uwpROr+ZC2zgODJTY1DeQ6cKhszAM94t8xGy5bodBA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793573967; h=DMARC-Filter:DKIM-Signature:Received:MIME-Version:Date:From:To:Cc: Subject:In-Reply-To:References:User-Agent:Message-ID:X-Sender: Content-Type:Content-Transfer-Encoding:X-AntiAbuse:X-AntiAbuse: X-AntiAbuse:X-AntiAbuse:X-AntiAbuse:X-Get-Message-Sender-Via: X-Authenticated-Sender:X-Source:X-Source-Args:X-Source-Dir; bh=UfWjHWL7Sf5149fxouKPsSV+//DCptgJPgsPxN+aK+8=; b=soY8m/2LAuWCnzH9nR4N/3o5mOxxWIWyTGvl+gwmew1rxbRhdLlpvjYkhfUjnUynxBEB R+i1PLB1YW6yCZm2zL+g4YUVFBKrHsjZqrUVQgJMVTrHQCXEVMb8hF1AhxuHxQ0mQHgvk dbSMj2lnnO0QA0vpSAWbQAVrGZAkpO6yY6bOE8USWVPnohGNz7MIks5TM5W3pybcFjHYR gdpjwssLxHoxtN7gsX1+XlBtPiBJkQ8TQ6HWm9etzxfjUkWIoVarnaMnnHMWg7lEJLQl0 UPfqHQCEPiA5Z2FDC0ix5T2UbKyYfJTa8VugxkvleNdKKSXQ7MRk4+y5SsO6QAVOhhg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.cyber.gouv.fr; spf=pass smtp.mailfrom=oss.cyber.gouv.fr; dkim=pass header.d=oss.cyber.gouv.fr header.i=@oss.cyber.gouv.fr header.a=rsa-sha256 header.s=default header.b=qXhfjLJN; arc=none smtp.remote-ip=51.159.188.251 X-Received: from oss.cyber.gouv.fr (oss.cyber.gouv.fr [51.159.188.251]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFB55606A324; Sun, 1 Nov 2026 22:59:26 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DFB55606A324 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.cyber.gouv.fr X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.cyber.gouv.fr X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=oss.cyber.gouv.fr; s=default; h=Content-Transfer-Encoding:Content-Type: Message-ID:References:In-Reply-To:Subject:Cc:To:From:Date:MIME-Version: Reply-To:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=UfWjHWL7Sf5149fxouKPsSV+//DCptgJPgsPxN+aK+8=; b=qXhfjLJNCxZ7lDoPzewLDwt/vV hhU5dXu5QoUtnf3Oh1oVSOBawYsEOyP7NKdY7xYn2mamekYL7Z4ag/twYP5Uo8KQF8EsUw9VWTIzL juz/jlH/ApyZwXyVJLbPajYtYZf5bU96+vkDdcpV+ojDuU/4OJgMuoixTzYi0LKPSYpTNKFXfZUCR SWHfXHS8pw4aWiODKX90iOJSN5Owum09q6Va+NoZ75d9rbGd7fncN9m37mobYAkneDapBx8U7c1ak R5exQOnAeAMPQunNcWtz7WtvfrgHZ7oq7QabrR1f/qBhwWfQKaiiZNDNfWXveluosAb9AOrdQX6xc 6ZFVATtw==; X-Received: from [::1] (port=58476 helo=pf-012.whm.fr-par.scw.cloud) by pf-012.whm.fr-par.scw.cloud with esmtpa (Exim 4.100.1) (envelope-from <jeremy.jean@oss.cyber.gouv.fr>) id 1xNeWF-00000004BUd-1dDV; Sun, 01 Nov 2026 23:59:19 +0100 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-Cc: subash.a.kasiviswanathan@oss.qualcomm.com, sean.tranchetti@oss.qualcomm.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, kuba@kernel.org X-In-Reply-To: <179357109791.3131.6434747837427266534@kernel.org> X-User-Agent: Roundcube Webmail/1.6.20 X-Sender: jeremy.jean@oss.cyber.gouv.fr X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - pf-012.whm.fr-par.scw.cloud X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - oss.cyber.gouv.fr X-Get-Message-Sender-Via: pf-012.whm.fr-par.scw.cloud: authenticated_id: jeremy.jean@oss.cyber.gouv.fr X-Authenticated-Sender: pf-012.whm.fr-par.scw.cloud: jeremy.jean@oss.cyber.gouv.fr