Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1121803rdb; Mon, 19 Feb 2024 05:08:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVFsLcX/VAnG5HKrsAQv2ssmchdys0IQetJMosMLPIIxGriPpoBFX2XplV+8QS9AGdhdqd5A3MeOTP5ccyfx0BYAoSzgE5CnNJnSH22Qw== X-Google-Smtp-Source: AGHT+IGENjhAl5J/6kTOV4tLnZaD0mspNrh1GnissRqdFE5CcDPxCHaOea49DgOitm6BmvEfH7v3 X-Received: by 2002:a17:906:ad5:b0:a3d:b3a7:b8ce with SMTP id z21-20020a1709060ad500b00a3db3a7b8cemr7638701ejf.0.1708348120327; Mon, 19 Feb 2024 05:08:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708348120; cv=pass; d=google.com; s=arc-20160816; b=tP7khr3iIFRyYECAyuuO1ajwYkeuFDVWpm8rQ13UMZQ0KC9g2CuGW2Up+5JEAXLU6r La8p9QRGn25WJzGlmVc2S45gYVfZEuPgYFmhKw3xsRot/DiXglzgwCFoIRwmqmnR2DeW DhNXk4myyXmv+KyQSrJ3jsvwvNAMHijmP2oscTT9cdhQCsT8zcxO+AWVJLWJdjOxb8nR 3j40hPVzevBznzN7u0Ttaezp4b0teJPo39a6Ze+ObuCFIJo7Pb8Y6GEYHVhz+0EVAPq3 kDppK0SfEI2nd5RO24GyHiT/4NVUl4fqCszhUAXz8jdIlG1d1n3PUQzp3SCOjcN5FpLT hwBw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-signature; bh=iIfSlUEslrWVPddWPziGhX/JsVABAGYKiD/rmY5VVxs=; fh=3Phck+oqta08zjExE7OEvaPaULh+aOihJ6tmlLVcZA4=; b=SDL35tB0cJuS3a8ZXx30tFXKWV2PNG4JyvxsSJp/W0tMd2A6xezvvHVQ4FlXmEOgIg i/7LaZ5yLRmZ7kpVSqOx6vhkusr7mwmP0iqt09WR2Oo3RIofT6LRtxFkfG43OjjDil7P FY3bitva64bopBCGVMbBQZQ/q0zhWHO8PUGjDIgQApQOvOf2TJPxCbyxfjQLv7GbL89L W8dnOaTQsDN5JunIj/l39b83+AENSbAYNcC5sNn17Sqzznvon8Be/cwsg6nqw2bzrcAO LAuEY+LZqwBjzRZTZMfkaRKecfwr4PMIEVycEyrV7mxrLv08rm+uQCMysx7UTu6r7L8k PBnw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=enfEQQeR; dkim=pass header.i=@suse.com header.s=susede1 header.b=enfEQQeR; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-71378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71378-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l11-20020a1709066b8b00b00a3e343bb1e4si1968557ejr.321.2024.02.19.05.08.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 05:08:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=enfEQQeR; dkim=pass header.i=@suse.com header.s=susede1 header.b=enfEQQeR; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-71378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71378-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 196E61F21BB9 for ; Mon, 19 Feb 2024 13:08:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 757F836AF5; Mon, 19 Feb 2024 13:08:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="enfEQQeR"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="enfEQQeR" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 B652D2D607; Mon, 19 Feb 2024 13:08:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708348082; cv=none; b=WtiIUtJdMsls9nPlzu5ZtGeKD3nRaVa5ZoFdJy7z59kcSaXVO393mrXHdRTJdnPsNgA6rV87IlAqyjUkSbm5pzDdARr32N0WK0f/9eHlwGAePqbs8ZLMBjxJl/N1nj0x+gSmKUelLl49ZlCvbIq1xirDc3DiTwGxlXkARgEMSb0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708348082; c=relaxed/simple; bh=aqhdz5jZvoHHhKuVHFSbbTrTM0VXAIh+AtbEXvKiV5Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=u7PUeqmBFQeva5pTOESjr9Nd/PVUyl0aScoT/66mbfdNpNu29E1OBJeROqFEViAJtBQwm31ljfrFB8D7dS3fHnTzS3l9V4RAfSoMlf7+bjfewpzNvYIE7rMlV0SJcRCttTvS0qxb17AC2PuMaOW+bdsInn3jilfRfD9dUDRHMV4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=enfEQQeR; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=enfEQQeR; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 521D722180; Mon, 19 Feb 2024 13:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1708348078; h=from:from:reply-to: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=iIfSlUEslrWVPddWPziGhX/JsVABAGYKiD/rmY5VVxs=; b=enfEQQeRmU6VXSNN8iWZmhdNJOHrOi3WxuFJq0cARxVCwIFkYIBUUMWXjIzQeUwafX5YJK gNFKQqr2XnPrgyxMZU0O3oC1b/s5e8QpA3fBtzXpiTA7f72boOzvhcgrH3Dsl1sSO9jlhZ Sq0oBzHdUlMKEXdmXMnrqPPZJhtNN2M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1708348078; h=from:from:reply-to: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=iIfSlUEslrWVPddWPziGhX/JsVABAGYKiD/rmY5VVxs=; b=enfEQQeRmU6VXSNN8iWZmhdNJOHrOi3WxuFJq0cARxVCwIFkYIBUUMWXjIzQeUwafX5YJK gNFKQqr2XnPrgyxMZU0O3oC1b/s5e8QpA3fBtzXpiTA7f72boOzvhcgrH3Dsl1sSO9jlhZ Sq0oBzHdUlMKEXdmXMnrqPPZJhtNN2M= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 05A3613647; Mon, 19 Feb 2024 13:07:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id S1IlO61S02UtTAAAD6G6ig (envelope-from ); Mon, 19 Feb 2024 13:07:57 +0000 Message-ID: <23ecde01-0e9a-4d2f-8194-294174ca7dbc@suse.com> Date: Mon, 19 Feb 2024 14:07:57 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RESEND RFC] kernel/ksysfs.c: restrict /sys/kernel/notes to root access To: Kees Cook , Greg KH Cc: Guixiong Wei , linux-hardening@vger.kernel.org, Boris Ostrovsky , Stefano Stabellini , Oleksandr Tyshchenko , Guixiong Wei , linux-kernel@vger.kernel.org References: <20240218073501.54555-1-guixiongwei@gmail.com> <2024021825-skiing-trustee-a56a@gregkh> <202402180028.6DB512C50@keescook> Content-Language: en-US From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= In-Reply-To: <202402180028.6DB512C50@keescook> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [0.62 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BAYES_HAM(-0.00)[21.84%]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_SEVEN(0.00)[9]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; R_MIXED_CHARSET(0.71)[subject]; FREEMAIL_CC(0.00)[gmail.com,vger.kernel.org,oracle.com,kernel.org,epam.com,bytedance.com]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: 0.62 On 18.02.24 10:04, Kees Cook wrote: > On Sun, Feb 18, 2024 at 08:47:03AM +0100, 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) = 0xffffffffbaead570. >> >> I've cc: the hardening list on this, I'm sure the developers there have >> opinions about this. > > Oh eww, why is Xen spewing addresses into the notes section? (This must > be how it finds its entry point? But that would be before relocations > happen...) Right. Xen is looking into the ELF-file to find the entry point of the kernel (PV and PVH guest types only). > > But yes, I can confirm that relocations are done against the .notes > section at boot, so the addresses exposed in .notes is an immediate > KASLR offset exposure. Relocations applied to the kernel when it has been started don't need to cover the notes section as far as Xen is concerned. Juergen