Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1419371ybp; Fri, 11 Oct 2019 14:03:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHsJGhK4sCzJQoNE8bCfuPo8dWVZ9we7/84kOcD8q/J1cyGT4bIEcJHlBgyqk4YzCOGAkt X-Received: by 2002:a05:6402:713:: with SMTP id w19mr15688767edx.113.1570827808296; Fri, 11 Oct 2019 14:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570827808; cv=none; d=google.com; s=arc-20160816; b=gfp0o0QIMffbuzJ0Pc33ekLfh0GymcTjdDCBexPIrDOWQJ61vQLpLjmy/o5MfN3nvm 043+GavfYw+GWCYW2+uuSHhVC2uTZdRNIah9c/+4lPxsXyZlrUnyJA5nUgZDYvMVzGsM 5mJ0IMJA9lbPXOxMWqjAC2wCCvFRbteb/SH2p/nl1zYv9HXtcyDTQ6N1bfMKUZ23bDqA vNk07TDtsKFV2KTVZfFY/ZamAqmOavIXw3dshVhRDKr+ZhByWYwK5Jn7WCl3qwSm/ik5 qsJd+pl7T19B5xfuzq0w+vdT2XxftCRIRKIPLz/WQ/hZ7x1rp1ztiK3Ngql10JRoEAOy K5PA== 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=FNABcTciGmLPgzKCUlHZRBRsyOpw5zPeOkeqEXDcIFc=; b=xKEvuQh5TAEsBqX5wJ88c2b83XUsRm70xY6qB5EqldHSortxHIv0qr+1vNnaJz1flD DGdjwg7fSKmyxOEHk8cxAwIbEjb+DwWXeVmVy6JmPUl1tJXzvcJ7CT0qVyIiTsjMOBR1 ogyBrZEnGXDlSH05WzFuuU10Gwal74nGQ4bENQXqjnCTp8bD66BAAtd9dT+13yXV05Sj a41nm3pv8k7MpBAUu0NlAAVX8Bm5cUGqh9xKBCb0tXowzPX119wAS4WyOFja8TFImPUb TWhKEvP8KeOBWPXv+fPqyFAcLwqCubiVqt38/ruF8Mi0UWHJ1fgRXEhRHzYOuwVDwqPc 0iNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=hiusd5bT; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si6078355ejh.169.2019.10.11.14.03.04; Fri, 11 Oct 2019 14:03:28 -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=@linux-foundation.org header.s=google header.b=hiusd5bT; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727974AbfJKUqd (ORCPT + 99 others); Fri, 11 Oct 2019 16:46:33 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:39135 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbfJKUqc (ORCPT ); Fri, 11 Oct 2019 16:46:32 -0400 Received: by mail-lj1-f195.google.com with SMTP id y3so11084313ljj.6 for ; Fri, 11 Oct 2019 13:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FNABcTciGmLPgzKCUlHZRBRsyOpw5zPeOkeqEXDcIFc=; b=hiusd5bTKbuf8Io1VHhHhrY3WPkC8HiE+LZAmpWF8M5eNj+z1KEhXR6703FdJnh6Fn mco4+ZkYzjQTqICNRn9LKyFFsCB9Owxm8mZcigV5i+SgI22JVStBEVyyBrw4SLHSEXt2 n8BsJjHPsRARgvmaaSQ1mbnYPbUvUTven4vcg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FNABcTciGmLPgzKCUlHZRBRsyOpw5zPeOkeqEXDcIFc=; b=UMn2XLYjz8a7N3FXtwogKo+6QQedxfRdz+1lA41ALsDg5QXZuGRbmY14Z/ctHtwc6l FvzL6/pPW8jnP3+VsgZ1MRl953xdkunlzrQHracqgVuodcHvIfOUOQE733hsyHPSKcKF RvcHWA2HVY8yw1Lhh2LoeHuWPRAqqnbYzhNuZpA+CG0MwQyjNWrzdBFlS/69f74UmB+3 Ag0c1hLqL0R5XWA9ylbo/TyBmLWeigbkum9PYLEMGmiv3Z3TboHCPLkCMFrqxukNOZnn A3vYo+ilL46GcFhmxWOAFUUAyq0OV/+C8Md9uOjPFrra3ooUj4pfCd1vW6qY6pNG39Uz Fcaw== X-Gm-Message-State: APjAAAWktX0SsqTOgbG4Dlw5tyr4Z8GvEHIohlT+ve+N9lMZy9c65td1 RBGh4ttuXHBXrdddTOttjZ/yKpOyrbk= X-Received: by 2002:a2e:6a04:: with SMTP id f4mr10613570ljc.186.1570826790297; Fri, 11 Oct 2019 13:46:30 -0700 (PDT) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com. [209.85.208.180]) by smtp.gmail.com with ESMTPSA id c4sm2159183lfm.4.2019.10.11.13.46.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Oct 2019 13:46:28 -0700 (PDT) Received: by mail-lj1-f180.google.com with SMTP id y23so11047264lje.9 for ; Fri, 11 Oct 2019 13:46:28 -0700 (PDT) X-Received: by 2002:a2e:2b91:: with SMTP id r17mr10481233ljr.1.1570826788212; Fri, 11 Oct 2019 13:46:28 -0700 (PDT) MIME-Version: 1.0 References: <20191011135458.7399da44@gandalf.local.home> <20191011162518.2f8c99ca@gandalf.local.home> In-Reply-To: <20191011162518.2f8c99ca@gandalf.local.home> From: Linus Torvalds Date: Fri, 11 Oct 2019 13:46:11 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] tracefs: Do not allocate and free proxy_ops for lockdown To: Steven Rostedt Cc: LKML , Matthew Garrett , James Morris James Morris , LSM List , Linux API , Ben Hutchings , Al Viro 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 Fri, Oct 11, 2019 at 1:25 PM Steven Rostedt wrote: > > OK, so I tried this approach, and there's a bit more than just a "few" > extra cases that use tracing_open_generic(). Yeah, that's more than I would have expected. That said, you also did what I consider a somewhat over-done conversion. Just do static inline bool tracefs_lockdown_or_disabled(void) { return tracing_disabled || security_locked_down(LOCKDOWN_TRACEFS); } and ignore the pointless return value (we know it's EPERM, and we really don't care). And then several of those conversions just turn into oneliner - if (tracing_disabled) + if (tracefs_lockdown_or_disabled()) return -ENODEV; patches instead. I'm also not sure why you bothered with a lot of the files that don't currently even have that "tracing_disabled" logic at all. Yeah, they show pre-existing tracing info, but even if you locked down _after_ starting some tracing, that's probably what you want. You just don't want people to be able to add new trace events. For example, maybe you want to have lockdown after you've booted, but still show boot time traces? I dunno. I feel like you re-did the original patch, and the original patch was designed for "least line impact" rather than for anything else. I also suspect that if you *actually* do lockdown at early boot (which is presumably one common case), then all you need is to do --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -418,6 +418,9 @@ struct dentry *tracefs_create_file( struct dentry *dentry; struct inode *inode; + if (security_locked_down(LOCKDOWN_TRACEFS)) + return NULL; + if (!(mode & S_IFMT)) mode |= S_IFREG; BUG_ON(!S_ISREG(mode)); and the "open-time check" is purely for "we did lockdown _after_ boot, but then you might well want to be able to read the existing trace information that you did before you locked down. Again - I think trying to emulate exactly what that broken lockdown patch did is not really what you should aim for. That patch was not only buggy, it really wasn't about what people really necessarily _want_, as about "we don't want to deal with tracing, so here's a minimal patch that doesn't even work". Linus