Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp574127ybg; Tue, 28 Jul 2020 13:10:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCQc5YrMHT0YdcSsOZL+1xBkxlqv2Vrx3KG4NJZr+hYnYMrd6KY8e3VdZ9deSBsIxQ0WNk X-Received: by 2002:a17:906:c20f:: with SMTP id d15mr16718269ejz.117.1595967038971; Tue, 28 Jul 2020 13:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595967038; cv=none; d=google.com; s=arc-20160816; b=uVktBHCAeg5rzDmcVT0VeTh/y71Spz5efXm5LpYTB3VxOS2xX9XsxS1ARowOV2XeG1 pxJ6ivUrtrVsz5mlVZS/6onV/KnhbxoXmnyV2c60yu4vMaES/7NF+jMEUta+eEfmx7F1 VxZEBHGmtIuOaowiyHN78itMNBoXDa0vHxwM3Y2mZ5UQCyn26NLqgBbqvt5f5MsFT/+N WYNA5/J1M1nWlrMZN7D2fQ2WJyptosRv2D3WwFYx280oY3IMTkdFGplPZC4JAbtkrF+P nPVGE8nTIXuIJuNVdx3zc0MvEmAnVHKItPQzsFdwzGNRWvaj7eqckmZljBiyY1eAmKyr RODQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=7dLNNRTV2GJLqVTQNBxoLMGUKeruJRc+tK69t/CHzL4=; b=RTJGC+MZEVhwzgcQGbXE5IM+kptMHxg6awWgVIrUzNq4ej0JxPOPeAqIK03nlzuDJQ ldLrA007kzQJrFlOUSekEX6n+uRCRZY+1vsKnMpAfRck+y3M4a8kPW8EbAQ/VJ/Mh5ee gV01zL7zwChsMfDYr0VbrLKwBe8QDT37ghBZDS9Ia3b3rN9bngj/YIxx9vIWoOLKKin5 8gfhzaw8WCF68rWNnUouoHQM75qSrRUJ3JVtd3g667TCx0I+uaX+tN1Z8t+DJX+feUPL 27n4Qz5Gg/CVgbMT7pCr52FBWyHmaQAFPG5cyz1bav1w1cw09KFQx6ODwzi/xTYKjfbh Pd5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=srYLnMZE; 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 bi24si7796615ejb.514.2020.07.28.13.10.17; Tue, 28 Jul 2020 13:10:38 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=srYLnMZE; 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 S1728346AbgG1UIO (ORCPT + 99 others); Tue, 28 Jul 2020 16:08:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728112AbgG1UIN (ORCPT ); Tue, 28 Jul 2020 16:08:13 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68703C061794 for ; Tue, 28 Jul 2020 13:08:13 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id d27so15864137qtg.4 for ; Tue, 28 Jul 2020 13:08:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=7dLNNRTV2GJLqVTQNBxoLMGUKeruJRc+tK69t/CHzL4=; b=srYLnMZE/6CsfNbhZXgRXeNbaHpEQRue6V16dDOedEn7I58IpYY7APoybLJnCMX0P9 KCmSG9lGSTZd5gJimR/yWMl8lrVniUTr4bqVEkOt2+xS4Ox7eRQwxVHLnX9TL0X2hQKF zW+7U70YnPfTet+7T2od9fd5zlJtw04VuAF6M1PwhnH6FJ3eVsEN6yQtN6w0OB+gfo/8 LBeTd5LVzDnaV1HtYyj79myhgYsSFKKhzjBoyXwfXGmdhKSN4aFaZrupw+4o4alBtZM6 DLZG/v9WyPdMTCAWgR7UckEBTTH7BedSw3LvQnMBef8zJi6ZI1eaAQLmG/CfpKXPmA7O m3iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=7dLNNRTV2GJLqVTQNBxoLMGUKeruJRc+tK69t/CHzL4=; b=mC9UVr2cYrpMXwWmnXCTf+kyEHHBj45ZjBt2xloNJJf+zrb8tNP0WuaD+c/yf4cGc/ qSLUcC1ImbbBIW4vKhvXPSTydOUY+7QZ3tPEafUeBB+1iuTUDOIVhfAHsjGdgUMuf05g U2oWXH2syzxwrPSlvoYGaRBjtpg2sos/L2BKsq6uqmjcgQvJ5WKwuZ0OY/vsTCZEwK7Z ZmlpiUnYVTHYyJ/WMJG50CNO/DTYCmwxl7iH7kKqDWkLX56Q2KMxCTcYRCk6yTuF3u7h 0ljuhi01TqV061TM3AWbv/YSoUgbl3HmUuRjtVu9dJerIuhMWME4iBpO40C5NPsqWhR7 2mgw== X-Gm-Message-State: AOAM5331r0upo90YUEWNcs70X8S49hSUKcx79LeYoEdydNphH1E8/vwi SHwSPS6MwEzYfwq4QBdet5I= X-Received: by 2002:ac8:7741:: with SMTP id g1mr13007508qtu.28.1595966892616; Tue, 28 Jul 2020 13:08:12 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id f130sm24457609qke.99.2020.07.28.13.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 13:08:12 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Tue, 28 Jul 2020 16:08:10 -0400 To: Kees Cook Cc: Arvind Sankar , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 8/8] x86/kaslr: Don't use 64-bit mem_vector for 32-bit kernel Message-ID: <20200728200810.GD4150860@rani.riverdale.lan> References: <20200727215047.3341098-1-nivedita@alum.mit.edu> <20200727230801.3468620-9-nivedita@alum.mit.edu> <202007281235.B9743EA@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <202007281235.B9743EA@keescook> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 28, 2020 at 12:37:12PM -0700, Kees Cook wrote: > On Mon, Jul 27, 2020 at 07:08:01PM -0400, Arvind Sankar wrote: > > Commit > > f28442497b5c ("x86/boot: Fix KASLR and memmap= collision") > > converted mem_vector type to use 64-bit on the 32-bit kernel as well, > > based on Thomas's review [0]. However: > > - the code still doesn't consistently use 64-bit types. For instance, > > mem_avoid_overlap uses 32-bit types when checking for overlaps. This > > is actually okay, as the passed in memory range will have been clipped > > to below 4G, but it is difficult to reason about the safety of the > > code. > > - KASLR on 32-bit can't use memory above 4G anyway, so it's pointless > > to keep track of ranges above 4G. > > > > Switch the type back to unsigned long, and use a helper function to clip > > regions to 4G on 32-bit, when storing mem_avoid, immovable_mem, EFI, > > E820 and command-line memory regions. > > The reason for long long is to avoid having to check for overflows in > any of the offset calculations. Why not just leave this as-is? > The first bullet: there are still unsigned long's in the code that get assigned mem_vector.start etc. Taking into account Ingo's review as well, I'm planning to just make all those u64 as well in v3, instead of this patch.