Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1829208yba; Thu, 25 Apr 2019 06:26:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqze1DHD+63MPLb2MnXdWU9KKML/LKXrN3ZKeszZ1O52H0cAU5jN2CpVqSOKT62noBgKmi9c X-Received: by 2002:a63:5b0a:: with SMTP id p10mr37858284pgb.282.1556198801178; Thu, 25 Apr 2019 06:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556198801; cv=none; d=google.com; s=arc-20160816; b=ApsPM4fQpNCQs/WugpXiWd/kGZ0skXJauk6RI/3hVDMso0/qD5H8FnmoTAp6w0x8xx VLMZd0/z6+ZCeqRC9/H2AW9xxqnZIswnGdJTXC5KWBQsgCJshEpTuLUNbQlI+LhI5jH8 mRIS6BsQ8KR/SLmLp7zlbstZ/MIzVCDDeg65arbSydiEZxHPO8IsCWhlv0LMRv6q9/OP AGzImYyQs+ZooGQRuanjrwUnvyrUEI8Wxt7ZwWPe22TUft+03zZRILp7DXpFmWFoctLr E1yV8l4UJvLjlIC+fc5jLBzRLKxeWsF/0MC2EMyd2L73SZhrFh+vcY/ghvAuNTEAttdp y2Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date; bh=MxwZgIPdWfRtarJZ6/RHOpfBXKNI+qfRsyGsBd6DecM=; b=LKT0l8rBH/PLjCdBCve9+STDzlrpZktRUjHQRQ6b38dcWTsM9B9yNPhva16S+Pn20B xihhslVDVtGiyXZFvAfPa7nuHUJ0t2wZNj1x1zIg4P9t4yVjiSmNK0/XbhocQwtGAjeZ XlEKIeVkfDhdWUm1NB47/OnQdFs1hbdRD5gG6xGjYSoq2Y7E0FECPhGvyC7uuXYpwooa N4cwXoQmYaXprDj1A99RaZTEwi/5zI4RuNqiTz+GtOhCRMYxluWcItHHx9nHyhJwFwtq kICtvi9jPEFC7rnabOJ7OVop/W5GM2UV/l1x60qITD/rhB9PcWlAdYzNBP7WpDvwpmOm UGQg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k12si22219591pls.436.2019.04.25.06.26.25; Thu, 25 Apr 2019 06:26:41 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729272AbfDYKtX (ORCPT + 99 others); Thu, 25 Apr 2019 06:49:23 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40388 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728944AbfDYKtX (ORCPT ); Thu, 25 Apr 2019 06:49:23 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3PAf26R030566 for ; Thu, 25 Apr 2019 06:49:21 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2s39c6dtgs-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Apr 2019 06:49:21 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Apr 2019 11:49:19 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 25 Apr 2019 11:49:17 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3PAnGMs46792952 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Apr 2019 10:49:16 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0525A5204F; Thu, 25 Apr 2019 10:49:16 +0000 (GMT) Received: from localhost (unknown [9.152.212.112]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id BACCA52051; Thu, 25 Apr 2019 10:49:15 +0000 (GMT) Date: Thu, 25 Apr 2019 12:49:14 +0200 From: Vasily Gorbik To: Matthew Garrett Cc: jmorris@namei.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, dhowells@redhat.com Subject: Re: [PATCH 26/27] debugfs: Restrict debugfs when the kernel is locked down References: <20190306235913.6631-1-matthewgarrett@google.com> <20190306235913.6631-27-matthewgarrett@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190306235913.6631-27-matthewgarrett@google.com> X-TM-AS-GCONF: 00 x-cbid: 19042510-0020-0000-0000-000003356F81 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19042510-0021-0000-0000-00002187DAA4 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-25_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904250068 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 06, 2019 at 03:59:12PM -0800, Matthew Garrett wrote: > From: David Howells > > static int open_proxy_open(struct inode *inode, struct file *filp) > { > struct dentry *dentry = F_DENTRY(filp); > @@ -147,6 +166,11 @@ static int open_proxy_open(struct inode *inode, struct file *filp) > return r == -EIO ? -ENOENT : r; > > real_fops = debugfs_real_fops(filp); > + > + r = -EPERM; > + if (debugfs_is_locked_down(inode, filp, real_fops)) > + goto out; > + > real_fops = fops_get(real_fops); > if (!real_fops) { > /* Huh? Module did not clean up after itself at exit? */ > @@ -272,6 +296,10 @@ static int full_proxy_open(struct inode *inode, struct file *filp) > return r == -EIO ? -ENOENT : r; > > real_fops = debugfs_real_fops(filp); > + r = -EPERM; > + if (debugfs_is_locked_down(inode, filp, real_fops)) > + goto out; > + > real_fops = fops_get(real_fops); > if (!real_fops) { > /* Huh? Module did not cleanup after itself at exit? */ Please be aware that this patch has been known to cause problems in distributions which picked this patch series already: ubuntu: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1807686 fedora: https://bugzilla.redhat.com/show_bug.cgi?id=1658675 as well as rhel 8. I've sent around this potential fix which has been picked by the distributions (offered via bugzillas), but went apparently unnoticed at lkml: https://lkml.org/lkml/2018/11/21/634 https://lkml.org/lkml/2018/11/21/635 """ With "debugfs: Restrict debugfs when the kernel is locked down" return code "r" is unconditionally set to -EPERM, which stays like that until function return if no "open" file operation defined, effectivelly resulting in "Operation not permitted" for all such files despite kernel lock down status or CONFIG_LOCK_DOWN_KERNEL being enabled. """ I would appreciate if you consider that change, possibly just squashing into yours.