Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1859931rwr; Fri, 28 Apr 2023 02:54:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6nElQsRRXmhh+yYZ6AIp7HJ3ogH2+wyIMmrMRHKWSmdM4QRjUp+xRmhsNPcowwy+mIK+dJ X-Received: by 2002:a17:902:9b95:b0:1a6:cb66:681f with SMTP id y21-20020a1709029b9500b001a6cb66681fmr4019838plp.46.1682675659481; Fri, 28 Apr 2023 02:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682675659; cv=none; d=google.com; s=arc-20160816; b=vfP2DLVtAGnCbT2xESYaVRHUZzYPeJsJHrhygRCSGc/NVVCJmcupnLBejPrh5UwwWr +MiHFqD7faAKNow+/n7UNcRt/cNqr9DHbaAAzbx9p4CWxpfc3bubp6ygdf95yndiNYNH 7gqe0S2fCEwSQaDfgoTzYfWWt+vuYOlbIkGKIEQBV+c2MfASwhRGe58tgdV3ziSIKGJB CmcqG3Kk96HqU1411XeXcFD50xCOxm42rLSWqi0jMutgUlLMKeqWM/mD+Tazm3PFn+Lv hlxWuSlWBkbnXCknMcc0MH8E1Ix1Ditoh2TdEqZ/z+mxVfFehdKJS+A8A3bvAdyXXHhI Z0fw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cmEZVhiF8fX9F4xTfFN7JAl1iwVobQtKpB4OGg7OWrQ=; b=I/1XVBuEqVG7jxfbUnJHhZV/FASvHjrzYOn+3MexYSxWsCCEhIybc8RquQUu9qNT2t fwS4E0XEVJk+3tE1rXXWB43flboK/WWlQzzs7laHCTmMsAJIwpauy7Qqs0tiMbwLIVa4 ZeaSacl2ny0LYzIePz6pHz/vAcSL3LihohXSkgX+QNCYe8Ge6CeUz6UBp4/x62ws1Gm+ lVlRrdZDWIjV9sVQkMKcHWmyNh9kk55MTI5MIGQpcmM+6fw4PFAy6usFsxoLvOOXKjpw YeNop3sYcf5TRY8+T+oTxhvyI/vNFNovc6lmEBS9Nm0JTrutK5W8U02tpAknynzccqJJ e9JQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a170902654400b001a6919158cbsi19457522pln.167.2023.04.28.02.54.07; Fri, 28 Apr 2023 02:54:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345771AbjD1JxM (ORCPT + 99 others); Fri, 28 Apr 2023 05:53:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345741AbjD1Jwq (ORCPT ); Fri, 28 Apr 2023 05:52:46 -0400 Received: from out0-222.mail.aliyun.com (out0-222.mail.aliyun.com [140.205.0.222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 255EB5FCD for ; Fri, 28 Apr 2023 02:52:22 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047193;MF=houwenlong.hwl@antgroup.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---.STCEPQo_1682675534; Received: from localhost(mailfrom:houwenlong.hwl@antgroup.com fp:SMTPD_---.STCEPQo_1682675534) by smtp.aliyun-inc.com; Fri, 28 Apr 2023 17:52:15 +0800 From: "Hou Wenlong" To: linux-kernel@vger.kernel.org Cc: "Thomas Garnier" , "Lai Jiangshan" , "Kees Cook" , "Hou Wenlong" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" Subject: [PATCH RFC 12/43] x86,rethook: Adapt assembly for PIE support Date: Fri, 28 Apr 2023 17:50:52 +0800 Message-Id: <8a0c7ca2d70bbc6162c97a87a73dafb24a6659a2.1682673543.git.houwenlong.hwl@antgroup.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham 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 Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Signed-off-by: Hou Wenlong Cc: Thomas Garnier Cc: Lai Jiangshan Cc: Kees Cook --- arch/x86/kernel/rethook.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/rethook.c b/arch/x86/kernel/rethook.c index 8a1c0111ae79..ff3733b765e0 100644 --- a/arch/x86/kernel/rethook.c +++ b/arch/x86/kernel/rethook.c @@ -27,7 +27,15 @@ asm( #ifdef CONFIG_X86_64 ANNOTATE_NOENDBR /* This is only jumped from ret instruction */ /* Push a fake return address to tell the unwinder it's a rethook. */ +#ifdef CONFIG_X86_PIE + " pushq $0\n" + " pushq %rdi\n" + " leaq arch_rethook_trampoline(%rip), %rdi\n" + " movq %rdi, 8(%rsp)\n" + " popq %rdi\n" +#else " pushq $arch_rethook_trampoline\n" +#endif UNWIND_HINT_FUNC " pushq $" __stringify(__KERNEL_DS) "\n" /* Save the 'sp - 16', this will be fixed later. */ -- 2.31.1