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: <20190418143431.GA16037@tigerII.localdomain>
Date:   Thu, 18 Apr 2019 23:34:31 +0900
From:   Sergey Senozhatsky <sergey.senozhatsky@...il.com>
To:     Petr Mladek <pmladek@...e.com>
Cc:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        "Tobin C . Harding" <me@...in.cc>, Joe Perches <joe@...ches.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Michal Hocko <mhocko@...e.cz>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v7 07/10] vsprintf: Consolidate handling of unknown
 pointer specifiers

On (04/17/19 13:53), Petr Mladek wrote:
> A reasonable compromise seems to be writing the unknown format specifier
> into the original string with a question mark, for example (%pC?).
> It should be self-explaining enough. Note that it is in brackets
> to follow the (null) style.

Hmm, seems that error string now sometimes try to `guess' what was the
error, but the guess can be misleading.

A very small example.
flags_string() can have a number of fmt specifiers - p, v, g.

        switch (fmt[1]) {
        case 'p':
                flags = *(unsigned long *)flags_ptr;
                /* Remove zone id */
                flags &= (1UL << NR_PAGEFLAGS) - 1;
                names = pageflag_names;
                break;
        case 'v':
                flags = *(unsigned long *)flags_ptr;
                names = vmaflag_names;
                break;
        case 'g':
                flags = *(gfp_t *)flags_ptr;
                names = gfpflag_names;
                break;
        default:
                WARN_ONCE(1, "Unsupported flags modifier: %c\n", fmt[1]);
                return buf;
        }

The new error message, however, will hint '%pG', which may or may not
be helpful.

> -char *flags_string(char *buf, char *end, void *flags_ptr, const char *fmt)
> +char *flags_string(char *buf, char *end, void *flags_ptr,
> +		   struct printf_spec spec, const char *fmt)
>  {
>  	unsigned long flags;
>  	const struct trace_print_flags *names;
> @@ -1760,8 +1767,7 @@ char *flags_string(char *buf, char *end, void *flags_ptr, const char *fmt)
>  		names = gfpflag_names;
>  		break;
>  	default:
> -		WARN_ONCE(1, "Unsupported flags modifier: %c\n", fmt[1]);
> -		return buf;
> +		return string_nocheck(buf, end, "(%pG?)", spec);
>  	}

Wouldn't it be better to use fmt[1] instead?

	-ss

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ