[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20140129104106.793524a07e48324a32dc6f06@linux-foundation.org>
Date: Wed, 29 Jan 2014 10:41:06 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Sebastian Capella <sebastian.capella@...aro.org>
Cc: "Eric W. Biederman" <ebiederm@...ssion.com>,
"Pavel Machek" <pavel@....cz>,
"Rafael J. Wysocki" <rjw@...ysocki.net>,
linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linaro-kernel@...ts.linaro.org, patches@...aro.org,
"Serge Hallyn" <serge.hallyn@...onical.com>,
"Stephen Warren" <swarren@...dia.com>,
"Jens Axboe" <axboe@...nel.dk>,
"Greg Kroah-Hartman" <gregkh@...uxfoundation.org>,
"Al Viro" <viro@...iv.linux.org.uk>
Subject: Re: [PATCH v3 1/2] init/do_mounts.c: ignore final \n in
name_to_dev_t
On Wed, 29 Jan 2014 10:29:56 -0800 Sebastian Capella <sebastian.capella@...aro.org> wrote:
> Hi Andrew,
>
> By the way, I do see a call (sysfs_streq) in use for this purpose
> other places. Sorry, I didn't find it while looking at the original
> problem. I'm not sure if this is preferable, but it appears to have
> been added specifically for the strings coming through sysfs.
Yes, I wrote it ;)
I didn't think sysfs_streq() is well suited to this problem. And the
issue of possibly-null-terminated-strings coming in from userspace is a
common one, so it is desirable that we build up the suite of utilities
to handle this.
There are probably quite a lot of open-coded \n trimming loops which
can be cleaned up using such tools.
grep -r "if .* == '\\\n'" .
> My preference is copying the string and cleaning it up before passing
> it to internal functions, even though we incur an allocation.
Yes. Here on the kernel/userspace boundary we are typically running in
GFP_KERNEL context and the code is not performance critical - it is a
good fit.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists