From: David Laight <David.Laight@ACULAB.COM>
To: 'Andy Shevchenko' <andriy.shevchenko@linux.intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Subject: RE: [PATCH v1 1/1] signal: Use %*ph for printing hexdump of a small buffer
Date: Tue, 13 Jun 2023 13:19:07 +0000 [thread overview]
Message-ID: <d2772156abdb4b2388d9b6f701c81adc@AcuMS.aculab.com> (raw)
In-Reply-To: <20230612220334.44177-1-andriy.shevchenko@linux.intel.com>
From: Andy Shevchenko
> Sent: 12 June 2023 23:04
>
> The kernel already has a helper to print a hexdump of a small
> buffer via pointer extension. Use that instead of open coded
> variant.
>
> In long term it helps to kill pr_cont() or at least narrow down
> its use.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> kernel/signal.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/signal.c b/kernel/signal.c
> index b5370fe5c198..6be2df76f0b4 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -1259,18 +1259,17 @@ static void print_fatal_signal(int signr)
> pr_info("potentially unexpected fatal signal %d.\n", signr);
>
> #if defined(__i386__) && !defined(__arch_um__)
> - pr_info("code at %08lx: ", regs->ip);
> {
> + unsigned char insn[16];
> int i;
> +
> for (i = 0; i < 16; i++) {
> - unsigned char insn;
> -
> - if (get_user(insn, (unsigned char *)(regs->ip + i)))
> + if (get_user(insn[i], (unsigned char __user *)(regs->ip + i)))
> break;
> - pr_cont("%02x ", insn);
> }
Isn't that just:
i = 16 - copy_from_user(insn, (unsigned char __user *)regs->ip, 16);
(the 16 should be sizeof (insn))
David
> +
> + pr_info("code at %08lx: %*ph\n", regs->ip, i, insn);
> }
> - pr_cont("\n");
> #endif
> preempt_disable();
> show_regs(regs);
> --
> 2.40.0.1.gaa8946217a0b
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
prev parent reply other threads:[~2023-06-13 13:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-12 22:03 Andy Shevchenko
2023-06-13 13:19 ` David Laight [this message]
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=d2772156abdb4b2388d9b6f701c81adc@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®