Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp206447lfu; Wed, 30 Mar 2022 20:57:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp50TDc5xe2/Pa29QvLf+g2b6tjTEP2pQ8z/GLy48I11BDkxO94L9dsxRHLFnB6DaCq7g1 X-Received: by 2002:a17:90b:1c0d:b0:1c7:3b02:aa68 with SMTP id oc13-20020a17090b1c0d00b001c73b02aa68mr3811730pjb.187.1648699034029; Wed, 30 Mar 2022 20:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648699034; cv=none; d=google.com; s=arc-20160816; b=bETXY3MDC5QDy+4XYyMrKGW6KJk+r/LSX4uO10nsuXPnLpH45SwfpXNek5UcBTlw5p /WHTW34sgRB8lMRw0NTSx4yNj4NwTTKfSqb4XTjOB5jnmS8DaWghbPVVtn+vnsHlFUnQ QRr+fiCoW4/c+igygrex4eK5XTcp8RnAodoGJAjtYwas+s4iYLabvGvFwayXoIYv4u4p 5z7nGJHBXrr0HjJEwmduQ2zd2A9NXzfBQ4mY7Iv1WqfpzMUyTmOrtZhfTj8LTX/Nrt6F oVcuDug2L11JKJxdins33VxJVTtlfvrmdesqIFFeFax2XASo+6Yvj1bxqH7FIWBzbVKy I47g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=COPVE+YCVdItyBKKIHvU8JepkXlG/YAiHQ11IqNO/mw=; b=mdN/rklNmK5EcQ8G0JP6scTHnvg8pQAoqH82jYnZGyQh7S8YqmiNzM50Bz0C+m6Ib9 GqDXqDQ6zuOQpNK+Und+TPNNE1xvjH4W9mombpxDxg9xUXdeyrQkQXM7w8XKb5UivoDN zzErjpwhLZcffaTTtCrLTTcn8HddeD/5ORwI8HQHdSQNpEYMTz2kMHumNSKOblN0oycU 79n/T3kJcJ5BynSsdyMHzcAkWATML4qvVb1tJCOE+rolLuVWdFdt7VMj5WZbFlTWdJKi 9Yn/F4iK484ua8Q3Q98rxyMycKeP+UchGFGxPpVttQsf9CnmQ3J5oMSCNPF6rkp+5Gkz nJCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i0VxgskM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u11-20020a63ef0b000000b003816043ee48si24810361pgh.61.2022.03.30.20.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 20:57:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i0VxgskM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 534D017154C; Wed, 30 Mar 2022 20:09:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345277AbiC3Mze (ORCPT + 99 others); Wed, 30 Mar 2022 08:55:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244567AbiC3Mz2 (ORCPT ); Wed, 30 Mar 2022 08:55:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D4A3B7C43; Wed, 30 Mar 2022 05:53:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA4A260DBD; Wed, 30 Mar 2022 12:53:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CEDD6C340EC; Wed, 30 Mar 2022 12:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648644822; bh=9Lzjr4C0o5+FuexRlUqn1UHUEVXyAWYqGNh6uZkxC+I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i0VxgskMCgRM4kAySGl45svHARNH1Vsj2v4R1/c+RIJI29ku2csDF2j3rFwiOxL00 zD2NzTqJ05g61MQJsfxU7IWLVUzO67+jusGwUN7Ec+u/DUUrd4Ju5Dm+kk8RSCBRWA faaoHHtIrNOmx3wSdMKj6qn+zcSk448lrazNpC5ZGzKfsUNbAV4vYXJix1bo9o2L3C XcOf/yEZedo1xCjlWd/zOjgKFWufBA3obKORa12PHQCz3XG2ooiekq+HITSjrD5deT 1Qv6/iU6hRN0GHDG8gLS6O2oJcOrPfBquBwY3f7BHTbu7Sx1P0Ahf2oXtpWwenYOt7 NOGodGQ697QUA== Date: Wed, 30 Mar 2022 15:53:38 +0300 From: Leon Romanovsky To: Xiaomeng Tong Cc: bharat@chelsio.com, jgg@ziepe.ca, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, roland@purestorage.com, stable@vger.kernel.org, vipul@chelsio.com Subject: Re: [PATCH] cxgb4: cm: fix a incorrect NULL check on list iterator Message-ID: References: <20220330123027.25897-1-xiam0nd.tong@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220330123027.25897-1-xiam0nd.tong@gmail.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 30, 2022 at 08:30:27PM +0800, Xiaomeng Tong wrote: > On Sun, 27 Mar 2022 19:38:31 +0300, Leon Romanovsky wrote: > > > > On Sun, Mar 27, 2022 at 03:35:42PM +0800, Xiaomeng Tong wrote: > > > The bug is here: > > > if (!pdev) { > > > > > > The list iterator value 'pdev' will *always* be set and non-NULL > > > by for_each_netdev(), so it is incorrect to assume that the > > > iterator value will be NULL if the list is empty or no element > > > found (in this case, the check 'if (!pdev)' can be bypassed as > > > it always be false unexpectly). > > > > > > To fix the bug, use a new variable 'iter' as the list iterator, > > > while use the original variable 'pdev' as a dedicated pointer to > > > point to the found element. > > > > I don't think that the description is correct. > > We are talking about loopback interface which received packet, the pdev will always exist. > > Do the both conditions impossible? > 1. the list is empty or > 2. we can not found a pdev due to this check > if (ipv6_chk_addr(&init_net, > (struct in6_addr *)peer_ip, > pdev, 1)) > iter, 1)) Yes, both are impossible. Thanks > > > Most likely. the check of "if (!pdev)" is to catch impossible situation where IPV6 packet > > was sent over loopback, but IPV6 is not enabled. > > -- > Xiaomeng Tong