From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20F3CC43467 for ; Sat, 19 Sep 2020 00:12:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 96506235F8 for ; Sat, 19 Sep 2020 00:12:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="L7h6oG+U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96506235F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D5FEB8E0001; Fri, 18 Sep 2020 20:12:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D0F056B0068; Fri, 18 Sep 2020 20:12:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C24E48E0001; Fri, 18 Sep 2020 20:12:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0231.hostedemail.com [216.40.44.231]) by kanga.kvack.org (Postfix) with ESMTP id AB9D86B0062 for ; Fri, 18 Sep 2020 20:12:05 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7366B180AD802 for ; Sat, 19 Sep 2020 00:12:05 +0000 (UTC) X-FDA: 77277883410.14.night14_4d1409a2712f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 5335718229835 for ; Sat, 19 Sep 2020 00:12:05 +0000 (UTC) X-HE-Tag: night14_4d1409a2712f X-Filterd-Recvd-Size: 5138 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Sat, 19 Sep 2020 00:12:04 +0000 (UTC) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 70167235FD for ; Sat, 19 Sep 2020 00:12:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600474323; bh=etjZlYYd1IIPDO1NfKNkztbf4goZGkm6DYQVvva74MI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=L7h6oG+UCIlVAj7i6PyxRQf7m9hC/1jmn3wsGAiTRhuPMAOQbzjvfwU1eUsohup7x nsEMlDfmILL1Qv9F7HCx4sxrvxUj9AqhKo2z0RWVDQolq2dDHte4dIn/vts80Gz3rj iLjVZ1Ydk2VK8jPEt1IyztAW9dwtHXaJ1tj9YxRE= Received: by mail-wm1-f41.google.com with SMTP id l15so7681325wmh.1 for ; Fri, 18 Sep 2020 17:12:03 -0700 (PDT) X-Gm-Message-State: AOAM533OKzzGJXo+D+e+LyILS1V5HKP/ZIljLgSFmk8z27gg29zRDMnx Ppmxa0Yrm8G9lW9OEi6IKXC1ZxzIY6a6aVOjTNf0EA== X-Google-Smtp-Source: ABdhPJxmOMUD3oJeWUBWSi+Yvq5YFeJEC+DLVGlDfJl03Mlbg5VJuyOxaSuU065pkOCJwFJ0EmxFOn3UVUdyN4X8nu8= X-Received: by 2002:a05:600c:4104:: with SMTP id j4mr17372943wmi.36.1600474321906; Fri, 18 Sep 2020 17:12:01 -0700 (PDT) MIME-Version: 1.0 References: <20200918192312.25978-1-yu-cheng.yu@intel.com> <20200918192312.25978-9-yu-cheng.yu@intel.com> In-Reply-To: <20200918192312.25978-9-yu-cheng.yu@intel.com> From: Andy Lutomirski Date: Fri, 18 Sep 2020 17:11:50 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v12 8/8] x86: Disallow vsyscall emulation when CET is enabled To: Yu-cheng Yu Cc: X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , "open list:DOCUMENTATION" , Linux-MM , linux-arch , Linux API , Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Sep 18, 2020 at 12:23 PM Yu-cheng Yu wrote: > > Emulation of the legacy vsyscall page is required by some programs > built before 2013. Newer programs after 2013 don't use it. > Disable vsyscall emulation when Control-flow Enforcement (CET) is > enabled to enhance security. > > Signed-off-by: Yu-cheng Yu > --- > v12: > - Disable vsyscall emulation only when it is attempted (vs. at compile time). > > arch/x86/entry/vsyscall/vsyscall_64.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c > index 44c33103a955..3196e963e365 100644 > --- a/arch/x86/entry/vsyscall/vsyscall_64.c > +++ b/arch/x86/entry/vsyscall/vsyscall_64.c > @@ -150,6 +150,15 @@ bool emulate_vsyscall(unsigned long error_code, > > WARN_ON_ONCE(address != regs->ip); > > +#ifdef CONFIG_X86_INTEL_CET > + if (current->thread.cet.shstk_size || > + current->thread.cet.ibt_enabled) { > + warn_bad_vsyscall(KERN_INFO, regs, > + "vsyscall attempted with cet enabled"); > + return false; > + } Nope, try again. Having IBT on does *not* mean that every library in the process knows that we have indirect branch tracking. The legacy bitmap exists for a reason. Also, I want a way to flag programs as not using the vsyscall page, but that flag should not be called CET. And a process with vsyscalls off should not be able to read the vsyscall page, and /proc/self/maps should be correct. So you have some choices: 1. Drop this patch and make it work. 2. Add a real per-process vsyscall control. Either make it depend on vsyscall=xonly and wire it up correctly or actually make it work correctly with vsyscall=emulate. NAK to any hacks in this space. Do it right or don't do it at all.