Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1642364pxy; Mon, 2 Aug 2021 06:56:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRu4zBE1JidWgzVyBpWBBwYMo65VYuc6GQ1FQb1TLlAuMrI2on4e5VPAWeskmZPWB38B9t X-Received: by 2002:a05:6e02:1d8d:: with SMTP id h13mr1216742ila.40.1627912570466; Mon, 02 Aug 2021 06:56:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912570; cv=none; d=google.com; s=arc-20160816; b=ZXpxuvVoD/tD069YmonKCi//HNlQ5d5mXfg8jzrFjXmyYsJAeG43WUutcMTBkjedMa /BpXW2ImShDC1Jxfm4GfyvLN0kg1/XFYu7tp7s6BwGSZMPTnM93po+JxA9rYGT3N31Dm irhIOFf4/ibz5q66g/UzB/jHaudCWeO+UB1eIpGXdY+tVwrdJ6lW5HNpNxzCp9qk9bQ3 OTRlpgbB2khD9Z+o5wgD5td/2dZhYZ0TZsNMUDaJEnLbRBqVHuN7NtzpQdDU0u7N08bE haO/TOSLli5uLGGliTGyn9FjUXRXWYC+dvkhig7/qicYoXyB32OGGXRb+FXoIgkKbhCr wc5A== 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=3YvWGq8uFhYTGAwceTx+C8BZwWNWKB5x6hpvr22x884=; b=kT4bhfti9XosIp6Ka2I61/8bDe+7+Kyuye2v1mv7UAt03aiUJZ63nPN54PpY2vHpkI zg74J4zxUL5crrYPCQo2jP4PiRfA97vL5GKWPrAsTb9HYQC51/dTqc7MuQnLg1bKfYQt 4oG8GdEIjyMt5gudZCcD8fqp+TodKGH/QJmr5PUUfwneNlMKLc1KRPSL60+fwTztDTIh ehAVC5vbWR7takT5cA1AYcn6xif16palTUr4bjDfWGIin/SoYx/waFcMV6BMLZ5p+Yr5 uhi9RE2Gu8bQySr1/O/TFvdqT+/BjzOFGbsPlzYVtLNxi4HcZH2Sr/x9C31qqiBVqbno Vkjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DIYpwKXS; 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 z14si13023390ilu.89.2021.08.02.06.55.58; Mon, 02 Aug 2021 06:56:10 -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=DIYpwKXS; 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 S236066AbhHBNyz (ORCPT + 99 others); Mon, 2 Aug 2021 09:54:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:33536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234770AbhHBNuC (ORCPT ); Mon, 2 Aug 2021 09:50:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D96DD61103; Mon, 2 Aug 2021 13:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912193; bh=KFdNe7Jh42YGEmZ1gQ/r+HkoAS86CXfZzlbotX9vKuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DIYpwKXSU1QInMWd57X9TP+H87Cs2IWRX81S4wRqsub6mpzoeksFetRJTVo0zSajR SNTyCrt9HGW8TGSGbnRLVKeXdO2dGA11cdWaxG3OmRHFWtkpQNRKqkNGQ00g6Kx3lj hS7T+7ZB20sF2+4B452EkMMdpWYsQL7AnJStYVps= 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.19 20/30] tipc: fix sleeping in tipc accept routine Date: Mon, 2 Aug 2021 15:44:58 +0200 Message-Id: <20210802134334.714170253@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134334.081433902@linuxfoundation.org> References: <20210802134334.081433902@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 3c41fb8edc5f..6aead6deaa6c 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -2440,7 +2440,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 @@ -2449,12 +2449,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)) @@ -2466,7 +2466,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