From patchwork Mon May 17 10:07:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 12261483 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=-13.8 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,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED,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 EF805C43460 for ; Mon, 17 May 2021 10:07:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D00DF611CA for ; Mon, 17 May 2021 10:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236080AbhEQKJH (ORCPT ); Mon, 17 May 2021 06:09:07 -0400 Received: from www.zeus03.de ([194.117.254.33]:39460 "EHLO mail.zeus03.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236032AbhEQKJG (ORCPT ); Mon, 17 May 2021 06:09:06 -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=nawEMLzWlS0z6SB6yinf2i6bYvZ JtCd1L00esRlOOSQ=; b=iQH4JncmIEYqYR5Y5C0bayD9dUUJvz0Yj9Ux86WVo1e V61mXl4miun7POG6lfpDrdtxcFid5cwlLiMXcSkzSA6+LtNMebIrbX1rKYd2JCGq kPLj9BE8h8EKaEIMPL2V/fcno0Po4xAiX3yC0EdjWVV5+2hWqk3qpMNuw+wBTiiY = Received: (qmail 2471376 invoked from network); 17 May 2021 12:07:47 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 17 May 2021 12:07:47 +0200 X-UD-Smtp-Session: l3s3148p1@8sD1w4PC/LggARa4RYY7ATBvQ5FTVwg4 From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Andy Shevchenko , Corentin Chary , Hans de Goede , Mark Gross , platform-driver-x86@vger.kernel.org Subject: [PATCH v3 1/2] platform/x86: samsung-laptop: use octal numbers for rwx file permissions Date: Mon, 17 May 2021 12:07:44 +0200 Message-Id: <20210517100746.29663-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Andy asked me to do it before working further on the code. Reviewed-by: Andy Shevchenko Signed-off-by: Wolfram Sang --- change since v2: added Andy's tag drivers/platform/x86/samsung-laptop.c | 35 +++++++++++---------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c index d5cec6e35bb8..763d97cbbe53 100644 --- a/drivers/platform/x86/samsung-laptop.c +++ b/drivers/platform/x86/samsung-laptop.c @@ -388,7 +388,7 @@ MODULE_PARM_DESC(force, "Disable the DMI check and forces the driver to be loaded"); static bool debug; -module_param(debug, bool, S_IRUGO | S_IWUSR); +module_param(debug, bool, 0644); MODULE_PARM_DESC(debug, "Debug enabled or not"); static int sabi_command(struct samsung_laptop *samsung, u16 command, @@ -705,7 +705,7 @@ static ssize_t set_performance_level(struct device *dev, return count; } -static DEVICE_ATTR(performance_level, S_IWUSR | S_IRUGO, +static DEVICE_ATTR(performance_level, 0644, get_performance_level, set_performance_level); static int read_battery_life_extender(struct samsung_laptop *samsung) @@ -774,7 +774,7 @@ static ssize_t set_battery_life_extender(struct device *dev, return count; } -static DEVICE_ATTR(battery_life_extender, S_IWUSR | S_IRUGO, +static DEVICE_ATTR(battery_life_extender, 0644, get_battery_life_extender, set_battery_life_extender); static int read_usb_charge(struct samsung_laptop *samsung) @@ -843,7 +843,7 @@ static ssize_t set_usb_charge(struct device *dev, return count; } -static DEVICE_ATTR(usb_charge, S_IWUSR | S_IRUGO, +static DEVICE_ATTR(usb_charge, 0644, get_usb_charge, set_usb_charge); static int read_lid_handling(struct samsung_laptop *samsung) @@ -908,7 +908,7 @@ static ssize_t set_lid_handling(struct device *dev, return count; } -static DEVICE_ATTR(lid_handling, S_IWUSR | S_IRUGO, +static DEVICE_ATTR(lid_handling, 0644, get_lid_handling, set_lid_handling); static struct attribute *platform_attributes[] = { @@ -1291,24 +1291,17 @@ static void samsung_debugfs_init(struct samsung_laptop *samsung) samsung->debug.sdiag_wrapper.data = samsung->sdiag; samsung->debug.sdiag_wrapper.size = strlen(samsung->sdiag); - debugfs_create_u16("command", S_IRUGO | S_IWUSR, root, - &samsung->debug.command); - debugfs_create_u32("d0", S_IRUGO | S_IWUSR, root, - &samsung->debug.data.d0); - debugfs_create_u32("d1", S_IRUGO | S_IWUSR, root, - &samsung->debug.data.d1); - debugfs_create_u16("d2", S_IRUGO | S_IWUSR, root, - &samsung->debug.data.d2); - debugfs_create_u8("d3", S_IRUGO | S_IWUSR, root, - &samsung->debug.data.d3); - debugfs_create_blob("data", S_IRUGO | S_IWUSR, root, - &samsung->debug.data_wrapper); - debugfs_create_blob("f0000_segment", S_IRUSR | S_IWUSR, root, + debugfs_create_u16("command", 0644, root, &samsung->debug.command); + debugfs_create_u32("d0", 0644, root, &samsung->debug.data.d0); + debugfs_create_u32("d1", 0644, root, &samsung->debug.data.d1); + debugfs_create_u16("d2", 0644, root, &samsung->debug.data.d2); + debugfs_create_u8("d3", 0644, root, &samsung->debug.data.d3); + debugfs_create_blob("data", 0644, root, &samsung->debug.data_wrapper); + debugfs_create_blob("f0000_segment", 0600, root, &samsung->debug.f0000_wrapper); - debugfs_create_file("call", S_IFREG | S_IRUGO, root, samsung, + debugfs_create_file("call", S_IFREG | 0444, root, samsung, &samsung_laptop_call_fops); - debugfs_create_blob("sdiag", S_IRUGO | S_IWUSR, root, - &samsung->debug.sdiag_wrapper); + debugfs_create_blob("sdiag", 0644, root, &samsung->debug.sdiag_wrapper); } static void samsung_sabi_exit(struct samsung_laptop *samsung) From patchwork Mon May 17 10:07:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 12261481 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,URIBL_BLOCKED,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 5E745C433B4 for ; Mon, 17 May 2021 10:07:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4202B6121F for ; Mon, 17 May 2021 10:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236209AbhEQKJH (ORCPT ); Mon, 17 May 2021 06:09:07 -0400 Received: from www.zeus03.de ([194.117.254.33]:39464 "EHLO mail.zeus03.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236080AbhEQKJG (ORCPT ); Mon, 17 May 2021 06:09:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=Z0f6aV6NsliMjT tzNpWaoTKaZ24I1TbtLb9a3MIBU8E=; b=IMma1yLQIWMkbtuv0zbkIFwbyX5W5r ZLnD4j2IwGmswWWiB/Jw+VrtAVRvqcKByzwJ0uPrOWfQaOEANDBnPqf01obQlfTb 6vDsK9Ag137TOvQF1WymA3DAUHemcFJPnmfTtQAKkOyI3mWm+iW76El4ZtM1Kkhg /FnaoxL3M1GdI= Received: (qmail 2471414 invoked from network); 17 May 2021 12:07:48 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 17 May 2021 12:07:48 +0200 X-UD-Smtp-Session: l3s3148p1@luD9w4PC/rggARa4RYY7ATBvQ5FTVwg4 From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Andy Shevchenko , Corentin Chary , Hans de Goede , Mark Gross , platform-driver-x86@vger.kernel.org Subject: [PATCH v3 2/2] platform/x86: samsung-laptop: set debugfs blobs to read only Date: Mon, 17 May 2021 12:07:45 +0200 Message-Id: <20210517100746.29663-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210517100746.29663-1-wsa+renesas@sang-engineering.com> References: <20210517100746.29663-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Those blobs can only be read. So, don't confuse users with 'writable' flags. Also, remove S_IFREG because debugfs takes care of that. Reviewed-by: Andy Shevchenko Signed-off-by: Wolfram Sang --- change since v2: added Andy's tag and removed S_IFREG drivers/platform/x86/samsung-laptop.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c index 763d97cbbe53..7ee010aa740a 100644 --- a/drivers/platform/x86/samsung-laptop.c +++ b/drivers/platform/x86/samsung-laptop.c @@ -1296,12 +1296,12 @@ static void samsung_debugfs_init(struct samsung_laptop *samsung) debugfs_create_u32("d1", 0644, root, &samsung->debug.data.d1); debugfs_create_u16("d2", 0644, root, &samsung->debug.data.d2); debugfs_create_u8("d3", 0644, root, &samsung->debug.data.d3); - debugfs_create_blob("data", 0644, root, &samsung->debug.data_wrapper); - debugfs_create_blob("f0000_segment", 0600, root, + debugfs_create_blob("data", 0444, root, &samsung->debug.data_wrapper); + debugfs_create_blob("f0000_segment", 0400, root, &samsung->debug.f0000_wrapper); - debugfs_create_file("call", S_IFREG | 0444, root, samsung, + debugfs_create_file("call", 0444, root, samsung, &samsung_laptop_call_fops); - debugfs_create_blob("sdiag", 0644, root, &samsung->debug.sdiag_wrapper); + debugfs_create_blob("sdiag", 0444, root, &samsung->debug.sdiag_wrapper); } static void samsung_sabi_exit(struct samsung_laptop *samsung)