Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4404690ioa; Wed, 27 Apr 2022 03:09:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1UNMh5EwSEaF7/JuAfRjYiZWxzBaoGgalplipz2QOAj7Jx0ScQo0FSYfobJclg3fNnjUz X-Received: by 2002:a17:902:c411:b0:15c:e82a:e854 with SMTP id k17-20020a170902c41100b0015ce82ae854mr20921145plk.18.1651054175336; Wed, 27 Apr 2022 03:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651054175; cv=none; d=google.com; s=arc-20160816; b=ymGJA/KnVldPaEJ3n/jHyRLSLyr2r253+Ee5NJJPu3Syj4/g7KBqLlWf6b9X0ZgTqJ cCkVPHfOWVrDAUjNqQyv72psvlzFOkNCiBy9YaE6pBLPjHgafFDxQgf1X30G17t/N9Mg fw3YTf6OXcEwy+/18FFE55J7MvXEztE5j3Z07Fz/iwdNHO0Jx1/oJ3qfG7DVHPnkeVY+ yDmtbG2NEkfIm9sSptMFOkjQ3R8rt2xuH4Cw9WzLNPLv64PRHTK2/dwpI5WT2RbkGlJK ExSxR/NBv3PpRxCc/KtFlqW9ULEEPyM0cHkOEHw/0/FwE5nvN6u+ZvPxYSRtR94sWbty DXDQ== 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=7EYMZpIU+Rp1G9irtotKzE6flUFbCZlibvCgAZ/9yV4=; b=LhNRupW8c9PWXuVQlRrtoPt42P5wtdYAMygfyLEen/mqwWLsYmp/w3b6lhPjV8s+Ox EZJnBWx6585pIIwjxZ0oC83n/8WeT+xwlgLFAVAnmZ8GWCMerdzRb3DRfPxkqAcT/GH3 R/e5/nzVAXHqCQid0SpvJxRzxZ+bSHsIF7eGy2uaWjp+88Tebb4P19YpOxjpFdFPY6zD /xSmnabxv9AP8+wtHNOy7iqrLMPnEAM4TBhmpIgf2mfqfQIbVWtcNv0fEGsYMmNDNcul qBNMKvh8UuBT74s/Ph+hpSrePbVOB+CHxPL5RznjBYvNKgoiHPBhS4Dy3tWWa/DmiMK/ 5hLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X4MG1tP4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o15-20020a056a0015cf00b0050ad23a8cfcsi1252169pfu.115.2022.04.27.03.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:09:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X4MG1tP4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5CB48306720; Wed, 27 Apr 2022 02:32:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346967AbiDZJFI (ORCPT + 99 others); Tue, 26 Apr 2022 05:05:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347164AbiDZIpy (ORCPT ); Tue, 26 Apr 2022 04:45:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 651CD7B54E; Tue, 26 Apr 2022 01:37:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1BFC1B81D18; Tue, 26 Apr 2022 08:37:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 882E3C385A0; Tue, 26 Apr 2022 08:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962252; bh=OaPySKJByytJen5e1W0EMoC2QsfHMewwNTZ8bZVe6E8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X4MG1tP4f9T64UfIKE550Ek6BADtlxLSRyGa2lt2JJUfV2JVUobGXSNpxf/YWGW9c XT5fcXFqwJ0qK3VxT9Bz0d2jyzDTc5yLLBNDunNISyiTNC4sNud2tRhOTqndyPaCQr DjmtxsZgLy/evMlNJSxc4IAJ1DLzqvTmyXXJWDJE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tony Lu , Karsten Graul , "David S. Miller" , Sasha Levin , syzbot+6e29a053eb165bd50de5@syzkaller.appspotmail.com Subject: [PATCH 5.15 034/124] net/smc: Fix sock leak when release after smc_shutdown() Date: Tue, 26 Apr 2022 10:20:35 +0200 Message-Id: <20220426081748.274052593@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tony Lu [ Upstream commit 1a74e99323746353bba11562a2f2d0aa8102f402 ] Since commit e5d5aadcf3cd ("net/smc: fix sk_refcnt underflow on linkdown and fallback"), for a fallback connection, __smc_release() does not call sock_put() if its state is already SMC_CLOSED. When calling smc_shutdown() after falling back, its state is set to SMC_CLOSED but does not call sock_put(), so this patch calls it. Reported-and-tested-by: syzbot+6e29a053eb165bd50de5@syzkaller.appspotmail.com Fixes: e5d5aadcf3cd ("net/smc: fix sk_refcnt underflow on linkdown and fallback") Signed-off-by: Tony Lu Acked-by: Karsten Graul Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/smc/af_smc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index fa8897497dcc..499058248bdb 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -2332,8 +2332,10 @@ static int smc_shutdown(struct socket *sock, int how) if (smc->use_fallback) { rc = kernel_sock_shutdown(smc->clcsock, how); sk->sk_shutdown = smc->clcsock->sk->sk_shutdown; - if (sk->sk_shutdown == SHUTDOWN_MASK) + if (sk->sk_shutdown == SHUTDOWN_MASK) { sk->sk_state = SMC_CLOSED; + sock_put(sk); + } goto out; } switch (how) { -- 2.35.1