Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2021368pxa; Mon, 3 Aug 2020 05:35:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8Tf1CVZvU3xq3USvxWHTK3inpQvtrVeS0EUe5adIIiv9aHmc668RSUV0pM7L+Zu239ibw X-Received: by 2002:a17:906:a201:: with SMTP id r1mr12657121ejy.432.1596458144437; Mon, 03 Aug 2020 05:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596458144; cv=none; d=google.com; s=arc-20160816; b=u3E8sIXYW6RtxjO4i3cin/DQl3tZG5u7DFpjXyC/LhCJnlPkgSC4RoUAcY23a9OHbH 975Xr6sGKHqK7Q/EdwSDYs2soTepMH0XefnTAr3jplF8pSdOpLric3cuJBGmeJ6vs19U hxajOtSIM3DpSc6Cv7egXYnWmL4edUrrYzQbYAI/JZnvbJDTX/sBNm3AudXaAMar+3SS Wo/KPC4s4depN2WfY9CKtMZ1U2fq+Ns4YVcaN+YEVryuVLD/Rq6lkIOhuZq6vxqLrbSO fUuCIvBPap7zIpJAFsRrT7HpfTxUir/zq5UenGYWH8saEBpXYGOUaHnphPDdvDhtyZ7F fFjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nsSAGS6+3hmQ16jQ7cSrgWLgHdKQBgSntkflTa2B+d0=; b=GkI82LagkX5Ar5PrhcghQOaWk30fT++XEdzryHtgsBTsqBgak64kkqEAHPn4blfVeI LGCCAffFq7f0MR0ltwu0P7VGkDzMLm++W4vUF36XFTPBVsHhUUhhueEh6I3rix6lwL7M UKOyXnwHYkvL6HS8Z7+CTOavAfderu7ZzsDrouScepc1kMseee0lDbmVlOYgx0cN0fgD 05Bh+ZvFY4FBV1DbtsmyIsptF2t089jwKxsijLfWN8LD6+ycsPsxmceklChmS083+IR7 YWgl9OaS0zjOmR2vKC8cAJ5ghOMG6CA+MBYn4eUKeoQis0dyYc7/5z6sPnj4BZwNldPa AuTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nuWEwKBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si10203997edz.228.2020.08.03.05.35.22; Mon, 03 Aug 2020 05:35:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nuWEwKBh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729292AbgHCMcT (ORCPT + 99 others); Mon, 3 Aug 2020 08:32:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:60106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729265AbgHCMcO (ORCPT ); Mon, 3 Aug 2020 08:32:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3ADEA2076B; Mon, 3 Aug 2020 12:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596457933; bh=i95n0WsFW8jreM24pKk2d83Mpzoj/NmK0klcShWUGuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nuWEwKBhO7RAsbDZi5XEpf0vgqlHs6dUiM47++I/YtlGk9GZ1+/D3bZ6okK2dnUmF Nea/r+VpKgWPPJTfJ/qyF1dagmqMEMAsQsUTiVrAMEOnQOgKuOchnNH6AOfiKsIJ9R C0rU3o7rP/NziqWXGTRoMcr1yPxba8t5voWxiq1g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ido Schimmel , Jiri Pirko , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 35/56] mlxsw: core: Increase scope of RCU read-side critical section Date: Mon, 3 Aug 2020 14:19:50 +0200 Message-Id: <20200803121852.041985890@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200803121850.306734207@linuxfoundation.org> References: <20200803121850.306734207@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ido Schimmel [ Upstream commit 7d8e8f3433dc8d1dc87c1aabe73a154978fb4c4d ] The lifetime of the Rx listener item ('rxl_item') is managed using RCU, but is dereferenced outside of RCU read-side critical section, which can lead to a use-after-free. Fix this by increasing the scope of the RCU read-side critical section. Fixes: 93c1edb27f9e ("mlxsw: Introduce Mellanox switch driver core") Signed-off-by: Ido Schimmel Reviewed-by: Jiri Pirko Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlxsw/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c index e180ec4f1a248..3cebea6f3e6ad 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -1605,11 +1605,13 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb, break; } } - rcu_read_unlock(); - if (!found) + if (!found) { + rcu_read_unlock(); goto drop; + } rxl->func(skb, local_port, rxl_item->priv); + rcu_read_unlock(); return; drop: -- 2.25.1