From patchwork Mon Feb 26 23:31:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 206974 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2391285dyb; Mon, 26 Feb 2024 15:33:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU2SVEjnW5Si5+sWzVohwHS97PpGk8/7dQpn5q8o9yDFtiP2HL0kaaBgleqHEMKTtn3aLqDTcO+RZWMZiOnvTZOmgPA4w== X-Google-Smtp-Source: AGHT+IHjGlz7UA7h+9S1GRdYWUSGMwDTs/XqCGPDcEGjJ1dV6xBQdU3u8fb4pADVCy280kVHfQxS X-Received: by 2002:a05:6a20:d045:b0:1a0:ed22:1b7d with SMTP id hv5-20020a056a20d04500b001a0ed221b7dmr659110pzb.3.1708990398216; Mon, 26 Feb 2024 15:33:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708990398; cv=pass; d=google.com; s=arc-20160816; b=tWKFvQD6CbOroAku+MOhm63zPEzFw/TrqOnpRtlBXHccZAlFJF6U+JiW5OH4pmFk3z bka3UjXW835MQ48mo9NfXH/MnSTcuNrpj1vlyWdqUfsnBuHN/100TMLp6DAWD26DWb58 0H8B0//Mo9h3NBZlxdSE/cRqfAPOGNbXjb/5Xn+6cPAhBto4Ko0hMU4WsoumGYCDtvPa enveT8j/AXb3u1WWs5ezXENZfhnxs4rOhJDsuZ3bmG4Lv+xXJvd3vmiKiY2kfFU7OE8W uWlo5jW7srYLUv+8P4c5U1ehhY+BK774mBg+ik8V2sBdaFgkkw4ToSmgBWsYb4x7nvJF +Eaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=e/+vWLgFOyGXzZvHbRQQYhnMyMxUqGESN9iHCw7s5MU=; fh=MtyaghIPPcmQSOVmXLqWYBZZ9ZCAMyWP4nQn0bnol6g=; b=EfF7XNoI1Qta8YBoJvaUEdeVKPw7Xl854J+sv3j00GHCOy7DpXvsPGt5oDTanDB2k7 n1B+GAw6O1Edo+WvfyePstVAShQGtfq9RwPstw/x3cUYPT6PQqnnJxStjRLCSqwTkiu7 0j3Z7+A+oDa7XgColmqN2W0V0K1eCjdZuW3jkB9Rx4kC9PWoCstb08u9QAY4qlvXoinK 4AsTZABijClcQBKayqCzV7kHQKtYwJ5q+A2/MuvoptieLuynq36tJRp0TOHAA2JfAOZ6 znXek/EU7cu8cCqns7k+yIxADkzJpVyOq3H1MrDxl4/5EL0Sd2X7C/gVhG1+XtkJ7jam 5PCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0UBjxsy7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-82441-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82441-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id co16-20020a17090afe9000b0029a8498e2c8si5720742pjb.8.2024.02.26.15.33.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 15:33:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82441-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0UBjxsy7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-82441-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82441-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7869AB22E4B for ; Mon, 26 Feb 2024 23:32:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF99113666C; Mon, 26 Feb 2024 23:31:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0UBjxsy7"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wkbR+21V" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E16A60864; Mon, 26 Feb 2024 23:31:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708990306; cv=none; b=XfTGiHp2Z/PD0m4dy+8NpdvEo5hvDn1LR9UZSx+quOYTWVYIKeqC8mLRVPz5ugHeZ8ZHtpmFBoTpmsQPFtbeG6NttcJ/n5BBItnFLG1SofxK5OoQn5izIQGJZVEpzcGn0pImwyz/QgApEfYbwyqiIa6OEfIlkfBHesG/nzO9Pxo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708990306; c=relaxed/simple; bh=Uj02hhUC3ciONiJFobENSypCac+14b1YFOPPRCYYOlQ=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=tBETB6ST96BdOqZWFn620aO8jfUPuHy8E8GitT42H36DBsPNw0yL/Wks9CjggpAbZW94LKkSRfe9RYFXlhHi9+pCfqfBwtTK3Rwr2MW8WXMsHPHFp9nsxQ2iD5CbGig6m1psGjy6o7GCXuyMhJ/7NJ9EAJkT1dbxN1YIVsk1ZfY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0UBjxsy7; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=wkbR+21V; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Mon, 26 Feb 2024 23:31:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708990302; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e/+vWLgFOyGXzZvHbRQQYhnMyMxUqGESN9iHCw7s5MU=; b=0UBjxsy7MYD4DhCHeghuFlKmXEnFVl7qg09685aTjRLdVCqMxdPc/9ZDDZtNbUwWVmdBO3 xeelNLeUDSEYBYTrg/rboHdkPPVXeyBigZqkeb48e0DAl8T+CMplRLig8mjd4vuTJFa8+B TGEtwu03cWan7Yw84QEN7gXngCh3EjFxYMoqGgy/bWV1rWGP1+tF7Ds7mSPkizKfqLRpTF 4GDbwdlu5Eeo9J835AuwTTfnyjav30fBvK/pgeP95CHeB1oWHRN8GQkFWOIMlIfAz8er2e toZ8eTBBZPs54RjLMO5Q8HNV75L4GZLXCdiV/N0KaeDuR8LlIqHSD6d9qA8pZA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708990302; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e/+vWLgFOyGXzZvHbRQQYhnMyMxUqGESN9iHCw7s5MU=; b=wkbR+21Vwi8weJWoI5V+D8shkmOPlfhQjox5NUlMUc21r/szfO3Rmj9J1VVWK46suTnaWL fb+hpkyp59IPtgAw== From: "tip-bot2 for Kees Cook" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/core] x86: Increase brk randomness entropy for 64-bit systems Cc: y0un9n132@gmail.com, Kees Cook , Thomas Gleixner , Jiri Kosina , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240217062545.1631668-1-keescook@chromium.org> References: <20240217062545.1631668-1-keescook@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170899030090.398.7397849626399402025.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792006315704173516 X-GMAIL-MSGID: 1792006315704173516 The following commit has been merged into the x86/core branch of tip: Commit-ID: 44c76825d6eefee9eb7ce06c38e1a6632ac7eb7d Gitweb: https://git.kernel.org/tip/44c76825d6eefee9eb7ce06c38e1a6632ac7eb7d Author: Kees Cook AuthorDate: Fri, 16 Feb 2024 22:25:43 -08:00 Committer: Thomas Gleixner CommitterDate: Tue, 27 Feb 2024 00:23:55 +01:00 x86: Increase brk randomness entropy for 64-bit systems 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 Signed-off-by: Kees Cook Signed-off-by: Thomas Gleixner Acked-by: Jiri Kosina Closes: https://lore.kernel.org/linux-hardening/CA+2EKTVLvc8hDZc+2Yhwmus=dzOUG5E4gV7ayCbu0MPJTZzWkw@mail.gmail.com/ Link: https://lore.kernel.org/r/20240217062545.1631668-1-keescook@chromium.org --- arch/x86/kernel/process.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index ab49ade..45a9d49 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); } /*