Re: [PATCH v3 1/2] init/do_mounts.c: ignore final \n inname_to_dev_t
From: Andrew Morton
Date: Wed Jan 29 2014 - 13:41:17 EST
On Wed, 29 Jan 2014 10:29:56 -0800 Sebastian Capella <sebastian.capella@xxxxxxxxxx> 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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/