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] [day] [month] [year] [list]
Message-ID: <d2772156abdb4b2388d9b6f701c81adc@AcuMS.aculab.com>
Date:   Tue, 13 Jun 2023 13:19:07 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Andy Shevchenko' <andriy.shevchenko@...ux.intel.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     Dave Hansen <dave.hansen@...ux.intel.com>
Subject: RE: [PATCH v1 1/1] signal: Use %*ph for printing hexdump of a small
 buffer

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@...ux.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)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ