From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8446 Path: news.gmane.org!not-for-mail From: Andy Lutomirski Newsgroups: gmane.linux.kernel,gmane.comp.lib.glibc.alpha,gmane.linux.lib.musl.general,gmane.comp.gcc.devel,gmane.comp.gnu.binutils Subject: Re: [musl] RFC: adding Linux vsyscall-disable and similar backwards-incompatibility flags to ELF headers? Date: Tue, 1 Sep 2015 22:03:27 -0700 Message-ID: References: <20150902025440.GG17773@brightrain.aerifal.cx> <20150902041815.GH17773@brightrain.aerifal.cx> <20150902045523.GI17773@brightrain.aerifal.cx> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1441170240 7891 80.91.229.3 (2 Sep 2015 05:04:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 2 Sep 2015 05:04:00 +0000 (UTC) Cc: Kees Cook , "linux-kernel@vger.kernel.org" , libc-alpha , "musl@lists.openwall.com" , gcc@gcc.gnu.org, Binutils To: Rich Felker Original-X-From: linux-kernel-owner@vger.kernel.org Wed Sep 02 07:04:00 2015 Return-path: Envelope-to: glk-linux-kernel-3@plane.gmane.org Original-Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZX0DH-0004TW-Jh for glk-linux-kernel-3@plane.gmane.org; Wed, 02 Sep 2015 07:03:59 +0200 Original-Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751806AbbIBFDt (ORCPT ); Wed, 2 Sep 2015 01:03:49 -0400 Original-Received: from mail-ob0-f174.google.com ([209.85.214.174]:33190 "EHLO mail-ob0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750951AbbIBFDs (ORCPT ); Wed, 2 Sep 2015 01:03:48 -0400 Original-Received: by obbbh8 with SMTP id bh8so17698294obb.0 for ; Tue, 01 Sep 2015 22:03:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=6bKnDYAo9FLkBxKW0WixSmzni2XPPfxus7gjZGb2LSQ=; b=BRooY3mbObVLb90heviXFVjJ7gleeISFphdH9XnfLhp3ddJ+3v5gJxZFsjQdT0B879 nshAlSr6ib4SbmzfYCiWRgOVEWAZEamPfxu9fBrOuTQBAvqGNyB6lnRBaAht74viK54N Tb3J+ho63sxfr2MHkeSN9ZNuJYPl4ivpsbmyPTZd5kqFG7MZvMnWGU1hSfh8+2OpCz1f p/R21G1W4j/WE7lZMZYSxhdBRnzZ16j0Him7RerV/YQpnVyGUgI1uwQHfwscFr+tI5tJ GZm2yue+YLsp1a0r1oIGJ4rdvY8wej6e7awChM9z7m+stVM3iwEJ5nCpE/T2uVWwdsx+ MkUg== X-Gm-Message-State: ALoCoQloJEypttIH83mwRtOwMNOULedGmaefsi4euoYN0c8mRL/FK0Ld08ZVHhm+Lq0AtL0iqwIF X-Received: by 10.60.143.98 with SMTP id sd2mr12507494oeb.23.1441170227219; Tue, 01 Sep 2015 22:03:47 -0700 (PDT) Original-Received: by 10.202.57.214 with HTTP; Tue, 1 Sep 2015 22:03:27 -0700 (PDT) In-Reply-To: <20150902045523.GI17773@brightrain.aerifal.cx> Original-Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Xref: news.gmane.org gmane.linux.kernel:2030654 gmane.comp.lib.glibc.alpha:55165 gmane.linux.lib.musl.general:8446 gmane.comp.gcc.devel:141125 gmane.comp.gnu.binutils:70935 Archived-At: On Tue, Sep 1, 2015 at 9:55 PM, Rich Felker wrote: > On Tue, Sep 01, 2015 at 09:32:22PM -0700, Andy Lutomirski wrote: >> On Tue, Sep 1, 2015 at 9:18 PM, Rich Felker wrote: >> > On Tue, Sep 01, 2015 at 08:39:27PM -0700, Andy Lutomirski wrote: >> >> On Tue, Sep 1, 2015 at 7:54 PM, Rich Felker wrote: >> >> > On Tue, Sep 01, 2015 at 05:51:44PM -0700, Andy Lutomirski wrote: >> >> >> Hi all- >> >> >> >> >> >> Linux has a handful of weird features that are only supported for >> >> >> backwards compatibility. The big one is the x86_64 vsyscall page, but >> >> >> uselib probably belongs on the list, too, and we might end up with >> >> >> more at some point. >> >> >> >> >> >> I'd like to add a way that new programs can turn these features off. >> >> >> In particular, I want the vsyscall page to be completely gone from the >> >> >> perspective of any new enough program. This is straightforward if we >> >> >> add a system call to ask for the vsyscall page to be disabled, but I'm >> >> >> wondering if we can come up with a non-syscall way to do it. >> >> >> >> >> >> I think that the ideal behavior would be that anything linked against >> >> >> a sufficiently new libc would be detected, but I don't see a good way >> >> >> to do that using existing toolchain features. >> >> >> >> >> >> Ideas? We could add a new phdr for this, but then we'd need to play >> >> >> linker script games, and I'm not sure that could be done in a clean, >> >> >> extensible way. >> >> > >> >> > Is there a practical problem you're trying to solve? My understanding >> >> > is that the vsyscall nonsense is fully emulated now and that the ways >> >> > it could be used as an attack vector have been mitigated. >> >> >> >> They've been mostly mitigated, but not fully. See: >> >> >> >> http://googleprojectzero.blogspot.com/2015/08/three-bypasses-and-fix-for-one-of.html >> > >> > That looks like it would be mitigated by not having any mapping there >> > at all and having the kernel just catch the page fault and emulate >> > rather than filling it with trapping opcodes for the kernel to catch. >> > >> >> Oddly, that causes a compatibility problem. There's a program called >> pin that does dynamic instrumentation and actually expects to be able >> to read the targets of calls. The way that Linux handles this now is > > Um, do people seriously need to do this dynamic instrumentation on > ancient obsolete binaries? This sounds to me like confused > requirements. Unclear. They certainly did, and I got a bug report, the first time around. That was a couple years ago. I suppose we could have a sysctl that you need to set to enable that use case. OTOH, I think that, as long as we have a way to distinguish new and old binaries, it's not that much harder to twiddle vsyscall readability per process than it is to twiddle vsyscall executability per process. --Andy