Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp453141rdb; Sat, 17 Feb 2024 17:25:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX8s/48C/xyF1IhVukZQWXn5pw76YRCOuQeiC3mc5IMCpYyufiCkQsa4y5X2ht5HJ6xK2tNjpan7GoLlr8A5e030IWzsx677zTKCCWEyw== X-Google-Smtp-Source: AGHT+IFov99nGAlyMVwFVQ04hYLaG4QY16E57hNFH45oKqgftvaRglirtq6j+qwqD5YyVkhCfuCb X-Received: by 2002:a17:906:b0d9:b0:a3d:2e0e:3f52 with SMTP id bk25-20020a170906b0d900b00a3d2e0e3f52mr6495703ejb.37.1708219548495; Sat, 17 Feb 2024 17:25:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708219548; cv=pass; d=google.com; s=arc-20160816; b=Y3YTgHiAnLdekwtWpDG9O8oIUnj1d0eJexh564yYX7DDBmAhNmwXC79O1z/4l5r0T2 ygyGLf9gRnsMtFOCcKzC5Noq5qo0VG/hpHJGNEiaS4N7fi2L3dPZrnCRFOWjYy4lCcPl UWyYHiI4FQdBs/RbfArMqzrmKuOTc3rjqihB1S8jEB9Tck5vyjPOoPJ+jWWA8f+peQv2 hq1R3THy6EkocZUub7F7/ufut7h0FAwG2ihLfFU2nIjGGi2BFG6w5TaoubkCpVMakcxi UtucbZ+KQYHgD7fyROwAmgBuqAc9jGrLL+1HLUyigDX+/N4YEJlixm+hU4LFSm1iFuJl 27+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=VuoBtT2e7jiJsHrgcaJkRcD5zeydER6RGTa0O/OCH9A=; fh=tVqFVjmFWIKuc3RseDhNJjNdUhYfnd6WDGDTf+G8ack=; b=SGALSgUH9SHmIxuL+uRKb2aYhjoHhmRZ8jbdNAET21cIQj7aAflVhCVFjnvnKDdYjb s/Ma4CNyXsN3zwMHlFzFawUpAGF2YUvgZI+TdFZun0ZL7OJ3elqdn6y2xdmNszP0K9/R chthC1pQVqpIqUEd0cEx3qA6959zjVxiTljk19/Pvs310Vrmntb2UBi5u2hdy2a7bm+r duFMuznGkIYA4HF3ChE9eVxte8OR5XbG0K2zysvRXxNFQF/kjscIc1nmp+QVFl7xfouX 89lZ6jxYBcRtzf4mai1N4o8f3EdWPFvxp9dsx92cdlQ0WKwH0mxEmX9u0jVhakaV5f9Y DtoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Xq5UyXTr; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-70135-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70135-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o7-20020a1709062e8700b00a3e40929aabsi602306eji.151.2024.02.17.17.25.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 17:25:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70135-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Xq5UyXTr; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-70135-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70135-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4306F1F21DE2 for ; Sun, 18 Feb 2024 01:25:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3ACDF15D4; Sun, 18 Feb 2024 01:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Xq5UyXTr" Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1BF8EDD for ; Sun, 18 Feb 2024 01:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708219537; cv=none; b=q+4DTXOESV9TuKbYy5z/DItD+U2BpxcYzzwBDpX213rCGjB5y+yb9v358pTTfd85uUXEV+07c/e9HI8YAFi1N3Hhw5PDS0W2Za9NlbUaUoFKN0QR9EtB1WoM7arw3da3a0BcjZtcGGHbiF1n+UDfw8YD+k0DehRdQRmDd1BFbps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708219537; c=relaxed/simple; bh=a3hJQoAtYSUkKDh/waTTxwVQsYYIvXqoZW7AfetXO1Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jyLzoXdIC/mG9/DDqzFIjUc4szjV4TqCiT+F1JICCyaF/ZlN1zugwZMZhYWSr/ekFk3kP0+ePfmqup9QRAhRrnFSXWFGGlT+g6TwfcJxJMOLbVVg3kP/Fid5wwTGw2Sj802yI4UP4yR1N/sY3Q6q0ky5mFKhGxZbaXb8Q8DN6fs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Xq5UyXTr; arc=none smtp.client-ip=209.85.160.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-2185d368211so2009527fac.3 for ; Sat, 17 Feb 2024 17:25:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1708219534; x=1708824334; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=VuoBtT2e7jiJsHrgcaJkRcD5zeydER6RGTa0O/OCH9A=; b=Xq5UyXTrn3X6COKYrRkFMlDVB0KcI0cr+RjjxXQ61P76WT6ApgRMYI6+4wF4Gv2qhI ggfozzffPJun+wMy5DBToaePmcgv12KzuLyUHk6eA2H14zScdcgC5MIfFEalLnastZUf EUbbNOXTUILTpIP1xoT4D6ygu0h3oCCzvrP0E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708219534; x=1708824334; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=VuoBtT2e7jiJsHrgcaJkRcD5zeydER6RGTa0O/OCH9A=; b=TidZMY2nSlE6GXhFlrP7HvBcUeBH5n1PNb2Ix0C48s7yl3l6I+uR5XgaDJcT6Fjr85 or6dy/lyJ2eyj5M7e7v5dH7Gu3Oo8JL0gLXJvUf0ZyPl+k5S1HR+qspC8oQ5pc6qTHCc LThr3My/kTss0eNtf94buHT4JErcgL2Ui+487PbQ6WamUCza1CMYhO93Bk7xXnRBqt4c 3Kunlf63LMBg9WcULpB9t1oQEFj2mmmER4ZfLbjEIFGQN7Qvh2tzhIRTxhzbtJwxIw/T mK/9k/M03KA4ZwZrxmnkssdZWgbrunMVYnTVQJWpZxCU8X+uhRkLxOgR4bJF5EW8B2RG tSKQ== X-Forwarded-Encrypted: i=1; AJvYcCVZHzddDYf2nDlBa4qoJrXfEjUWavycLEeewnLn+4sewHKnrDzn7znwqCPD/7NGbxm0Is/1moG5+PqAkdEKMusitptW4dIv4o+X6cRJ X-Gm-Message-State: AOJu0YyUGCMV5HUcOLL+Vjo4/pe1otSyqU6TjzDJ92OHklVP8Ed0jhWx rzZ4WRRXA4L0hddvbBMRJopGwKIj4tZkrXXDbVarGEEZ8zxHjrPkWBaxzQ4LgQ== X-Received: by 2002:a05:6871:453:b0:21e:bbdf:8b94 with SMTP id e19-20020a056871045300b0021ebbdf8b94mr543705oag.37.1708219533979; Sat, 17 Feb 2024 17:25:33 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id r135-20020a632b8d000000b005dc4f9cecdcsm2168893pgr.86.2024.02.17.17.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 17:25:33 -0800 (PST) Date: Sat, 17 Feb 2024 17:25:32 -0800 From: Kees Cook To: "H. Peter Anvin" Cc: Jiri Kosina , Geert Uytterhoeven , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Peter Zijlstra , Qi Zheng , Alexandre Ghiti , Al Viro , Christian Brauner , Jan Kara , Eric Biederman , Christophe Leroy , Josh Poimboeuf , "Kirill A. Shutemov" , Rick Edgecombe , Brian Gerst , Bjorn Helgaas , Tony Battersby , linux-kernel@vger.kernel.org, y0un9n132@gmail.com, x86@kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH 0/2] Adjust brk randomness Message-ID: <202402171723.914538A526@keescook> References: <20240217062035.work.493-kees@kernel.org> <05E12A71-D8A4-4E6D-9C9D-024251C1BDC7@zytor.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <05E12A71-D8A4-4E6D-9C9D-024251C1BDC7@zytor.com> On Sat, Feb 17, 2024 at 04:25:33PM -0800, H. Peter Anvin wrote: > On February 16, 2024 10:25:42 PM PST, Kees Cook wrote: > >Hi, > > > >It was recently pointed out[1] that x86_64 brk entropy was not great, > >and that on all architectures the brk can (when the random offset is 0) > >be immediately adjacent to .bss, leaving no gap that could stop linear > >overflows from the .bss. Address both issues. > > > >-Kees > > > >Link: https://lore.kernel.org/linux-hardening/CA+2EKTVLvc8hDZc+2Yhwmus=dzOUG5E4gV7ayCbu0MPJTZzWkw@mail.gmail.com [1] > > > >Kees Cook (2): > > x86: Increase brk randomness entropy on x86_64 > > binfmt_elf: Leave a gap between .bss and brk > > > > arch/x86/kernel/process.c | 5 ++++- > > fs/binfmt_elf.c | 3 +++ > > 2 files changed, 7 insertions(+), 1 deletion(-) > > > > Why do we even have the brk, or perhaps more importantly, why do we use it? Is there any reason whatsoever why glibc uses brk instead of mmap to her heap memory? > > I thought the base of the brk wasn't even known to userspace other than in the form of the image end... AFAIK, it's part of ELF ABI, and the loader uses it only for very early allocations. e.g. it's what shows up as "[heap]" in /proc/$pid/maps. It's also available to any program that wants it still (see "man brk"). I don't think glibc has plans to redirect it. -- Kees Cook