Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp724585ybm; Wed, 22 May 2019 10:25:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5aUUpWxz0vmCM408DfeZNKns0sIsy9ZLzAkLsIvmIadXX8uz8MUd+oa+m9XR4vslderLk X-Received: by 2002:a17:902:7d8a:: with SMTP id a10mr1355856plm.63.1558545945720; Wed, 22 May 2019 10:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558545945; cv=none; d=google.com; s=arc-20160816; b=XpYWVw6zRpGi9zVEHTB4a5HYANQrITaY+qoA0hF6TZIj036/Dzqkn3AcR0xIe0fDjz 8jAYsDqsBms7rWWFS19HzinqmMRQsN18l4X1EGzi/HkJyLAz/xR+ofRP8/4Wm9P5RF/L FBGSNswQLoaDFldX3SJByqNqfc+XiWWUjEd6Uc13d+Q76Y8uaOmGXOGoHBKGJlFAAYkN vfS5DWrCnV+GRAFsRSTs83iTccL8hNHhfHxTS/R/NqhkZQIRZK5X5jPSV/CjZvm6t1Fm u+Y3joFwDaP7OZDdy2KOZA5Uh3oXc5AZHUKFCXX7uPbnohtrxgbPnOq/YH73YbdsdN4j 0Zsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rOBQF4RNGprJ+BQmSagcj04ZJL6gmj3s+7BuzKIF2uQ=; b=KhCURR2nedR0D3d4PBf84EZ8seC+LtI9WtdDjwVZr1igKQlV5FCpAKVZD9uDxRU5PY T/9YIMEybUKBmNmgcACYZGMicagFrrhngU05Qk0hnvUTZ68BMlBTyaTXoi58tMEfSP8J +Pe5NljfnGYodUNs8I4+ux0V1cVuz/iarg5dSkmFLzZ+fiCy5Qvij8y5DoOjIq6svHmh syoO/qAz7e3KLamgF1uT3M4A1ZDRnPpcJJ4NzpPcd/uwMdWQGfHn24h3zBDSHEvHxsD0 /cJnmS/aNtjNUn1oQReaamkf7TQkzD4EW4QPh6/sbajZLFZ1Pp8w5oV45ikn3VAEEFaI M4PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1pdRS2Me; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 95si25979683pld.143.2019.05.22.10.25.30; Wed, 22 May 2019 10:25:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1pdRS2Me; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729683AbfEVRIr (ORCPT + 99 others); Wed, 22 May 2019 13:08:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:52292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729430AbfEVRIq (ORCPT ); Wed, 22 May 2019 13:08:46 -0400 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 3EEB321773 for ; Wed, 22 May 2019 17:08:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558544925; bh=KwHz/SRjtllr+zkYrk6zVA1VtRKBkaAPNxi83l4/ZRw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=1pdRS2Meoh8spHhkBCq2eiddUJ+I1CbE63gDNTFixwAHU3Osxquu20mS1v2gDmnu7 jl5Qh7ljtjsOQYEcZJptolgEYemI9HeZOXxrtNAXM3ZchvL6yDF5hbQhf6ZNCrirJl wRuOi/eQQRMIrAcoldviMweKvdFsQm74wSbE8cTE= Received: by mail-wr1-f45.google.com with SMTP id r7so3122067wrr.13 for ; Wed, 22 May 2019 10:08:45 -0700 (PDT) X-Gm-Message-State: APjAAAWI9Bnrd9Pd6aZj1M5/7rLUuXKbc+JVmNIHspsjQTKzCdGgdqvQ m3SB+ecP1M6Pcwd3CIqfi+4V75znIxGUEshCagnbJA== X-Received: by 2002:adf:e90b:: with SMTP id f11mr2236592wrm.291.1558544923770; Wed, 22 May 2019 10:08:43 -0700 (PDT) MIME-Version: 1.0 References: <20190521224013.3782-1-matthewgarrett@google.com> In-Reply-To: From: Andy Lutomirski Date: Wed, 22 May 2019 10:08:32 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC] Turn lockdown into an LSM To: Matthew Garrett Cc: James Morris , LSM List , Linux Kernel Mailing List , Andy Lutomirski Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 22, 2019 at 9:49 AM Matthew Garrett wrote: > > On Tue, May 21, 2019 at 7:40 PM James Morris wrote: > > An LSM could also potentially implement its own policy for the hook. > > That was my plan. Right now the hook just gets an ASCII description of > the reason for the lockdown - that seems suboptimal for cases like > SELinux. What information would you want? My initial thinking was to > just have a stable enum of lockdown reasons that's in the UAPI headers > and then let other LSM tooling consume that, but I haven't spent > enough time with the internals of SELinux to know if there'd be a more > attractive solution. I may be in the minority here, but I see this issue as a significant downside of making lockdown more flexible. If we stick with just "this may violate integrity" and "this may violate confidentiality", then the ABI surface is nice and narrow. If we start having a big uapi list of things that might qualify for lockdown, we need to worry about compatibility issues. This isn't purely theoretical. Lockdown has some interesting interactions with eBPF. I don't want to be in a situation where v1 of lockdown has a few eBPF hooks, but a later update improves the eBPF vs lockdown interaction so that you can do more with eBPF on a locked down kernel. But now any such change has to worry about breaking the lockdown LSM ABI. And I still think it would be nice to have some credible use case for a more fine grained policy than just the tri-state. Having a lockdown policy of "may not violate kernel confidentiality except using kprobes" may be convenient, but it's also basically worthless, since kernel confidentiality is gone. All this being said, I do see one big benefit for LSM integration: SELinux or another LSM could allow certain privileged tasks to bypass lockdown. This seems fine, except that there's potential nastiness where current->cred isn't actually a valid thing to look at in the current context. So I guess my proposal is: use LSM, but make the hook very coarse grained: int security_violate_confidentiality(const struct cred *) and int security_violate_integrity(const struct cred *). --Andy