Path: csiph.com!aioe.org!bofh.it!news.nic.it!robomod From: Kees Cook Newsgroups: linux.kernel Subject: Re: [PATCH v3 2/3] x86/ldt: Make modify_ldt optional Date: Fri, 24 Jul 2015 02:10:01 +0200 Message-ID: References: X-Original-To: Willy Tarreau Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=44rjJFb/cUCuPwzPYYVTo1m7B6A61EycsiyUZpTUY6c=; b=BeR54fUTIIBr0WpDuwvrE3UltMJtyEBrH5uBYmKXELpXEYjHL9B6CyuA2fQRFFcWx2 BPcW3MuMk47ZwYCchX6Co+LeqZ1TYSOjb26QpNxz2FAg+MG3mbVPNor5iPxJWUXCWPGW cN2/DJFF3Zgik/HZoDFxu6VRM2sGYZ+4aZ0G25ZwMepWKf6kjoQttljncYBdiAZp7tnp acic+Iz1YLPugtjclySYxLV17YX415HxFLIwpkD1IT+aLW2hCh8Q3zRFwBew5bGPb8Z0 7Ot5tGkP28bDc3PdJSJvr0ubJDkATzD0LnIuj5bpetNAtmfMg9j9QJ8ye1kuXmQShwQ0 HeBg== Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=44rjJFb/cUCuPwzPYYVTo1m7B6A61EycsiyUZpTUY6c=; b=bxIY5mChIZxKKi92ACXO+JMUTFTF8yYAbfGGbhjFeJDP54uqNHtlz+nYXJ3VSaMsec EjmEHg8sxGgRPtUHKkuz4A6XLgdJLVrjLTkt+aXZWg3C/9RykYXD+lqs/uTKbjrylTvy bc/6mAeMTkUcijBRrVmM7YqMtWDN4VdZQjw10= X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=44rjJFb/cUCuPwzPYYVTo1m7B6A61EycsiyUZpTUY6c=; b=mEZV76GD5UuR8TvkbKdkXibTcM8vEiACb9JOm4Vz4T9m/y8Ac9koAva2HfjuUxUQ8r Yo8E8Rw27bxwYerpYZeEC32FMebQFz6kdbik3C20Ap0as1t7IKnsLVRnnrgDRqExu9a7 X75crPyeafs+HsyjJUIF4mQ4cKjlW2khq9rDNa6sOXQ5vUA1B9ZFJo2BdYc25arfWd1f mKCJBSYJMYMqeWhGHL6yf563V0WprTIc2KYRn8unDLBSGANnfbbYCyrySNrQ9atGCH7H q0/A5GzRm+fua4o2HQatEwwf7Q22k0kHmpj7swbOjlC1c6koKk2VIkC7/LrcG9cBRBBY UYcg== X-Gm-Message-State: ALoCoQk5z620CAFEmVkqObmbdE/+frEgzXSHsCErWYp5ZdTI2u/5LNyPctgXuoj/l3ugLcdXVqXj MIME-Version: 1.0 X-Received: by 10.50.6.38 with SMTP id x6mr1348798igx.74.1437696561339; Thu, 23 Jul 2015 17:09:21 -0700 (PDT) X-Google-Sender-Auth: iiR9e8A206rl46KlGlpubDFBGLQ Content-Type: text/plain; charset=UTF-8 Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 62 Organization: linux.* mail to news gateway X-Original-Cc: Andy Lutomirski , Andy Lutomirski , Peter Zijlstra , Steven Rostedt , "security@kernel.org" , X86 ML , Borislav Petkov , Sasha Levin , LKML , Konrad Rzeszutek Wilk , Boris Ostrovsky , Andrew Cooper , Jan Beulich , xen-devel X-Original-Date: Thu, 23 Jul 2015 17:09:21 -0700 X-Original-Message-ID: X-Original-References: <7bfde005b84a90a83bf668a320c7d4ad1b940065.1437592883.git.luto@kernel.org> <20150723102434.GA2929@1wt.eu> <20150723235805.GA3191@1wt.eu> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: aioe.org linux.kernel:1191408 On Thu, Jul 23, 2015 at 4:58 PM, Willy Tarreau wrote: > On Thu, Jul 23, 2015 at 04:40:14PM -0700, Andy Lutomirski wrote: >> On Thu, Jul 23, 2015 at 4:36 PM, Kees Cook wrote: >> > I've been pondering something like this that is even MORE generic, for >> > any syscall. Something like a "syscalls" directory under >> > /proc/sys/kernel, with 1 entry per syscall. "0" is "available", "1" is >> > disabled, and "-1" disabled until next boot. >> > >> >> It might want to be /proc/sys/kernel/syscalls/[abi]/[name], possibly >> with more than just those options. We might want "disabled, returns >> ENOSYS", "disabled, returns EPERM", and a lock bit. >> >> On x86 at least, the implementation's easy -- we can just poke the >> syscall table. > > I wouldn't do it these days. Around 2000-2001, with a friend we designed > a module with its userland counterpart which was called "overloader". The > principle was to intercept syscalls in order to enforce some form of > policies, log values, or remap paths, etc. The first use was to log all > file creations during a "make install" to more easily build packages. It > was at the era where it was easy to modify the syscall table from a module, > in kernel 2.2. > > We quickly found that beyond logging/rewriting syscall arguments, it had > limited use cases when used as a "syscall firewall" because many syscalls > are still too coarse to decide whether you want to enable/disable them. > I remember that socketcall() and ioctl() were among the annoying ones. > Either you totally enable or totally disable. In the end, the only valid > use cases we found for enabling/disabling a syscall were limited to a very > small set for debugging purposes, in order to force some application code > to detect a missing implementation and switch to an alternative (eg: these > days if you suspect a bug in epoll you could disable it and force the app > to use poll instead). It was still useful to disable module loading and > FS mounting but that was about all by then. > > All this to say that probably only a handful of tricky syscalls would > need an on/off switch but clearly not all of them at all, so I'd rather > add a few entries just for the relevant ones, mainly to fix compatibility > issues and nothing more. Eg: what's the point of disabling exit(), wait(), > kill(), fork() or getpid()... It would only increase the difficulty to > sort out bug reports. > > Just my opinion, Well, I would really like to have something like this around so that I can trivially globally disable syscalls when they have security risks. My hack[1] to disable kexec_load, for example, was terrible while I waited for a kernel that supported the disable_kexec_load sysctl. -Kees [1] https://outflux.net/blog/archives/2013/12/10/live-patching-the-kernel/ -- Kees Cook Chrome OS Security -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/