Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3717701imm; Mon, 8 Oct 2018 08:26:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV602BHSAGdqW3ie2BW2BWqnQoWCP55EI6pxh5qylT4fqO6BNqsHRVTrT/x0WLnoIWKnXII7l X-Received: by 2002:a62:c502:: with SMTP id j2-v6mr26339674pfg.194.1539012401663; Mon, 08 Oct 2018 08:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539012401; cv=none; d=google.com; s=arc-20160816; b=ze6Nvs+6O3meiYkRaywBMNkyYmp1Le5QN8VwIRuX8l8faSzfqTylyYysQUgLLjjzzx +tHftHkAfawRa7cA8dAGQw63vPtGB37euaFyMZzPUUUze2qhyXsyVauoNVirMxcZMbSZ Ab8blR+5Dl1ZwnkXx1Knc3QtlxDA+oNiMiBYZD70Oqfbjh6f4nHxGlc6p7wrT1xCngZN w57dbf+AhsGYlp2xDfRiXHnsMXKQL5e7mOTGt/l4YNa/yfV9BGpGkJWrkKsKsjR0ANFp zhTl0scwp1ce6USo8aoFeXYe2yYCf/EBvXijZ2PUQ1icq13K3p62iWRaCkjRux3CnMkV fKKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=JZbnRzWkt1Uk8TzNWM2yxl+e6BfXIbvgRQCAyeJ81L0=; b=YbpMWI836GUJGG4sIo/v3rdy70AecLU/3EsD4H7BdueLjClIUv7s2HU1YFAd1wMwXf obLIQ1J3TykOZB1uulFc1CEaj+ziLoDPGEACRulBLU7Py+QB+sYYx/TwWLXxyZDPdB/e hGtp0xFPbdFlexYdvidaLhVWNlYElB6IiWBgVK9oC6xhjW5jubLY0zVMcDHjtPMnQGy4 TsHCN9xgrc+ITuthLr4RePE/uMDTLuUkpeS8aKemmJJu6/1nqaD671zu5zdi01064cz0 0yA6gwjbmnV/MlzJzlc6kXr9Q/dSfYLSrTJIaiwKcW9bM3qrcTm2FP3oImzT7Ap9skPa wbFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hnjTKVTZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8-v6si18579665ple.80.2018.10.08.08.26.26; Mon, 08 Oct 2018 08:26:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hnjTKVTZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727150AbeJHWiL (ORCPT + 99 others); Mon, 8 Oct 2018 18:38:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:56488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727370AbeJHWiL (ORCPT ); Mon, 8 Oct 2018 18:38:11 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6AA572089D; Mon, 8 Oct 2018 15:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539012356; bh=GJh47ICuaA/uWlFrils0n+dj/JMqCigEt1OhCV2DPYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hnjTKVTZeXvA3p/w6cm/jKIaQTEhgH2GQqiN5+QFgr4azy8KRkQ7PQQvmo3ZiDexL 389ewfV4xX89wUtYpSVQPygHvnxowXcG8njLs0NDHT+J1LuCFZf29j87FtRCjzX15e F5xOXJr2TtLS26S+L3mqzbcGo3DfoiML87vqyodk= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ursula Braun , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.18 30/58] net/smc: fix non-blocking connect problem Date: Mon, 8 Oct 2018 11:24:55 -0400 Message-Id: <20181008152523.70705-30-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181008152523.70705-1-sashal@kernel.org> References: <20181008152523.70705-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ursula Braun [ Upstream commit 648a5a7aed346c3b8fe7c32a835edfb0dfbf4451 ] In state SMC_INIT smc_poll() delegates polling to the internal CLC socket. This means, once the connect worker has finished its kernel_connect() step, the poll wake-up may occur. This is not intended. The wake-up should occur from the wake up call in smc_connect_work() after __smc_connect() has finished. Thus in state SMC_INIT this patch now calls sock_poll_wait() on the main SMC socket. Signed-off-by: Ursula Braun Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/smc/af_smc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index e7de5f282722..effa87858b21 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -612,7 +612,10 @@ static void smc_connect_work(struct work_struct *work) smc->sk.sk_err = -rc; out: - smc->sk.sk_state_change(&smc->sk); + if (smc->sk.sk_err) + smc->sk.sk_state_change(&smc->sk); + else + smc->sk.sk_write_space(&smc->sk); kfree(smc->connect_info); smc->connect_info = NULL; release_sock(&smc->sk); @@ -1345,7 +1348,7 @@ static __poll_t smc_poll(struct file *file, struct socket *sock, return EPOLLNVAL; smc = smc_sk(sock->sk); - if ((sk->sk_state == SMC_INIT) || smc->use_fallback) { + if (smc->use_fallback) { /* delegate to CLC child sock */ mask = smc->clcsock->ops->poll(file, smc->clcsock, wait); sk->sk_err = smc->clcsock->sk->sk_err; -- 2.17.1