From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFE543EA94C for ; Thu, 9 Jul 2026 08:48:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783586889; cv=none; b=QP7ogV/AZvlBrRGk/fCclcrL6NzPceh7t3PDcJ7uwjlEPj75h9xoQqEUePOKKh/GcJQCj1O2P+AJYmmhOX0tVSgiDhufKaljcizEyYoZwmqvpJQz7vW5hLEHebBaPyAZRZkSf3ZRnojbazp1QdRIrSIdZeIlFnaY3WsA0PPScq0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783586889; c=relaxed/simple; bh=/L+tqpwaYO9W0zF/nWpLyI2lH1dRyW25/cwwkrtvFjQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eNgr6p2Wh03E0EhlDyBGnrC0hWYK5UwM5BH3/Dvq28i1p0ZwYD7x32aV3r+Sg3/YHIofK40BSJ3WLVG0xIqZ78tqqZs9mcYZ0Hc/HCttXKlG3lws0gLMM2q12dMRMm2lMMXBDM08niylhpDwBIdkadALOOn7xEHOjDir89VOWWI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=eTvWoI/P; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=NF4rGnOu; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eTvWoI/P"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="NF4rGnOu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783586885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uNLDe2YV79k3XNGNarb7q5y3JmQjEGvvYqB7WFiB7AU=; b=eTvWoI/PmjUhg4ylvuzo0ytJEVhiryAyw19hegCI2stkIAVK3rvBDG+q9oNof6eAHlXfEm DNP2nOl0PRwgPbrqRYNrjTMGGo8QpWz5nnNFhWQREPforAhdqjQ5/wVBX492pFCdT98YDS yERRJ1+Kx1BSwXpmRSmeqLRB/VLTpbs= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-eAAhw2dnMjyO-FKl0jmPCg-1; Thu, 09 Jul 2026 04:48:04 -0400 X-MC-Unique: eAAhw2dnMjyO-FKl0jmPCg-1 X-Mimecast-MFC-AGG-ID: eAAhw2dnMjyO-FKl0jmPCg_1783586883 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-492714d002cso10989595e9.0 for ; Thu, 09 Jul 2026 01:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1783586883; x=1784191683; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=uNLDe2YV79k3XNGNarb7q5y3JmQjEGvvYqB7WFiB7AU=; b=NF4rGnOuBsGMgTryhWYuj6quxb6GKMPKZR6iYqqK8COomx9ijVgAR6F1S6LGPEVhm2 GRsg8qjBD1H61Boqw8PP82NaeziAn8gDRRRi3zrTQD7OKBNQif9ssiJaoOFm61KdVGcE cR/gYBFEVRHgtc/YTu8/06IXZ2/IIrsrUGI2jWyJI44JFwkOggLHOGXF7qbf4m4t5Ft+ MTxjl0dlp3N+JTeUtdVmoZgBAvyA7d09mip727jPh6COYjW90XmfpCfwFFMl7uV8bjT9 Qifdjynowg+lRucb3ZVuguyMWPwzZVs655lF1tsLjqyzZPypN/b8bnPuWZ2IPuBtQPfp r4HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783586883; x=1784191683; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=uNLDe2YV79k3XNGNarb7q5y3JmQjEGvvYqB7WFiB7AU=; b=jxizIDNNcwgqoL7l6ryq7y5ZA5pSeZffMIr9AbLC439E03gZe7g1HMVyEWng89Qb61 cBsEIaCTxB2vfA2476jQbthFIXJGP5vHBtxRcD9IUdxV86cDpSKywYJJoj2AX8nFOu5m O/c70envFa2ywkrl/hCTn//JHsR4Fgg0/1+KGjaN7IZHpXmkCLo70Kc7aO6PdUjO5Wtc ZjNMxvwnxufc4mN8dj78EAPAAgfvOGx6GveSH2qXbm8I+41lZ1weztrbOuI9fdCpyC7r U6GV/W0KN/A4m8ztHJIPudAmUNRjY1taPYMUSg9ISktqAkDRVk7obWSesU2T2Q/qXd24 Hqew== X-Forwarded-Encrypted: i=1; AHgh+Rqe29xxnHBW+MFJJY7WATdmpGdlaHAMVNpw/hciK2Y5YdUaVUL26Z/uGJImOZgPVxWE+etlcSTvE+V3edY=@vger.kernel.org X-Gm-Message-State: AOJu0Yw3aaHUvGbeczYqKm+8V6foILB9fRqqptjl7YSGBBSveej+A5+1 bKfSgODO8M11N9jFgLwgZxR1Kghgw4ArZznmBPkhsZOl+L3x1gi08+65l1lFoPW8AlTr7I1jvqU m8Ys9+kqOEWx8vQEZ1ros/F+ktqxniTXaPBCznMydab+PW8C9AbhjdaB297D8BCmS0A== X-Gm-Gg: AfdE7cnH9qbCg/7dNHOAMTNt2r11OeYzzssltMZDNzBJ1Tp0TFtIfXpeXklpl8Ki2Ia yFsmS+mtYHTZzgWinDYNA5SiLbdOBk4KewK+sU8XLRV+yERb1ywIt1Lw0OF7Qqg7uMov+eDf1TU tb5ZcmPWHKJdgRd5hvITpocLyx1xlK1H7sCtXcneafqAdYZYYKWcbtV2/Zd6/GJnXZ7eVQwxvwO pveSWONs6/hMWWBkpS4URmLzBCutrcjGNZhuv9mOuFIY42MXyHbtw3v/S54asiMp6Z8/OvJWqzI ozeQfRu7dEestvhGQ33z3O+XgJRTeoH7Y8r22KTYvjJUvf07WcS5SYyBoNrvaVZ7RwaQQmmId2H V/jAKRzKbCdRqsR3qRu3d5Ctsp4ZZRZhwGmIUi1Nk2ITM9DHbvQQKjcc0hkp9YNyoOOpqhWAavE lrPVJasEyn3Fq0 X-Received: by 2002:a05:600c:6206:b0:493:a573:179b with SMTP id 5b1f17b1804b1-493e68d145dmr61356375e9.30.1783586883330; Thu, 09 Jul 2026 01:48:03 -0700 (PDT) X-Received: by 2002:a05:600c:6206:b0:493:a573:179b with SMTP id 5b1f17b1804b1-493e68d145dmr61355965e9.30.1783586882805; Thu, 09 Jul 2026 01:48:02 -0700 (PDT) Received: from ?IPV6:2a0d:3344:5521:6b10:58fd:68f:7756:389d? ([2a0d:3344:5521:6b10:58fd:68f:7756:389d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493e5a58853sm97520615e9.1.2026.07.09.01.48.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Jul 2026 01:48:02 -0700 (PDT) Message-ID: <656ea643-bf7d-4ad0-9020-7ca3f49f9e82@redhat.com> Date: Thu, 9 Jul 2026 10:47:59 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net v4] net: macb: drop in-flight Tx SKBs on close To: =?UTF-8?Q?Th=C3=A9o_Lebrun?= , Nicolas Ferre , Claudiu Beznea , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jeff Garzik , Conor Dooley Cc: Paolo Valerio , Nicolai Buchwitz , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Gregory CLEMENT , =?UTF-8?Q?Beno=C3=AEt_Monin?= , Tawfik Bayouk , Thomas Petazzoni , Maxime Chevallier , stable@vger.kernel.org References: <20260702-macb-drop-tx-v4-1-1c833eebdbc8@bootlin.com> From: Paolo Abeni Content-Language: en-US In-Reply-To: <20260702-macb-drop-tx-v4-1-1c833eebdbc8@bootlin.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 7/2/26 5:37 PM, Théo Lebrun wrote: > The MACB driver has since forever leaked the outgoing SKBs that > have not yet been marked as completed. They live in queue->tx_skb > which gets freed without remorse nor checking. > > macb_free_consistent() gets called in a few codepaths, but only close will > trigger the added expressions. In macb_open() and macb_alloc_consistent() > failure cases, queues' tx_skb just got allocated and are empty. > > Fixes: 89e5785fc8a6 ("[PATCH] Atmel MACB ethernet driver") > Cc: stable@vger.kernel.org > Reviewed-by: Nicolai Buchwitz > Signed-off-by: Théo Lebrun > --- > Changes in v4: > - Drop the skb_drop_reason code. No other Ethernet driver does that and > the reasoning (because our stats are broken) is a bad one. > - Take Rb trailer from Nicolai. > - Drop email that gets rejected. > - Rebase upon latest net/main (d8e8b85a85fe). > - Link to v3: https://patch.msgid.link/20260617-macb-drop-tx-v3-0-d4c7e57d890b@bootlin.com > > Changes in v3: > - Drop stats fixing. A proper fix deserves its own net-next refactoring > series to migrate to netdev_stat_ops (ynltool uAPI), which will come > in later. We keep the tx_dropped++ because they are safe as every > other context is disabled when macb_free_consistent() is called. > - Rebased to latest net/main (406e8a651a7b), nothing to report. > - Link to v2: https://patch.msgid.link/20260428-macb-drop-tx-v2-0-647f5199d8df@bootlin.com > > Changes in v2: > - Increment tx_dropped stat once per SKB, not once per frame. > - Reset tx_head & tx_tail to avoid keeping stalled cursors. > - Fix SKB dropped reasons throughout by adding the reason as parameter > to macb_tx_unmap(). This is a new patch. Then the drop-all-on-close > fix can use this ability to report we are not consuming SKBs. > - Add increment to stats->tx_dropped on DMA mapping failure and > tx_error_task. Done as separate patches (3 and 4). > - Rebase upon net/main @ 46f74a3f7d57, nothing to report. > - Link to v1: https://patch.msgid.link/20260424-macb-drop-tx-v1-1-b3ecb787d84d@bootlin.com > --- > drivers/net/ethernet/cadence/macb_main.c | 21 +++++++++++++++++++-- > 1 file changed, 19 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c > index fd282a1700fb..d394f1f43b68 100644 > --- a/drivers/net/ethernet/cadence/macb_main.c > +++ b/drivers/net/ethernet/cadence/macb_main.c > @@ -2668,8 +2668,25 @@ static void macb_free_consistent(struct macb *bp) > dma_free_coherent(dev, size, bp->queues[0].rx_ring, bp->queues[0].rx_ring_dma); > > for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) { > - kfree(queue->tx_skb); > - queue->tx_skb = NULL; > + if (queue->tx_skb) { > + unsigned int dropped = 0, tail; > + > + for (tail = queue->tx_tail; tail != queue->tx_head; > + tail++) { > + if (macb_tx_skb(queue, tail)->skb) > + dropped++; > + macb_tx_unmap(bp, macb_tx_skb(queue, tail), 0); > + } > + > + queue->stats.tx_dropped += dropped; > + bp->dev->stats.tx_dropped += dropped; > + > + kfree(queue->tx_skb); > + queue->tx_skb = NULL; > + } > + > + queue->tx_head = 0; > + queue->tx_tail = 0; Both sashikos noted this could race vs tx_error_task, but it looks like a pre-existing issue, and I think it should be addressed with a follow-up patch. /P