[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20121022161454.GC23199@sergelap>
Date: Mon, 22 Oct 2012 11:14:54 -0500
From: Serge Hallyn <serge.hallyn@...onical.com>
To: Aristeu Rozanski <aris@...hat.com>
Cc: linux-kernel@...r.kernel.org, Dave Jones <davej@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Tejun Heo <tj@...nel.org>, Li Zefan <lizefan@...wei.com>,
James Morris <jmorris@...ei.org>,
Pavel Emelyanov <xemul@...nvz.org>,
Jiri Slaby <jslaby@...e.cz>, cgroups@...r.kernel.org
Subject: Re: [PATCH 3/4] device_cgroup: stop using simple_strtoul()
Quoting Aristeu Rozanski (aris@...hat.com):
> This patch converts the code to use kstrtou32() instead of simple_strtoul()
> which is deprecated. The real size of the variables are u32, so use kstrtou32
> instead of kstrtoul
>
>
> Cc: Dave Jones <davej@...hat.com>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: Tejun Heo <tj@...nel.org>
> Cc: Li Zefan <lizefan@...wei.com>
> Cc: James Morris <jmorris@...ei.org>
> Cc: Pavel Emelyanov <xemul@...nvz.org>
> Cc: Serge Hallyn <serge.hallyn@...onical.com>
Acked-by: Serge E. Hallyn <serge.hallyn@...ntu.com>
> Cc: Jiri Slaby <jslaby@...e.cz>
> Signed-off-by: Aristeu Rozanski <aris@...hat.com>
>
> ---
> security/device_cgroup.c | 28 ++++++++++++++++++++++------
> 1 file changed, 22 insertions(+), 6 deletions(-)
>
> --- github.orig/security/device_cgroup.c 2012-10-19 16:35:46.366102913 -0400
> +++ github/security/device_cgroup.c 2012-10-19 16:35:50.801229331 -0400
> @@ -361,8 +361,8 @@ static int devcgroup_update_access(struc
> int filetype, const char *buffer)
> {
> const char *b;
> - char *endp;
> - int count;
> + char temp[12]; /* 11 + 1 characters needed for a u32 */
> + int count, rc;
> struct dev_exception_item ex;
>
> if (!capable(CAP_SYS_ADMIN))
> @@ -405,8 +405,16 @@ return 0;
> ex.major = ~0;
> b++;
> } else if (isdigit(*b)) {
> - ex.major = simple_strtoul(b, &endp, 10);
> - b = endp;
> + memset(temp, 0, sizeof(temp));
> + for (count = 0; count < sizeof(temp) - 1; count++) {
> + temp[count] = *b;
> + b++;
> + if (!isdigit(*b))
> + break;
> + }
> + rc = kstrtou32(temp, 10, &ex.major);
> + if (rc)
> + return -EINVAL;
> } else {
> return -EINVAL;
> }
> @@ -419,8 +427,16 @@ ex.major = simple_strtoul(b, &endp, 10
> ex.minor = ~0;
> b++;
> } else if (isdigit(*b)) {
> - ex.minor = simple_strtoul(b, &endp, 10);
> - b = endp;
> + memset(temp, 0, sizeof(temp));
> + for (count = 0; count < sizeof(temp) - 1; count++) {
> + temp[count] = *b;
> + b++;
> + if (!isdigit(*b))
> + break;
> + }
> + rc = kstrtou32(temp, 10, &ex.minor);
> + if (rc)
> + return -EINVAL;
> } else {
> return -EINVAL;
> }
>
--
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