From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
linux-mm@kvack.org, Vlastimil Babka <vbabka@suse.cz>
Subject: Re: [PATCH] vsprintf: Make %pGp print the hex value
Date: Tue, 12 Oct 2021 11:55:50 +0200 [thread overview]
Message-ID: <1093c8db-5d96-18ff-cb27-e74cddb757a4@rasmusvillemoes.dk> (raw)
In-Reply-To: <20211008193829.849532-1-willy@infradead.org>
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@infradead.org>
> ---
> 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
next prev parent reply other threads:[~2021-10-12 9:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-08 19:38 Matthew Wilcox (Oracle)
2021-10-12 8:46 ` [vsprintf] 97265529aa: kernel-selftests.lib.printf.sh.fail kernel test robot
2021-10-12 9:55 ` Rasmus Villemoes [this message]
2021-10-12 11:11 ` [PATCH] vsprintf: Make %pGp print the hex value Matthew Wilcox
2021-10-12 11:32 ` Matthew Wilcox
2021-10-12 11:57 ` Rasmus Villemoes
2021-10-12 16:11 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1093c8db-5d96-18ff-cb27-e74cddb757a4@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=linux-mm@kvack.org \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox