From patchwork Fri Sep 29 21:11:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 13404842 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90EB0E71D5C for ; Fri, 29 Sep 2023 21:12:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2ED9A8D00DE; Fri, 29 Sep 2023 17:12:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29D948E000A; Fri, 29 Sep 2023 17:12:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13D1D8D0102; Fri, 29 Sep 2023 17:12:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 06F218D00DE for ; Fri, 29 Sep 2023 17:12:03 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C56261205B1 for ; Fri, 29 Sep 2023 21:12:02 +0000 (UTC) X-FDA: 81290882484.13.0B956B4 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf22.hostedemail.com (Postfix) with ESMTP id 02A20C0016 for ; Fri, 29 Sep 2023 21:12:00 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=aZvO5OuZ; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3oD0XZQwKCKcZHTPaVScHULUNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--samitolvanen.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3oD0XZQwKCKcZHTPaVScHULUNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--samitolvanen.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696021921; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FR1ZKwT/o63KmLhMDo8tUZzc0vKzUsUCbtQdapDGJGA=; b=GVBMttpKOIPsVhzibkZ1th9FOX4Jk1rkOueSS4LwaevIMtS94EUcpHsRIqmngqMPlnH6c4 7fRkUtp6jr0n9VhduOUbwIHGcFOzmyF493DP8x1ahUvGLhQADAXdPj6cMgQtrI8eRMLplx zuQAplR3Wt/hkJOmVQglS7eAdg1qzjM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=aZvO5OuZ; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf22.hostedemail.com: domain of 3oD0XZQwKCKcZHTPaVScHULUNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--samitolvanen.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3oD0XZQwKCKcZHTPaVScHULUNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--samitolvanen.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696021921; a=rsa-sha256; cv=none; b=yoTUkDJ2bk8H3uyTJqD+x/P7JuiWSgEpQ3MI0RXo3lx3O51Ij4Hv6SXVcpV/jlIyM28i8f EUmBjwSYFSs5t6G4wVSH7X4Rnetuix9ib6cv/e7744GzM+QQZd26iMB4RxlQhCBhfU8bHb IYorDx1FAdlBCYsxfMtsGBWNisFQ25I= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-d852a6749baso22172332276.0 for ; Fri, 29 Sep 2023 14:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696021920; x=1696626720; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FR1ZKwT/o63KmLhMDo8tUZzc0vKzUsUCbtQdapDGJGA=; b=aZvO5OuZt4JSbbBdbAyQIVbaHHRrZjf2kbY0FtTeN5oI7lpdtQL+8dC3C/fiXNDFIG 1WfI3IN6ep4/Typpgn0sGWECR+7jdRDWfbmWIYBgJrC0sqEM9Aq3BDZtf09LvDWbQcLo +A0ru5tUWE1XrE1c9u4aUGxieT/SGdy/mESHjdDLG6Uuge5R0LIBmPLMJE7IKUkPukRH fngaUUKMxaI1nL4CVGtxWonQCWDUc+UPL8p0F7lpOlcDX+WHpqjx9LP9fwB8TK8OFuR4 F6B3osKReeDbm+50ODyDtKli5FqES+/e49tc5Fmg1npto5M/Sgr0Q0iG8IrWTvuIbvaC D9Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696021920; x=1696626720; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FR1ZKwT/o63KmLhMDo8tUZzc0vKzUsUCbtQdapDGJGA=; b=LqQw0NY3zltSzWMBzbpLAeD0mGon47YWoJBqZgD+f9WWDvYpKVX0nqooKWEsQvOYhp Z2ejgdR7TiZzyy77iuMlTZKMCyEMBCZzCS84bk56nZCGyrdBMzg1zZuyIyPST37vtUuW N3GHpPUqY23qBEknJXelAdLkprqCtoYaZzvQnAGPUfY4/dLWT4cCO1y/KUalivrz+vgQ F2QERB9B5nId2c4ED6MbiQD3NniqZpz+DjD6kLwmEHvYdmBUIxQsnObCRkt8SM6b4EAF GuJq3ljzchjIGeWY+c20fgoxhHZPsPRVErIYHTpAJy+mR1DLaDwgJQt9DJTCsjTlR9hf A2NQ== X-Gm-Message-State: AOJu0YxNa5pNJD2c1P+6x29Cx87WMvh16AULJu6vusOHCBluGzbNIaUi 7qpxo7Hh7gxK7orXt1wTp9h8RVAbHxC8yHi2C8M= X-Google-Smtp-Source: AGHT+IHnDIypgcCWBxPESiB/yrBCpKXqORME3PWFhWMxCeyFk9cmGmraRzLwQcSrcYatS2Uvi9kN6m0eWCmXEF8Vfz0= X-Received: from samitolvanen.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4f92]) (user=samitolvanen job=sendgmr) by 2002:a25:6812:0:b0:d13:856b:c10a with SMTP id d18-20020a256812000000b00d13856bc10amr77200ybc.3.1696021920090; Fri, 29 Sep 2023 14:12:00 -0700 (PDT) Date: Fri, 29 Sep 2023 21:11:57 +0000 In-Reply-To: <20230929211155.3910949-4-samitolvanen@google.com> Mime-Version: 1.0 References: <20230929211155.3910949-4-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=1359; i=samitolvanen@google.com; h=from:subject; bh=ARqQmg1Q7FqF1vgF9dpD7yhcKdtd1MfRgn2maiynoVQ=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBlFz2bINQRa9JuNqXpxYBQVzDJb/c0+7N1HB+sp 2/Sm1UUS7iJAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCZRc9mwAKCRBMtfaEi7xW 7vOOC/9tO/6MqlDPfjsiexFNXOEfW7Ar2H9OEVyVIE92EgZgm/mYuBlQqBRKkWvnSCUPZ+ktWxw /8gD9WFejtTnKMje8tf/4wwgxbVQuClXmgi7zZQJvbJ2+SG6cp6B7JcXsMhPsJsbuh3NhTEQj/o pgpvv9Uyv2mK/vRlud+N82dGqhUfLNAWNPfHmZmQ/tMcij5bpFL8VvhWPFF6Akufb6mjaM9D8vG +cR914ZzFo93wp2YlrOemHXK7uUcqH8HHjkYtoFn7o8xhU+VQ7oy1yajipTLM7ewaa0tOrdIWqa 08cpT5V8GX3uAGGuFOzPlMxeF7o/GIDLXMxDfovUqIRoGLzciTjGMCqRmRapZU6oY3GqWEqPSnx GnCaN0xzRvU31sMOUQQkusxUC/3qLR05lv7v/sDAlG5Yah5czQB5w1+2ClKsbQ3sCX6HmpcfWsx r/VvM19V0Dekn+5QLhuwnCOlt6Hs+HBdn3kG1truvPJvtRa+QxsCoiBcfxXnVWnQrVOuI= X-Mailer: git-send-email 2.42.0.582.g8ccd20d70d-goog Message-ID: <20230929211155.3910949-5-samitolvanen@google.com> Subject: [PATCH 1/2] mm: Change mmap_rnd_bits_max to __ro_after_init From: Sami Tolvanen To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Morton , Kees Cook Cc: linux-mm@kvack.org, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Sami Tolvanen X-Rspamd-Queue-Id: 02A20C0016 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: dsfhn8s7eigbhh97zxcft9q6im7jn89i X-HE-Tag: 1696021920-556116 X-HE-Meta: U2FsdGVkX1+Z+5Ujra6OVFcu23P3/gBk9itRT5HM1rB3i1BBnycFbm9dN0FnW23GnSpjkbk2cw8w3BfaVfjNkucXr+2DTcj+izXRQ6JjYzLMn53Ec13HUzhcEoU90Wr4v7+C9AbZygN3H+b5uG+X5+WQpZjHOZ1M2pZX8FN6allEHFTU3Z3vPCTx1cWXOUhR182v60UP4JWJ2vRkp8N+1rVtPujollucj293ICkPHPTRYETAkh7cpPSnjRSYd2sojYXWRkTs64eBf7bhguMp0QCUvvDnLvSdnP+BbVFozq7BuD5IpJ1oLgcrazAyn0semChOQ6Mk0OsCJIdtVoMMn8FJfLKjNaXQ+eN1V7XCHl4aHcufEQ5j8GEwcIi0iBycygeR4rHEUTPPY4slHvF/32qzrsyxOeY7eE/o9/5ccj/rnusjBFsOh11Tu6Pw6y+W02uN4StGtHNUBCQNd2kT5Tx5D7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fYobJOGhAV8cOeLG8Nk7qr8vbEmdQ/z8Jpfo6X79qwel2tb0TW5/WMiIzt0nTA0Rtpy/xVNRX0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Allow mmap_rnd_bits_max to be updated on architectures that determine virtual address space size at runtime instead of relying on Kconfig options by changing it from const to __ro_after_init. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- include/linux/mm.h | 2 +- mm/mmap.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index bf5d0b1b16f4..72a98b2afaf9 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -86,7 +86,7 @@ extern int sysctl_legacy_va_layout; #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS extern const int mmap_rnd_bits_min; -extern const int mmap_rnd_bits_max; +extern int mmap_rnd_bits_max __ro_after_init; extern int mmap_rnd_bits __read_mostly; #endif #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS diff --git a/mm/mmap.c b/mm/mmap.c index b56a7f0c9f85..ed1b178b223a 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -64,7 +64,7 @@ #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS const int mmap_rnd_bits_min = CONFIG_ARCH_MMAP_RND_BITS_MIN; -const int mmap_rnd_bits_max = CONFIG_ARCH_MMAP_RND_BITS_MAX; +int mmap_rnd_bits_max __ro_after_init = CONFIG_ARCH_MMAP_RND_BITS_MAX; int mmap_rnd_bits __read_mostly = CONFIG_ARCH_MMAP_RND_BITS; #endif #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS From patchwork Fri Sep 29 21:11:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 13404843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4A1DE71D56 for ; Fri, 29 Sep 2023 21:12:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49ABC8E000B; Fri, 29 Sep 2023 17:12:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 44A6C8E000A; Fri, 29 Sep 2023 17:12:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EB1A8E000B; Fri, 29 Sep 2023 17:12:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1D3348E000A for ; Fri, 29 Sep 2023 17:12:06 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id F0395405A5 for ; Fri, 29 Sep 2023 21:12:05 +0000 (UTC) X-FDA: 81290882610.16.4508633 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf16.hostedemail.com (Postfix) with ESMTP id 1F1CA180011 for ; Fri, 29 Sep 2023 21:12:02 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=qsmBK5TH; spf=pass (imf16.hostedemail.com: domain of 3oT0XZQwKCKgaIUQbWTdIVMVOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--samitolvanen.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3oT0XZQwKCKgaIUQbWTdIVMVOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--samitolvanen.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696021923; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=19scQT+vZguMbMPGvwbswmmwWeMyYkP13y1R8IKgsdo=; b=NL6W4zRU4HXM4FGmhjjt/0/S+yOim0pp4x4QudY6QEDLy5lQQHU82td07W6PpwQi0TG/hR tp4DD8eF8weqkxW9lskUCaUVNJl37KG32gQODM/leMrtNYXof/jpa8Hsxy7uqj6oQllP3P w1AesMvBt0DZcYHVwGEg2F82Hfh+Te4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=qsmBK5TH; spf=pass (imf16.hostedemail.com: domain of 3oT0XZQwKCKgaIUQbWTdIVMVOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--samitolvanen.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=3oT0XZQwKCKgaIUQbWTdIVMVOWWOTM.KWUTQVcf-UUSdIKS.WZO@flex--samitolvanen.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696021923; a=rsa-sha256; cv=none; b=du+ziWt71lkRhQumw834eZ9Ep6FfaQn6z9w+wF85QJYUTgURNNCAUYDaEaRNS4uURA6Yrq ca6t2Fx0tF/3xPsSQCjkP4LZ1o6Ne63ZRYAQNNYlYhKMkry6l9UXjqJlqVC5oEB+sJUAqv r8+hmq7v7Ji7QbKz4LEFbQ55ChHZhis= Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-1c625a7c507so101652925ad.2 for ; Fri, 29 Sep 2023 14:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696021922; x=1696626722; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=19scQT+vZguMbMPGvwbswmmwWeMyYkP13y1R8IKgsdo=; b=qsmBK5THV3suNN9acb6EUPHXx58oQ37ADI0BgkUfLrg+yxlJqt8TeX3aPMKZ7Q/0GD m+n8WLh4AUe3Ud+MGfts2lUBWfxtH2VtGNW9Lv/n/FiQJR3u25D2t2drmAuYZUNRN50S XDStz8a5KijhAaFcwsa3AhDEpYAreR+jep5SiX3NfOLV8D+43Br2UsctbvCBwdieCDca +civTFynPklt3Hr7p7808PoNP3i+LIePM56waMXsx9l6Ww9z8fSdpxgWNkTZ2xtKBrD4 6QufSJVzckoDPhftTSpc0KgU0SsUlh7B6H/oUSSeTrxYX3pNXJjViozEg2W52IcTK6ts trzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696021922; x=1696626722; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=19scQT+vZguMbMPGvwbswmmwWeMyYkP13y1R8IKgsdo=; b=Ka3HxiM2l6/YIWFkLo/1+OfV12yoRgWROavQvE764jVZ58N8pu3AUhrOPtugKkVbsd Y0fVR/mJAbUclp9nsjC9P2c6dyp9xswk8mZfL/Bymqy6xd8WFVManN3fp2t/yUP3YJN1 TKhb54npTVgABKgZrDGAqKtXiuCADdinWoT8LU7+iGB4lvTTzjMBEofkcAa15kpHcJzr zMQixtY24sJcgSOgtiwacwH3i6+hBlXua54GH4RXTcN3t6SVxZiCfJqpDpY331D7aGQj ekdJovJon62pel1l2E7jaK+OgLs3hf/AzTye2r75jOF6EVXD2id/8moVVzWJ75D89Ax6 OS7w== X-Gm-Message-State: AOJu0YzI7h7pt62iUuwBC4nLRlWb8A994dkTBsIgsrP4F1KzMjkHP0MT DmjkgW2XVchQpHZ8wuECnxdat+XOFKpBQrZYEIk= X-Google-Smtp-Source: AGHT+IEu8pWqkhn949EN2w2MEEmF4sIQU2CD0ztiPLeuQl+OuKcbvmbHD9LpYfISQSvkmvSO3SxPVHDUipdN2Hi1oC8= X-Received: from samitolvanen.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4f92]) (user=samitolvanen job=sendgmr) by 2002:a17:903:1c8:b0:1c6:d25:8730 with SMTP id e8-20020a17090301c800b001c60d258730mr75155plh.0.1696021921796; Fri, 29 Sep 2023 14:12:01 -0700 (PDT) Date: Fri, 29 Sep 2023 21:11:58 +0000 In-Reply-To: <20230929211155.3910949-4-samitolvanen@google.com> Mime-Version: 1.0 References: <20230929211155.3910949-4-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=1191; i=samitolvanen@google.com; h=from:subject; bh=MSLQAq+u1Gq1vqQPv1L24OvfGxs9lQjVrKINsuZaDko=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBlFz2bXFheIUWsMCgpXroYNEMEHJSzh7lHXZPhb Ah07CUmBI2JAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCZRc9mwAKCRBMtfaEi7xW 7oPqC/9r2/xEbO/XFpLcUfW8kI4zwGyW+1Bc7PLy9I1XUD02QER16SuVa1TjN8rJQPDmOMsvTB5 T5jEE8zHkuv5iPAUTq/yfdsqgq7Z9o7WUqulun2nOY9Z455ZDOwLvbCIfEXhOthriqRBjm08Kd8 068lN/FADXcZatUB50UlQahfJo08fLC7oUQ5xDGv0aXR6pnqONVNs/F1FhlysA15ZmM0HVhJePX 6NcJ3HNNPyvbDbeafLIysEsEirdqqDLbxHXo6W0v7OFcevxKffQom+ZUD8w0SlBJsnrgLSQYfrL 4SDgYPIT3RgVrVY58SpSU/IrpswNMkcW1oGV+VpuE8vh5HfISvX0Y/jFIK76jIL1xM9gdG/5oKD xSBdaJPOnpK9Gcze/0uC08IM5oubP3raIy1qzWvrbWFce1KlRfKgkHLVVNp7KcJmqHe0lhZqoI4 gKx2VGQd8AOM+C9TUeca+0u6bNkxxIvvO6e8Zupt2MkaleKzO1xxv6N14XGwr2/VkIpsg= X-Mailer: git-send-email 2.42.0.582.g8ccd20d70d-goog Message-ID: <20230929211155.3910949-6-samitolvanen@google.com> Subject: [PATCH 2/2] riscv: mm: Update mmap_rnd_bits_max From: Sami Tolvanen To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Morton , Kees Cook Cc: linux-mm@kvack.org, linux-riscv@lists.infradead.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Sami Tolvanen X-Rspamd-Queue-Id: 1F1CA180011 X-Rspam-User: X-Stat-Signature: 9hg7twofczyiukaes547f467qmnhapg5 X-Rspamd-Server: rspam01 X-HE-Tag: 1696021922-32201 X-HE-Meta: U2FsdGVkX19kQgdDJnfqDG5CuX9oAeGwQ5E5b1YRwVWUBTeybv8XVvf3EE2Q6QZmWiuFBFagmrIj6QNJ7McF8ROftBmZ/CJNIv41E+62CET6H91JUXzSSHWu0OAIKqBB3psiUO968xTKzYxmjxN0WSS0P1D2OzuyRZurL/gDyJCMX2oqQ2JMfIoc3mgccG3gAVvpXjZgVJBztho/V9oL15jwTOd3ASKlG+286Feey6r8jDJSlJBVpRFoLGE0oFTf5TBoK88l1RxLz55SFXYxfKRMn309Pf5kANjjHB+hHN4ge+yEPJCoGEOinzewq8JJWxYKRGn+7VxpkYn1Rw+gm+JH10nZ23Fe9dqLJP3iBpD5d0/13/tTRVcsXmyGJPZW75Wdmracb7WJKzjH9z7BzCShkMIWu8/6MLbLJGyT98lZ537/bKmR2hrXILOTrXj0ExQORM292D4Qbmuog7S/ePKSJlUVpszMMjbW5zPwMcj6FebfKtsn+TfN5scoZ6AyHO+f6Tq4xgNQkWkNfHokVxoeIaoNiS4fGjKDuR01gX/By5SIPnoVKXIQmN4GJ1SP1YhoXkf9DdeZf/sV53+YAOBecE9U9qQ3C6OeWkx0eA+yEw+uhD72h008Uu79c9Wua8cW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icity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: ARCH_MMAP_RND_BITS_MAX is based on Sv39, which leaves a few potential bits of mmap randomness on the table if we end up enabling 4/5-level paging. Update mmap_rnd_bits_max to take the final address space size into account. This increases mmap_rnd_bits_max from 24 to 33 with Sv48/57. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- arch/riscv/mm/init.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 0798bd861dcb..ff8d21a6cb2d 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -762,6 +762,11 @@ static int __init print_no5lvl(char *p) } early_param("no5lvl", print_no5lvl); +static void __init set_mmap_rnd_bits_max(void) +{ + mmap_rnd_bits_max = MMAP_VA_BITS - PAGE_SHIFT - 3; +} + /* * There is a simple way to determine if 4-level is supported by the * underlying hardware: establish 1:1 mapping in 4-level page table mode @@ -1071,6 +1076,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) #if defined(CONFIG_64BIT) && !defined(CONFIG_XIP_KERNEL) set_satp_mode(dtb_pa); + set_mmap_rnd_bits_max(); #endif /*