Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1192396

Re: [PATCH 4/3] x86/ldt: allow to disable modify_ldt at runtime

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [PATCH 4/3] x86/ldt: allow to disable modify_ldt at runtime
Date Sat, 25 Jul 2015 18:10:01 +0200
Message-ID <pQabn-YF-5@gated-at.bofh.it> (permalink)
References <pQ0lH-3FD-3@gated-at.bofh.it> <pQ0lH-3FD-1@gated-at.bofh.it> <pQ185-4Pc-5@gated-at.bofh.it> <pQ1rr-5bo-3@gated-at.bofh.it> <pQ2xc-6Hb-17@gated-at.bofh.it> <pQ7nd-5oa-29@gated-at.bofh.it>
X-Original-To Willy Tarreau <w@1wt.eu>
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=CHqraS5sTVegMR1aavsQZpKuAZNwXFIBcyEuDzCxJII=; b=a89uNLd8ZSAHGoqI7Oc48SWCApJeMQz78xsTvBaWorZO4x/AKSRqSsY/Cww100yUKV 4NrZpypUw3hVb1+PNfOvgWCRCIS+RroMyu7Wgg8LoiRGmiddFV4Nl+qfzssLsNhHgHSy Nq23yjFQVBSBBL1HkqJG62jwkxgKuPARGrU6Oh1htH8pSuyzI96lvdsqHNqMW5mmqdJs JATA65mSou1H56jJWOtBD4C8FVJ+/a5ouS+5BAyosBQmipvvha374s31LMZQRMUOx4a/ 1G2uqrcxfmFxQmtPUJwhXjMCn3Hug+uQxeHMMFPR49LvGiLvJqzIHo0oZDWrhU0Y27pj DCmA==
X-Gm-Message-State ALoCoQm4NnEwVjAuIvFrOlsNVLU6s3jwHcJPYt0XwNRLzx00Lu8bdmNLnydq+Y56kPjf8gfnm8N8
X-Received by 10.112.8.108 with SMTP id q12mr18935687lba.113.1437840539220; Sat, 25 Jul 2015 09:08:59 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 60
Organization linux.* mail to news gateway
X-Original-Cc Andy Lutomirski <luto@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Steven Rostedt <rostedt@goodmis.org>, "security@kernel.org" <security@kernel.org>, X86 ML <x86@kernel.org>, Borislav Petkov <bp@alien8.de>, Sasha Levin <sasha.levin@oracle.com>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>, Boris Ostrovsky <boris.ostrovsky@oracle.com>, Andrew Cooper <andrew.cooper3@citrix.com>, Jan Beulich <jbeulich@suse.com>, xen-devel <xen-devel@lists.xen.org>, Kees Cook <keescook@chromium.org>
X-Original-Date Sat, 25 Jul 2015 09:08:39 -0700
X-Original-Message-ID <CALCETrV+OB0qxtw5CHaZc5RftuCUax04RxTyi_bt4ZKDJ2GB0g@mail.gmail.com>
X-Original-References <cover.1437802102.git.luto@kernel.org> <7286d77aa81abc38dc40362e2439861427064f6f.1437802102.git.luto@kernel.org> <20150725062343.GA3902@1wt.eu> <CALCETrX0ExTFXVdNthwBRheg4vsffPThVuyn7uAcj_TGwpXgiA@mail.gmail.com> <20150725075052.GA3918@1wt.eu> <20150725130340.GA17257@1wt.eu>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref aioe.org linux.kernel:1192396

Show key headers only | View raw


On Sat, Jul 25, 2015 at 6:03 AM, Willy Tarreau <w@1wt.eu> wrote:
> On Sat, Jul 25, 2015 at 09:50:52AM +0200, Willy Tarreau wrote:
>> On Fri, Jul 24, 2015 at 11:44:52PM -0700, Andy Lutomirski wrote:
>> > I'm all for it, but I think it should be hard-disablable in config,
>> > too, for the -tiny people.
>>
>> I totally agree.
>>
>> > If we add a runtime disable, let's do a
>> > separate patch, and you and Kees can fight over how general it should
>> > be.
>>
>> Initially I was thinking about changing it for a 3-state option but
>> that would prevent X86_16BIT from being hard-disablable, so I'll do
>> something completely separate.
>
> So here comes the proposed patch. It adds a default setting for the
> sysctl when the option is not hard-disabled (eg: distros not wanting
> to take risks with legacy apps). It suggests to leave the option off.
> In case a syscall is blocked, a printk_ratelimited() is called with
> relevant info (program name, pid, uid) so that the admin can decide
> whether it's a legitimate call or not. Eg:
>
>   Denied a call to modify_ldt() from a.out[1736] (uid: 100). Adjust sysctl if this was not an exploit attempt.
>
> I personally think it completes well your series, hence the 4/3 numbering.
> Feel free to adopt it if you cycle another round and if you're OK with it
> of course.
>

There's one thing that I think is incomplete here.  Currently, espfix
triggers if SS points to the LDT.  It's possible for SS to point to
the LDT even with modify_ldt disabled, and there's a decent amount of
attack surface there.

Can we improve this?  Two ideas:

1. In the asm, patch out or otherwise disable espfix if that sysctl
has never been set.  (Ick.)

2. When modify_ldt is runtime-disabled (or compile-time disabled,
perhaps), disallow setting the LDT bit in SS in the handful of places
that would allow it (ptrace and sigreturn off the top of my head).  We
don't need to worry about (regs->ss & 4) being set on kernel entry
because we'll never be in user mode with that bit set if the LDT is
disabled, but that bit could still be set using kernel APIs.  (In
fact, my sigreturn test does exactly that.)

Hmm.  With synchronous LDT, we could plausibly check at runtime in the
espfix code, too.  We used to use LAR to do this, but hpa removed it
when he realized that it was racy.  It shouldn't be racy any more,
because, with my patches applied, the LDT never changes while
interrupts are off.

--Andy
--
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/

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 4/3] x86/ldt: allow to disable modify_ldt at runtime Andy Lutomirski <luto@amacapital.net> - 2015-07-25 18:10 +0200
  Re: [PATCH 4/3] x86/ldt: allow to disable modify_ldt at runtime Willy Tarreau <w@1wt.eu> - 2015-07-25 18:40 +0200
    Re: [PATCH 4/3] x86/ldt: allow to disable modify_ldt at runtime Andy Lutomirski <luto@amacapital.net> - 2015-07-25 19:50 +0200
      Re: [PATCH 4/3] x86/ldt: allow to disable modify_ldt at runtime Willy Tarreau <w@1wt.eu> - 2015-07-25 20:50 +0200

csiph-web