Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp178629lqb; Tue, 4 Jun 2024 08:19:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVyjJtLQCva1V0TZ3DoqruIUOJh+77iCbro7bUIMPgJwXvnV39NslQofPnRLcdn5Xt/dM6jpWLL0uNuG8zSrAUvICNe1LXsOlJjrE1w2w== X-Google-Smtp-Source: AGHT+IFZ64WALbQv64crH5IzWf9/i9Hx9Q7h0v5LFcd7DuAlh9n0dt/WNjBrRme7MjeyoUVDHk9O X-Received: by 2002:a05:6a00:2d25:b0:6ed:2f0d:8d73 with SMTP id d2e1a72fcca58-7027fbaa4cemr4061771b3a.3.1717514355093; Tue, 04 Jun 2024 08:19:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717514354; cv=pass; d=google.com; s=arc-20160816; b=vobMkUMCHeZIuNmCqckCmIpa9t1EuFCCpxj9uvRf5BkqQFNPa392jxZ63dAcEQ+43U zktQEzxhFVJcGmdV4YLtASmuUTu5nylycN+1OEQCQFKbiIFPLpI6t94IOLC6XIZXlvd0 wQzYhBlwcJuuF/pXMzoNzpiUipooQ8LAqj9E0O0WRsONY0Wn/f4ICOSWOlF/7mVBv1Tf yKeCi6qBsQfBapW5KEt59rbVs5fs3LdFrEfQmKUm8hXXH46CTNRqFkt8t6ijaND2fZZD +V9qE7bgKhhWdN+spPSm7ZrHOycdYMy08JEBR7OroNgGIty23OxyVfQnQeHzb0gnpr1i i0XA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3mz7LAqZKMyj/6h1UX9DVJWkbseZydReWAY7A8vqpq4=; fh=nRRWXM9iU8lUEYDdDyzhZynYKm28rNTUggjEkIZ86OE=; b=Sgqk7fY+GuzSqz5ynF7zhjjergYg5trTJVI/esnPv8xmxDprOdukcYoDxqDMyFFwv5 sXqIQOpSTlPv5I2O3NRAgIOYvtunGgS5udqRmi9ZPKJDgG3gOKfxbRaGf6OrSQm4gKA2 0LDjaNrsuR/c7CwomO01FBdfetQO2ikY3N0T5k4N8dSpzt/vV9xHRuDbbi8069QY+Nxg A4gnUiNjCV5rodKDPtzvbidzBJF/03VnAe57IiZTVYlN4riY8xthEoDu+EMS36fiZ4WX o1vq6vbxvtoXjEzLEHE/YjWo71tNO61Es62VK2deEAZLXySZNNwzvsnTLN+v2ZNEOVL8 ZwRg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MyrZhOp1; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-200938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35c73bfd1si8524802a12.733.2024.06.04.08.19.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 08:19:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MyrZhOp1; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-200938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 71FB7281355 for ; Tue, 4 Jun 2024 15:19:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2AB0143C5A; Tue, 4 Jun 2024 15:19:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MyrZhOp1" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CBA86D30B; Tue, 4 Jun 2024 15:19:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717514342; cv=none; b=Wx5Jj2szk48x/0fJhGqfF541N+0FjyswEJ1l9icHMYDCH1J1/jP9nt5UawZPIr1UOOwBJODga6QuxVuTRWVLry995IPAwczriWtakL1In1opm0ZWdiRi3Z9DWxxxn7d7WKQreo5E1lOAsSaEYS/R+hmqgOEizN3rq6pj+Aq3ObQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717514342; c=relaxed/simple; bh=SgYhZ1mbIunBtwN4LKIszTbrQvB7J8eU/XbTXIjeK1I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TB+VotbM6doXY6PzfCYAEa5gSF0qYKcEdZ4q35KGjW4XYGw4hooa09FWzCQJvh4aDkZgIlf4KjIobc/yL19wa8qnh2+cXNeVhvy5+xktqyBqTCOa3kVIs2xdW1Us9scc90Knt/VvQlZvKt/8SWKoHRUDnZ2xkafeCp+Iq5xEbfU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MyrZhOp1; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AEDCC2BBFC; Tue, 4 Jun 2024 15:18:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717514342; bh=SgYhZ1mbIunBtwN4LKIszTbrQvB7J8eU/XbTXIjeK1I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MyrZhOp15I4XFkFD+6fehBKN2mI4y5rGUfIh9flVaQMTk7j+KqUkgTuT4qKqbjHZB q333b3h11kdC3Wc+/3qNCGkLw8D6Z++35usa8mQ81mqSAD+zMFIquk2uX+Nn7u97B7 c8d4Zu8BgGuSobzdZdqks9FnbB2gYB2UAfZZP/GV+HyY0d6pYuqBsL3hVHGHgQ7fiY yG1tQoTjmARwBu8+y40vGzGxjBk72VffHwwN1Z/L61agKiHL3vIJ800ryuLvQE5zGQ 4JIlzAEEzVxRTEet/DZexud0+/HeIdANRcpFtK/iDyiYApg0WRrRVOzJdIIGZRAeMC RU8uo0vqYXLng== Date: Tue, 4 Jun 2024 16:18:55 +0100 From: Simon Horman To: Yan Zhai Cc: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern , Abhishek Chauhan , Mina Almasry , Florian Westphal , Alexander Lobakin , David Howells , Jiri Pirko , Daniel Borkmann , Sebastian Andrzej Siewior , Lorenzo Bianconi , Pavel Begunkov , linux-kernel@vger.kernel.org, kernel-team@cloudflare.com, Jesper Dangaard Brouer Subject: Re: [RFC v2 net-next 7/7] af_packet: use sk_skb_reason_drop to free rx packets Message-ID: <20240604151855.GT491852@kernel.org> References: 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=us-ascii Content-Disposition: inline In-Reply-To: On Fri, May 31, 2024 at 06:43:00PM -0700, Yan Zhai wrote: > Replace kfree_skb_reason with sk_skb_reason_drop and pass the receiving > socket to the tracepoint. > > Signed-off-by: Yan Zhai > --- > net/packet/af_packet.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c > index fce390887591..3133d4eb4a1b 100644 > --- a/net/packet/af_packet.c > +++ b/net/packet/af_packet.c Hi Yan Zhai, Near the top of packet_rcv, immediately after local variable declarations, and before sk is initialised is the following: if (skb->pkt_type == PACKET_LOOPBACK) goto drop; > @@ -2226,7 +2226,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, > skb->len = skb_len; > } > drop: > - kfree_skb_reason(skb, drop_reason); > + sk_skb_reason_drop(sk, skb, drop_reason); So sk may be used uninitialised here. Similarly in tpacket_rcv() Flagged by clang-18 W=1 allmodconfig builds on x86_64. > return 0; > } > > @@ -2494,7 +2494,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, > skb->len = skb_len; > } > drop: > - kfree_skb_reason(skb, drop_reason); > + sk_skb_reason_drop(sk, skb, drop_reason); > return 0; > > drop_n_account: > @@ -2503,7 +2503,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, > drop_reason = SKB_DROP_REASON_PACKET_SOCK_ERROR; > > sk->sk_data_ready(sk); > - kfree_skb_reason(copy_skb, drop_reason); > + sk_skb_reason_drop(sk, copy_skb, drop_reason); > goto drop_n_restore; > } > > -- > 2.30.2 > >