Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3701221pxb; Mon, 24 Jan 2022 15:46:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyi+wCN/9Fqw/ADnaIa0/n/IICmvA4HDEDBTYCH01GmSzkGiKX5yQYgdZE4du+Z1s8uJR+8 X-Received: by 2002:a63:7d43:: with SMTP id m3mr13203694pgn.301.1643067976827; Mon, 24 Jan 2022 15:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643067976; cv=none; d=google.com; s=arc-20160816; b=vBxZX79gn43HK56EDKJ/b9nS/JpGRvB9bE5Fk4g9pRPhmuejhlIy7VNJL5/4hwl7Mb 61q+0Tb3JVXJSUXmeYwsY6dqkSOJuL0FEs2WJZzeBfYakM5XWVlDghNs7gNtIWPLUwv8 1/jS0Am6ESGqBrxxS6fwJ6le579OSjMl01z1cC/LB/g3WFgWhf/xnwt59boHCEe3TC0S UrtSJYmu0d4lmgWlPKzm32rLURkvkg7IfojNfg/Fyjkj8B0jgK5FMnTcElHtdh6/2tl+ As4DObTaYfBK3rlV4y0iItuRREgkDyLRyy17eLlLDy+8pQWM+97Ty/gHCgVs7eHyjjTx ybig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RFzwSPklR3s1oOgKD4gIWFZwbvf3fWnREU/F2I+9fgk=; b=fXjCVWGGDX1GVV0C3PSi98QeLerc5MRFASA4atKbkFxSxndX91OMh5z4QSgtYFXSzf 69vy3w1RbHty/iQgYJ7cKUKDmRAeuhmI4NnNFej0oGWwo+bY7jkWnvvFhZsa+9xrCKP4 6LxnF53vMjHYXkc7nueTB52J3iHT2XQDnzkZVE5VcyImEvWMKnwIwpkkhyN5oFE6mV9X 8FvsRd1RCL5v+Fg/U36IjXEOde7UR8JgghJpe6aKN+12hE62eRg4XtE1/Ze8iAZ0C51D xANcaE3UJ0ryTUat7i4ptj7YCB87xkI1C225sNNYjtlfqDUTdLtZnZt+hv6Npw7MouMG 8wxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i1pYtNUe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m25si16226943pgv.794.2022.01.24.15.46.03; Mon, 24 Jan 2022 15:46:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i1pYtNUe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1844398AbiAXXjA (ORCPT + 99 others); Mon, 24 Jan 2022 18:39:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382484AbiAXW6D (ORCPT ); Mon, 24 Jan 2022 17:58:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECAB4C02B87B; Mon, 24 Jan 2022 13:12:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 942B9B81243; Mon, 24 Jan 2022 21:12:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97C6AC340E7; Mon, 24 Jan 2022 21:12:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058778; bh=yCS3kdcuvrsLpG2x1smI/oLscK7914Esvp5KKO44Nv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i1pYtNUec6sM6/7KbgnpE7CB9X+hB5illv/TepczY2eBiSYZP8zzTnz5ScK0bna8Z YkC7QgR5sISYbmDait3g5nYEjhqTZl7cWQYcH5mEFNYbU92WuIo0LNpVrgmwTWlgn7 Jt3Byeak5i0WdZq9r5kSldj5rrs/yUu9U2Lc5ZVw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Suchanek , Sasha Levin Subject: [PATCH 5.16 0398/1039] debugfs: lockdown: Allow reading debugfs files that are not world readable Date: Mon, 24 Jan 2022 19:36:27 +0100 Message-Id: <20220124184138.697023872@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Suchanek [ Upstream commit 358fcf5ddbec4e6706405847d6a666f5933a6c25 ] When the kernel is locked down the kernel allows reading only debugfs files with mode 444. Mode 400 is also valid but is not allowed. Make the 444 into a mask. Fixes: 5496197f9b08 ("debugfs: Restrict debugfs when the kernel is locked down") Signed-off-by: Michal Suchanek Link: https://lore.kernel.org/r/20220104170505.10248-1-msuchanek@suse.de Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- fs/debugfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 7d162b0efbf03..950c63fa4d0b2 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -147,7 +147,7 @@ static int debugfs_locked_down(struct inode *inode, struct file *filp, const struct file_operations *real_fops) { - if ((inode->i_mode & 07777) == 0444 && + if ((inode->i_mode & 07777 & ~0444) == 0 && !(filp->f_mode & FMODE_WRITE) && !real_fops->unlocked_ioctl && !real_fops->compat_ioctl && -- 2.34.1