* [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules
@ 2011-06-27 22:15 Richard Weinberger
2011-06-27 22:15 ` [PATCH 2/4] um: Add netpoll support Richard Weinberger
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Richard Weinberger @ 2011-06-27 22:15 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, user-mode-linux-devel, Richard Weinberger
When UML is compiled with _FORTIFY_SOURCE we have to
export all _chk() functions which are used in modules.
For now it's only the case for __sprintf_chk().
Tested-by: Florian Fainelli <florian@openwrt.org>
Reported-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
arch/um/os-Linux/user_syms.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c
index 05f5ea8..45ffe46 100644
--- a/arch/um/os-Linux/user_syms.c
+++ b/arch/um/os-Linux/user_syms.c
@@ -113,3 +113,8 @@ EXPORT_SYMBOL(__stack_smash_handler);
extern long __guard __attribute__((weak));
EXPORT_SYMBOL(__guard);
+
+#ifdef _FORTIFY_SOURCE
+extern int __sprintf_chk(char *str, int flag, size_t strlen, const char *format);
+EXPORT_SYMBOL(__sprintf_chk);
+#endif
--
1.7.5.4
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH 2/4] um: Add netpoll support 2011-06-27 22:15 [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules Richard Weinberger @ 2011-06-27 22:15 ` Richard Weinberger 2011-06-27 22:15 ` [PATCH 3/4] um, exec: remove redundant set_fs(USER_DS) Richard Weinberger ` (2 subsequent siblings) 3 siblings, 0 replies; 9+ messages in thread From: Richard Weinberger @ 2011-06-27 22:15 UTC (permalink / raw) To: akpm; +Cc: linux-kernel, user-mode-linux-devel, Richard Weinberger To make netconsole usable on UML, it's ethernet driver needs netpoll support. Signed-off-by: Richard Weinberger <richard@nod.at> --- arch/um/drivers/net_kern.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index 47d0c37..22745b4 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c @@ -262,6 +262,15 @@ static int uml_net_change_mtu(struct net_device *dev, int new_mtu) return 0; } +#ifdef CONFIG_NET_POLL_CONTROLLER +static void uml_net_poll_controller(struct net_device *dev) +{ + disable_irq(dev->irq); + uml_net_interrupt(dev->irq, dev); + enable_irq(dev->irq); +} +#endif + static void uml_net_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { @@ -364,6 +373,9 @@ static const struct net_device_ops uml_netdev_ops = { .ndo_set_mac_address = eth_mac_addr, .ndo_change_mtu = uml_net_change_mtu, .ndo_validate_addr = eth_validate_addr, +#ifdef CONFIG_NET_POLL_CONTROLLER + .ndo_poll_controller = uml_net_poll_controller, +#endif }; /* -- 1.7.5.4 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/4] um, exec: remove redundant set_fs(USER_DS) 2011-06-27 22:15 [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules Richard Weinberger 2011-06-27 22:15 ` [PATCH 2/4] um: Add netpoll support Richard Weinberger @ 2011-06-27 22:15 ` Richard Weinberger 2011-06-27 22:15 ` [PATCH 4/4] um: Reinstate kernel version in generated .config Richard Weinberger 2011-06-29 15:37 ` [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules Vitaliy Ivanov 3 siblings, 0 replies; 9+ messages in thread From: Richard Weinberger @ 2011-06-27 22:15 UTC (permalink / raw) To: akpm Cc: linux-kernel, user-mode-linux-devel, Mathias Krause, Richard Weinberger From: Mathias Krause <minipli@googlemail.com> The address limit is already set in flush_old_exec() so this set_fs(USER_DS) is redundant. Signed-off-by: Mathias Krause <minipli@googlemail.com> Cc: Richard Weinberger <richard@nod.at> Signed-off-by: Richard Weinberger <richard@nod.at> --- arch/um/kernel/exec.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c index 09bd7b5..939a4a6 100644 --- a/arch/um/kernel/exec.c +++ b/arch/um/kernel/exec.c @@ -38,7 +38,6 @@ void flush_thread(void) void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp) { - set_fs(USER_DS); PT_REGS_IP(regs) = eip; PT_REGS_SP(regs) = esp; } -- 1.7.5.4 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/4] um: Reinstate kernel version in generated .config 2011-06-27 22:15 [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules Richard Weinberger 2011-06-27 22:15 ` [PATCH 2/4] um: Add netpoll support Richard Weinberger 2011-06-27 22:15 ` [PATCH 3/4] um, exec: remove redundant set_fs(USER_DS) Richard Weinberger @ 2011-06-27 22:15 ` Richard Weinberger 2011-06-29 15:37 ` [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules Vitaliy Ivanov 3 siblings, 0 replies; 9+ messages in thread From: Richard Weinberger @ 2011-06-27 22:15 UTC (permalink / raw) To: akpm Cc: linux-kernel, user-mode-linux-devel, Geert Uytterhoeven, Richard Weinberger From: Geert Uytterhoeven <geert@linux-m68k.org> commit 0954828fcbf3bd13d593499b16b901a4e801b0b9 ("kconfig: replace KERNELVERSION usage by the mainmenu's prompt") made the kernel version disappear from the generated .config file when configuring for UML. As UML's Kconfig doesn't have a mainmenu, kconfig falls back to the default string "Linux Kernel Configuration". Add a suitable mainmenu to the main UML Kconfig file to fix this. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Richard Weinberger <richard@nod.at> --- arch/um/Kconfig.x86 | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/arch/um/Kconfig.x86 b/arch/um/Kconfig.x86 index 8aae429..d31ecf3 100644 --- a/arch/um/Kconfig.x86 +++ b/arch/um/Kconfig.x86 @@ -1,3 +1,5 @@ +mainmenu "User Mode Linux/$SUBARCH $KERNELVERSION Kernel Configuration" + source "arch/um/Kconfig.common" menu "UML-specific options" -- 1.7.5.4 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules 2011-06-27 22:15 [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules Richard Weinberger ` (2 preceding siblings ...) 2011-06-27 22:15 ` [PATCH 4/4] um: Reinstate kernel version in generated .config Richard Weinberger @ 2011-06-29 15:37 ` Vitaliy Ivanov 2011-06-29 15:42 ` Richard Weinberger 3 siblings, 1 reply; 9+ messages in thread From: Vitaliy Ivanov @ 2011-06-29 15:37 UTC (permalink / raw) To: Richard Weinberger; +Cc: akpm, linux-kernel, user-mode-linux-devel On Tue, Jun 28, 2011 at 1:15 AM, Richard Weinberger <richard@nod.at> wrote: > When UML is compiled with _FORTIFY_SOURCE we have to > export all _chk() functions which are used in modules. > For now it's only the case for __sprintf_chk(). > > Tested-by: Florian Fainelli <florian@openwrt.org> > Reported-by: Florian Fainelli <florian@openwrt.org> > Signed-off-by: Richard Weinberger <richard@nod.at> > --- > arch/um/os-Linux/user_syms.c | 5 +++++ > 1 files changed, 5 insertions(+), 0 deletions(-) > > diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c > index 05f5ea8..45ffe46 100644 > --- a/arch/um/os-Linux/user_syms.c > +++ b/arch/um/os-Linux/user_syms.c > @@ -113,3 +113,8 @@ EXPORT_SYMBOL(__stack_smash_handler); > > extern long __guard __attribute__((weak)); > EXPORT_SYMBOL(__guard); > + > +#ifdef _FORTIFY_SOURCE > +extern int __sprintf_chk(char *str, int flag, size_t strlen, const char *format); > +EXPORT_SYMBOL(__sprintf_chk); > +#endif > -- Can you please clarify why it's needed? I use FORTIFY_SOURCES on Linus' tree UML on Ubuntu w/ no problems and w/o this patch... Thanks, Vitaliy ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules 2011-06-29 15:37 ` [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules Vitaliy Ivanov @ 2011-06-29 15:42 ` Richard Weinberger 2011-06-29 16:33 ` Vitaliy Ivanov 2011-06-29 16:42 ` Geert Uytterhoeven 0 siblings, 2 replies; 9+ messages in thread From: Richard Weinberger @ 2011-06-29 15:42 UTC (permalink / raw) To: Vitaliy Ivanov; +Cc: akpm, linux-kernel, user-mode-linux-devel Am Mittwoch 29 Juni 2011, 17:37:54 schrieb Vitaliy Ivanov: > On Tue, Jun 28, 2011 at 1:15 AM, Richard Weinberger <richard@nod.at> wrote: > > When UML is compiled with _FORTIFY_SOURCE we have to > > export all _chk() functions which are used in modules. > > For now it's only the case for __sprintf_chk(). > > > > Tested-by: Florian Fainelli <florian@openwrt.org> > > Reported-by: Florian Fainelli <florian@openwrt.org> > > Signed-off-by: Richard Weinberger <richard@nod.at> > > --- > > arch/um/os-Linux/user_syms.c | 5 +++++ > > 1 files changed, 5 insertions(+), 0 deletions(-) > > > > diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c > > index 05f5ea8..45ffe46 100644 > > --- a/arch/um/os-Linux/user_syms.c > > +++ b/arch/um/os-Linux/user_syms.c > > @@ -113,3 +113,8 @@ EXPORT_SYMBOL(__stack_smash_handler); > > > > extern long __guard __attribute__((weak)); > > EXPORT_SYMBOL(__guard); > > + > > +#ifdef _FORTIFY_SOURCE > > +extern int __sprintf_chk(char *str, int flag, size_t strlen, const char > > *format); +EXPORT_SYMBOL(__sprintf_chk); > > +#endif > > -- > > Can you please clarify why it's needed? I use FORTIFY_SOURCES on > Linus' tree UML on Ubuntu w/ no problems and w/o this patch... The problem appears only when a UML kernel module is using sprintf(). E.g: CONFIG_UML_WATCHDOG. Then loading the module will fail because of the missing symbol __sprintf_chk(). Thanks, //richard ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules 2011-06-29 15:42 ` Richard Weinberger @ 2011-06-29 16:33 ` Vitaliy Ivanov 2011-06-29 16:42 ` Geert Uytterhoeven 1 sibling, 0 replies; 9+ messages in thread From: Vitaliy Ivanov @ 2011-06-29 16:33 UTC (permalink / raw) To: Richard Weinberger; +Cc: akpm, linux-kernel, user-mode-linux-devel On Wed, Jun 29, 2011 at 6:42 PM, Richard Weinberger <richard@nod.at> wrote: > Am Mittwoch 29 Juni 2011, 17:37:54 schrieb Vitaliy Ivanov: >> On Tue, Jun 28, 2011 at 1:15 AM, Richard Weinberger <richard@nod.at> wrote: >> > When UML is compiled with _FORTIFY_SOURCE we have to >> > export all _chk() functions which are used in modules. >> > For now it's only the case for __sprintf_chk(). >> > >> > Tested-by: Florian Fainelli <florian@openwrt.org> >> > Reported-by: Florian Fainelli <florian@openwrt.org> >> > Signed-off-by: Richard Weinberger <richard@nod.at> >> > --- >> > arch/um/os-Linux/user_syms.c | 5 +++++ >> > 1 files changed, 5 insertions(+), 0 deletions(-) >> > >> > diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c >> > index 05f5ea8..45ffe46 100644 >> > --- a/arch/um/os-Linux/user_syms.c >> > +++ b/arch/um/os-Linux/user_syms.c >> > @@ -113,3 +113,8 @@ EXPORT_SYMBOL(__stack_smash_handler); >> > >> > extern long __guard __attribute__((weak)); >> > EXPORT_SYMBOL(__guard); >> > + >> > +#ifdef _FORTIFY_SOURCE >> > +extern int __sprintf_chk(char *str, int flag, size_t strlen, const char >> > *format); +EXPORT_SYMBOL(__sprintf_chk); >> > +#endif >> > -- >> >> Can you please clarify why it's needed? I use FORTIFY_SOURCES on >> Linus' tree UML on Ubuntu w/ no problems and w/o this patch... > > The problem appears only when a UML kernel module is using sprintf(). > E.g: CONFIG_UML_WATCHDOG. > Then loading the module will fail because of the missing symbol __sprintf_chk(). Thanks. Acked-by: Vitaliy Ivanov <vitalivanov@gmail.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules 2011-06-29 15:42 ` Richard Weinberger 2011-06-29 16:33 ` Vitaliy Ivanov @ 2011-06-29 16:42 ` Geert Uytterhoeven 2011-06-29 16:57 ` Richard Weinberger 1 sibling, 1 reply; 9+ messages in thread From: Geert Uytterhoeven @ 2011-06-29 16:42 UTC (permalink / raw) To: Richard Weinberger Cc: Vitaliy Ivanov, akpm, linux-kernel, user-mode-linux-devel, Florian Fainelli On Wed, Jun 29, 2011 at 17:42, Richard Weinberger <richard@nod.at> wrote: > Am Mittwoch 29 Juni 2011, 17:37:54 schrieb Vitaliy Ivanov: >> On Tue, Jun 28, 2011 at 1:15 AM, Richard Weinberger <richard@nod.at> wrote: >> > When UML is compiled with _FORTIFY_SOURCE we have to >> > export all _chk() functions which are used in modules. >> > For now it's only the case for __sprintf_chk(). >> > >> > Tested-by: Florian Fainelli <florian@openwrt.org> >> > Reported-by: Florian Fainelli <florian@openwrt.org> >> > Signed-off-by: Richard Weinberger <richard@nod.at> >> > --- >> > arch/um/os-Linux/user_syms.c | 5 +++++ >> > 1 files changed, 5 insertions(+), 0 deletions(-) >> > >> > diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c >> > index 05f5ea8..45ffe46 100644 >> > --- a/arch/um/os-Linux/user_syms.c >> > +++ b/arch/um/os-Linux/user_syms.c >> > @@ -113,3 +113,8 @@ EXPORT_SYMBOL(__stack_smash_handler); >> > >> > extern long __guard __attribute__((weak)); >> > EXPORT_SYMBOL(__guard); >> > + >> > +#ifdef _FORTIFY_SOURCE >> > +extern int __sprintf_chk(char *str, int flag, size_t strlen, const char >> > *format); +EXPORT_SYMBOL(__sprintf_chk); >> > +#endif >> > -- >> >> Can you please clarify why it's needed? I use FORTIFY_SOURCES on >> Linus' tree UML on Ubuntu w/ no problems and w/o this patch... > > The problem appears only when a UML kernel module is using sprintf(). > E.g: CONFIG_UML_WATCHDOG. > Then loading the module will fail because of the missing symbol __sprintf_chk(). What about changing harddog_user.c to not use sprintf(), but snprintf()? Besides, the code does look fishy to me: char pid_buf[sizeof("nnnnn\0")]; sprintf(pid_buf, "%d", os_getpid()); os_getpid() returns int: int os_getpid(void) { return syscall(__NR_getpid); } but sys_getpid() returns long. So we truncate a (possibly 64-bit number) to 32-bit, and format it in a buffer that has space for 5 chars only... 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] 9+ messages in thread
* Re: [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules 2011-06-29 16:42 ` Geert Uytterhoeven @ 2011-06-29 16:57 ` Richard Weinberger 0 siblings, 0 replies; 9+ messages in thread From: Richard Weinberger @ 2011-06-29 16:57 UTC (permalink / raw) To: Geert Uytterhoeven Cc: Vitaliy Ivanov, akpm, linux-kernel, user-mode-linux-devel, Florian Fainelli Am Mittwoch 29 Juni 2011, 18:42:43 schrieb Geert Uytterhoeven: > On Wed, Jun 29, 2011 at 17:42, Richard Weinberger <richard@nod.at> wrote: > > Am Mittwoch 29 Juni 2011, 17:37:54 schrieb Vitaliy Ivanov: > >> On Tue, Jun 28, 2011 at 1:15 AM, Richard Weinberger <richard@nod.at> wrote: > >> > When UML is compiled with _FORTIFY_SOURCE we have to > >> > export all _chk() functions which are used in modules. > >> > For now it's only the case for __sprintf_chk(). > >> > > >> > Tested-by: Florian Fainelli <florian@openwrt.org> > >> > Reported-by: Florian Fainelli <florian@openwrt.org> > >> > Signed-off-by: Richard Weinberger <richard@nod.at> > >> > --- > >> > arch/um/os-Linux/user_syms.c | 5 +++++ > >> > 1 files changed, 5 insertions(+), 0 deletions(-) > >> > > >> > diff --git a/arch/um/os-Linux/user_syms.c > >> > b/arch/um/os-Linux/user_syms.c index 05f5ea8..45ffe46 100644 > >> > --- a/arch/um/os-Linux/user_syms.c > >> > +++ b/arch/um/os-Linux/user_syms.c > >> > @@ -113,3 +113,8 @@ EXPORT_SYMBOL(__stack_smash_handler); > >> > > >> > extern long __guard __attribute__((weak)); > >> > EXPORT_SYMBOL(__guard); > >> > + > >> > +#ifdef _FORTIFY_SOURCE > >> > +extern int __sprintf_chk(char *str, int flag, size_t strlen, const > >> > char *format); +EXPORT_SYMBOL(__sprintf_chk); > >> > +#endif > >> > -- > >> > >> Can you please clarify why it's needed? I use FORTIFY_SOURCES on > >> Linus' tree UML on Ubuntu w/ no problems and w/o this patch... > > > > The problem appears only when a UML kernel module is using sprintf(). > > E.g: CONFIG_UML_WATCHDOG. > > Then loading the module will fail because of the missing symbol > > __sprintf_chk(). > > What about changing harddog_user.c to not use sprintf(), but snprintf()? Then we still have to export __snprintf_chk(). Anyway, replacing all the ugly sprintf() by snprintf() is already on my TODO list. harddog_user.c is not the only user. > Besides, the code does look fishy to me: > > char pid_buf[sizeof("nnnnn\0")]; > sprintf(pid_buf, "%d", os_getpid()); > > os_getpid() returns int: > > int os_getpid(void) > { > return syscall(__NR_getpid); > } > > but sys_getpid() returns long. > > So we truncate a (possibly 64-bit number) to 32-bit, and format it > in a buffer that has space for 5 chars only... True, the code assumes quite short pid numbers. Thanks for pointing this out! The sizeof("nnnnn\0") notation is very error-prone, UML is riddled with it. It's time to get rid of it. Thanks, //richard ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-06-29 16:57 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-06-27 22:15 [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules Richard Weinberger 2011-06-27 22:15 ` [PATCH 2/4] um: Add netpoll support Richard Weinberger 2011-06-27 22:15 ` [PATCH 3/4] um, exec: remove redundant set_fs(USER_DS) Richard Weinberger 2011-06-27 22:15 ` [PATCH 4/4] um: Reinstate kernel version in generated .config Richard Weinberger 2011-06-29 15:37 ` [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules Vitaliy Ivanov 2011-06-29 15:42 ` Richard Weinberger 2011-06-29 16:33 ` Vitaliy Ivanov 2011-06-29 16:42 ` Geert Uytterhoeven 2011-06-29 16:57 ` Richard Weinberger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®