Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp542476rdb; Sat, 17 Feb 2024 23:47:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUOWsOKZuF4DyHLfqIYIJBZhxTFe35FQy32Nw1hTEVgi/tEPs28Jq0rXgn2foHh6bwzbSu+CmzS3C2pMgdDuhIgbhz3cfkoL8wkD00Nag== X-Google-Smtp-Source: AGHT+IHfWX5DUy4EMtG1Ie7PXzxfGKtf60p84u1f+XxMdEwZSF0n8Xmw4QdRtOGSZ0Hjj2exkiD/ X-Received: by 2002:aa7:854d:0:b0:6e3:e797:2eef with SMTP id y13-20020aa7854d000000b006e3e7972eefmr1124335pfn.4.1708242440466; Sat, 17 Feb 2024 23:47:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708242440; cv=pass; d=google.com; s=arc-20160816; b=kGon3GCm8+d5F2ffLWQuhqr4dCR7Du0cmfkCdU7k/KkUy3fkFdX9+EWczl7YJe40Pk ctDsI1je8H3wS/HPJMefa4RRsfJIoeJTxWuSkXuvDUF0wSWvTzOoMD+HKtpG8Vdr/c8S jmKqrpigDlTuPmHPpfAWGth+OaP+7ANdF+mFd8feC+Vqy2FmJOS3K/jYz3LBKIEvK8QN 0ukMaWKim/6hmHAAE3X0+1tiy1nMFc2FqIxdoGJTcBxVuuOjfGrI/UKfm0iYwAGx/Fs7 CnUBeIxkJ5PYKnBioerEJ4RRJRP5i1Rj7zQ11Yp2ZZSfqTF8T3k4CqwrDOEWWvjAr8Ot 6reg== 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=sYCuqUtfvnneTztv9W1vNRX70snl+hPGYllAAcXMxCM=; fh=3ZAahSDC5ZgrmaYPuUx3j9sVc2LOsdPaXAmy/viMZRI=; b=jzFmyMUCnDA11HUUBCK+RmwPhEI0BPSewFKyqpMfRZLZzS8wcP22V8NPunpvYl4VaG jXsBoENgSeUahlAxim7Q70ClZYv/GDY97SUVNWGLUC0UxOAbp3HXMu2wUT+NvwEZzJ6G Bk2ymofsE2wodsp3M+J3INzfIh3Jrl1cETPtm1wAEz3Fo6Ia8uK2UrCZpaDKiz3DQ3O6 larQGrLghMCvOhghpKMHBfUiiX6mrWNqLsTRTzaye9p1m32B1n25O6mWqs8DE0pkCwfL Z5qa9ErvDxulntqzDocxpmLA60JjPvhcFkCsB9iDq1eEsbzwHg/x13Op4hTtie+GV/Mk FrcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lrJH4PXP; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-70254-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70254-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h18-20020aa786d2000000b006e090184596si2611803pfo.331.2024.02.17.23.47.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 23:47:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70254-linux.lists.archive=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=@linuxfoundation.org header.s=korg header.b=lrJH4PXP; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-70254-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70254-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DAD1BB2204A for ; Sun, 18 Feb 2024 07:47:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C6A5E544; Sun, 18 Feb 2024 07:47:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="lrJH4PXP" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4686C2CA8; Sun, 18 Feb 2024 07:47:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708242427; cv=none; b=oYplBnMAzMieAUscnSTcHnoMEHYCcVHExT06/yoSNiLjm0SSMHzcLYrO5U0d+Sq+BeF9suvdhRYV+FXX/4CY9e/edOwXPzEITM3AqDZtewHRikXHzuKM2lMadikSj+IeVe0Sbm9zd7kXWI+w+SRF5LeFpr5gFhT/0LiF/WvzfW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708242427; c=relaxed/simple; bh=BKs6y9EPQXIUNlMVIpvBS2yT3Xy2/9dOIOPM54bzss8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TuaNIVzUa99w7cRKLgnSc7/ZNzBNW8Et+J9FU6tFDW3AiQTM1TiHGU6hHYn0wlGNfGW+87ee+ospS27xLbex2TSRIIXay6ZgyYJcLJgsSa2tQRTHQCUTEUdEB2A6wH9ffMq/LJvjIG8Xzx7xD6m2opQ30E8KtGDI1uQr945F52E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lrJH4PXP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55038C433C7; Sun, 18 Feb 2024 07:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708242426; bh=BKs6y9EPQXIUNlMVIpvBS2yT3Xy2/9dOIOPM54bzss8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lrJH4PXPj/dz7a/quQl5Hjug7zHvT5vyRayjwBJFYOwA8GIMArzsiA9avJPhw5js9 bZyXGSWdNpsFtd3rycPnV5UkltleXfQ9kqrmrTr2Q9t2JOOkcNz7qSAsrsgmIMinUF hEJYTKgQKin7fiEjAUpmojYcbu3WfGgkZYZaPC8c= Date: Sun, 18 Feb 2024 08:47:03 +0100 From: Greg KH To: Guixiong Wei Cc: linux-hardening@vger.kernel.org, jgross@suse.com, boris.ostrovsky@oracle.com, linux-kernel@vger.kernel.org, Guixiong Wei Subject: Re: [RESEND RFC] kernel/ksysfs.c: restrict /sys/kernel/notes to root access Message-ID: <2024021825-skiing-trustee-a56a@gregkh> References: <20240218073501.54555-1-guixiongwei@gmail.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: <20240218073501.54555-1-guixiongwei@gmail.com> 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) = 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 = { > .attr = { > .name = "notes", > - .mode = S_IRUGO, > + .mode = S_IRUSR, > }, > .read = ¬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? And what about the module notes files? If you change one, shouldn't you change all? thanks, greg k-h