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  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]
Date:   Mon, 15 Apr 2019 11:18:12 +0200
From:   Petr Mladek <pmladek@...e.com>
To:     Alastair D'Silva <alastair@...ilva.org>
Cc:     'Alastair D'Silva' <alastair@....ibm.com>,
        'Jani Nikula' <jani.nikula@...ux.intel.com>,
        'Joonas Lahtinen' <joonas.lahtinen@...ux.intel.com>,
        'Rodrigo Vivi' <rodrigo.vivi@...el.com>,
        'David Airlie' <airlied@...ux.ie>,
        'Daniel Vetter' <daniel@...ll.ch>,
        'Karsten Keil' <isdn@...ux-pingi.de>,
        'Jassi Brar' <jassisinghbrar@...il.com>,
        'Tom Lendacky' <thomas.lendacky@....com>,
        "'David S. Miller'" <davem@...emloft.net>,
        'Jose Abreu' <Jose.Abreu@...opsys.com>,
        'Kalle Valo' <kvalo@...eaurora.org>,
        'Stanislaw Gruszka' <sgruszka@...hat.com>,
        'Benson Leung' <bleung@...omium.org>,
        'Enric Balletbo i Serra' <enric.balletbo@...labora.com>,
        "'James E.J. Bottomley'" <jejb@...ux.ibm.com>,
        "'Martin K. Petersen'" <martin.petersen@...cle.com>,
        'Greg Kroah-Hartman' <gregkh@...uxfoundation.org>,
        'Alexander Viro' <viro@...iv.linux.org.uk>,
        'Sergey Senozhatsky' <sergey.senozhatsky@...il.com>,
        'Steven Rostedt' <rostedt@...dmis.org>,
        'Andrew Morton' <akpm@...ux-foundation.org>,
        intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
        linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        ath10k@...ts.infradead.org, linux-wireless@...r.kernel.org,
        linux-scsi@...r.kernel.org, linux-fbdev@...r.kernel.org,
        devel@...verdev.osuosl.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 2/4] lib/hexdump.c: Optionally suppress lines of filler
 bytes

On Sat 2019-04-13 09:28:03, Alastair D'Silva wrote:
> > -----Original Message-----
> > From: Petr Mladek <pmladek@...e.com>
> > Sent: Saturday, 13 April 2019 12:04 AM
> > To: Alastair D'Silva <alastair@....ibm.com>
> > Cc: alastair@...ilva.org; Jani Nikula <jani.nikula@...ux.intel.com>;
> Joonas
> > Lahtinen <joonas.lahtinen@...ux.intel.com>; Rodrigo Vivi
> > <rodrigo.vivi@...el.com>; David Airlie <airlied@...ux.ie>; Daniel Vetter
> > <daniel@...ll.ch>; Karsten Keil <isdn@...ux-pingi.de>; Jassi Brar
> > <jassisinghbrar@...il.com>; Tom Lendacky <thomas.lendacky@....com>;
> > David S. Miller <davem@...emloft.net>; Jose Abreu
> > <Jose.Abreu@...opsys.com>; Kalle Valo <kvalo@...eaurora.org>;
> > Stanislaw Gruszka <sgruszka@...hat.com>; Benson Leung
> > <bleung@...omium.org>; Enric Balletbo i Serra
> > <enric.balletbo@...labora.com>; James E.J. Bottomley
> > <jejb@...ux.ibm.com>; Martin K. Petersen <martin.petersen@...cle.com>;
> > Greg Kroah-Hartman <gregkh@...uxfoundation.org>; Alexander Viro
> > <viro@...iv.linux.org.uk>; Sergey Senozhatsky
> > <sergey.senozhatsky@...il.com>; Steven Rostedt <rostedt@...dmis.org>;
> > Andrew Morton <akpm@...ux-foundation.org>; intel-
> > gfx@...ts.freedesktop.org; dri-devel@...ts.freedesktop.org; linux-
> > kernel@...r.kernel.org; netdev@...r.kernel.org;
> > ath10k@...ts.infradead.org; linux-wireless@...r.kernel.org; linux-
> > scsi@...r.kernel.org; linux-fbdev@...r.kernel.org;
> > devel@...verdev.osuosl.org; linux-fsdevel@...r.kernel.org
> > Subject: Re: [PATCH 2/4] lib/hexdump.c: Optionally suppress lines of
> filler
> > bytes
> > 
> > On Wed 2019-04-10 13:17:18, Alastair D'Silva wrote:
> > > From: Alastair D'Silva <alastair@...ilva.org>
> > >
> > > Some buffers may only be partially filled with useful data, while the
> > > rest is padded (typically with 0x00 or 0xff).
> > >
> > > This patch introduces flags which allow lines of padding bytes to be
> > > suppressed, making the output easier to interpret:
> > > HEXDUMP_SUPPRESS_0X00, HEXDUMP_SUPPRESS_0XFF
> > >
> > > The first and last lines are not suppressed by default, so the
> > > function always outputs something. This behaviour can be further
> > > controlled with the HEXDUMP_SUPPRESS_FIRST &
> > HEXDUMP_SUPPRESS_LAST flags.
> > >
> > > An inline wrapper function is provided for backwards compatibility
> > > with existing code, which maintains the original behaviour.
> > >
> > 
> > > diff --git a/lib/hexdump.c b/lib/hexdump.c index
> > > b8a164814744..2f3bafb55a44 100644
> > > --- a/lib/hexdump.c
> > > +++ b/lib/hexdump.c
> > > +void print_hex_dump_ext(const char *level, const char *prefix_str,
> > > +			int prefix_type, int rowsize, int groupsize,
> > > +			const void *buf, size_t len, u64 flags)
> > >  {
> > >  	const u8 *ptr = buf;
> > > -	int i, linelen, remaining = len;
> > > +	int i, remaining = len;
> > >  	unsigned char linebuf[64 * 3 + 2 + 64 + 1];
> > > +	bool first_line = true;
> > >
> > >  	if (rowsize != 16 && rowsize != 32 && rowsize != 64)
> > >  		rowsize = 16;
> > >
> > >  	for (i = 0; i < len; i += rowsize) {
> > > -		linelen = min(remaining, rowsize);
> > > +		bool skip = false;
> > > +		int linelen = min(remaining, rowsize);
> > > +
> > >  		remaining -= rowsize;
> > >
> > > +		if (flags & HEXDUMP_SUPPRESS_0X00)
> > > +			skip = buf_is_all(ptr + i, linelen, 0x00);
> > > +
> > > +		if (!skip && (flags & HEXDUMP_SUPPRESS_0XFF))
> > > +			skip = buf_is_all(ptr + i, linelen, 0xff);
> > > +
> > > +		if (first_line && !(flags & HEXDUMP_SUPPRESS_FIRST))
> > > +			skip = false;
> > > +
> > > +		if (remaining <= 0 && !(flags & HEXDUMP_SUPPRESS_LAST))
> > > +			skip = false;
> > > +
> > > +		if (skip)
> > > +			continue;
> > 
> > IMHO, quietly skipping lines could cause a lot of confusion, espcially
> when the address is not printed.
> >
> It's up to the caller to decide how they want it displayed.

I wonder who would want to quietly skip some data values.
Are you using it yourself? Could you please provide an
example?

I do not see why we would need to complicate the API and code
by this.

The behavior proposed by Tvrtko Ursulin makes much more
sense. I mean
https://lkml.kernel.org/r/929244ed-cc7f-b0f3-b5ac-50e798e83188@linux.intel.com


> > I wonder how it would look like when we print something like:
> > 
> >     --- skipped XX lines full of 0x00 ---
> 
> This could be added as a later enhancement, with a new flag (eg.
> HEXDUMP_SUPPRESS_VERBOSE).

Who will add this later? Frankly, this looks like a half baked
feature that it good enough for you. If you want it upstream,
it must behave reasonably and it must be worth it.

Best Regards,
Petr

Powered by blists - more mailing lists