From patchwork Tue May 4 12:17:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 12238005 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F4AAC433ED for ; Tue, 4 May 2021 12:17:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4BBF7613BC for ; Tue, 4 May 2021 12:17:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230310AbhEDMSd (ORCPT ); Tue, 4 May 2021 08:18:33 -0400 Received: from www.zeus03.de ([194.117.254.33]:37332 "EHLO mail.zeus03.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbhEDMSc (ORCPT ); Tue, 4 May 2021 08:18:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=k1; bh=2yyPH8se0+nZ6UbxlCbOuNBeCyT 1VfdEGO0/Rfn1+qg=; b=mg0cGIDNFEcN4pT7dU/bz4dBMh0S9LiKBCzdfA/hjsK +ufW3tbvlzqhIVQyLYQcVzgp2d/IR2N56shr+N/Odo1PYijxOBKOSRxur1iz+sDu 743jJG6gUkDAvDFQiKm/K1Cbnatdvt6vnjx5FoipsXBOsp2+4u5bXyYnCJD9VIzw = Received: (qmail 1352815 invoked from network); 4 May 2021 14:17:35 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 4 May 2021 14:17:35 +0200 X-UD-Smtp-Session: l3s3148p1@n3zPD4DBqIsgAwDPXxOMAJUzfx/HAvHg From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Wolfram Sang , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH] debugfs: only accept read attributes for blobs Date: Tue, 4 May 2021 14:17:20 +0200 Message-Id: <20210504121721.43385-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Blobs can only be read. So, keep only 'read' file attributes because the others will not work and only confuse users. Signed-off-by: Wolfram Sang --- I was confused for a second, thinking blobs can be written to. I will fix the few in-kernel users doing it wrong seperately. fs/debugfs/file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 686e0ad28788..d6aa6e04b7af 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -890,7 +890,8 @@ static const struct file_operations fops_blob = { /** * debugfs_create_blob - create a debugfs file that is used to read a binary blob * @name: a pointer to a string containing the name of the file to create. - * @mode: the permission that the file should have + * @mode: the read permission that the file should have (other permissions are + * masked out) * @parent: a pointer to the parent dentry for this file. This should be a * directory dentry if set. If this parameter is %NULL, then the * file will be created in the root of the debugfs filesystem. @@ -914,7 +915,7 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode, struct dentry *parent, struct debugfs_blob_wrapper *blob) { - return debugfs_create_file_unsafe(name, mode, parent, blob, &fops_blob); + return debugfs_create_file_unsafe(name, mode & S_IRUGO, parent, blob, &fops_blob); } EXPORT_SYMBOL_GPL(debugfs_create_blob);