From patchwork Tue Jul 5 04:55:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cengiz Can X-Patchwork-Id: 1652233 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=vjlK7zEb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LcVmR4JRPz9s2R for ; Tue, 5 Jul 2022 14:57:59 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1o8adG-0000di-A8; Tue, 05 Jul 2022 04:57:54 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1o8adF-0000d3-1X for kernel-team@lists.ubuntu.com; Tue, 05 Jul 2022 04:57:53 +0000 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id B610E3F838 for ; Tue, 5 Jul 2022 04:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1656997072; bh=SrKbxYQShM69ENdtjY2qA44lGfpHvRHXg+6WdI3K42c=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vjlK7zEbnMORBK/+wkBxRZIl5H1hAFNbbz14wXknHGJGCfIs4HTRQfScI4bxcQfCs ks8fHRtFD2FXhHItRdb3qVveMkLIyTzVlRp7cFLJv0pgdqMv/UHWEwluitvmg/GD7P 4ktplml3FvE9gfJ6QQOXLQs62pSgZX/UKkfFXzhsfk6JEx22Kr3zvG7yUMse56DV5m qb4/FoMgu/mefaSzQqQ80ZEtqofFi8T7RZDRS8RwjWicouNeXXH+E34iBrt5FFYhXi QbKnM3U9OPA/PZI/HKAOEWHQrf3elTPqA2nMwR+UitBVH7pyPt71QYO7D7OjNVkL8b rzMcukbXIRQbg== Received: by mail-ed1-f71.google.com with SMTP id i9-20020a05640242c900b004373cd1c4d5so8427571edc.2 for ; Mon, 04 Jul 2022 21:57:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SrKbxYQShM69ENdtjY2qA44lGfpHvRHXg+6WdI3K42c=; b=Bs7+X7jG2clqz87YvqIgKspmmEf7te2lQFZcStt7A76fVSxXpyzgHXRFknjT1lgZkQ u8q1NahmqfBLEfuxCj7KQVBOw0qTsI0fyL65vsaGg4A2fxQyPRjNs0Pe/JO4gweMXEiI x/4Malw9BSihCjNotFJeArl3tclHHtTv1y/OB7GenRerhryFPArRZ58Wjv0hXvOhTEYY lqhg6EB5v/BXHk4HOBNCUIdjtEU5XLS6kTTTWWGFjEPbHrKLcj2VOckPeG1tksN6WDWn 1+baI+D9WjX7soZM6WOMPrrSZzO3oqV9TUGbKJqr5hPp21FpuMImpBJWByOLdliYctml 2JzA== X-Gm-Message-State: AJIora9DXbOVrroxxYYK96VSqbjqnf+FqyFsJ0/nLgcSMyxiH71JVa/w vY8NqfdOVOBCA3CeWebWm3TcQrnNmpmwqIOucC9l3J/HnPEFN9MlJs9NxLAdJKIpm0mwg7Dlm7k 0dG2J6glIwEKEN9DA/gK/n3AE6UR+Lfc7UlR4+hWjHQ== X-Received: by 2002:a05:6402:40d2:b0:438:3203:cadd with SMTP id z18-20020a05640240d200b004383203caddmr38845993edb.95.1656997072168; Mon, 04 Jul 2022 21:57:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t+rUczVoiTIcsWxd/5zJ4h5s/96DUzMuJZ+4iXuGwkK73e0eW8/7K3zWs8+h4OaZBiV2qgxg== X-Received: by 2002:a05:6402:40d2:b0:438:3203:cadd with SMTP id z18-20020a05640240d200b004383203caddmr38845979edb.95.1656997071975; Mon, 04 Jul 2022 21:57:51 -0700 (PDT) Received: from localhost ([46.2.184.254]) by smtp.gmail.com with ESMTPSA id u3-20020aa7db83000000b0043580ac5888sm22120131edt.82.2022.07.04.21.57.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 21:57:51 -0700 (PDT) From: Cengiz Can To: kernel-team@lists.ubuntu.com Subject: [SRU][OEM-5.17][PATCH v2 2/2] SUNRPC: Don't leak sockets in xs_local_connect() Date: Tue, 5 Jul 2022 07:55:56 +0300 Message-Id: <20220705045549.274705-7-cengiz.can@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220705045549.274705-1-cengiz.can@canonical.com> References: <20220705045549.274705-1-cengiz.can@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Trond Myklebust If there is still a closed socket associated with the transport, then we need to trigger an autoclose before we can set up a new connection. Reported-by: wanghai (M) Fixes: f00432063db1 ("SUNRPC: Ensure we flush any closed sockets before xs_xprt_free()") Signed-off-by: Trond Myklebust CVE-2022-28893 (cherry picked from commit aad41a7d7cf6c6fa804c872a2480f8e541da37cf) Signed-off-by: Cengiz Can --- net/sunrpc/xprtsock.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index ca562443debd8..716b121ca14ac 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -1925,6 +1925,9 @@ static void xs_local_connect(struct rpc_xprt *xprt, struct rpc_task *task) struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); int ret; + if (transport->file) + goto force_disconnect; + if (RPC_IS_ASYNC(task)) { /* * We want the AF_LOCAL connect to be resolved in the @@ -1937,11 +1940,17 @@ static void xs_local_connect(struct rpc_xprt *xprt, struct rpc_task *task) */ task->tk_rpc_status = -ENOTCONN; rpc_exit(task, -ENOTCONN); - return; + goto out_wake; } ret = xs_local_setup_socket(transport); if (ret && !RPC_IS_SOFTCONN(task)) msleep_interruptible(15000); + return; +force_disconnect: + xprt_force_disconnect(xprt); +out_wake: + xprt_clear_connecting(xprt); + xprt_wake_pending_tasks(xprt, -ENOTCONN); } #if IS_ENABLED(CONFIG_SUNRPC_SWAP)