From patchwork Tue Sep 19 16:52:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 142138 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3777373vqi; Tue, 19 Sep 2023 17:33:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGax2GlxxADjkd/AZFvJ2bIBVn6WCz77DKKg42HoEDBcp684VUNOMY9GQ6xTRJEHSx9MhHP X-Received: by 2002:a17:902:db0f:b0:1c0:cbaf:6954 with SMTP id m15-20020a170902db0f00b001c0cbaf6954mr1555381plx.25.1695170000215; Tue, 19 Sep 2023 17:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695170000; cv=none; d=google.com; s=arc-20160816; b=B6DNlcQlX4F8GzpUIYQqe3omk6v874OPrgYZzUXUNh5+xqV1gaq0+oiTL9kRh96u3G jG3H7vxPEpidNWgKkowQMWmU+bRvngELh0UsXlzslQNYevgkXGOENV3csaqS9xpfyxJ0 Y3qfCo78VrvzdGZ7o/nQEJvFp7A+rbxj71a4tg08bOPRP9cDkZl2YadrBGIX+nZbwrJv 46Ytx+bZdbj/J4ihgNiQJb3tPXy5WeFwmDVe5f/pJvdtvXgRHcFLxyAHttS4ROZzWbfX d6w/3gkzP85ejK+a5P3CKu89nKPDXK1HsCSo3R3YbYDXdHU+KY1I+/WCdeEinahN750r L88Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=NMeI9uputI/pj8YoMC32t3WcmDkFWOVztpcbTOrmJbw=; fh=/RxRH6gs73pFrnq5QWPTqmLSwpaf43otSRmToAos3ak=; b=ZvycTYEnMobAF7socA6zmDWdHfQBHKwwK8tXYfhe4jsf1EIxuKzFX6OuJ5z8aK39QU S2ECYe23gIzV/zNa9cRv4sNxmRusk9BhVfB9/4kAbeLYdxxWeJneksoeuYluQCVc9ni5 SMu2MGhM/7P8oJB5oRI2xJmrpPUtDcgU9yPswIH8bDWpuYuufUEWcbGzh762OqaGzoZm PHLYB1scn2Z1IWMxi26PjsCjYmIu78mh70DCXNvIUkjPOfFGzrUhc0DMbeMjy5Lp841k YxEV1OZyJxyXSpbo9MkqAQW9Q2H1a9AwUnZV5J90maqQ+uA6si85pvZ3Sa/dXp5JQMTr BfMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hszdx5Jw; dkim=neutral (no key) header.i=@linutronix.de header.b=yLPc2Aco; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id u7-20020a170902e5c700b001c5b9ef1d34si592994plf.340.2023.09.19.17.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 17:33:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hszdx5Jw; dkim=neutral (no key) header.i=@linutronix.de header.b=yLPc2Aco; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id A6C2280569B3; Tue, 19 Sep 2023 09:53:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231651AbjISQxD (ORCPT + 26 others); Tue, 19 Sep 2023 12:53:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbjISQxB (ORCPT ); Tue, 19 Sep 2023 12:53:01 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63E89D6; Tue, 19 Sep 2023 09:52:55 -0700 (PDT) Date: Tue, 19 Sep 2023 16:52:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695142373; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NMeI9uputI/pj8YoMC32t3WcmDkFWOVztpcbTOrmJbw=; b=hszdx5JwGyr4GTEUnHjRktznD1q//wmaU4hQ071L2YpFYKQ4Uy/1ClRvMDneNT5xP4uipa M1mTNMcikuvLJ5oo6poyuf4fsdKFPHkhLgkPWHXfuefwNKgsQjR2j5/U3IYKBUi58H2AHX 7Yj6z35W9c/JIM/In5eZ805j8f/DRiREAi4CwK3mUvBf6sxrBY4MIrwYidyBlLLVpnnUVQ 13x5wcmvPUHym3MCbpx7muHhpiWLYw2Rk4d99v6EMmOJ6z+sO3SEyPTYc7gLXfTwybAt+m ZDMBC+/R4KaOzQ4DsiCJhZCEvyiSkNdLQ6gsj0+pAcGxEU6HL69N5bdl/B08oA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695142373; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NMeI9uputI/pj8YoMC32t3WcmDkFWOVztpcbTOrmJbw=; b=yLPc2AcoHeTkLp3VpeHbViumCIdWPCI4rlvuqiECxmzoOzjsqNDebyJdHDbE5rsA2pH9iv tcBBQZMQs52m5WDQ== From: "tip-bot2 for Rick Edgecombe" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/shstk: Remove useless clone error handling Cc: Rick Edgecombe , Dave Hansen , "H.J. Lu" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <169514237318.27769.7169875590985275390.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 09:53:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777514578266591085 X-GMAIL-MSGID: 1777514578266591085 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 748c90c693363d05c6b2f3915edc7999a2f71837 Gitweb: https://git.kernel.org/tip/748c90c693363d05c6b2f3915edc7999a2f71837 Author: Rick Edgecombe AuthorDate: Fri, 08 Sep 2023 13:36:54 -07:00 Committer: Dave Hansen CommitterDate: Tue, 19 Sep 2023 09:18:34 -07:00 x86/shstk: Remove useless clone error handling When clone fails after the shadow stack is allocated, any allocated shadow stack is cleaned up in exit_thread() in copy_process(). So the logic in copy_thread() is unneeded, and also will not handle failures that happen outside of copy_thread(). In addition, since there is a second attempt to unmap the same shadow stack, there is a race where an newly mapped region could get unmapped. So remove the logic in copy_thread() and rely on exit_thread() to handle clone failure. Fixes: b2926a36b97a ("x86/shstk: Handle thread shadow stack") Signed-off-by: Rick Edgecombe Signed-off-by: Dave Hansen Tested-by: H.J. Lu Link: https://lore.kernel.org/all/20230908203655.543765-3-rick.p.edgecombe%40intel.com --- arch/x86/kernel/process.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 9f09091..b6f4e83 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -257,13 +257,6 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) if (!ret && unlikely(test_tsk_thread_flag(current, TIF_IO_BITMAP))) io_bitmap_share(p); - /* - * If copy_thread() if failing, don't leak the shadow stack possibly - * allocated in shstk_alloc_thread_stack() above. - */ - if (ret) - shstk_free(p); - return ret; }