* [pull request] Pull request for branch yem-kconfig-for-next @ 2013-06-29 14:21 Yann E. MORIN 2013-06-29 14:21 ` [PATCH 1/1] kconfig: allow "hex" and "range" to support longs Yann E. MORIN 0 siblings, 1 reply; 4+ messages in thread From: Yann E. MORIN @ 2013-06-29 14:21 UTC (permalink / raw) To: linux-kbuild; +Cc: linux-kernel, Michal Marek, Yann E. MORIN, Kees Cook From: "Yann E. MORIN" <yann.morin.1998@free.fr> Hello Michal, All, Please pull this kconfig fix from Kees that enables 64-bit-wide (ie. signed long) [int,hex] ranges. Regards, Yann E. MORIN. The following changes since commit 490f16171119a16e05d670306c105f3b45c38837: Revert "kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG" (2013-06-26 15:49:00 +0200) are available in the git repository at: git://gitorious.org/linux-kconfig/linux-kconfig.git yem-kconfig-for-next for you to fetch changes up to b57caaaed2bd127fe656e6c145970ed6a05c0125: kconfig: allow "hex" and "range" to support longs (2013-06-29 15:30:17 +0200) ---------------------------------------------------------------- Kees Cook (1): kconfig: allow "hex" and "range" to support longs scripts/kconfig/symbol.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- .-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/1] kconfig: allow "hex" and "range" to support longs 2013-06-29 14:21 [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN @ 2013-06-29 14:21 ` Yann E. MORIN 2013-07-18 10:08 ` Geert Uytterhoeven 0 siblings, 1 reply; 4+ messages in thread From: Yann E. MORIN @ 2013-06-29 14:21 UTC (permalink / raw) To: linux-kbuild; +Cc: linux-kernel, Michal Marek, Kees Cook, Yann E. MORIN From: Kees Cook <keescook@chromium.org> The parsing routines for Kconfig files use strtol(), but store and render values as int. Switch types and formating to long to support a wider range of values. For example, 0x80000000 wasn't representable. Signed-off-by: Kees Cook <keescook@chromium.org> Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> --- scripts/kconfig/symbol.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 387d554..d550300 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym) return NULL; } -static int sym_get_range_val(struct symbol *sym, int base) +static long sym_get_range_val(struct symbol *sym, int base) { sym_calc_value(sym); switch (sym->type) { @@ -155,7 +155,7 @@ static int sym_get_range_val(struct symbol *sym, int base) static void sym_validate_range(struct symbol *sym) { struct property *prop; - int base, val, val2; + long base, val, val2; char str[64]; switch (sym->type) { @@ -179,9 +179,9 @@ static void sym_validate_range(struct symbol *sym) return; } if (sym->type == S_INT) - sprintf(str, "%d", val2); + sprintf(str, "%ld", val2); else - sprintf(str, "0x%x", val2); + sprintf(str, "0x%lx", val2); sym->curr.val = strdup(str); } @@ -594,7 +594,7 @@ bool sym_string_valid(struct symbol *sym, const char *str) bool sym_string_within_range(struct symbol *sym, const char *str) { struct property *prop; - int val; + long val; switch (sym->type) { case S_STRING: -- 1.8.1.2 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] kconfig: allow "hex" and "range" to support longs 2013-06-29 14:21 ` [PATCH 1/1] kconfig: allow "hex" and "range" to support longs Yann E. MORIN @ 2013-07-18 10:08 ` Geert Uytterhoeven 2013-07-18 15:57 ` Kees Cook 0 siblings, 1 reply; 4+ messages in thread From: Geert Uytterhoeven @ 2013-07-18 10:08 UTC (permalink / raw) To: Yann E. MORIN, Kees Cook Cc: linux-kbuild, linux-kernel, Michal Marek, Andrew Morton On Sat, Jun 29, 2013 at 4:21 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote: > From: Kees Cook <keescook@chromium.org> > > The parsing routines for Kconfig files use strtol(), but store and > render values as int. Switch types and formating to long to support a > wider range of values. For example, 0x80000000 wasn't representable. 0x80000000 does fit in an int. If it's printed as hex, it's treated as unsigned. Is there a "0" missing, or am I missing something? > Signed-off-by: Kees Cook <keescook@chromium.org> > Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr> > Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr> > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> > --- > scripts/kconfig/symbol.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c > index 387d554..d550300 100644 > --- a/scripts/kconfig/symbol.c > +++ b/scripts/kconfig/symbol.c > @@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym) > return NULL; > } > > -static int sym_get_range_val(struct symbol *sym, int base) > +static long sym_get_range_val(struct symbol *sym, int base) > { > sym_calc_value(sym); > switch (sym->type) { Changing all these "int" to "long" only matters on 64-bit platforms. As kconfig is built on the host, this will cause different behavior when cross-compiling 64-bit (I assume that's where you need it most) kernels on a 32-bit or a 64-bit host. Probably you wanted to use "long long" instead of "long", and switch to "strtoll()", to make them always 64-bit? Still, beware using 64-bit config symbols with arithmetic shell operations from a Makefile, cfr. https://lkml.org/lkml/2013/6/13/200. Sorry for only noticing now, after it went into 3.11-rc1. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] kconfig: allow "hex" and "range" to support longs 2013-07-18 10:08 ` Geert Uytterhoeven @ 2013-07-18 15:57 ` Kees Cook 0 siblings, 0 replies; 4+ messages in thread From: Kees Cook @ 2013-07-18 15:57 UTC (permalink / raw) To: Geert Uytterhoeven Cc: Yann E. MORIN, linux-kbuild, linux-kernel, Michal Marek, Andrew Morton On Thu, Jul 18, 2013 at 3:08 AM, Geert Uytterhoeven <geert@linux-m68k.org> wrote: > On Sat, Jun 29, 2013 at 4:21 PM, Yann E. MORIN <yann.morin.1998@free.fr> wrote: >> From: Kees Cook <keescook@chromium.org> >> >> The parsing routines for Kconfig files use strtol(), but store and >> render values as int. Switch types and formating to long to support a >> wider range of values. For example, 0x80000000 wasn't representable. > > 0x80000000 does fit in an int. If it's printed as hex, it's treated as unsigned. > Is there a "0" missing, or am I missing something? 0x80000000 is 1 more than INT_MAX, but you're right about the hex printing. Regardless, it was still being truncated in kconfig (probably due to signed comparisons). I had to switch the formatting since the type changed, though. >> Signed-off-by: Kees Cook <keescook@chromium.org> >> Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr> >> Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr> >> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> >> --- >> scripts/kconfig/symbol.c | 10 +++++----- >> 1 file changed, 5 insertions(+), 5 deletions(-) >> >> diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c >> index 387d554..d550300 100644 >> --- a/scripts/kconfig/symbol.c >> +++ b/scripts/kconfig/symbol.c >> @@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym) >> return NULL; >> } >> >> -static int sym_get_range_val(struct symbol *sym, int base) >> +static long sym_get_range_val(struct symbol *sym, int base) >> { >> sym_calc_value(sym); >> switch (sym->type) { > > Changing all these "int" to "long" only matters on 64-bit platforms. > As kconfig is built on the host, this will cause different behavior when > cross-compiling 64-bit (I assume that's where you need it most) kernels > on a 32-bit or a 64-bit host. > > Probably you wanted to use "long long" instead of "long", and switch > to "strtoll()", to make them always 64-bit? That's an excellent point; I hadn't considered the cross-compiling from a 32-bit host. > Still, beware using 64-bit config symbols with arithmetic shell operations from > a Makefile, cfr. https://lkml.org/lkml/2013/6/13/200. Yeah, noted. I don't have plans to pass kconfig items through the shell. > Sorry for only noticing now, after it went into 3.11-rc1. Thanks for pointing it out! I don't think there is huge urgency since nothing is (yet) using > INT_MAX values in kconfig. Regardless, I'll send a new patch that switches to long long. -Kees -- Kees Cook Chrome OS Security ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-07-18 15:57 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-06-29 14:21 [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN 2013-06-29 14:21 ` [PATCH 1/1] kconfig: allow "hex" and "range" to support longs Yann E. MORIN 2013-07-18 10:08 ` Geert Uytterhoeven 2013-07-18 15:57 ` Kees Cook
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.