From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755640Ab2JVQPD (ORCPT ); Mon, 22 Oct 2012 12:15:03 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:42816 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751938Ab2JVQPA (ORCPT ); Mon, 22 Oct 2012 12:15:00 -0400 Date: Mon, 22 Oct 2012 11:14:54 -0500 From: Serge Hallyn To: Aristeu Rozanski Cc: linux-kernel@vger.kernel.org, Dave Jones , Andrew Morton , Tejun Heo , Li Zefan , James Morris , Pavel Emelyanov , Jiri Slaby , cgroups@vger.kernel.org Subject: Re: [PATCH 3/4] device_cgroup: stop using simple_strtoul() Message-ID: <20121022161454.GC23199@sergelap> References: <20121022134536.172969567@napanee.usersys.redhat.com> <20121022134537.125748392@napanee.usersys.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121022134537.125748392@napanee.usersys.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Aristeu Rozanski (aris@redhat.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 > Cc: Andrew Morton > Cc: Tejun Heo > Cc: Li Zefan > Cc: James Morris > Cc: Pavel Emelyanov > Cc: Serge Hallyn Acked-by: Serge E. Hallyn > Cc: Jiri Slaby > Signed-off-by: Aristeu Rozanski > > --- > 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; > } > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Serge Hallyn Subject: Re: [PATCH 3/4] device_cgroup: stop using simple_strtoul() Date: Mon, 22 Oct 2012 11:14:54 -0500 Message-ID: <20121022161454.GC23199@sergelap> References: <20121022134536.172969567@napanee.usersys.redhat.com> <20121022134537.125748392@napanee.usersys.redhat.com> Mime-Version: 1.0 Return-path: Content-Disposition: inline In-Reply-To: <20121022134537.125748392-cd6kKtb6gxi3M6m420IelR/sF2h8X+2i0E9HWUfgJXw@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Aristeu Rozanski Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Dave Jones , Andrew Morton , Tejun Heo , Li Zefan , James Morris , Pavel Emelyanov , Jiri Slaby , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Quoting Aristeu Rozanski (aris-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org): > 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 > Cc: Andrew Morton > Cc: Tejun Heo > Cc: Li Zefan > Cc: James Morris > Cc: Pavel Emelyanov > Cc: Serge Hallyn Acked-by: Serge E. Hallyn > Cc: Jiri Slaby > Signed-off-by: Aristeu Rozanski > > --- > 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; > } >