Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp685580imu; Tue, 27 Nov 2018 20:09:15 -0800 (PST) X-Google-Smtp-Source: AJdET5f2OnpPVmY9d5OEaa84BasuTAH0MxWOB9gs+aDR+FfV3y4hl6dP4s+G3CiPyrF3nbgerv8s X-Received: by 2002:a62:8c11:: with SMTP id m17mr35944571pfd.224.1543378155497; Tue, 27 Nov 2018 20:09:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543378155; cv=none; d=google.com; s=arc-20160816; b=ENGsbpe4kOGYpfM64QpGAZGMZYOWjLvn7A1AJ94va37TPFefSYZzVoXtWmKqzc7G+G Xd+7H7zbO4pK5Sw5EmQp+5HtEyBx+wEYVC0bm1VGT1eJU6YHqumKTQYroc+mIYmgGjcg dtFWELIPks9asN/z8Q3Hxvauakc3aUue/FHVgNxhIyJW6uDh5unJVMekYtKbqjJdSN28 +s8S6QCy0PsOHaxYKmSZuLv3OTnRlt/7nqEOOPqFjG+86ChZ4R4dA7Tf53yohYcOmHGh SsealK8/qEUQemwMaOweKEjEIkNceRUmwgfdZOUVEVxAiM5q1zidhNQGX/x5Bh4+gI2n J0nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=umZQ2fk7qr1o/tqflNk6lboeJgH9Z2FxEZLgOhpIE6s=; b=y1Iz+PgAa+ms8zByH89vcOC25XJJH3Kkf1507gJ6bsYeYtPKnPjm0/PDo/BDM3TsEr GjKFUAOExavuRsvpAUO3Z7LEwVECfueb2g7c7LdCvGpzbrKulb7ulAw8wNBb925TRbVS PGOHfcQQSupMxY+SBYohrJ0SONwyA4tZLDMjCpS3L/TPzwKb3jzYet4kSnm2SuW4dXdY TbH6ggufciB7oDMdRjsmVQhFJk1IwgzoORpOzXgndKofSTA+xzChxGFZ8oEorhUKtbgw Y1jpNV1Qb47y65+lQ2hNm/bo1F4apv91hjUB5y2+bR5JQVQzJUhPZDmnx6RNzLw5m9BA h+lw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o68si6056768pfo.140.2018.11.27.20.09.00; Tue, 27 Nov 2018 20:09:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727240AbeK1PIf (ORCPT + 99 others); Wed, 28 Nov 2018 10:08:35 -0500 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:49435 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726894AbeK1PIf (ORCPT ); Wed, 28 Nov 2018 10:08:35 -0500 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id wAS48K1P020178; Wed, 28 Nov 2018 05:08:20 +0100 Date: Wed, 28 Nov 2018 05:08:20 +0100 From: Willy Tarreau To: Yueyi Li Cc: "gregkh@linuxfoundation.org" , "donb@securitymouse.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] lzo: fix ip overrun during compress. Message-ID: <20181128040820.GC19711@1wt.eu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yueyi, On Tue, Nov 27, 2018 at 10:34:26AM +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). Thanks for this report. (...) > diff --git a/lib/lzo/lzo1x_compress.c b/lib/lzo/lzo1x_compress.c > index 236eb21..a0265a6 100644 > --- a/lib/lzo/lzo1x_compress.c > +++ b/lib/lzo/lzo1x_compress.c > @@ -17,6 +17,9 @@ > #include > #include "lzodefs.h" > > +#define OVERFLOW_ADD_CHECK(a, b) \ > + ((size_t)~0 - (size_t)(a) < (size_t)(b) ? true : false) > + I think the test would be easier to grasp this way : #define OVERFLOW_ADD_CHECK(a, b) \ ((size_t)(b) >= (size_t)((void*)0 - (void *)(a))) But the following should be more efficient since we build with -fno-strict-overflow : #define OVERFLOW_ADD_CHECK(a, b) \ (((a) + (b)) < (a)) Could you please recheck ? Thanks, Willy