All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: dsterba@suse.cz, Yueyi Li <liyueyi@live.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"donb@securitymouse.com" <donb@securitymouse.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	markus@oberhumer.com
Subject: Re: [PATCH v2] lzo: fix ip overrun during compress.
Date: Wed, 28 Nov 2018 15:15:47 +0100	[thread overview]
Message-ID: <20181128141547.GD20409@1wt.eu> (raw)
In-Reply-To: <20181128135242.gy3avmbp2pdmjaka@twin.jikos.cz>

Hi David,

On Wed, Nov 28, 2018 at 02:52:42PM +0100, David Sterba wrote:
> The fix is adding a few branches to code that's supposed to be as fast
> as possible. The branches would be evaluated all the time while
> protecting against one signle bad page address. This does not look like
> a good performance tradeoff.

That was my concern as well, though the simplified test should be cheaper
especially since the branch is (almost) never taken and easily predicted.

> > +#define OVERFLOW_ADD_CHECK(a, b)  \
> > +		(((a) + (b)) < (a))
> 
> I'm not sure if this is generally safe overflow check (never not
> optimized out). Here it depends on the types of 'a' and 'b' that are
> pointer (ip) and size_t (m_len). GCC has __builtin_add_overflow_p so
> that one should be used where possible.

Sure but that one came with gcc 7 which is not exactly a reasonable
prerequisite especially when it comes to stable kernels. However I'm
now seeing that we have include/linux/overflow.h which provides this.
I have not checked what versions support it though, but 4.14 already
doesn't have it. Thus a fallback will be needed anyway and maintaining
two versions is not exactly the best thing to have to do :-/

Willy

  reply	other threads:[~2018-11-28 14:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28  7:31 [PATCH v2] lzo: fix ip overrun during compress Yueyi Li
2018-11-28 13:52 ` David Sterba
2018-11-28 14:15   ` Willy Tarreau [this message]
2018-11-29 16:49   ` Dave Rodgman
2018-11-30  3:05     ` Yueyi Li
2018-11-30 12:20       ` Dave Rodgman
2018-12-03  2:46         ` Yueyi Li
2018-12-03  3:05           ` Yueyi Li
2018-12-04 10:20   ` Markus F.X.J. Oberhumer
2018-12-05  3:07     ` Yueyi Li
2018-12-06 15:03       ` Markus F.X.J. Oberhumer
2018-12-12  5:21         ` Yueyi Li
2018-12-12 12:35           ` Markus F.X.J. Oberhumer
2018-12-14 13:56             ` Richard Weinberger
2018-12-14 16:46               ` Kees Cook
2018-12-16 16:56                 ` Markus F.X.J. Oberhumer
2018-12-18  9:25                   ` Yueyi Li

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=20181128141547.GD20409@1wt.eu \
    --to=w@1wt.eu \
    --cc=donb@securitymouse.com \
    --cc=dsterba@suse.cz \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liyueyi@live.com \
    --cc=markus@oberhumer.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.