mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Yueyi Li <liyueyi@live.com>
Cc: "markus@oberhumer.com" <markus@oberhumer.com>,
	"w@1wt.eu" <w@1wt.eu>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"dave.rodgman@arm.com" <dave.rodgman@arm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] lzo: fix ip overrun during compress.
Date: Wed, 12 Dec 2018 13:03:22 +0100	[thread overview]
Message-ID: <20181212120321.GQ23615@suse.cz> (raw)
In-Reply-To: <BLUPR13MB0289674CD6079E25C2A17497DFA70@BLUPR13MB0289.namprd13.prod.outlook.com>

On Wed, Dec 12, 2018 at 07:03:14AM +0000, Yueyi Li wrote:
> It`s possible ip overrun in lzo1x_1_do_compress() when compressed page is
> point to the end of memory and which virtual address is 0xfffffffffffff000.
> Leading to a NULL pointer access during the get_unaligned_le32(ip).
> 
> ip = x9 = 0x0000000000000009 is overflow.
> 
> @@ -224,8 +224,8 @@ int lzo1x_1_compress(const unsigned char *in, size_t in_len,
>  
>  	while (l > 20) {
>  		size_t ll = l <= (M4_MAX_OFFSET + 1) ? l : (M4_MAX_OFFSET + 1);
> -		uintptr_t ll_end = (uintptr_t) ip + ll;
> -		if ((ll_end + ((t + ll) >> 5)) <= ll_end)
> +		// check for address space wraparound
> +		if (((uintptr_t) ip + ll + ((t + ll) >> 5)) <= (uintptr_t) ip)
>  			break;

Please use the /* */ comment style and enhance the comment contents to
be more descriptive what overflows and how.

>  		BUILD_BUG_ON(D_SIZE * sizeof(lzo_dict_t) > LZO1X_1_MEM_COMPRESS);
>  		memset(wrkmem, 0, D_SIZE * sizeof(lzo_dict_t));
> -- 
> 2.7.4
> 

      reply	other threads:[~2018-12-12 12:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-12  7:03 Yueyi Li
2018-12-12 12:03 ` David Sterba [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=20181212120321.GQ23615@suse.cz \
    --to=dsterba@suse.cz \
    --cc=dave.rodgman@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liyueyi@live.com \
    --cc=markus@oberhumer.com \
    --cc=w@1wt.eu \
    /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®