lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 29 Jun 2011 18:42:43 +0200
From:	Geert Uytterhoeven <geert@...ux-m68k.org>
To:	Richard Weinberger <richard@....at>
Cc:	Vitaliy Ivanov <vitalivanov@...il.com>, akpm@...ux-foundation.org,
	linux-kernel@...r.kernel.org,
	user-mode-linux-devel@...ts.sourceforge.net,
	Florian Fainelli <florian@...nwrt.org>
Subject: Re: [PATCH 1/4] um: Fix _FORTIFY_SOURCE=2 support for kernel modules

On Wed, Jun 29, 2011 at 17:42, Richard Weinberger <richard@....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@....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@...nwrt.org>
>> > Reported-by: Florian Fainelli <florian@...nwrt.org>
>> > Signed-off-by: Richard Weinberger <richard@....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@...ux-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
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ