[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGXu5j+wYmD9H96dY738ALS2OVyeaCj-xjWm95LgGxnZ_ZcViw@mail.gmail.com>
Date: Thu, 18 Jul 2013 08:57:12 -0700
From: Kees Cook <keescook@...omium.org>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: "Yann E. MORIN" <yann.morin.1998@...e.fr>,
linux-kbuild <linux-kbuild@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Michal Marek <mmarek@...e.cz>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 1/1] kconfig: allow "hex" and "range" to support longs
On Thu, Jul 18, 2013 at 3:08 AM, Geert Uytterhoeven
<geert@...ux-m68k.org> wrote:
> On Sat, Jun 29, 2013 at 4:21 PM, Yann E. MORIN <yann.morin.1998@...e.fr> wrote:
>> From: Kees Cook <keescook@...omium.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@...omium.org>
>> Tested-by: "Yann E. MORIN" <yann.morin.1998@...e.fr>
>> Reviewed-by: "Yann E. MORIN" <yann.morin.1998@...e.fr>
>> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@...e.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
--
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