Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp401014lqp; Thu, 21 Mar 2024 05:05:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWUerF6dGXblWWz1iuFPM5Cp5ykBAjkAhRtDt6SDSPUWu7IuFiwyU/3Fj4Uq0mX9pL2Gz+GQZ2uYbHqxDnKnsmPy9DczI7ZV0zTT7dgIw== X-Google-Smtp-Source: AGHT+IFMHPSdmDa+C3+VA5A4OcQH4dmWAyZlBvRvk4RdZZeUVNPvnfamBuaJKSrIF3ArpS0GNxFm X-Received: by 2002:a05:6a00:3d48:b0:6ea:6d59:ffce with SMTP id lp8-20020a056a003d4800b006ea6d59ffcemr2123504pfb.15.1711022733554; Thu, 21 Mar 2024 05:05:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711022733; cv=pass; d=google.com; s=arc-20160816; b=wJZeg61DMNn5BgQUJjfMIkQq8CknuBV3tvA7GSpL/ytTgZLE0rQo2JcdakdoeTh9M9 UnHCSSrpzgFAJlMhtG7EsfE6rUXMo3Ki5qDUHpOBfVrAiezZ4ZmuOORWR1FnwyqUFPjJ RZhaLvGbD+EQyJwWbzgweqw+vNPDMxR8NNKnygRvEwCozNt7b4U9zf3INoyk3fu/uVZV UIOE4DuReM8STfUXiYd3I4KyftljxmQIfHNt3P1Ebt/eEW8KSbiBoedNYKBLKvoqaYup gcXdgdqqc0w3UfSKqh7kjFZZL89qw11hx5lmezyDOEak3+oy1SBNaemOTO+7YjkHmmwm RIuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=dzQOMqP+u6zjg+/2tvOHdzu2yszw6GqHLlFUciNsd7g=; fh=r4x8NXQIjTZgFRyGxzFJXngKvQy8WqtCZw06LAOJbSs=; b=Sa/Qe/gKWXHsd8xyAbRA08J6lpAhmDhR6z79Z/+LVrRCh7ZLEZmKUdR1a08DGt0ngD GJAY/D/M1yYdyt5L879i95boaoE5gYqwRxxSx6yOWn2qPP73XDwHi8VNDLVRouvX9pYw xOEOf/fDs4xyraRS7a4QmKZwlJylpD7XW+UIjWHegbYiVQO9lsaAn/bfNrpMKyu7HA8h VuO3Bo0u5R4pJ/GJoru8zVLFysFWfSXar7xNuatIpC3t9JqTUummP7Uy1oWJQ0BJnJm8 ZtVsAhdePbX+BiN9SXBtPzHgvyLDlM6wdS//d3qWoUwu4up/W/ZdVctvwl6BCaCLvOyW tG6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=astralinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-110000-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110000-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k5-20020a636f05000000b005e42b5cb08bsi14009983pgc.110.2024.03.21.05.05.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 05:05:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110000-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=astralinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-110000-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110000-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 333C02832BB for ; Thu, 21 Mar 2024 12:05:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5045876037; Thu, 21 Mar 2024 12:05:24 +0000 (UTC) Received: from new-mail.astralinux.ru (new-mail.astralinux.ru [51.250.53.164]) (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 F2CA26E602; Thu, 21 Mar 2024 12:05:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=51.250.53.164 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711022723; cv=none; b=IE5kjOkDepMKJfxnetrE505ghhovp+xeogmlUyMx2gM2WKIn1531SYyF1UMnZjFxLXIV36T84fOrFngZWCTxsx2Xr5KjDPCB6rdeLWy2/BWkp1MdDyYCrw+GSJlbzGq1h7Heq4ChK/AU87X9UHoU3UXIY6ThhBRaRY/0yVMd/0I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711022723; c=relaxed/simple; bh=EERyoR1JLibpqXpHBJIxplkz5PbGSchJCH8HqFMz73k=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Z4c2UBBedDp6QWnx+83vH7ULKK9xUqnND0B8p1NMJYbJexzE7Uzhk758NAlHGUT7A9mMnpK6cDMGoHXvsS0XKAzPCYAKACrCQ5Dg7ZsKTTBbpwd26gWwEhkHIi0EhsTX2y5CLzzYd8V1NM8U7z2YdZElQ3C1iTuYxrGilxnDyD8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=astralinux.ru; spf=pass smtp.mailfrom=astralinux.ru; arc=none smtp.client-ip=51.250.53.164 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=astralinux.ru Received: from [172.20.10.9] (unknown [176.59.168.90]) by new-mail.astralinux.ru (Postfix) with ESMTPA id 4V0kfq1c5wzqSPm; Thu, 21 Mar 2024 15:05:07 +0300 (MSK) Message-ID: Date: Thu, 21 Mar 2024 15:04:22 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: RuPost Desktop Subject: Re: [PATCH] flow_dissector: prevent NULL pointer dereference in __skb_flow_dissect Content-Language: ru To: Jiri Pirko Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org References: <20240320125635.1444-1-abelova@astralinux.ru> From: Anastasia Belova In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-DrWeb-SpamScore: -100 X-DrWeb-SpamState: legit X-DrWeb-SpamDetail: gggruggvucftvghtrhhoucdtuddrgedvfedrvdehuddgtddvucetufdoteggodetrfcurfhrohhfihhlvgemucfftfghgfeunecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttderjeenucfhrhhomheptehnrghsthgrshhirgcuuegvlhhovhgruceorggsvghlohhvrgesrghsthhrrghlihhnuhigrdhruheqnecuggftrfgrthhtvghrnhepkeetkefhhedugfekfeevteefuedufffggedvheetgedtgefhleeghfeghfekledtnecuffhomhgrihhnpehlihhnuhigthgvshhtihhnghdrohhrghdpkhgvrhhnvghlrdhorhhgnecukfhppedujeeirdehledrudeikedrledtnecurfgrrhgrmhephhgvlhhopegludejvddrvddtrddutddrlegnpdhinhgvthepudejiedrheelrdduieekrdeltdemgeehfeefvddpmhgrihhlfhhrohhmpegrsggvlhhovhgrsegrshhtrhgrlhhinhhugidrrhhupdhnsggprhgtphhtthhopeejpdhrtghpthhtohepjhhirhhisehrvghsnhhulhhlihdruhhspdhrtghpthhtohepuggrvhgvmhesuggrvhgvmhhlohhfthdrnhgvthdprhgtphhtthhopegvughumhgriigvthesghhoohhglhgvrdgtohhmpdhrtghpthhtohepkhhusggrsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehnvghtuggvvhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlih hnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlvhgtqdhprhhojhgvtghtsehlihhnuhigthgvshhtihhnghdrohhrgh X-DrWeb-SpamVersion: Vade Retro 01.423.251#02 AS+AV+AP Profile: DRWEB; Bailout: 300 X-AntiVirus: Checked by Dr.Web [MailD: 11.1.19.2307031128, SE: 11.1.12.2210241838, Core engine: 7.00.62.01180, Virus records: 12528151, Updated: 2024-Mar-21 09:51:42 UTC] 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. Also I agree that this is quite a minor fix, but I still insist that it would be better to add a check. > >> >>>> 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 >>