Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1452385pxb; Sat, 15 Jan 2022 12:38:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5mCcIEGofkIf7XOlpxUH4O1XjCFAtxGy2Rs+ufCeK8a7yxzcbEQcUQbP/w73u9juQd2pB X-Received: by 2002:a50:cc04:: with SMTP id m4mr6485949edi.17.1642279138084; Sat, 15 Jan 2022 12:38:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642279138; cv=none; d=google.com; s=arc-20160816; b=X6TEvKFJxD4IvC0t8yRNh5H58BXjiBM2usWYyrQTGRCCEIEyEAkkh9YAj00pZUXX40 +gn1J1tcChWQqjGNgTEpNyt0UNu6uy4waKIQKM0jpUs9hONaroAxbEStnqJUmhZthQ9u p9lFieZ/4Fe5YiQVbgOGX6IT400loS2Tuy1uV+ZciTsRsYTnwwcmkVdKjoQgtsek4mCX PkXyzF7QMXB0lSZI817Rc6sFiAs4IbyCa1tMAH+UQLHj5gvGdMqaZ1Yv8q0Td7fqxQSq e7ynVAqVZaHdH9OAW7f7J7xhVvD3p+x/V778vLa4HKECfCX+vRzA5yZwsd9irVEwzvH3 Dd2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rv6zD8oYOxpw0HDgwGJIhbDBWypsLSfWsSYdgii+Xoo=; b=cu0q4JhddtimcEmmPe5WHVstuYUrfrYya08QNK1YMEpUx0mxghCWcSE0S4nRVMluxC j4qnKX1y+f1GzyXgBa5cAKz7qUUyR6xUAzAHND5erFweVDXKKqhuQaZDXIlfcVgaJTS+ bI90t8r9ihKjSzZtggl3BGBMnLDe2PnlG2OLjeWZKx+v6coQG8+tjxvkoetEz6uovQw8 ecohB9i/9hXQ98brW5F9HiQ7ZJJGa58K6A0DwWUxAhOkDl4G0kjYaFDXXy4HHNW4qaGm 94AcWiDay8Uq8wigy9vmttmk4zDnnkVGZKdytTQQMGf/bzGWxzW6kZ/vZ4CNsJgSjuGv SQDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=cicGWt4W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qk35si4792963ejc.323.2022.01.15.12.38.33; Sat, 15 Jan 2022 12:38:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=cicGWt4W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230364AbiAOINY (ORCPT + 99 others); Sat, 15 Jan 2022 03:13:24 -0500 Received: from mail.skyhub.de ([5.9.137.197]:36848 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbiAOINX (ORCPT ); Sat, 15 Jan 2022 03:13:23 -0500 Received: from zn.tnic (dslb-088-067-202-008.088.067.pools.vodafone-ip.de [88.67.202.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id E80001EC0532; Sat, 15 Jan 2022 09:13:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1642234398; h=from:from: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:in-reply-to:in-reply-to: references:references; bh=rv6zD8oYOxpw0HDgwGJIhbDBWypsLSfWsSYdgii+Xoo=; b=cicGWt4WPbN0crFLtUwX/r5R4DtCR6d8Cz7emXW+hiaco2hf8lw6DXcF39EQtmZHel6e/6 M110+6e9PM9QxjdATGC5Ax+PqwKJQQ9Gsy229bl7mAUHXi67vIWu34+ml5niRDC4khnKLo OcbUPh+wodeLZKBR2ynfw5kT/ybAZMI= Date: Sat, 15 Jan 2022 09:13:24 +0100 From: Borislav Petkov To: Andy Lutomirski Cc: "Peter Zijlstra (Intel)" , Sean Christopherson , kernel test robot , Josh Poimboeuf , Linux Kernel Mailing List , the arch/x86 maintainers , lkp@lists.01.org, lkp@intel.com Subject: Re: [PATCH] x86/entry_32: Fix segment exceptions Message-ID: References: <20220106083523.GB32167@xsang-OptiPlex-9020> <73020277-d49f-7aae-22db-945e040a31a2@kernel.org> <760ea801-8394-4e0c-9ec3-23e36e436551@www.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <760ea801-8394-4e0c-9ec3-23e36e436551@www.fastmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 14, 2022 at 03:48:31PM -0800, Andy Lutomirski wrote: > Acked-by: Andy Lutomirski I actually did this new version: --- From: Borislav Petkov Subject: [PATCH] x86/entry_32: Remove GS from the pt_regs offsets and fixup regs Document how GS (and its stack slot) on 32-bit are used. Fixes: 9cdbeec40968 ("x86/entry_32: Fix segment exceptions") Signed-off-by: Borislav Petkov --- arch/x86/entry/entry_32.S | 4 +++- arch/x86/include/asm/extable_fixup_types.h | 5 +++-- arch/x86/lib/insn-eval.c | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index a7ec22b1d06c..addc3966ee20 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -20,7 +20,9 @@ * 1C(%esp) - %ds * 20(%esp) - %es * 24(%esp) - %fs - * 28(%esp) - unused -- was %gs on old stackprotector kernels + * 28(%esp) - unused -- was %gs on old stackprotector kernels. %gs is unused in + * kernel mode in 32-bit and holds the user value. When handling exceptions, the + * C-exception handler address is pushed into the GS-slot on the stack. * 2C(%esp) - orig_eax * 30(%esp) - %eip * 34(%esp) - %cs diff --git a/arch/x86/include/asm/extable_fixup_types.h b/arch/x86/include/asm/extable_fixup_types.h index 503622627400..0aa5f4d3234f 100644 --- a/arch/x86/include/asm/extable_fixup_types.h +++ b/arch/x86/include/asm/extable_fixup_types.h @@ -20,11 +20,12 @@ #define EX_DATA_FLAG(flag) ((flag) << EX_DATA_FLAG_SHIFT) #define EX_DATA_IMM(imm) ((imm) << EX_DATA_IMM_SHIFT) -/* segment regs */ +#ifdef CONFIG_X86_32 +/* segment regs, valid only for 32-bit code, see pt_regoff */ #define EX_REG_DS EX_DATA_REG(8) #define EX_REG_ES EX_DATA_REG(9) #define EX_REG_FS EX_DATA_REG(10) -#define EX_REG_GS EX_DATA_REG(11) +#endif /* flags */ #define EX_FLAG_CLEAR_AX EX_DATA_FLAG(1) diff --git a/arch/x86/lib/insn-eval.c b/arch/x86/lib/insn-eval.c index b781d324211b..cfc4d13b7d5b 100644 --- a/arch/x86/lib/insn-eval.c +++ b/arch/x86/lib/insn-eval.c @@ -432,7 +432,10 @@ static const int pt_regoff[] = { offsetof(struct pt_regs, ds), offsetof(struct pt_regs, es), offsetof(struct pt_regs, fs), - offsetof(struct pt_regs, gs), + /* + * Can't use that one, see top of entry_32.S + * offsetof(struct pt_regs, gs), + */ #endif }; -- 2.29.2 -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette