Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6239937iob; Tue, 10 May 2022 13:41:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsWk4xee/i7MngU/Dj2mwUjOXlMuCxzPFKRRi373TeGWSq2q+Z1Pv1jq0WgdkE2xoahx5F X-Received: by 2002:a17:907:3da1:b0:6f4:2d69:75f6 with SMTP id he33-20020a1709073da100b006f42d6975f6mr21400157ejc.389.1652215302226; Tue, 10 May 2022 13:41:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652215302; cv=none; d=google.com; s=arc-20160816; b=V5QY9gejbBNwlgq06R6s9z3AGzJMaV5F3cLSRTYvVKDfXF41yV9cXN581/RxDU4gg/ uV4uPd3I23NvM076erBSdDnX+lTc9klBReWcGRpHuSD4jgNTCE7kFv+eUpi0D3Ru3u54 VsWCPcDVmfq1vXUTjwr1UM/NMMMjMkS5INSIcKgMnuE+183Eo38BgHXvNAppGcukZUWC k3crNPwpnKT/pp/pH65V+WWFoIHGSAdrHNNjwZljnTgHlBt5qcSRYzM8l2Ergs5Gf7h1 L276bzdB/6px12ozJ48+RDLUYL8ZYylYLPRlP86vWXiq4dPuxPiLIHOhwX9VuJR22Nh+ FMzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J6CNqZrfRGq2v4dCTvkf2PjW3LgMADdm/a5onxp07GQ=; b=qqGbSz+0DXLlMRZyn3W3ds7ioxdKPXEQUDMN7ciSAP0CQ64StB3Psh5eqS4afAMmKx f2C+V1ii44d+Y5ZIRWTerzt50Cdw6FdjjzTltIm1HYws+SjKqN3RK2LoVZQFplVaDa3g ik0aPZ6da9TBdzKDBAb2w3GTTk02KGZbWJbrNFqB3uIGJHGZx2TjU0NHU6LyEO3O9+oc 68WoUs9PzVeUpCj1xKhColKvZauO2AcFaKtwB/9MNVWV2KcazlKCd79tbiACAKWIon+r ouAdBvpngisZqUXXmOrFdHRfQ7HvtvPgS7c2dBM3o5tRPce27c8B1R3UIY933T/AsoMj apQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AQCKxq9Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm22-20020a170907949600b006f39901edd6si387928ejc.400.2022.05.10.13.41.18; Tue, 10 May 2022 13:41:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AQCKxq9Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344132AbiEJO2L (ORCPT + 99 others); Tue, 10 May 2022 10:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245499AbiEJN55 (ORCPT ); Tue, 10 May 2022 09:57:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B32BC5D99; Tue, 10 May 2022 06:39:24 -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 ams.source.kernel.org (Postfix) with ESMTPS id DB102B81DB8; Tue, 10 May 2022 13:39:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F3E5C385C2; Tue, 10 May 2022 13:39:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652189961; bh=KZUPbZ2/lAnhpPz4LDVUkyit7YrbW8ZuGD+hJrBPgNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AQCKxq9Y3MMYJLxfDl/2Q3uH+jN4nB1gbiHbAR2NZugJtBfjOFLpYRmjajgUEaZNP YX1PmujYxx41bb98mCKB1WsufZZB3Dl32mv6gFkwR3fXrKr3SZEjANHq4KNMTLaqnC JLb7BT3xyFn9ydDU1PHsH/rEqrPzemvuJlnka/rw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mustafa Ismail , Shiraz Saleem , Jason Gunthorpe Subject: [PATCH 5.17 082/140] RDMA/irdma: Fix possible crash due to NULL netdev in notifier Date: Tue, 10 May 2022 15:07:52 +0200 Message-Id: <20220510130743.957566574@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130741.600270947@linuxfoundation.org> References: <20220510130741.600270947@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 From: Mustafa Ismail commit 1c9043ae0667a43bd87beeebbdd4bed674713629 upstream. For some net events in irdma_net_event notifier, the netdev can be NULL which will cause a crash in rdma_vlan_dev_real_dev. Fix this by moving all processing to the NETEVENT_NEIGH_UPDATE case where the netdev is guaranteed to not be NULL. Fixes: 6702bc147448 ("RDMA/irdma: Fix netdev notifications for vlan's") Link: https://lore.kernel.org/r/20220425181703.1634-4-shiraz.saleem@intel.com Signed-off-by: Mustafa Ismail Signed-off-by: Shiraz Saleem Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/irdma/utils.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) --- a/drivers/infiniband/hw/irdma/utils.c +++ b/drivers/infiniband/hw/irdma/utils.c @@ -258,18 +258,16 @@ int irdma_net_event(struct notifier_bloc u32 local_ipaddr[4] = {}; bool ipv4 = true; - real_dev = rdma_vlan_dev_real_dev(netdev); - if (!real_dev) - real_dev = netdev; - - ibdev = ib_device_get_by_netdev(real_dev, RDMA_DRIVER_IRDMA); - if (!ibdev) - return NOTIFY_DONE; - - iwdev = to_iwdev(ibdev); - switch (event) { case NETEVENT_NEIGH_UPDATE: + real_dev = rdma_vlan_dev_real_dev(netdev); + if (!real_dev) + real_dev = netdev; + ibdev = ib_device_get_by_netdev(real_dev, RDMA_DRIVER_IRDMA); + if (!ibdev) + return NOTIFY_DONE; + + iwdev = to_iwdev(ibdev); p = (__be32 *)neigh->primary_key; if (neigh->tbl->family == AF_INET6) { ipv4 = false; @@ -290,13 +288,12 @@ int irdma_net_event(struct notifier_bloc irdma_manage_arp_cache(iwdev->rf, neigh->ha, local_ipaddr, ipv4, IRDMA_ARP_DELETE); + ib_device_put(ibdev); break; default: break; } - ib_device_put(ibdev); - return NOTIFY_DONE; }