Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1646807pxy; Mon, 2 Aug 2021 07:01:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjodkBwHB02bECYANXk3tklW2hBfiU0D+YIj/hW76jDDr4GGOJovr5RPi3fYCPxdYpsSR5 X-Received: by 2002:a05:6602:228d:: with SMTP id d13mr2438746iod.36.1627912918043; Mon, 02 Aug 2021 07:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912918; cv=none; d=google.com; s=arc-20160816; b=mCJdQGkqAY4j8TvK4TvJHJrU2hvivR9kVfrtivJZd+eVsuHEG+3ZI8LFHhoEZGDacb fqgocszS7qUyD1sxRaXYcjVtHmDHzXaqnmOm9WIwslXowfnqeeZL0KJesvlAzgrac00X AHHe0lQjiplahdX0W1vVm+0liiejm53eL8YQ6win5ttOmh+fKKFQt6ghJnUPN04wng58 cs+Z46Z+cTTqD2tB1O4ZdPrfWC4I9ZZL5RYZW2o0zRenTm8Tms/p/e//EvHF394fic9x p4byl4XCOUCirCWF1MNwH5DPBpxuDQ9gX1jPUDDkMJDJgNPDIqPieR8sNYpa1xdy6vhZ fhtg== 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=gGVq0IC31Ve7u/Br8N+FIfaFgLjK3u2lTytyU+XI55k=; b=k4tKXclyCA+clwfujgmtukahO/B5WelYaHEmWBy5vTIzwDk73bkNl0R01JGYyyA/36 b0ppZBDUCyxzKmreDiVDSbCmMmRuXA/JtRNTZMMIk0fGa5WudATyhm9a5+RgItdeQyHH i0vAIyMJhcoOICTWZCi+nEBm8Hwa9ey6zyDaELGGexgWU40bJpKrNhbmQvl+z2W1W2y3 e5KUJBWB4R/43ZYwowXjoa0jbeHmvT5GJeP9tk2C318TcS9C6IstkCPT386eS62Y+s2B FUXGruSAF3dOPFsffD3zkvAKlT3jUuBEJ0N8alFKY6JYLsTU9MnFknKzkaRtgSOZzOKx 9Tzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q4lFSkTl; 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 m10si15214296ilu.53.2021.08.02.07.01.43; Mon, 02 Aug 2021 07:01:58 -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=Q4lFSkTl; 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 S236111AbhHBOA3 (ORCPT + 99 others); Mon, 2 Aug 2021 10:00:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:34430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236095AbhHBNy6 (ORCPT ); Mon, 2 Aug 2021 09:54:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AF80360FF2; Mon, 2 Aug 2021 13:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912389; bh=tO9UUuTQNQKd/bo2w1JXgnCgQC2G2hjgPQP5tBsGR60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q4lFSkTlsSVJzWgFfuJdNQaKJ2svknYTcqwbB6JcLg7J4EKfJiWl9lVgMNFFTJRPC OuNlhocHGsXO+bCK/YHAzEFDaZrgRbs8691QvpSK1+5rpnWBiIGU3ja+d6B9bMqpbU JEiLxtU/0Q2SAss4NbsHfUMAZlO41HngyaRurcQ8= 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 5.10 38/67] tipc: fix sleeping in tipc accept routine Date: Mon, 2 Aug 2021 15:45:01 +0200 Message-Id: <20210802134340.323058565@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134339.023067817@linuxfoundation.org> References: <20210802134339.023067817@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 694c432b9710..4f9bd95b4eee 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -2650,7 +2650,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 @@ -2659,12 +2659,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)) @@ -2676,7 +2676,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