Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1129239rdb; Mon, 19 Feb 2024 05:22:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVeikJ2Y5IU1irCLHZMcBV6DgW+k7ULntd6vCzOMQG/l+D2nr0pqiFCmPKiIsHk8trPr537BR/pPqZI3W//QHbzr49epGZLqJ3DoXF+xg== X-Google-Smtp-Source: AGHT+IGpjaCcwKMk7/9mDeWxKKGT7YwFftYLtgHGcZ1V9Cwe+U32EIkB3cjutbwckeBvNyhA1Pmz X-Received: by 2002:a05:620a:171e:b0:787:6c4e:5552 with SMTP id az30-20020a05620a171e00b007876c4e5552mr2269321qkb.74.1708348949023; Mon, 19 Feb 2024 05:22:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708348949; cv=pass; d=google.com; s=arc-20160816; b=p3il5qwjtxHXvB2o7hP7Lm8r7PVFTzPqrgi6Z3h4Ux6mB4KTRM/zv7W4ptdx9tWjsB Vjho0m+0R3qs0f29UOkVXajnwTA6BvrwVkW3YJgSv5on4JhRDAAhuIOHy4jyMmtaNyKY Ul044YiqN9TrOxWRp37QYwQ3U3Wda9/dzTb8qrTDyzxHhotiXuEannFRtQhVEWkekOJ6 hJjpo/V6BfoHXwIsAQBmu0bgMBwWMhQXLpkGPYuDH0xH/R4v5uIzk3RMGsafsEv2EYSS 64swSC0tsT7PVHbw4o11nsuXBxqb06myd18HKmPVdDElSJA4tDIic5SkKRMRqXjGsddV otJQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=XR/z2c5RZraUzauY2z56Ou90i3GAu2aYjsgtVMp28As=; fh=icPIS531c/mGqIx8j+SvKDLuqwguKrMxcFZwIbl1cc4=; b=hPjEubuVBNIBPykaXNKLdgjDoYcF+MCubVPFVUsTZ9vx9UEua9CwQ6a4fXZGu0jggO UXHac9nxF34jo6dqNFz1FvKNX004fSkzPnAj8LnG/gh7e5TM47elZWLxSGZUVjxlyuZe g87FFkzwNnUpw3sj0TKH3doog5oCeKeHvlBm/iOKr2wzd3rrPKtKSw4T9T/MX0zqO7XW Dxi3K+QjV982jdyEmeJrioHID8a9LuJGq1s1f+afm8UNuO/tpnp2qNRXcWLwrmdnpmNJ EkprCBCFowTHn5eCU1AcCAWRfITuU4zTJ3tkgHS2tVbV9yvwmhIy/3Pgw/aqB3XvAITU LOlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="dxKxvUE/"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-71399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71399-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w25-20020a05620a149900b007873e53a462si6163217qkj.338.2024.02.19.05.22.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 05:22:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="dxKxvUE/"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-71399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71399-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B630F1C21861 for ; Mon, 19 Feb 2024 13:22:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F235A36134; Mon, 19 Feb 2024 13:22:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dxKxvUE/" Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 747ED364C6 for ; Mon, 19 Feb 2024 13:22:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708348937; cv=none; b=nh+ekG/oSA1kkEHHnBp/QCOXU1dGhXJisBA5CDjftiN4xfzNio3mRxfg6QclytiijM7Ny7auVIlQ9yapkatya7XX0sOvViwMyEP0ylyFVmvAtLLrc8Iym+J9mnPCZPTrZ5m+rQj7VObopuCJneIcTFFzF5vh6AGcytvFv4SvkMs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708348937; c=relaxed/simple; bh=7gbzT0bFlv7Vx+qBIh0t/oLWx0mTJwXdNjLV3zbFmRU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=vA1oy3LDYSRZLgAUrCbDevM/X42YlRpcI/uEZqdvstxmS+Y8Jj9N2ICf1kxRDY5Ph7BLvqvVq1uU9xI8lCma6oCcmpA8EQg6NqJXoBQkVIp46Qj3dI1UFgIAnI08eFKk6omYWoOvAwFDgIvyG2ZS7TF/a1Zb+5EozwDjtAVnv6g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=dxKxvUE/; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5647f4aac6aso7092a12.0 for ; Mon, 19 Feb 2024 05:22:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708348934; x=1708953734; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XR/z2c5RZraUzauY2z56Ou90i3GAu2aYjsgtVMp28As=; b=dxKxvUE/0uVP0R13Uri2E2vM7/cRDswa7hV7Wiekqx6dUuev7d3+nG9k/Cej0NhUnO AyGz4duGKTbwCsEzytJw1Y1TFf7PtrdUmHJBxOdUfAY9XWwjOe2eySWLCWhDHBMrXpl/ if6HP1itS5gN6ErgWppcURwDjhjvjtVDF1SVb8fOtYIqcbsbJchs3C8TNfDCXLibzhqs Lylm9vkW93wM5yLV8kz/K2D0vvceD/hp/ycYCOJH3VHS56cn9lpS214CDOTbuaVneHah OipvVonwqCasJ+RiBnrg63+bpQ5E46+k8PJio7By6K7UVl0TLop6ZGHUa39J65vquGmP VRZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708348934; x=1708953734; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XR/z2c5RZraUzauY2z56Ou90i3GAu2aYjsgtVMp28As=; b=V28IApBLfhRI9ConvfPu7sGuMe/EtPnwo4ENLxbInUECGSI8aJzyP6/O2DX/eDEvl3 TH12W5iqt28ecNnO6sZrUZ4ULYXPRpRk5LpSgFUB7Y75sGLwpCFCE5BsfKQrSWA5zEam 8YdDNTabf+poYSEIXa8vwriCj6qYNxk+RU4qj1DXX0tLQsjsKAPcJM6yu8DvjsCtDcEj e4T5iCIIPyuk/R52RVBvTwSC+mDYyqpw0oWSP8uhZWMlgmo3i5UTSgKt3zWhiusb44sU Jp4g0oVMP2eyocis2zDCrHJ9VhlOpq6S7ZLDpQvPUKPY6oZX1J2AGkYkP+wvN3EHz5hD jZnA== X-Forwarded-Encrypted: i=1; AJvYcCXZi61J9+qrK60whtroraH23hNvu3LE1V8VYt80PHwEllnx7D1k8VY39KzVvfj0iuj3WXJeqNw8rDJY0TXtTJnXQxqk45XdZ1+cqCEd X-Gm-Message-State: AOJu0YxDn5T76+nTraGYuDswyJ5VrW0YRWKDunekduZQx4UxBy8Yfgv2 DqLNM+arQX9F+9K/SPumjRt5L3BA4if9rGHVqSXMudWuDBx00jrR753cfDKDKtUDuiZnQIy/hlw vx1W9UR0EKNRN28eEdDGF5GNtkTEJvKr0sBOLBPDmtW9gq9RXqfQl X-Received: by 2002:a05:6402:1649:b0:564:55e5:6ee1 with SMTP id s9-20020a056402164900b0056455e56ee1mr140228edx.2.1708348933587; Mon, 19 Feb 2024 05:22:13 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240218073501.54555-1-guixiongwei@gmail.com> <2024021825-skiing-trustee-a56a@gregkh> In-Reply-To: <2024021825-skiing-trustee-a56a@gregkh> From: Jann Horn Date: Mon, 19 Feb 2024 14:21:37 +0100 Message-ID: Subject: Re: [RESEND RFC] kernel/ksysfs.c: restrict /sys/kernel/notes to root access To: Greg KH Cc: Guixiong Wei , linux-hardening@vger.kernel.org, jgross@suse.com, boris.ostrovsky@oracle.com, linux-kernel@vger.kernel.org, Guixiong Wei Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Feb 18, 2024 at 8:47=E2=80=AFAM Greg KH wrote: > > On Sun, Feb 18, 2024 at 03:35:01PM +0800, Guixiong Wei wrote: > > From: Guixiong Wei > > > > Restrict non-privileged user access to /sys/kernel/notes to > > avoid security attack. > > > > The non-privileged users have read access to notes. The notes > > expose the load address of startup_xen. This address could be > > used to bypass KASLR. > > How can it be used to bypass it? > > KASLR is, for local users, pretty much not an issue, as that's not what > it protects from, only remote ones. > > > For example, the startup_xen is built at 0xffffffff82465180 and > > commit_creds is built at 0xffffffff810ad570 which could read from > > the /boot/System.map. And the loaded address of startup_xen is > > 0xffffffffbc265180 which read from /sys/kernel/notes. So the loaded > > address of commit_creds is 0xffffffffbc265180 - (0xffffffff82465180 > > - 0xffffffff810ad570) =3D 0xffffffffbaead570. > > I've cc: the hardening list on this, I'm sure the developers there have > opinions about this. > > > Signed-off-by: Guixiong Wei > > --- > > kernel/ksysfs.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c > > index b1292a57c2a5..09bc0730239b 100644 > > --- a/kernel/ksysfs.c > > +++ b/kernel/ksysfs.c > > @@ -199,7 +199,7 @@ static ssize_t notes_read(struct file *filp, struct= kobject *kobj, > > static struct bin_attribute notes_attr __ro_after_init =3D { > > .attr =3D { > > .name =3D "notes", > > - .mode =3D S_IRUGO, > > + .mode =3D S_IRUSR, > > }, > > .read =3D ¬es_read, > > }; > > No objection from me, but what userspace tool requires access to this > file today? Will it break if permissions are changed on it? FWIW, https://codesearch.debian.net/search?q=3D%2Fsys%2Fkernel%2Fnotes&lite= ral=3D1 shows that (from what I can tell) this is mostly used by stuff like perf, libdwfl and systemtap for figuring out the kernel's build-id, probably mostly for kernel profiling?