Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp632696iog; Mon, 13 Jun 2022 09:32:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiVgMmdq8S+ua8afEM6P7zE8F+0xksaGmR/yw5GcYfEHPnywhet0qhsNqahsQxmMJjylZw X-Received: by 2002:a05:6a00:18a9:b0:51b:f63b:6f7c with SMTP id x41-20020a056a0018a900b0051bf63b6f7cmr149039pfh.49.1655137931280; Mon, 13 Jun 2022 09:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655137931; cv=none; d=google.com; s=arc-20160816; b=slPADHmaftaC9mbzizZTId3lxXoRHivZaRHVRvmjZrX0xBstmvHLOolQqcZDOLai9i KXtqt1k53DkEXbii+B0U0z5JzbPmk7Vmr5+aSE4+hhGFlMwTqri+2Kfle73IECPqRm/P gd8phstcJ04Qou43P6LA//t6YHALEXIxRmeWouYUo9TiSpUSAZcW7zeKLipmX3/mtEvf 3t3gB+rigap9gznZG2auLoknXr2lbFba8q4Wu1vn/inAy/2+yaPT9mOqo11gm9MhdEJG 2GGkbn3v+Jlfe89SJrAaDibel2/Myj7J21bRXRULlEPPNBB5KKR98LXROCKj9MN7Heb9 SLDw== 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=0C1TApMbZy3syeK9ID7FRAlxZ91lOTCCVuziSgqZ33w=; b=UlHNUSHtcTSJlFddmCBYlru0JZlNr+llOGArzLjoQP3yhzHkkaoyLpXbIjzuV8Wf3h d625Tp4oQjezVAfjUWgoLNywucKJ2aQMJOjIYt2RtOcgdhn1IyV+sBnWJrTWdsblg1tx AZfodH+DePNnv5EHJr5sXYj0s78OwH7GVx8qwlkzTEyYAVOIuijWm+a6nZKEN1tYDeqi 4A/WYqoa1jyFESVifBLXG18IvAZqwE+gjkhxIolDfVh4C4Wu6D2HKsgRxvK3YCnhmh7Z UTYuQyskcd8VOWxKRU0q6ivBPs5n+9Zscn/Y3bRYeeX/cKup5lPpGd1pwdt4xrbUf6hA y/9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=asd2nRPf; 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 i2-20020a62c102000000b0051c28de280fsi8934414pfg.346.2022.06.13.09.31.57; Mon, 13 Jun 2022 09:32:11 -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=asd2nRPf; 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 S1380140AbiFMNxm (ORCPT + 99 others); Mon, 13 Jun 2022 09:53:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379215AbiFMNuL (ORCPT ); Mon, 13 Jun 2022 09:50:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA67C2A435; Mon, 13 Jun 2022 04:33:23 -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 0550DB80E93; Mon, 13 Jun 2022 11:33:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 671A9C3411C; Mon, 13 Jun 2022 11:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655120000; bh=QDH42gKm5gGWv+NIEhenKt9NGcU0y959xwFHE/pD/gM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=asd2nRPfUGfDNN2GNnpet3qBRD5ZopxXPKlkZZjHFMRuteKSQbktiXjT1z+B2Jpn0 lcwAzWsYg4AXwIBFSA+XCmNcFXDottFVCi04mmJbpX7K2HKt83dOTZaw6e+r8ZAMjB QcwNPgBQhkqyjMhZiJxPqyngkM6HWLPOOhDScPEI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuniyuki Iwashima , Paolo Abeni , Sasha Levin Subject: [PATCH 5.18 197/339] af_unix: Fix a data-race in unix_dgram_peer_wake_me(). Date: Mon, 13 Jun 2022 12:10:22 +0200 Message-Id: <20220613094932.642406521@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094926.497929857@linuxfoundation.org> References: <20220613094926.497929857@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=-8.3 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 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: Kuniyuki Iwashima [ Upstream commit 662a80946ce13633ae90a55379f1346c10f0c432 ] unix_dgram_poll() calls unix_dgram_peer_wake_me() without `other`'s lock held and check if its receive queue is full. Here we need to use unix_recvq_full_lockless() instead of unix_recvq_full(), otherwise KCSAN will report a data-race. Fixes: 7d267278a9ec ("unix: avoid use-after-free in ep_remove_wait_queue") Signed-off-by: Kuniyuki Iwashima Link: https://lore.kernel.org/r/20220605232325.11804-1-kuniyu@amazon.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/unix/af_unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index e71a312faa1e..4aed12e94221 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -490,7 +490,7 @@ static int unix_dgram_peer_wake_me(struct sock *sk, struct sock *other) * -ECONNREFUSED. Otherwise, if we haven't queued any skbs * to other and its full, we will hang waiting for POLLOUT. */ - if (unix_recvq_full(other) && !sock_flag(other, SOCK_DEAD)) + if (unix_recvq_full_lockless(other) && !sock_flag(other, SOCK_DEAD)) return 1; if (connected) -- 2.35.1