From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753363AbbCLKjZ (ORCPT ); Thu, 12 Mar 2015 06:39:25 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:40297 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751121AbbCLKjW (ORCPT ); Thu, 12 Mar 2015 06:39:22 -0400 Message-ID: <55016CC8.3070304@roeck-us.net> Date: Thu, 12 Mar 2015 03:39:04 -0700 From: Guenter Roeck User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Greg Kroah-Hartman , Vivien Didelot CC: linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com Subject: Re: [PATCH v2 2/3] sysfs: Only accept read/write permissions for file attributes References: <1426098131-20106-1-git-send-email-vivien.didelot@savoirfairelinux.com> <1426098131-20106-3-git-send-email-vivien.didelot@savoirfairelinux.com> <20150312100151.GD3682@kroah.com> In-Reply-To: <20150312100151.GD3682@kroah.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-CTCH-PVer: 0000001 X-CTCH-Spam: Unknown X-CTCH-VOD: Unknown X-CTCH-Flags: 0 X-CTCH-RefID: str=0001.0A020205.55016CD9.019D,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 X-CTCH-Score: 0.001 X-CTCH-ScoreCust: 0.000 X-CTCH-Rules: C_4847, X-CTCH-SenderID: linux@roeck-us.net X-CTCH-SenderID-Flags: 0 X-CTCH-SenderID-TotalMessages: 2 X-CTCH-SenderID-TotalSpam: 0 X-CTCH-SenderID-TotalSuspected: 0 X-CTCH-SenderID-TotalConfirmed: 0 X-CTCH-SenderID-TotalBulk: 0 X-CTCH-SenderID-TotalVirus: 0 X-CTCH-SenderID-TotalRecipients: 0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: mailgid no entry from get_relayhosts_entry X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/12/2015 03:01 AM, Greg Kroah-Hartman wrote: > On Wed, Mar 11, 2015 at 02:22:10PM -0400, Vivien Didelot wrote: >> For sysfs file attributes, only read and write permissions make sense. >> Mask provided attribute permissions accordingly and send a warning >> to the console if invalid permission bits are set. >> >> This patch is originally from Guenter [1] and includes the fixup >> explained in the thread, that is printing permissions in octal format >> and limiting the scope of attributes to SYSFS_PREALLOC | 0664. >> >> [1] https://lkml.org/lkml/2015/1/19/599 >> >> Cc: Guenter Roeck >> Signed-off-by: Vivien Didelot >> --- >> fs/sysfs/group.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c >> index 3fdccd9..b400c04 100644 >> --- a/fs/sysfs/group.c >> +++ b/fs/sysfs/group.c >> @@ -55,6 +55,12 @@ static int create_files(struct kernfs_node *parent, struct kobject *kobj, >> if (!mode) >> continue; >> } >> + >> + WARN(mode & ~(SYSFS_PREALLOC | 0664), >> + "Attribute %s: Invalid permissions 0%o\n", >> + (*attr)->name, mode); >> + >> + mode &= SYSFS_PREALLOC | 0664; > > How does a "normal" boot look with this warning in place? There still > seem to be a number of files in sysfs that might trigger this. > I was under the impression that they all were addressed, but I may have missed some pattern(s). Can you point me to an example, by any chance ? > Also, we have a build-time warning if a sysfs file is this type of > attribute, shouldn't we just rely on that instead of this run-time > warning? > The mode value can be returned from an is_visible function, and even if not there is no guarantee that the build-time warning triggers (attribute lists can be generated manually, for example). Thanks, Guenter