From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com
Subject: Re: [PATCH] sysfs: group: allow is_visible to drop permissions
Date: Sat, 17 Jan 2015 19:11:26 -0800 [thread overview]
Message-ID: <20150118031126.GA8929@kroah.com> (raw)
In-Reply-To: <54BB102B.1060606@roeck-us.net>
On Sat, Jan 17, 2015 at 05:45:15PM -0800, Guenter Roeck wrote:
> On 01/17/2015 02:09 PM, Vivien Didelot wrote:
> >Hi Guenter, Greg,
> >
> [ .. ]
>
> >
> >BTW Guenter, does this patch make sense to you?
> >
>
> It does make sense to me to only use the return value from is_visible
> for the mode.
>
> As for which bits to use, I am not entirely sure. I think it would be
> more important to first decide which bits should be acceptable to start with.
>
> Then I would _always_ only use the bits from mode, masked against the
> valid bits, whatever they are.
>
> umode_t mode = (*attr)->mode;
> ...
> if (grp->is_visible) {
> mode = grp->is_visible(kobj, *attr, i);
> if (!mode)
> continue;
> }
>
> WARN(mode & ~(S_IRUGO | S_IWUGO | SYSFS_PREALLOC), /* optional */
> "Attribute %s: Invalid permission 0x%x\n", (*attr)->name, mode);
>
> mode &= S_IRUGO | S_IWUGO | SYSFS_PREALLOC;
> error = sysfs_add_file_mode_ns(parent, *attr, false, mode, NULL);
> ...
>
> >
> >My assumption here was that the attribute group is_visible function
> >should just be able to adjust the UGO bits. Am I correct?
> >
> I would think so.
>
> >I'm not even sure about the execute permission though. Only one driver
> >uses it for an attribute and it seems wrong, in drivers/hid/hid-lg4ff.c:
> >
> >static DEVICE_ATTR(range, S_IRWXU | S_IRWXG | S_IROTH, lg4ff_range_show, lg4ff_range_store);
> >
> That seems wrong.
>
> >
> >The actual behavior seems wrong to me. Again, what happens is you return
> >SYSFS_PREALLOC, that the underlying sysfs_add_file_mode_ns() function is
> >actually checking?
> >
> Ultimately, the implementor asked for it.
>
> >IMHO, if we want an attribute group to only be able to "hide or show" an
> >attribute, then is_visible (as the name suggests) should return a
> >boolean. If we want it be able to adjust permissions (as it seems
> >correct, given the examples), we should identify which permissions are
> >OK to change, deprecate is_visible function (to avoid code break) in
> >favor of a new one which limits the bits to that scope.
> >
>
> Up to Greg to decide. From my perspective, we have lived with is_visible
> for several years and overall it seems to work. Sure, it lacks a clear
> API, but that can be fixed without changing a lot of code just to replace
> the function name.
If someone wants to submit a "cleaner" patch, I'm always willing to
review it, but the one submitted here I can't take for the reasons I
gave at the least.
thanks,
greg k-h
prev parent reply other threads:[~2015-01-18 3:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-16 21:29 [PATCH] sysfs: group: allow is_visible to drop permissions Vivien Didelot
2015-01-16 22:21 ` Greg Kroah-Hartman
2015-01-17 0:22 ` Vivien Didelot
2015-01-17 1:52 ` Guenter Roeck
2015-01-17 14:12 ` Greg Kroah-Hartman
2015-01-17 22:09 ` Vivien Didelot
2015-01-18 1:45 ` Guenter Roeck
2015-01-18 3:11 ` Greg Kroah-Hartman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150118031126.GA8929@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=kernel@savoirfairelinux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=vivien.didelot@savoirfairelinux.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox