From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-pm@vger.kernel.org
Subject: Re: [PATCH v1 1/3] PM / sysfs: Convert to use sysfs_streq()
Date: Wed, 15 Nov 2017 13:41:35 +0200 [thread overview]
Message-ID: <1510746095.25007.238.camel@linux.intel.com> (raw)
In-Reply-To: <20171115103252.GA32656@amd>
On Wed, 2017-11-15 at 11:32 +0100, Pavel Machek wrote:
> Hi!
>
> > ...instead of custom approach.
> >
> > const char * buf, size_t n)
> > {
> > - char *cp;
> > - int len = n;
> > -
> > - cp = memchr(buf, '\n', n);
> > - if (cp)
> > - len = cp - buf;
> > device_lock(dev);
> > - if (len == sizeof ctrl_auto - 1 && strncmp(buf, ctrl_auto,
> > len) == 0)
> > + if (sysfs_streq(buf, ctrl_auto))
> > pm_runtime_allow(dev);
> > - else if (len == sizeof ctrl_on - 1 && strncmp(buf, ctrl_on,
> > len) == 0)
> > + else if (sysfs_streq(buf, ctrl_on))
> > pm_runtime_forbid(dev);
> > else
> > n = -EINVAL;
>
> Are you sure?
Yes.
> _streq does not get passed size_t n; how does it
> guarantee no out-of-bounds access?
It's guaranteed by kernfs for every attribute that relies on it.
https://www.spinics.net/lists/kernel/msg2635067.html
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2017-11-16 13:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 18:28 [PATCH v1 1/3] PM / sysfs: Convert to use sysfs_streq() Andy Shevchenko
2017-11-10 18:28 ` [PATCH v1 2/3] PM / sysfs: Remove redundant 'else' keyword Andy Shevchenko
2017-11-15 12:01 ` Pavel Machek
2017-11-10 18:28 ` [PATCH v1 3/3] PM / sysfs: Convert to use DEVICE_ATTR_RO / DEVICE_ATTR_RW Andy Shevchenko
2017-11-15 12:04 ` Pavel Machek
2017-11-15 10:32 ` [PATCH v1 1/3] PM / sysfs: Convert to use sysfs_streq() Pavel Machek
2017-11-15 11:41 ` Andy Shevchenko [this message]
2017-11-15 12:01 ` Pavel Machek
2017-12-06 1:00 ` Rafael J. Wysocki
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=1510746095.25007.238.camel@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rjw@rjwysocki.net \
/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;
as well as URLs for NNTP newsgroup(s).