Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp422974lqp; Thu, 21 Mar 2024 05:43:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFeDJ2E6cQLHADU26CspbuDs4GmpZ4q78uLgmL4V7uRz2jGoe8x8v1nxtDqv31f41aPq8tU7IVJoe7XJqX3JKfues4GXXj8Y1w66uh3Q== X-Google-Smtp-Source: AGHT+IHZQye6xcHDeRq+4f0TKGrO/1+S+WG2yY0K/8tGAkZsZlwpgdn7laaM0obeDVsIb+tUZE2M X-Received: by 2002:a05:6402:3715:b0:568:9d31:2a75 with SMTP id ek21-20020a056402371500b005689d312a75mr6379260edb.4.1711024996599; Thu, 21 Mar 2024 05:43:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711024996; cv=pass; d=google.com; s=arc-20160816; b=da/Fyi2Dm0WvcWm11vQWCwzYJXw51LMu2Uab3s0WJuAGTLXvcESmRlTtSgW3OVry2W rLGdr0MVhpkSTkx9gK5Wtp79GquEgFyRw4qglWkPBOrl4SxGonVu5cfthoUbMkV4wWXB P0CMMo0ej36/d/mFviWfc+QLCpt76Qtyh6yEFWytwWQHwBtPbsZR00y7wELz5GD7RdIO HPnkiGy3fYU8HlzjtDPnKE327BKn7fY8khc75aMBU+g6jgoAwo9SGL/8kth5/s86kYGY aPeA+9gFMt5qWYbZw5gdTJK9ILRB7mSwuK2Cct/ZkI27Z+JOPKeGfYiq8Z4BUlbwdtrQ Z7Xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Y6dKbdT6CKun5+cypb7qTPiuf+ERRmXIczUU4oFpp24=; fh=DyMD5am3CHxktyzwYf/qgNiQpdwb+Q/jqZnFHxjREpI=; b=PdbPd+mlM5lTZmKmER0qUAZNy1h1JkYLJ7STsC1q2YRCwXY+ek2SroGwcHJfhdLzeO 4fNsD/D+HKTVPRjve43/JrEWJgf2dEHxl7gQiPzgzQVCqgxWTLxZLcGgkzK/D8335afW Ta4dwX3YN1GF8iNQV2iwNeXfK6dC2yhgsuJb9+Oow5iEa2kmlvZz7acEuYhWwJ06vNjF u4T3/lR5tfbPbs6OdruRdnCuDaejYNl6Q5MP4FHXWbgfxquzWgotFxe1umBfdY0M/3v0 qaPfzeoZe+vR9ine0t207BOV32b5a5zEWZwc23oH/eAgorj70WTOlsdb7XHtxWbIsMzv JQbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@resnulli-us.20230601.gappssmtp.com header.s=20230601 header.b=aWPwam1x; arc=pass (i=1 dkim=pass dkdomain=resnulli-us.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-110045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110045-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id cw14-20020a056402228e00b0056ba94c15e5si1877203edb.93.2024.03.21.05.43.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 05:43:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@resnulli-us.20230601.gappssmtp.com header.s=20230601 header.b=aWPwam1x; arc=pass (i=1 dkim=pass dkdomain=resnulli-us.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-110045-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110045-linux.lists.archive=gmail.com@vger.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 am.mirrors.kernel.org (Postfix) with ESMTPS id F1A991F2243D for ; Thu, 21 Mar 2024 12:43:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A33183CC3; Thu, 21 Mar 2024 12:43:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="aWPwam1x" Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 C969583CB4 for ; Thu, 21 Mar 2024 12:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711024986; cv=none; b=kAIslk2e4seZJ2CcVS4WTz+5eW68zfub1ZaHh5YghdUm6i+UxvpBK0cEWlW1Xhk8LqBUvR4DPsbhjpG18p7/WTvGrOaYjGElLyc4FhS5r9OLZJhXhMsiW7aGALoiTY1rDhRGFOVaTEFnHkmdnw4ynnBGO3Ir+rrWj2Mj3T2U8rE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711024986; c=relaxed/simple; bh=EQ6hbRDXSCTTLbQhaUR33aI/6wiYbgEj/Sko9Wjmw00=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=faf5kqbysDDD5oMsmqj8HHNh21I9sXBqc8Z3R4cnu3GmDazwUJ4cXcRd8W8YKUqBKFFNtNM++bC8DajSi6lPMepoSqnrFW7jJchJU2LOIgp+1V9ttR/oZm1GvbHqVrBcgaNfAy5rJ4uLJyeuChUO6wr/yKS06ZzHpkA1rNVYY0E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=aWPwam1x; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-414618e6820so7374105e9.0 for ; Thu, 21 Mar 2024 05:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1711024983; x=1711629783; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Y6dKbdT6CKun5+cypb7qTPiuf+ERRmXIczUU4oFpp24=; b=aWPwam1xt6jJieVMQ5Zy9pafzF3M91jZcZNKFjM93JvC3qqN8j5g3JrjDBo3xeXVA2 JwSFLoYo4NKWXCkltNcg3eJfTKGgDJI7WIHZXB8ZQxDgq7KvImSacJsrthniJZhj3srL cEx8xkA6aByNHeixrdTkjWYqOGEuvFDT3YyfbOXOzraBPGpbhS9Mj5lODYGC8/9jNqK3 vU1K5Tv7t6IgYViH9hofDTISn5sa5Tc+b9lu+dQaOmstGl60keeMPt4QOl8PW4JEYdvD zAWtHAKVKRpS2BsFRs6ujatRPLtGwGpD2HF9E6IZjY802DeQPOALbiAz0caanFett0KX 3Jzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711024983; x=1711629783; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Y6dKbdT6CKun5+cypb7qTPiuf+ERRmXIczUU4oFpp24=; b=LncF4mx7VOZtfW9tmg/WeHOgeAf9v6gCNWdNT4AUyE5jzi8KHqjoiJtMlSmBE1MmrX vhx/xZlRzneA5KLyahftYx4SCWztPILnh7fp4lt2IOg7Ctf8kZPQcHDxgbVwSWkiC9hc HfvUql1m1WrkIPJJ6+DDUk5w3OIZsK/U2qZ3dy0NXPWZrg++lfWdy0nBguMfFZv+2EFD FvtsOh1QY6AmC815gY36HkuUILrQY7wUKjsZuFaJ547SzJ5LjIGHzVu7CDsQsgf0nTOe tnRQVJSjuP04aWzmeyeO+sjd8npMCZqe6ffuw/X/ghH5N3PHwZfjIRyoykVFt6f9gOoE 6CFg== X-Forwarded-Encrypted: i=1; AJvYcCVVtdeBcZagrE1liUu9oGoa79DSHyAiQ5dhl9c1NsuUlV56A/2T3VPb/UFXfOoDls6zIzWnAQLxKSXkd1/aaZXfzY7E30e/uuJHvOKU X-Gm-Message-State: AOJu0YwFLm3x9GnEo1gwkfce8rRPnTXQ1BuxFhOBZm/srRue3DciYpDL xX+jn5f/yvPkujDbN8hwNG+wYqAqy9oU+ViaPWsNG4fWjn9SaJvyyivpgmco1ZI= X-Received: by 2002:a05:600c:310f:b0:414:5ec3:8fcb with SMTP id g15-20020a05600c310f00b004145ec38fcbmr7811199wmo.23.1711024982740; Thu, 21 Mar 2024 05:43:02 -0700 (PDT) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id p5-20020a05600c468500b004132ae838absm5529132wmo.43.2024.03.21.05.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 05:43:02 -0700 (PDT) Date: Thu, 21 Mar 2024 13:42:58 +0100 From: Jiri Pirko To: Anastasia Belova Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: Re: [PATCH] flow_dissector: prevent NULL pointer dereference in __skb_flow_dissect Message-ID: References: <20240320125635.1444-1-abelova@astralinux.ru> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Thu, Mar 21, 2024 at 01:04:22PM CET, abelova@astralinux.ru wrote: > > >21/03/24 13:57, Jiri Pirko пишет: >> Thu, Mar 21, 2024 at 10:36:53AM CET, abelova@astralinux.ru wrote: >> > >> > 20/03/24 16:38, Jiri Pirko пишет: >> > > Wed, Mar 20, 2024 at 01:56:35PM CET, abelova@astralinux.ru wrote: >> > > > skb is an optional parameter, so it may be NULL. >> > > > Add check defore dereference in eth_hdr. >> > > > >> > > > Found by Linux Verification Center (linuxtesting.org) with SVACE. >> > > Either drop this line which provides no value, or attach a link to the >> > > actual report. >> > > >> > It is an established practice for our project. You can find 700+ applied >> > patches with similar line: >> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?qt=grep&q=linuxtesting.org >> Okay. So would it be possible to attach a link to the actual report? > >Unfortunately no as far as results of the SVACE static analysis tool are >not available publicly at the moment. So, don't mention it, has no value what so ever. No place for advertisements like this. > > >Also I agree that this is quite a minor fix, but I still insist >that it would be better to add a check. It is not possible (prove us wrong) to hit this bug in real world. No point to fix nobug. > >> >> > >> > > > Fixes: 67a900cc0436 ("flow_dissector: introduce support for Ethernet addresses") >> > > This looks incorrect. I believe that this is the offending commit: >> > > commit 690e36e726d00d2528bc569809048adf61550d80 >> > > Author: David S. Miller >> > > Date: Sat Aug 23 12:13:41 2014 -0700 >> > > >> > > net: Allow raw buffers to be passed into the flow dissector. >> > > >> > Got it. >> > >> > > > Signed-off-by: Anastasia Belova >> > > > --- >> > > > net/core/flow_dissector.c | 2 +- >> > > > 1 file changed, 1 insertion(+), 1 deletion(-) >> > > > >> > > > diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c >> > > > index 272f09251343..05db3a8aa771 100644 >> > > > --- a/net/core/flow_dissector.c >> > > > +++ b/net/core/flow_dissector.c >> > > > @@ -1137,7 +1137,7 @@ bool __skb_flow_dissect(const struct net *net, >> > > > rcu_read_unlock(); >> > > > } >> > > > >> > > > - if (dissector_uses_key(flow_dissector, >> > > > + if (skb && dissector_uses_key(flow_dissector, >> > > > FLOW_DISSECTOR_KEY_ETH_ADDRS)) { >> > > > struct ethhdr *eth = eth_hdr(skb); >> > > > struct flow_dissector_key_eth_addrs *key_eth_addrs; >> > > Looks like FLOW_DISSECT_RET_OUT_BAD should be returned in case the >> > > FLOW_DISSECTOR_KEY_ETH_ADDRS are selected and there is no skb, no? >> > I agree, I'll send the second version. >> > >> > Anastasia Belova >> > > >