Received: by 10.192.165.148 with SMTP id m20csp792214imm; Fri, 27 Apr 2018 07:35:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqsKCc9NMLAvnXDzm8gzwUwl7loZsofFma4XITHHYuzmIdklU7EjgZo1IEyayx8EUlTxO3J X-Received: by 2002:a63:ba05:: with SMTP id k5-v6mr2343646pgf.39.1524839746089; Fri, 27 Apr 2018 07:35:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524839746; cv=none; d=google.com; s=arc-20160816; b=Qp0tl8hjnUCAyL4F4Q2j0WiFR6iWTY6mM7GadLCQnVI26ZVebaa4cCN4xYNlr2ZAKn iMPCu0DLja1O50g4StJcmxpKCEC6B9U70PMoXT3DNnRifB4d8bgMYdMw7EPQHS9eCzm9 E9alMghGMZTGHwNOACSq5UeWzoAvIV5Us9zzP/vflXUi+xK7TIfxSmGBN9B3BByKU8yT ds6dTgc9fubjp49AG5sLXHUdUmuwt7/V9HXrqltSFr1fuyNQa8Mj2IDWsU+MKlQJFC+R lvjC4/lYd0jYLKqMqj5JDQlRSR+hkbAtItA3wjPzGe/+f77KiGjZqRILpfsWfqx6kN9/ /NuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=uEzyR9Lytg3OuDGQX4USzc0feSnNttZw4+6WR9Cg3zs=; b=GOHgRuRonE+UNkkQDINCPKiQjJum+dt+jJNVlXcF0lBBera50ISF0GHc8TaJAFZdKM POJp/zBZJngh+BwOEPfr6qkSk1DBKTtLgwld0Sq3FgLJtV4CZejGgwF7WtQWtg3xiEBC maxN1aloBwNmqJmNLIwYQqTAIANfQxwF8xA+FiofZl0FAlDSTXIK7vJphBRjJnMV7yI0 oTst6oJzyIc15HZBzHITSUk/84znslfQfhhTO+sR9003Z+lfOn5vFFCiS1D9VQNqlTmA HCOf4eljoYqM0kFAUrOop+9nRnHx8RsLzxfJDlj2zSmj+5okBgGFhk/rPVZV8+O4kczw /Fhg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j7si56872pfh.3.2018.04.27.07.35.32; Fri, 27 Apr 2018 07:35:46 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934784AbeD0OKF (ORCPT + 99 others); Fri, 27 Apr 2018 10:10:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:55254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934772AbeD0OKD (ORCPT ); Fri, 27 Apr 2018 10:10:03 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 65BC321892; Fri, 27 Apr 2018 14:10:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65BC321892 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ursula Braun , Stephen Hemminger , "David S. Miller" Subject: [PATCH 4.16 19/81] net/smc: fix shutdown in state SMC_LISTEN Date: Fri, 27 Apr 2018 15:58:21 +0200 Message-Id: <20180427135744.381601356@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135743.216853156@linuxfoundation.org> References: <20180427135743.216853156@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ursula Braun [ Upstream commit 1255fcb2a655f05e02f3a74675a6d6525f187afd ] Calling shutdown with SHUT_RD and SHUT_RDWR for a listening SMC socket crashes, because commit 127f49705823 ("net/smc: release clcsock from tcp_listen_worker") releases the internal clcsock in smc_close_active() and sets smc->clcsock to NULL. For SHUT_RD the smc_close_active() call is removed. For SHUT_RDWR the kernel_sock_shutdown() call is omitted, since the clcsock is already released. Fixes: 127f49705823 ("net/smc: release clcsock from tcp_listen_worker") Signed-off-by: Ursula Braun Reported-by: Stephen Hemminger Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/smc/af_smc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1254,14 +1254,12 @@ static int smc_shutdown(struct socket *s rc = smc_close_shutdown_write(smc); break; case SHUT_RD: - if (sk->sk_state == SMC_LISTEN) - rc = smc_close_active(smc); - else - rc = 0; - /* nothing more to do because peer is not involved */ + rc = 0; + /* nothing more to do because peer is not involved */ break; } - rc1 = kernel_sock_shutdown(smc->clcsock, how); + if (smc->clcsock) + rc1 = kernel_sock_shutdown(smc->clcsock, how); /* map sock_shutdown_cmd constants to sk_shutdown value range */ sk->sk_shutdown |= how + 1;