From patchwork Tue Feb 9 14:29:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 8262321 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E41FF9F1C1 for ; Tue, 9 Feb 2016 14:33:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 257AE20270 for ; Tue, 9 Feb 2016 14:33:06 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BC582026D for ; Tue, 9 Feb 2016 14:33:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aT9J1-0000gs-77; Tue, 09 Feb 2016 14:30:15 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aT9Iz-0000gn-2F for xen-devel@lists.xen.org; Tue, 09 Feb 2016 14:30:13 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id 65/A7-08977-4F7F9B65; Tue, 09 Feb 2016 14:30:12 +0000 X-Env-Sender: prvs=8404692a2=anthony.perard@citrix.com X-Msg-Ref: server-8.tower-21.messagelabs.com!1455028210!14791875!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 1988 invoked from network); 9 Feb 2016 14:30:11 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-8.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 9 Feb 2016 14:30:11 -0000 X-IronPort-AV: E=Sophos;i="5.22,421,1449532800"; d="scan'208";a="337016566" From: Anthony PERARD To: Date: Tue, 9 Feb 2016 14:29:39 +0000 Message-ID: <1455028179-32517-1-git-send-email-anthony.perard@citrix.com> X-Mailer: git-send-email 2.7.1 MIME-Version: 1.0 X-DLP: MIA1 Cc: Anthony PERARD , Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH v3] hvmloader: Fix scratch_alloc to avoid overlaps X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP scratch_alloc() set scratch_start to the last byte of the current allocation. The value of scratch_start is then reused as is (if it is already aligned) in the next allocation. This result in a potential reuse of the last byte of the previous allocation. Signed-off-by: Anthony PERARD --- Change in v3: - change to be similair to mem_alloc() --- tools/firmware/hvmloader/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index d779fd7..9382709 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -478,7 +478,7 @@ void *scratch_alloc(uint32_t size, uint32_t align) if ( align < 16 ) align = 16; - s = (scratch_start + align - 1) & ~(align - 1); + s = (scratch_start + align) & ~(align - 1); e = s + size - 1; BUG_ON(e < s);