Message ID | 20240217062545.1631668-1-keescook@chromium.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 DF37AC48BC3 for <linux-mm@archiver.kernel.org>; Sat, 17 Feb 2024 06:25:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E49246B006E; Sat, 17 Feb 2024 01:25:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E1FFE6B0071; Sat, 17 Feb 2024 01:25:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C99776B007B; Sat, 17 Feb 2024 01:25:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B6D026B0071 for <linux-mm@kvack.org>; Sat, 17 Feb 2024 01:25:51 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 74BD3120188 for <linux-mm@kvack.org>; Sat, 17 Feb 2024 06:25:51 +0000 (UTC) X-FDA: 81800310102.14.B369154 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf30.hostedemail.com (Postfix) with ESMTP id A5E2580010 for <linux-mm@kvack.org>; Sat, 17 Feb 2024 06:25:48 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=gDxObcmj; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf30.hostedemail.com: domain of keescook@chromium.org designates 209.85.210.177 as permitted sender) smtp.mailfrom=keescook@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708151148; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PfIR0fBKHcHTu35XI9I/l5YesMfUJfSS9sUu5LMaD84=; b=jU6T4Oj2PsAoJtbFAb4f3rZ/w7qCAdQNMSjtLMRhGemKtvkElx9gEkb+edDzAQILqAfYFh 0S9N03XHyWn7WXmaiiUfhuhn1EdrqKarn0fprmq87nbMMNRai7qAeLHrwSGAcJl1UePJaW hJ8EJ+z85vxOU8c6Z2FdldbU6KdEINI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=gDxObcmj; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf30.hostedemail.com: domain of keescook@chromium.org designates 209.85.210.177 as permitted sender) smtp.mailfrom=keescook@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708151148; a=rsa-sha256; cv=none; b=rye714A9N4M+8Y8ADFzsllqNFutvRDoVw2VBWzrav5va1KtSHUX+JkPiJlL/TCRyYPRoMe EcDTBvujoqsbDnO4dzostctPE195Lztii0OiqKhp5qeuwlJqNv2CgspkFHcJcgjgIIoNAh nQupw4qqYmVk48x/Rj+zhfG4Ld+hsvs= Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6e08dd0fa0bso2340953b3a.1 for <linux-mm@kvack.org>; Fri, 16 Feb 2024 22:25:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1708151147; x=1708755947; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PfIR0fBKHcHTu35XI9I/l5YesMfUJfSS9sUu5LMaD84=; b=gDxObcmjIstvAGoFqesuYR/Ed4Kl1VsSRWGxUnbd/UMZp2sMsHNp7/JGlzRcgtT1si j/39bBTodsJeX3FwcBl6oFrGjSi/I3sHR2OllcMYfyKS6m13mnwvHbyw+uaJ9BaoE3+C 0tHBYkXrMf7XpVoC49plSUdUdIFCsglENQ0Mw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708151147; x=1708755947; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PfIR0fBKHcHTu35XI9I/l5YesMfUJfSS9sUu5LMaD84=; b=qz8cZ4xVUTdUanGg0xb4bsvh7w1opzOV8Vt3C9vNbyQGMGqOGroWN+JsOSAB73R5l0 pYKYe4eq9+l9zgX92jdAmxVnDPF/RDp/aYNtuqbe37Rv9nbdXFRYaw0UucI14BxtIuOL GpLzKKbj7vV8Mj8zKUDsheUC8+zWQWcINuT22geUIlg29jFKDMMNlgryJF16vd6W6bci GzTiMy/j/9X32Hd1jHk+eaHdp0ofdNMT9o+nLUAO8ilgHxaIZxiAvYKTu74P/3TXlJ5q UR4x5RA1nR70n1kMQdV29d6uaFm3360wW+6GGJ7j6E9d0i89zoMUaf/ykDBWyfcuyJIB JyzA== X-Forwarded-Encrypted: i=1; AJvYcCX/ah7sVOyHIlEyx+gHJpvUQLoVUt5zC1SFuzuO6qhXI0FzRw1WedHbWDx5aTDmKMGqlnPBkXjESQo9FFqBbnL8IeM= X-Gm-Message-State: AOJu0YxvCO2SrThIVA3K2wf+SuIn66XJHAdWy1rK8FS/KUcxK8UOYA+Q hZn9Gl/DYXdH/1qa+0PP4Yz2zGQZ8K5QIQai4Z7XMqpbvEhF2bsPji0zoitY3A== X-Google-Smtp-Source: AGHT+IEN7kra6nhd0C/U//cqra0sN9TAy99jtLP7gl6N1oR+rsshp77a8Yk2AxFV0aGXX6usEqGwwA== X-Received: by 2002:a05:6a00:2292:b0:6e0:8c11:9878 with SMTP id f18-20020a056a00229200b006e08c119878mr13296297pfe.7.1708151147635; Fri, 16 Feb 2024 22:25:47 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id p9-20020aa79e89000000b006e35c1aceeesm233949pfq.197.2024.02.16.22.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 22:25:46 -0800 (PST) From: Kees Cook <keescook@chromium.org> To: Jiri Kosina <jikos@kernel.org> Cc: Kees Cook <keescook@chromium.org>, y0un9n132@gmail.com, Geert Uytterhoeven <geert@linux-m68k.org>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, "H. Peter Anvin" <hpa@zytor.com>, Peter Zijlstra <peterz@infradead.org>, Qi Zheng <zhengqi.arch@bytedance.com>, Alexandre Ghiti <alexghiti@rivosinc.com>, x86@kernel.org, Al Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>, Eric Biederman <ebiederm@xmission.com>, Christophe Leroy <christophe.leroy@csgroup.eu>, Josh Poimboeuf <jpoimboe@kernel.org>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, Rick Edgecombe <rick.p.edgecombe@intel.com>, Brian Gerst <brgerst@gmail.com>, Bjorn Helgaas <bhelgaas@google.com>, Tony Battersby <tonyb@cybernetics.com>, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org Subject: [PATCH 1/2] x86: Increase brk randomness entropy on x86_64 Date: Fri, 16 Feb 2024 22:25:43 -0800 Message-Id: <20240217062545.1631668-1-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240217062035.work.493-kees@kernel.org> References: <20240217062035.work.493-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1595; i=keescook@chromium.org; h=from:subject; bh=J8yZ3FuS1LWrR5jVIrwba2SyB7GFZoxGQ5Gq7wzczYA=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBl0FFofylSSc0zctidXuws91GIZAfUD3EvfMTgD C7ILFWiQEWJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZdBRaAAKCRCJcvTf3G3A JuvKD/0YST+WQlVawQvhCb3pQXdND3wneO4rAAc1MIaPKKYFGzOMCeSQYBifV0JEeFHph1WsrQC n4+hCw/MTLwSm24DnSu1EEevAaPtL2voVeq16UMZrkG/yapEWn3+250s3daI8qSEHpaTs+lqmrY 20PeyS18a3NDnzD6VRtlc/Ud4NM4lTrD59tsR9Zypsk8QkTOW11SzkDOU36Vewr5lvz9WlASgCb uX115bQ6YNYuZQkpWi0z4MlnmeNcdOuQnupP0FwTKJDVMHrN+vvFac+rR68LNoQtHQMqb0yZKXr iaQfIX0RbdI1t7Ns/XMSdQQfLgvkslY3PnQ7KanuL/2iVQSA+qYKaUHT1q5rU9VB+w3Dck4Dmye Mw0zNvdQB8Y4A4EnGY6HYyO6ucLRSQtEfIuXbYYszYSq6wZmHI2F8gQrXTQN6dKrHavZBh6DOSY Ep4Xtnl5207P/j3tkJ2WlgxPesAECiupJebylL9V96dhr12EkUmNs83ixnDjhgIhd/q1C66ZLuD gOP5XrfxOIcEw0QQFj8sFRcjpHdAnouwZruQruo4ED1IAeSMX2ThvD6Di09uNBuIX4r27aUDkF4 PMMxi3r0jO2Iy/OhTCP2lOG3dtuz7BSAH3EaHzmxqr7QyGazjc6Mux/rumcsyyFjQTLaXMsCYg5 3MpCUeeX8WL+hxg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Stat-Signature: qbmxfyqo6mcgnmrnw375fdduofd9pirs X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A5E2580010 X-HE-Tag: 1708151148-72191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LJp1RjuNQojHxfH7VZhjUGJ0Fj7ym07uYezmjeCCqv9ZFGgKdA9WgZtxIElvVAzXO93G+JGv8MnbE828qn1cgJ3Xavp2WBl96BZ1qI= 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Adjust brk randomness
|
expand
|
On Fri, 16 Feb 2024, Kees Cook wrote: > In commit c1d171a00294 ("x86: randomize brk"), arch_randomize_brk() was > defined to use a 32MB range (13 bits of entropy), but was never increased > when moving to 64-bit. The default arch_randomize_brk() uses 32MB for > 32-bit tasks, and 1GB (18 bits of entropy) for 64-bit tasks. Update > x86_64 to match the entropy used by arm64 and other 64-bit architectures. > > Reported-by: y0un9n132@gmail.com > Closes: https://lore.kernel.org/linux-hardening/CA+2EKTVLvc8hDZc+2Yhwmus=dzOUG5E4gV7ayCbu0MPJTZzWkw@mail.gmail.com/ > Signed-off-by: Kees Cook <keescook@chromium.org> Wow, this is a pretty aged code indeed. Acked-by: Jiri Kosina <jkosina@suse.com> Thanks,
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index ab49ade31b0d..45a9d496fe2a 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -1030,7 +1030,10 @@ unsigned long arch_align_stack(unsigned long sp) unsigned long arch_randomize_brk(struct mm_struct *mm) { - return randomize_page(mm->brk, 0x02000000); + if (mmap_is_ia32()) + return randomize_page(mm->brk, SZ_32M); + + return randomize_page(mm->brk, SZ_1G); } /*
In commit c1d171a00294 ("x86: randomize brk"), arch_randomize_brk() was defined to use a 32MB range (13 bits of entropy), but was never increased when moving to 64-bit. The default arch_randomize_brk() uses 32MB for 32-bit tasks, and 1GB (18 bits of entropy) for 64-bit tasks. Update x86_64 to match the entropy used by arm64 and other 64-bit architectures. Reported-by: y0un9n132@gmail.com Closes: https://lore.kernel.org/linux-hardening/CA+2EKTVLvc8hDZc+2Yhwmus=dzOUG5E4gV7ayCbu0MPJTZzWkw@mail.gmail.com/ Signed-off-by: Kees Cook <keescook@chromium.org> --- Cc: Jiri Kosina <jikos@kernel.org> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Qi Zheng <zhengqi.arch@bytedance.com> Cc: Alexandre Ghiti <alexghiti@rivosinc.com> Cc: x86@kernel.org --- arch/x86/kernel/process.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)