From: Sebastian Capella <sebastian.capella@linaro.org>
To: Pavel Machek <pavel@ucw.cz>
Cc: len.brown@intel.com, linaro-dev@lists.linaro.org,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
rjw@sisk.pl, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH RFC 1/2] PM / Hibernate: use name_to_dev_t to parse resume
Date: Fri, 30 Aug 2013 11:42:30 -0700 [thread overview]
Message-ID: <20130830184230.28518.71814@capellas-linux> (raw)
In-Reply-To: <20130830113533.GA7226@amd.pavel.ucw.cz>
Quoting Pavel Machek (2013-08-30 04:35:33)
> On Mon 2013-08-26 10:40:50, Sebastian Capella wrote:
> > Quoting Pavel Machek (2013-08-25 08:38:11)
> > > Is the allocation actually neccessary? At the very least this should
> > > test for NULL...
> >
> > name_to_dev_t expects a non-const name, but the buffer passed in
> > is const. I also am removing the '\n' if found at the end of the
> > string which would violate the const.
>
> Fix name_to_dev_t, then. No need to do memory allocation just to work
> around const.
>
Hi Pavel,
The issue is really Removing the \n from the user space input. The
flow is:
const input buf -> copy to work buffer, remove newline -> name_to_dev_t
ssize_t resume_store(..., const char *buf, size_t n)
// copy buf, strip off trailing newline, pass to name_to_dev_t
dev_t name_to_dev_t(char *name)
The const in the restore_store buffer comes from the function type of the
store member of the kobj_attribute. I don't believe this should be changed.
Currently, name_to_dev_t will fail in some cases if a trailing \n is present.
Is it more appropriate to handle stripping the newline in the store
function rather than modifying name_to_dev_t to clean it up?
It seems logical for name_to_dev_t to take a const name parameter as
there should be no reason to modify the name buffer passed to it.
I'll be happy to make a patch to do this, but without hardening
name_to_dev_t against trailing newlines, it would not be neccesary for
this problem.
Thanks for your time and comments!
Sebastian
next prev parent reply other threads:[~2013-08-30 18:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-21 19:46 [PATCH RFC 0/2] PM / Hibernate: sysfs resume Sebastian Capella
2013-08-21 19:46 ` [PATCH RFC 1/2] PM / Hibernate: use name_to_dev_t to parse resume Sebastian Capella
2013-08-25 15:38 ` Pavel Machek
[not found] ` <20130825153811.GA4795-tWAi6jLit6GreWDznjuHag@public.gmane.org>
2013-08-26 17:10 ` Sebastian Capella
2013-08-26 17:40 ` Sebastian Capella
2013-08-30 11:35 ` Pavel Machek
2013-08-30 18:42 ` Sebastian Capella [this message]
2013-09-17 20:50 ` Sebastian Capella
2013-09-18 13:01 ` Pavel Machek
2013-08-21 19:46 ` [PATCH RFC 2/2] PM / Hibernate: add section for resume options Sebastian Capella
2013-09-05 11:56 ` Pavel Machek
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=20130830184230.28518.71814@capellas-linux \
--to=sebastian.capella@linaro.org \
--cc=len.brown@intel.com \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
/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).