Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2144867iof; Tue, 7 Jun 2022 21:14:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRf8fL2FiNu4KflNCEIuiIFw4j3PVRKATzoLrRbO/vR1FLEcp4HvOZZVawmEB3jzkDoLjo X-Received: by 2002:a17:903:22cb:b0:167:992f:60c4 with SMTP id y11-20020a17090322cb00b00167992f60c4mr5160283plg.22.1654661690330; Tue, 07 Jun 2022 21:14:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661690; cv=none; d=google.com; s=arc-20160816; b=S+ATuG6vqkKoR4Ez+2fclrHcfDB1kRZA/8seRAb0zOVkymID+IlRFpi6Wk4kABjvf3 br38ML/6fGCCbc+Z+8uRzByCAmgy+XOSetFGCPad++MuoNbo3m0i5OSWdmOv8+j0Xn7q rYFb2/FMncFoaP5D3HlrqjLTKRLUR7ht5FhPXN5XJhAmiUGSTP9JfauJhgkVYMWZXDrI 3hpn3alEpMo22QrhRGTiOCefN8vlax3vNsBfs/2SYjA5qO/wN2ip8gNRsfgKNHhm4YoV dohq+Ji28xpojtI18/+9ViYKOuZ0JU2+Y4HyqGDX6NuqywANuGpYDalnX51b6+bptl1i UDFw== 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=QO4sGKJOBwX/cxBqv5sNLUoJqOSwHFO/6HEaPQjExXE=; b=M/1ve72HfpyO/14UmoNiVqTgdwCW3YkipyRj9TDUK+GkQYGXJJkFnZRB4zqpLj+0Du Vkk9DyGdwf00Nx2nFj/hlhZHXwFN+PoTVeKT2g+kcvG8kk9Pfg0FJU5lVuwTSv214kIF gS2qg/kP8Q1vi5Ltcqry5STmdc037VlZZ0jJQLd68bCy/gfdUTP4jx4XnDqC/ClMWp5C Cyndj9I5rLXpLA6EziKMcNH48l4/MHZO2rErPXf6ptSsk8fyXW+BAKCSpWSOsvONZ1HA m+DsDKyetdRFeODEAeazrTp0wGdLYZ5Hjfh6PCU3/gWiy8yteVH8gH199bRaBE1/rE4p 1b1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HhuZuvjH; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q14-20020a632a0e000000b003fd69ac1f4asi16262834pgq.873.2022.06.07.21.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:14:50 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HhuZuvjH; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1276F22DFAC; Tue, 7 Jun 2022 20:46:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387068AbiFGWtw (ORCPT + 99 others); Tue, 7 Jun 2022 18:49:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381462AbiFGVkp (ORCPT ); Tue, 7 Jun 2022 17:40:45 -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 C5EA12332D7; Tue, 7 Jun 2022 12:07:00 -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 F3E766185A; Tue, 7 Jun 2022 19:06:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A7B0C3411C; Tue, 7 Jun 2022 19:06:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628819; bh=T6MiXZpB06tcLxMbXmqVOWVYpW3czv+bImNQtA0WiII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HhuZuvjHe+jteG1pxNqhHNviF0W2q4pEtoG9ilh5KGq1Uvz332LdVYkmiyIHJ6SzT T6S7sOPLfSv0cL4AlhLLPCn8beyLzd/vdIHBzPn47isZCc39f+QFrC+A/0rlzsULVr oKPtWmV9suSwrh9KCaSLRbl/fzRCKDmZBJj5UMc4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Neil Horman , Vlad Yasevich , Marcelo Ricardo Leitner , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 468/879] sctp: read sk->sk_bound_dev_if once in sctp_rcv() Date: Tue, 7 Jun 2022 18:59:46 +0200 Message-Id: <20220607165016.462618613@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 From: Eric Dumazet [ Upstream commit a20ea298071f46effa3aaf965bf9bb34c901db3f ] sctp_rcv() reads sk->sk_bound_dev_if twice while the socket is not locked. Another cpu could change this field under us. Fixes: 0fd9a65a76e8 ("[SCTP] Support SO_BINDTODEVICE socket option on incoming packets.") Signed-off-by: Eric Dumazet Cc: Neil Horman Cc: Vlad Yasevich Cc: Marcelo Ricardo Leitner Acked-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sctp/input.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sctp/input.c b/net/sctp/input.c index 90e12bafdd48..4f43afa8678f 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c @@ -92,6 +92,7 @@ int sctp_rcv(struct sk_buff *skb) struct sctp_chunk *chunk; union sctp_addr src; union sctp_addr dest; + int bound_dev_if; int family; struct sctp_af *af; struct net *net = dev_net(skb->dev); @@ -169,7 +170,8 @@ int sctp_rcv(struct sk_buff *skb) * If a frame arrives on an interface and the receiving socket is * bound to another interface, via SO_BINDTODEVICE, treat it as OOTB */ - if (sk->sk_bound_dev_if && (sk->sk_bound_dev_if != af->skb_iif(skb))) { + bound_dev_if = READ_ONCE(sk->sk_bound_dev_if); + if (bound_dev_if && (bound_dev_if != af->skb_iif(skb))) { if (transport) { sctp_transport_put(transport); asoc = NULL; -- 2.35.1