Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1638166pxy; Mon, 2 Aug 2021 06:49:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/8Fx2pDhA92lhEDlD54x+YtfbeEP6Ax7XjJ79hxwJB+YTslOcY6gFDohtq3kolQB4bX4q X-Received: by 2002:a05:6638:cba:: with SMTP id x26mr11030700jad.98.1627912195108; Mon, 02 Aug 2021 06:49:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912195; cv=none; d=google.com; s=arc-20160816; b=wVLGi+nEpSS6bbrmashl4xAQoFrLM1s/aFAWxJWXYCEeQqpOlRnJ1tDRAPERQTahGe x1hywceuFuGm1R9w22Na4II/k7i2mSym+oLGhBdDtkB0C+Tg18SUWlX6lBQWItsfYTSZ GsbzgBBAZOE/xrFjX4NrKjcs2UFVocNVaD871EzRzSjjQigw3POPopbxFfeWOd3/1+S/ 1Pel3AqoX90z43YGABcz7BRBYKQj/I6iacynvZYggKOs1XQ21BgpQiNu2n9M+kuaMVDu P9Xp8xgHJwIeGwNj7WWgBKQ0D0zO/a1LWshYRcB/VGxkM0x6qTkUaIEFdouwe+1pl7P2 iw6w== 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=CijHCndVjDgbUDlKMTFbl2sWpuxXMgOn9QKsL0oHSWw=; b=JSmLPPwc3LyHWoI4x6kXyInyEXN7+6Ip+KFMENsx5LSxeHbAZS3auO1oxxqNmR/QZ3 100zjk4Znu31pY9D+pR/PH47J7U7CpR03Em9FFU/lvdB0CoxKP3nikHeQ5s8ueOoyF92 qR47TnJh4tOdlMSGjUr6xjEy53CzJ/t8zghqwYJ0relO8r9N9a336ksPvADNjwKF1X2W EUKktjQZnAH5aniMX/H2j4Ib6sBhIahB/LkBGinlWw1mrt0YBMRGYi49tjYnVvzOWjnK YsDefM+nqGvrMv/jr9ZJY/V3ZUl6GPFpgDR/wJNlvZ88oVAS2Kf+3QrYyHOc+df+gmK9 uVEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TUQjdX4n; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p19si12725496iov.90.2021.08.02.06.49.43; Mon, 02 Aug 2021 06:49:55 -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=@linuxfoundation.org header.s=korg header.b=TUQjdX4n; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234350AbhHBNsU (ORCPT + 99 others); Mon, 2 Aug 2021 09:48:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:56038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233994AbhHBNqt (ORCPT ); Mon, 2 Aug 2021 09:46:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C491860527; Mon, 2 Aug 2021 13:46:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912000; bh=iQcu7CsfD8tjdJ3BJklQRoNL+bjJ1nq6ktJ6QaVMAmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TUQjdX4nOFRUI8KnmCeTm/14toF6ZrCnmXIE1iZPhsFXFUCHp8LyNSuFQ+qD7MdTe jCvafGlpgIVmz14aS/YSEm9dduhr6pe4gZNBApYGOQK3yAh76Ug+cPGS25SFhQbL8D Kitzw472I/Y5s0XgPQG/vNP/RV92INFyG0csYJE0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Maloy , Hoang Le , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 22/26] tipc: fix sleeping in tipc accept routine Date: Mon, 2 Aug 2021 15:44:32 +0200 Message-Id: <20210802134332.749168639@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134332.033552261@linuxfoundation.org> References: <20210802134332.033552261@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hoang Le [ Upstream commit d237a7f11719ff9320721be5818352e48071aab6 ] The release_sock() is blocking function, it would change the state after sleeping. In order to evaluate the stated condition outside the socket lock context, switch to use wait_woken() instead. Fixes: 6398e23cdb1d8 ("tipc: standardize accept routine") Acked-by: Jon Maloy Signed-off-by: Hoang Le Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/tipc/socket.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 3ad9158ecf30..9d15bb865eea 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -1987,7 +1987,7 @@ static int tipc_listen(struct socket *sock, int len) static int tipc_wait_for_accept(struct socket *sock, long timeo) { struct sock *sk = sock->sk; - DEFINE_WAIT(wait); + DEFINE_WAIT_FUNC(wait, woken_wake_function); int err; /* True wake-one mechanism for incoming connections: only @@ -1996,12 +1996,12 @@ static int tipc_wait_for_accept(struct socket *sock, long timeo) * anymore, the common case will execute the loop only once. */ for (;;) { - prepare_to_wait_exclusive(sk_sleep(sk), &wait, - TASK_INTERRUPTIBLE); if (timeo && skb_queue_empty(&sk->sk_receive_queue)) { + add_wait_queue(sk_sleep(sk), &wait); release_sock(sk); - timeo = schedule_timeout(timeo); + timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo); lock_sock(sk); + remove_wait_queue(sk_sleep(sk), &wait); } err = 0; if (!skb_queue_empty(&sk->sk_receive_queue)) @@ -2016,7 +2016,6 @@ static int tipc_wait_for_accept(struct socket *sock, long timeo) if (signal_pending(current)) break; } - finish_wait(sk_sleep(sk), &wait); return err; } -- 2.30.2