Re: [PATCH] vsprintf: Make %pGp print the hex value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/10/2021 21.38, Matthew Wilcox (Oracle) wrote:
> All existing users of %pGp want the hex value as well as the decoded
> flag names.  This looks awkward (passing the same parameter to printf
> twice), so move that functionality into the core.  If we want, we
> can make that optional with flag arguments to %pGp in the future.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> ---
>  lib/test_printf.c   | 2 ++
>  lib/vsprintf.c      | 8 ++++++++
>  mm/debug.c          | 2 +-
>  mm/memory-failure.c | 8 ++++----
>  mm/page_owner.c     | 4 ++--
>  mm/slub.c           | 4 ++--
>  6 files changed, 19 insertions(+), 9 deletions(-)
> 
> diff --git a/lib/test_printf.c b/lib/test_printf.c
> index 55082432f37e..32d748d1ae02 100644
> --- a/lib/test_printf.c
> +++ b/lib/test_printf.c
> @@ -614,6 +614,7 @@ page_flags_test(int section, int node, int zone, int last_cpupid,
>  	bool append = false;
>  	int i;
>  
> +	snprintf(cmp_buf + size, BUF_SIZE - size, "%x(", flags);

This generates the hex value without leading 0x, however...

>  	flags &= PAGEFLAGS_MASK;
>  	if (flags) {
>  		page_flags |= flags;
> @@ -648,6 +649,7 @@ page_flags_test(int section, int node, int zone, int last_cpupid,
>  		size = strlen(cmp_buf);
>  		append = true;
>  	}
> +	snprintf(cmp_buf + size, BUF_SIZE - size, ")");
>  
>  	test(cmp_buf, "%pGp", &page_flags);
>  }
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index d7ad44f2c8f5..214098248610 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -2023,6 +2023,11 @@ char *format_page_flags(char *buf, char *end, unsigned long flags)
>  	bool append = false;
>  	int i;
>  
> +	buf = number(buf, end, flags, default_flag_spec);

...default_flag_spec has '.flags = SPECIAL | SMALL,', i.e. what one
would get from %#x . I'm guessing that's what upsets 0-day.

Geez it would be nice if 0day actually reported the "Expected foo, but
bar was emitted to the buffer".

Rasmus




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux