Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp666423ybg; Tue, 28 Jul 2020 15:58:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFP9C+l3zuwOJJeskmqDO96mKauzfdX6JDyfsvssTj8i5KoLgSeAHnri+1Ge8G5sOhho3B X-Received: by 2002:aa7:d848:: with SMTP id f8mr27996734eds.329.1595977137990; Tue, 28 Jul 2020 15:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595977137; cv=none; d=google.com; s=arc-20160816; b=vkiLgTvkI535ceDpHIrf/0IlDcDZk3Bwueep8JKi1KrpHJxGWBIp/L1/MUv+veoJNZ deQerF64kSw9ll/F00fHs82IhM0faxw/nKqI4fpHRW6cfWiTxcM4oxlyEVi8Yxnt5GoF u2u1l9wCON5v6evMkyFxQwmTg4NKRBAV997fVKxvuXQsaIT17Oe4Qfd8+1WKXth5OvCC 9djd02P7oW/FPvLapRHp8tuOeNC5Me4fniLht1FWjgAbUaUIDz+l5Hy8PhWGhJcVmMPo 28zvDjXDlv3MOXjwu9QwargIwzUFg1hmwZyX5VgSLkIF31xWP4xW/TH1u47w8Hz9VQIR etHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nW2VBq/cRDmniFEJbcbARyqEcq2nkZVSxT1F5MUGWsA=; b=EDOn/aERd08r0nC5huCvyls5+60vZA4n61yOLTqPh5ka91ql03t5BBEBvDpPqEF6vO htcQTec0kJfggMoYD7DLnqZ2rEDzV2fdnqEhSN/e+7BqNUvhNlGgVA8rZnj094ZwCV3L tvmTLdKeoTt02jVfNaCjh7guEGBYwjFEMGUQUoI1F/hCa+Y5nvNkHkTKKR4RIq1l9kh7 +RMjHMx6bUztua6NG3KD/mlZHS3imYo5S8fO9Cz/NOVrMvv+/g0GFhUc7wOK95q4a8o9 hnjAUI5YJLgeojeTQRM8Q4YOuIf0qbhMlrf4H9HCvjncn1suX3w2Knrr339GhSagNUYB EXpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qt10si8892979ejb.196.2020.07.28.15.58.36; Tue, 28 Jul 2020 15:58:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730134AbgG1W5r (ORCPT + 99 others); Tue, 28 Jul 2020 18:57:47 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:34081 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729958AbgG1W5c (ORCPT ); Tue, 28 Jul 2020 18:57:32 -0400 Received: by mail-qt1-f195.google.com with SMTP id x12so7727270qtp.1 for ; Tue, 28 Jul 2020 15:57:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nW2VBq/cRDmniFEJbcbARyqEcq2nkZVSxT1F5MUGWsA=; b=R/9bXLNFYXSxT49BSLgUDWsBLVVJB2kkTVI9cfXHATBFUYT9HCylPJHakdAoA9332x qK5cGKcpwx0shAnkwy66nLlY2JLWtBentNvAZEk/WzaXOJD1llaQ938PF9CjAeVGuf0i AA92xBAUnvGRi76fnMwwlDzST4GCHZA5KOR1DdCiP97oYPZPcXpKBtA/DDFWq3aHeWf7 iXD+iRhH0pRi8fUMAdWFc8rvQw7WpLspTPUjZZqzG3R0cJnAIqwiMMcQ2HrTRFhgR/1X C3TPryEvS9jcDFYXbdL4qzmkuGjHCVeC7LNwM72dmFsvq9cBo1Dieu4EVXuQEX99atzd qZGw== X-Gm-Message-State: AOAM533JdOES61gmAL2+76NiKMfSBotO/0102LOlaNSGDyyS0ISYjsZF goOohszWCdXJNvqfukI8D90= X-Received: by 2002:ac8:7454:: with SMTP id h20mr28348878qtr.84.1595977051396; Tue, 28 Jul 2020 15:57:31 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id o187sm88118qkd.112.2020.07.28.15.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 15:57:31 -0700 (PDT) From: Arvind Sankar To: Kees Cook , x86@kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v3 10/21] x86/kaslr: Fix off-by-one error in process_gb_huge_pages Date: Tue, 28 Jul 2020 18:57:11 -0400 Message-Id: <20200728225722.67457-11-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200727230801.3468620-1-nivedita@alum.mit.edu> References: <20200727230801.3468620-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the remaining size of the region is exactly 1Gb, there is still one hugepage that can be reserved. Signed-off-by: Arvind Sankar --- arch/x86/boot/compressed/kaslr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index d074986e8061..0df513e3e2ce 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -562,7 +562,7 @@ process_gb_huge_pages(struct mem_vector *region, unsigned long image_size) size = region->size - (addr - region->start); /* Check how many 1GB huge pages can be filtered out: */ - while (size > PUD_SIZE && max_gb_huge_pages) { + while (size >= PUD_SIZE && max_gb_huge_pages) { size -= PUD_SIZE; max_gb_huge_pages--; i++; -- 2.26.2