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]
Message-ID: <a15062721388e1d7a9bdfe2ad57d5f872d9daa7a.camel@perches.com>
Date:   Mon, 09 Apr 2018 07:38:27 -0700
From:   Joe Perches <joe@...ches.com>
To:     Martin Schwidefsky <schwidefsky@...ibm.com>
Cc:     Heiko Carstens <heiko.carstens@...ibm.com>,
        linux-s390@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Petr Mladek <pmladek@...e.com>
Subject: Re: s390: defective uses of va_arg in __debug_sprintf_event

On Mon, 2018-04-09 at 14:39 +0200, Martin Schwidefsky wrote:
> On Fri, 06 Apr 2018 12:08:43 -0700
> Joe Perches <joe@...ches.com> wrote:
> 
> > debug_sprintf_event calls __debug_sprintf_event
> > with a format and arguments.
> > 
> > There various types of arguments used in these
> > call, but __debug_sprintf_event uses va_arg
> > with only long as the type argument so random
> > errors could occur because the type and argument
> > are supposed to match.
> > 
> >     debug_entry_t *__debug_sprintf_event(debug_info_t *id, int level, char *string, ...)
> >     {
> >     	    [...]
> >     	    va_start(ap, string);
> >     	    curr_event->string = string;
> >     	    for (idx = 0; idx < min(numargs, (int)(id->buf_size / sizeof(long)) - 1); idx++)
> >     	    	    curr_event->args[idx] = va_arg(ap, long);
> >     	    va_end(ap);
> >     	    [...]
> >     }
> > 
> > from man va_arg
> > 
> >     va_arg()
> > 
> >     if type is not compatible with the type of the actual next argument
> >     (as promoted according to the default argument promotions),
> >     random errors will occur.
> > 
> > For instance, uses like:
> > 
> > arch/s390/kernel/perf_cpum_sf.c:919:    debug_sprintf_event(sfdbg, 6, "pmu_enable: es=%i cs=%i ed=%i cd=%i "
> > arch/s390/kernel/perf_cpum_sf.c-920-                        "tear=%p dear=%p\n", cpuhw->lsctl.es, cpuhw->lsctl.cs,
> > arch/s390/kernel/perf_cpum_sf.c-921-                        cpuhw->lsctl.ed, cpuhw->lsctl.cd,
> > arch/s390/kernel/perf_cpum_sf.c-922-                        (void *) cpuhw->lsctl.tear, (void *) cpuhw->lsctl.dear);
> > 
> > where the first 3 arguments are int but their type
> > as used by va_arg in __debug_sprintf_event is long
> > which could produce random errors.
> 
> In principle you are right that the va_arg handling is not 100%
> correct. It works though because the C ABI for s390x requires
> that arguments are sign- or zero-extended to 64 bits by the caller
> of a function. This is true for values passed in registers and for
> the variable argument list.

Thanks.

Reference:
http://legacy.redhat.com/pub/redhat/linux/7.1/es/os/s390x/doc/lzsabi0.pdf
(found via your explanation)

It might be nice to explain that somewhere in
Documentation/s390 if it's not there already.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ