Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2039705imu; Wed, 21 Nov 2018 05:57:41 -0800 (PST) X-Google-Smtp-Source: AJdET5eSbJZqlpKZ2Wt+kYOWqZNvqQZxK0d7O4gQ1q34LZCkc5K7hVPMZFjibfspVFKQkE+OcICf X-Received: by 2002:a62:4886:: with SMTP id q6mr7090720pfi.182.1542808661721; Wed, 21 Nov 2018 05:57:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542808661; cv=none; d=google.com; s=arc-20160816; b=CgPi4DjUGdQurUzGvSsYj4FYsI8ONtCYtk1ViSY7inNbzs5cGf80W0bd3XA9zquUbQ 2cXEowOtwbrCDJVXI0spSmw6+eG0vslnC7sjpEV/UrqHa7fYi4WFzGmj7Cbgg3VSbM9I jAgXORmTpw+URD5oy2WVP96XfdAVCS/WxDy8yu+b3qoubcJbIVVH6OnUKzdWVv5va9Zl mG7doh2JoVgwCEWRwe61hTnIEQ1n5JPyFAFuCdWyAPy/Po9L1YpQYce7xojE2Ztpy8jq LEhTZuZpGREgwDVHzoQrzKquumikYMnSLnFP0pBDchTUprGAM4NJQETzCgVbQ4C4xb5G e4QA== 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=GqUc7jkkbCKTQOkqN3UR2Yad5lZT2FEvTJRomnt8jmU=; b=HpZltfb5LuPdlhz79SkFAaaA3AS82sNjDIkSI1FBmGAxiceOjLxpk6tRbsdtTaTxtY vBrabTX5DoiPKHZzZ+nwVpm8vttE3iQ3OFFwGL7salrBOZqS3kwsY+rOfOY9fGlKzdj7 h9fPwlsMy3U3Twd7TmjHkvBOWPtla59au7XN5jzqzj0rZgT5GRxA7+osl3vFfALlMCDi AFG5iSjDM4dRNMeJ3bODeRzv5XHnNG/XBIbVik/qIFrnVrrRI+a/FUhe3tNx5sFM48LA dy8Qk3LZUiU2G3wyHIyVGFtoCGC/yUZV2WYIoekANOxZNR4rs/ozG5wmIys06zniZ3Hx eW9w== 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 b19si23165635pfm.100.2018.11.21.05.57.16; Wed, 21 Nov 2018 05:57:41 -0800 (PST) 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 S1730147AbeKUWjb (ORCPT + 99 others); Wed, 21 Nov 2018 17:39:31 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33574 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729128AbeKUWjb (ORCPT ); Wed, 21 Nov 2018 17:39:31 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wALBx6kw056071 for ; Wed, 21 Nov 2018 07:05:22 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2nw5p847fp-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 21 Nov 2018 07:05:22 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Nov 2018 12:05:20 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 21 Nov 2018 12:05:17 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wALC5GXF60817580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 21 Nov 2018 12:05:16 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4EB1CA4060; Wed, 21 Nov 2018 12:05:16 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C844A405F; Wed, 21 Nov 2018 12:05:16 +0000 (GMT) Received: from localhost (unknown [9.152.212.229]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 21 Nov 2018 12:05:15 +0000 (GMT) Date: Wed, 21 Nov 2018 13:05:10 +0100 From: Vasily Gorbik To: David Howells , James Morris Cc: Martin Schwidefsky , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH next-lockdown 1/1] debugfs: avoid EPERM when no open file operation defined References: <4136.1522452584@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 x-cbid: 18112112-0008-0000-0000-000002963F3F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112112-0009-0000-0000-000022006F52 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-21_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 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-1811210107 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. In particular this breaks 2 debugfs files on s390: /sys/kernel/debug/s390_hypfs/diag_304 /sys/kernel/debug/s390_hypfs/diag_204 To address that set EPERM return code only when debugfs_is_locked_down returns true. Fixes: 3fc322605158 ("debugfs: Restrict debugfs when the kernel is locked down") Signed-off-by: Vasily Gorbik --- fs/debugfs/file.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 51cb894c21f2..89c86faaa02a 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -167,9 +167,10 @@ static int open_proxy_open(struct inode *inode, struct file *filp) real_fops = debugfs_real_fops(filp); - r = -EPERM; - if (debugfs_is_locked_down(inode, filp, real_fops)) + if (debugfs_is_locked_down(inode, filp, real_fops)) { + r = -EPERM; goto out; + } real_fops = fops_get(real_fops); if (!real_fops) { @@ -296,9 +297,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)) + if (debugfs_is_locked_down(inode, filp, real_fops)) { + r = -EPERM; goto out; + } real_fops = fops_get(real_fops); if (!real_fops) { -- 2.18.0.13.gd42ae10