All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kconfig: protect locale-unsafe calls
@ 2011-08-16  5:19 Arnaud Lacombe
  2011-08-16  5:21 ` Arnaud Lacombe
  2011-08-31 12:19 ` Michal Marek
  0 siblings, 2 replies; 6+ messages in thread
From: Arnaud Lacombe @ 2011-08-16  5:19 UTC (permalink / raw)
  To: linux-kbuild; +Cc: s.koylux, Arnaud Lacombe

There is a few calls in kconfig where we end-up using tolower(3) or toupper(3)
in an unsafe manner. As highlighted by Serdar, it would seem that Turkish's
locale do not have representable lowercase for the Engligh capital-dotless-i.

Introduces locale-safe portion in the backend where we reset the local to the
default "C".

Reported-by: Serdar KÖYLÜ <s.koylux@gmail.com>
Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
---
 scripts/kconfig/confdata.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 5a58965..7b1bbb8 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -828,6 +828,8 @@ static int conf_split_config(void)
 	if (chdir("include/config"))
 		return 1;
 
+	setlocale(LC_ALL, "C");
+
 	res = 0;
 	for_all_symbols(i, sym) {
 		sym_calc_value(sym);
@@ -918,6 +920,9 @@ static int conf_split_config(void)
 		}
 		close(fd);
 	}
+
+	setlocale(LC_ALL, "");
+
 out:
 	if (chdir("../.."))
 		return 1;
@@ -956,6 +961,8 @@ int conf_write_autoconf(void)
 		return 1;
 	}
 
+	setlocale(LC_ALL, "C");
+
 	conf_write_heading(out, &kconfig_printer_cb, NULL);
 
 	conf_write_heading(tristate, &tristate_printer_cb, NULL);
@@ -979,6 +986,9 @@ int conf_write_autoconf(void)
 
 		conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
 	}
+
+	setlocale(LC_ALL, "");
+
 	fclose(out);
 	fclose(tristate);
 	fclose(out_h);
-- 
1.7.6.153.g78432


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] kconfig: protect locale-unsafe calls
  2011-08-16  5:19 [PATCH] kconfig: protect locale-unsafe calls Arnaud Lacombe
@ 2011-08-16  5:21 ` Arnaud Lacombe
  2011-08-31 12:19 ` Michal Marek
  1 sibling, 0 replies; 6+ messages in thread
From: Arnaud Lacombe @ 2011-08-16  5:21 UTC (permalink / raw)
  To: linux-kbuild; +Cc: s.koylux, Arnaud Lacombe

Hi,

On Tue, Aug 16, 2011 at 1:19 AM, Arnaud Lacombe <lacombar@gmail.com> wrote:
> There is a few calls in kconfig where we end-up using tolower(3) or toupper(3)
> in an unsafe manner. As highlighted by Serdar, it would seem that Turkish's
> locale do not have representable lowercase for the Engligh capital-dotless-i.
>
> Introduces locale-safe portion in the backend where we reset the local to the
> default "C".
>
> Reported-by: Serdar KÖYLÜ <s.koylux@gmail.com>
> Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
>
This is not a perfect solution as we might writing stuff on the
console on those protected range, but that's a start.

 - Arnaud

> ---
>  scripts/kconfig/confdata.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index 5a58965..7b1bbb8 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -828,6 +828,8 @@ static int conf_split_config(void)
>        if (chdir("include/config"))
>                return 1;
>
> +       setlocale(LC_ALL, "C");
> +
>        res = 0;
>        for_all_symbols(i, sym) {
>                sym_calc_value(sym);
> @@ -918,6 +920,9 @@ static int conf_split_config(void)
>                }
>                close(fd);
>        }
> +
> +       setlocale(LC_ALL, "");
> +
>  out:
>        if (chdir("../.."))
>                return 1;
> @@ -956,6 +961,8 @@ int conf_write_autoconf(void)
>                return 1;
>        }
>
> +       setlocale(LC_ALL, "C");
> +
>        conf_write_heading(out, &kconfig_printer_cb, NULL);
>
>        conf_write_heading(tristate, &tristate_printer_cb, NULL);
> @@ -979,6 +986,9 @@ int conf_write_autoconf(void)
>
>                conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
>        }
> +
> +       setlocale(LC_ALL, "");
> +
>        fclose(out);
>        fclose(tristate);
>        fclose(out_h);
> --
> 1.7.6.153.g78432
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kconfig: protect locale-unsafe calls
  2011-08-16  5:19 [PATCH] kconfig: protect locale-unsafe calls Arnaud Lacombe
  2011-08-16  5:21 ` Arnaud Lacombe
@ 2011-08-31 12:19 ` Michal Marek
  2011-08-31 13:31   ` [PATCH] staging/cxt1e1: Header cleanup Michal Marek
                     ` (2 more replies)
  1 sibling, 3 replies; 6+ messages in thread
From: Michal Marek @ 2011-08-31 12:19 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: linux-kbuild, s.koylux

On 16.8.2011 07:19, Arnaud Lacombe wrote:
> There is a few calls in kconfig where we end-up using tolower(3) or toupper(3)
> in an unsafe manner. As highlighted by Serdar, it would seem that Turkish's
> locale do not have representable lowercase for the Engligh capital-dotless-i.
> 
> Introduces locale-safe portion in the backend where we reset the local to the
> default "C".
> 
> Reported-by: Serdar KÖYLÜ <s.koylux@gmail.com>
> Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
> ---
>  scripts/kconfig/confdata.c |   10 ++++++++++

I think that just changing kconfig will make things even worse, because
fixdep does the same operation (CONFIG_FOO -> include/config/foo.h) and
would get out of sync with kconfig now. I guess the direct cause for
Serdar's build failure was this staging driver:
drivers/staging/cxt1e1/sbecom_inline_linux.h:

    53  #if defined(CONFIG_MODVERSIONS) && defined(MODULE) && !
defined(MODVERSIONS)
    54  #define MODVERSIONS
    55  #endif
    56
    57  #ifdef MODULE
    58  #ifdef MODVERSIONS
    59  #include <config/modversions.h>
                  ^^^^^^^^^^^^^^^^^^^^
    60  #endif
    61  #include <linux/module.h>
    62  #endif
    63  #endif

I'll send a patch cleaning this up once I verify that it really is the
cause.

As for the tollower/toupper issue, I would propose a much simpler way:
Let's not try to be cute and simply use include/config/FOO_BAR.h for
each CONFIG_FOO_BAR. x86_64 allmodconfig results in some 5k symbols
enabled, I'm sure any filesystem will handle a directory with 5k files
in it.

Michal

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] staging/cxt1e1: Header cleanup
  2011-08-31 12:19 ` Michal Marek
@ 2011-08-31 13:31   ` Michal Marek
  2011-08-31 13:35   ` [PATCH] kconfig: protect locale-unsafe calls Arnaud Lacombe
  2011-09-01 14:23   ` Michal Marek
  2 siblings, 0 replies; 6+ messages in thread
From: Michal Marek @ 2011-08-31 13:31 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, Arnaud Lacombe, s.koylux, linux-kbuild, Bob Beers

Remove dead and unused code in sbecom_inline_linux.h. This also fixes a
build failure under Turkish locale, where include/config/modversions.h
is incorrectly named as modversIons.h (an unrelated kbuild bug) and the
driver tries to needlessly include the empty file.

Reported-by: Serdar KÖYLÜ <s.koylux@gmail.com>
Cc: Bob Beers <bob.beers@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
---
 drivers/staging/cxt1e1/sbecom_inline_linux.h |   64 --------------------------
 1 files changed, 0 insertions(+), 64 deletions(-)

diff --git a/drivers/staging/cxt1e1/sbecom_inline_linux.h b/drivers/staging/cxt1e1/sbecom_inline_linux.h
index c0563e6..9ea2c0c 100644
--- a/drivers/staging/cxt1e1/sbecom_inline_linux.h
+++ b/drivers/staging/cxt1e1/sbecom_inline_linux.h
@@ -43,81 +43,17 @@
  */
 
 
-#if defined (__FreeBSD__) || defined (__NetBSD__)
-#include <sys/types.h>
-#else
 #include <linux/types.h>
-#if defined(CONFIG_SMP) && ! defined(__SMP__)
-#define __SMP__
-#endif
-#if defined(CONFIG_MODVERSIONS) && defined(MODULE) && ! defined(MODVERSIONS)
-#define MODVERSIONS
-#endif
-
-#ifdef MODULE
-#ifdef MODVERSIONS
-#include <config/modversions.h>
-#endif
 #include <linux/module.h>
-#endif
-#endif
-
 #include <linux/kernel.h>       /* resolves kmalloc references */
 #include <linux/skbuff.h>       /* resolves skb references */
 #include <linux/netdevice.h>    /* resolves dev_kree_skb_any */
 #include <asm/byteorder.h>      /* resolves cpu_to_le32 */
 
-#if 0
-
-/*** PORT POINT WARNING
- ***
- *** Under Linux 2.6 it has been found that compiler is re-ordering
- *** in-lined pci_write_32() functions to the detrement of correct
- *** hardware setup.  Therefore, inlining of PCI accesses has been
- *** de-implemented, and subroutine calls have been implemented.
- ***/
-
-static inline u_int32_t
-pci_read_32 (u_int32_t *p)
-{
-#ifdef FLOW_DEBUG
-    u_int32_t   v;
-
-    FLUSH_PCI_READ ();
-    v = le32_to_cpu (*p);
-    if (cxt1e1_log_level >= LOG_DEBUG)
-        pr_info("pci_read : %x = %x\n", (u_int32_t) p, v);
-    return v;
-#else
-                FLUSH_PCI_READ ();      /* */
-    return le32_to_cpu (*p);
-#endif
-}
-
-static inline void
-pci_write_32 (u_int32_t *p, u_int32_t v)
-{
-#ifdef FLOW_DEBUG
-    if (cxt1e1_log_level >= LOG_DEBUG)
-        pr_info("pci_write: %x = %x\n", (u_int32_t) p, v);
-#endif
-    *p = cpu_to_le32 (v);
-    FLUSH_PCI_WRITE ();             /* This routine is called from routines
-                                     * which do multiple register writes
-                                     * which themselves need flushing between
-                                     * writes in order to guarantee write
-                                     * ordering.  It is less code-cumbersome
-                                     * to flush here-in then to investigate
-                                     * and code the many other register
-                                     * writing routines. */
-}
-#else
 /* forward reference */
 u_int32_t   pci_read_32 (u_int32_t *p);
 void        pci_write_32 (u_int32_t *p, u_int32_t v);
 
-#endif
-
 
 /*
  * system dependent callbacks
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] kconfig: protect locale-unsafe calls
  2011-08-31 12:19 ` Michal Marek
  2011-08-31 13:31   ` [PATCH] staging/cxt1e1: Header cleanup Michal Marek
@ 2011-08-31 13:35   ` Arnaud Lacombe
  2011-09-01 14:23   ` Michal Marek
  2 siblings, 0 replies; 6+ messages in thread
From: Arnaud Lacombe @ 2011-08-31 13:35 UTC (permalink / raw)
  To: Michal Marek; +Cc: linux-kbuild, s.koylux

Hi,

On Wed, Aug 31, 2011 at 8:19 AM, Michal Marek <mmarek@suse.cz> wrote:
> On 16.8.2011 07:19, Arnaud Lacombe wrote:
>> There is a few calls in kconfig where we end-up using tolower(3) or toupper(3)
>> in an unsafe manner. As highlighted by Serdar, it would seem that Turkish's
>> locale do not have representable lowercase for the Engligh capital-dotless-i.
>>
>> Introduces locale-safe portion in the backend where we reset the local to the
>> default "C".
>>
>> Reported-by: Serdar KÖYLÜ <s.koylux@gmail.com>
>> Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
>> ---
>>  scripts/kconfig/confdata.c |   10 ++++++++++
>
> I think that just changing kconfig will make things even worse, because
> fixdep does the same operation (CONFIG_FOO -> include/config/foo.h) and
> would get out of sync with kconfig now. I guess the direct cause for
> Serdar's build failure was this staging driver:
> drivers/staging/cxt1e1/sbecom_inline_linux.h:
>
>    53  #if defined(CONFIG_MODVERSIONS) && defined(MODULE) && !
> defined(MODVERSIONS)
>    54  #define MODVERSIONS
>    55  #endif
>    56
>    57  #ifdef MODULE
>    58  #ifdef MODVERSIONS
>    59  #include <config/modversions.h>
>                  ^^^^^^^^^^^^^^^^^^^^
>    60  #endif
>    61  #include <linux/module.h>
>    62  #endif
>    63  #endif
>
> I'll send a patch cleaning this up once I verify that it really is the
> cause.
>
> As for the tollower/toupper issue, I would propose a much simpler way:
> Let's not try to be cute and simply use include/config/FOO_BAR.h for
> each CONFIG_FOO_BAR. x86_64 allmodconfig results in some 5k symbols
> enabled, I'm sure any filesystem will handle a directory with 5k files
> in it.
>
fine with me.

 - Arnaud

> Michal
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kconfig: protect locale-unsafe calls
  2011-08-31 12:19 ` Michal Marek
  2011-08-31 13:31   ` [PATCH] staging/cxt1e1: Header cleanup Michal Marek
  2011-08-31 13:35   ` [PATCH] kconfig: protect locale-unsafe calls Arnaud Lacombe
@ 2011-09-01 14:23   ` Michal Marek
  2 siblings, 0 replies; 6+ messages in thread
From: Michal Marek @ 2011-09-01 14:23 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: linux-kbuild, s.koylux

On 31.8.2011 14:19, Michal Marek wrote:
> As for the tollower/toupper issue, I would propose a much simpler way:
> Let's not try to be cute and simply use include/config/FOO_BAR.h for
> each CONFIG_FOO_BAR. x86_64 allmodconfig results in some 5k symbols
> enabled, I'm sure any filesystem will handle a directory with 5k files
> in it.

Unfortunately, we can't do this, because updating from a tree that used
include/config/foo/bar.h would result in missed rebuilds :-(.

Michal

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-09-01 14:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-16  5:19 [PATCH] kconfig: protect locale-unsafe calls Arnaud Lacombe
2011-08-16  5:21 ` Arnaud Lacombe
2011-08-31 12:19 ` Michal Marek
2011-08-31 13:31   ` [PATCH] staging/cxt1e1: Header cleanup Michal Marek
2011-08-31 13:35   ` [PATCH] kconfig: protect locale-unsafe calls Arnaud Lacombe
2011-09-01 14:23   ` Michal Marek

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.