From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2F11A1AB503; Tue, 18 Jun 2024 12:41:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718714472; cv=none; b=afYhZapjr6Or3XIjEYelaQXn319KbReKYvDVQxMadLtFzzljVfQHlyMa6BH/7q6WBQvD8D9v9tecQbq8rXsjGu3gqfcJ9AYOjHJ9+zrDwk2Y7xefJWa8h/RfA/vwaTulAJsMJRhQo7a4fMLZV27DxHu2mDkstl3cn4nlTyL0xXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718714472; c=relaxed/simple; bh=7mGrHxL0HdzTrs7BZbgAKSPQi9Yjl+WUY+0IgMEes/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=igzkrq+BsjSaRt4oeJQtMZi6fzFzdH00t0WdRm2NdDF1MpwhQ+DiJWwlW9kIG2BfbJ9paf6wWrUlP6vTAI2U1u6+o7gnUXJ9NtZqzKWMPm7XAb8MJZHZlAtUFCdBLeDdPTx4U8wRrKKcg/9cN3p/lkWHhjm2nOibmAmHGsWboOI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J0XEO+se; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="J0XEO+se" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16C69C3277B; Tue, 18 Jun 2024 12:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718714472; bh=7mGrHxL0HdzTrs7BZbgAKSPQi9Yjl+WUY+0IgMEes/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J0XEO+se9SuZDvWlQu4WBog0tfuisPRwY3QpkSTgovSNj1ZNxaBb0XK/v5JgdWzV0 V6/gEZtbV8nrVgYhkjbBpNrzqQBV9ztiT4bev9XXklNKQuMsxQ6MNhhKEO+CzuhLsB rQn21zJ3hbpQqBafLljOAMLgXPUK2lVFr4irLCn2iiBHbRQJ36Ft0M0Spn9KU5TIFj qms4NmrlGN1lH20QKr/2HspCDhEvcAqx2AVMkK+uqTEMpn52S5Nr5/9HYNvNF6SrLe aJzC8G2rYFSkfsYHmqVpFqIZgAjlBWBOTeOBp3oGAYNc0K5Sd5rFVITTIu1cbqrTVE K4SHgMWRvlmXQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Eric Dumazet , Paolo Abeni , Jakub Kicinski , Sasha Levin , davem@davemloft.net, dsahern@kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 25/29] ila: block BH in ila_output() Date: Tue, 18 Jun 2024 08:39:51 -0400 Message-ID: <20240618124018.3303162-25-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240618124018.3303162-1-sashal@kernel.org> References: <20240618124018.3303162-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.94 Content-Transfer-Encoding: 8bit From: Eric Dumazet [ Upstream commit cf28ff8e4c02e1ffa850755288ac954b6ff0db8c ] As explained in commit 1378817486d6 ("tipc: block BH before using dst_cache"), net/core/dst_cache.c helpers need to be called with BH disabled. ila_output() is called from lwtunnel_output() possibly from process context, and under rcu_read_lock(). We might be interrupted by a softirq, re-enter ila_output() and corrupt dst_cache data structures. Fix the race by using local_bh_disable(). Signed-off-by: Eric Dumazet Acked-by: Paolo Abeni Link: https://lore.kernel.org/r/20240531132636.2637995-5-edumazet@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv6/ila/ila_lwt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/ipv6/ila/ila_lwt.c b/net/ipv6/ila/ila_lwt.c index 8c1ce78956bae..9d37f7164e732 100644 --- a/net/ipv6/ila/ila_lwt.c +++ b/net/ipv6/ila/ila_lwt.c @@ -58,7 +58,9 @@ static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb) return orig_dst->lwtstate->orig_output(net, sk, skb); } + local_bh_disable(); dst = dst_cache_get(&ilwt->dst_cache); + local_bh_enable(); if (unlikely(!dst)) { struct ipv6hdr *ip6h = ipv6_hdr(skb); struct flowi6 fl6; @@ -86,8 +88,11 @@ static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb) goto drop; } - if (ilwt->connected) + if (ilwt->connected) { + local_bh_disable(); dst_cache_set_ip6(&ilwt->dst_cache, dst, &fl6.saddr); + local_bh_enable(); + } } skb_dst_set(skb, dst); -- 2.43.0