Received: by 10.192.165.156 with SMTP id m28csp1153627imm; Wed, 11 Apr 2018 13:27:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/7rZjVVflj9dn6Q5E78HdDtAr67/Y0tm3dJIvUYn6lLHgr+P/oHJsl5LLDPYIiv+OOv7WL X-Received: by 10.99.95.214 with SMTP id t205mr4573641pgb.145.1523478449485; Wed, 11 Apr 2018 13:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523478449; cv=none; d=google.com; s=arc-20160816; b=zSHCxa4iJYL9QeYeoWa3yWAEQIhdmkmrMC1x7rHzyZkMFhtqj3bGZGEkL3JyKu+W/u kc9vrsOvcC4MFgbfjvnOuJVmbzASnbGhF4sKbaEtt1N6beVzaT5BqwQrRFOEuuhscVul GupiKjaw0q2EEL3O6co5GxPxo2t39aw25ZrVBJje1I9BRmRSy13pv3Mq3wFsHjGaBhkZ OdACcHKWK6Y8d+oF7cHVaHKEoRa+quCUatSTljKajkyfV34iqd23S+plCa6wnY/kLBoT QLFaTzZIWIsx48ern5KBdVmDizC2EGHSnauAm8yGRbEnAQaGBn+DofkJv0vwt2BK5t07 vDzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from :arc-authentication-results; bh=Jusqw35Y1+MMekIAufqK1wOmZIJzn+zl0oRxY41UI1c=; b=eXBTPScnmQBzO/tQ/8Y5fEBTxu/lLehT7lSZJs4Io8zwYirNjK7lmWeAhKcYeMmvFC xJNt30wPQQGdolPuWdU9bT3YNE9P+9W6mxUDxl0hHl+/tQYfKG4LN6HNwM849KISJT/N e2N0/VnUj/Iq0ov4Ga+uGwTsbarqlX4/coChMUIKyE6N8i86UQTyi3wkUiPXxJIkvXYx A3TJsKuW4QNX3MfsCnYkDqcsh/T7f6+WVfHgr9UPNgyOAqksDOoWgObIml2pXYK/uFbd vTJTdWE/nR9hvt/2AdyTcguoUbSO0KIRQQPjONqWiQt+d2xAmXccK79Kh81GJPF1p+wQ zY6w== ARC-Authentication-Results: i=1; mx.google.com; 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 w2-v6si1740861plz.206.2018.04.11.13.26.52; Wed, 11 Apr 2018 13:27:29 -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; 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 S932921AbeDKSvs (ORCPT + 99 others); Wed, 11 Apr 2018 14:51:48 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:36484 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755691AbeDKSvn (ORCPT ); Wed, 11 Apr 2018 14:51:43 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1f6KqM-0000dj-IH; Wed, 11 Apr 2018 12:51:42 -0600 Received: from [97.119.140.30] (helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1f6Kq6-0002ih-Sn; Wed, 11 Apr 2018 12:51:42 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: David Howells Cc: torvalds@linux-foundation.org, linux-man@vger.kernel.org, linux-api@vger.kernel.org, jmorris@namei.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org References: <152346387861.4030.4408662483445703127.stgit@warthog.procyon.org.uk> <152346403637.4030.15247096217928429102.stgit@warthog.procyon.org.uk> Date: Wed, 11 Apr 2018 13:50:12 -0500 In-Reply-To: <152346403637.4030.15247096217928429102.stgit@warthog.procyon.org.uk> (David Howells's message of "Wed, 11 Apr 2018 17:27:16 +0100") Message-ID: <87zi29k26z.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1f6Kq6-0002ih-Sn;;;mid=<87zi29k26z.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.119.140.30;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+HjSKZKEIiTmAWbs6f2zRx4tfe2/F5Omg= X-SA-Exim-Connect-IP: 97.119.140.30 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa07.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TM2_M_HEADER_IN_MSG,XMNoVowels,XMSubLong autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;David Howells X-Spam-Relay-Country: X-Spam-Timing: total 15017 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 3.1 (0.0%), b_tie_ro: 2.3 (0.0%), parse: 0.73 (0.0%), extract_message_metadata: 2.7 (0.0%), get_uri_detail_list: 1.16 (0.0%), tests_pri_-1000: 2.7 (0.0%), tests_pri_-950: 1.15 (0.0%), tests_pri_-900: 0.97 (0.0%), tests_pri_-400: 19 (0.1%), check_bayes: 18 (0.1%), b_tokenize: 6 (0.0%), b_tok_get_all: 6 (0.0%), b_comp_prob: 2.0 (0.0%), b_tok_touch_all: 2.2 (0.0%), b_finish: 0.63 (0.0%), tests_pri_0: 144 (1.0%), check_dkim_signature: 0.46 (0.0%), check_dkim_adsp: 2.8 (0.0%), tests_pri_500: 14837 (98.8%), poll_dns_idle: 14830 (98.8%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 24/24] debugfs: Restrict debugfs when the kernel is locked down X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org David Howells writes: > Disallow opening of debugfs files that might be used to muck around when > the kernel is locked down as various drivers give raw access to hardware > through debugfs. Given the effort of auditing all 2000 or so files and > manually fixing each one as necessary, I've chosen to apply a heuristic > instead. The following changes are made: > > (1) chmod and chown are disallowed on debugfs objects (though the root dir > can be modified by mount and remount, but I'm not worried about that). > > (2) When the kernel is locked down, only files with the following criteria > are permitted to be opened: > > - The file must have mode 00444 > - The file must not have ioctl methods > - The file must not have mmap > > (3) When the kernel is locked down, files may only be opened for reading. > > Normal device interaction should be done through configfs, sysfs or a > miscdev, not debugfs. > Note that this makes it unnecessary to specifically lock down show_dsts(), > show_devs() and show_call() in the asus-wmi driver. > > I would actually prefer to lock down all files by default and have the > the files unlocked by the creator. This is tricky to manage correctly, > though, as there are 19 creation functions and ~1600 call sites (some of > them in loops scanning tables). Why is mounting debugfs allowed at all? Last I checked (it has been a while) the code quality of debugfs was fine for debugging but debugfs was not safe to mount on a production system. Maybe the code quality is better now but for a filesystem that is not supposed to be needed for developers letting us mount debugfs seems odd. Eric