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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20131115094931.GB31656@ab42.lan>
Date:	Fri, 15 Nov 2013 10:49:33 +0100
From:	Christian Ruppert <christian.ruppert@...lis.com>
To:	"H. Peter Anvin" <hpa@...or.com>
Cc:	Pavel Roskin <proski@....org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org,
	Vineet Gupta <Vineet.Gupta1@...opsys.com>,
	Noam Camus <noamc@...hip.com>
Subject: Re: [PATCH 2/2] x86: Add support for uncompressed kernel images

On Thu, Nov 14, 2013 at 09:45:12AM -0800, H. Peter Anvin wrote:
> On 11/14/2013 12:38 AM, Christian Ruppert wrote:
> > diff --git a/lib/decompress_copy.c b/lib/decompress_copy.c
> > new file mode 100644
> > index 0000000..8a41090
> > --- /dev/null
> > +++ b/lib/decompress_copy.c
> > @@ -0,0 +1,47 @@
> > +#include <linux/decompress/mm.h>
> > +
> > +#define NOZIP_BUFSZ (16 * 1024)
> > +STATIC int INIT nozip(unsigned char *buf, int len,
> > +			int(*fill)(void*, unsigned int),
> > +			int(*flush)(void*, unsigned int),
> > +			unsigned char *outbuf,
> > +			int *pos,
> > +			void(*error)(char *x))
> > +{
> > +	char *b;
> > +
> > +	if (buf)
> > +		b = buf;
> > +	else
> > +		b = malloc(NOZIP_BUFSZ);
> > +
> > +	if (!b) {
> > +		error("Out of memory while allocating buffer");
> > +		return -1;
> > +	}
> > +
> > +	if (flush) {
> > +		if (!len)
> > +			len = fill(b, NOZIP_BUFSZ);
> > +
> > +		len = flush(b, len);
> > +	} else {
> > +		if (!len)
> > +			len = fill(outbuf, NOZIP_BUFSZ);
> > +		else {
> > +			int i;
> > +			for (i = 0; i < len; i++)
> > +				outbuf[i] = b[i];
> 
> Clever way of doing memcpy().  I know some other compression
> implementations open-code memmove(), but using it for the entire data
> set in the most common case is atrocious.  If we need to get a default
> implementation of memmove() we should just do that.

Actually, the x86 architecture already contains a basic implementation
of memcpy in its self-decompressor. Correct me if I'm wrong but I guess
memmove is not required since I don't expect the output of a generic
decompression function to overlap with its input.

We can simply use that function if we agree that
. either nozip is x86 specific
. or every architecture using this code must bring along its own memcpy
  implementation in its self-decompressor.

Do you think that would be OK?

Greetings,
  Christian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ