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