From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=52.26.1.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795976628; b=sKBAhiuUkJ06FDG0nSzgKuOrmjTx04jr+qqMmdmd2xEtvp/PSajPFhDjz0P8c1a3D02A Zq541brO8y3KIeIaTYSgfkDePWkWhU1xY4WT+SiUXqW6uvA2nP9ox2jkDIK8gvKNedj3S 6zU9L5NAaphqMgvxeoLeH7o3VRvHWVIcGdALc/SS0yejpX6AE+CWTrqJMLdhUYDNcKrLb QbBdDPcxNBhvLGoVojkMbOeRj6K0BAuQw9H/X3LAtku7vEHcLp6/Fcxjwp9JEEoUzKVyz eRJt3T6mC8iQFJTvvnCgnhncpKCTJLlWSMcX4ak3IugEj7PGUCF7k8zc+/E2dafL5qQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795976628; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:Received:Received:X-Farcaster-Flow-ID:Received:Received: From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; bh=s/f15TlOSe7ye3TxZrNREh6cCcaBH4jfENlzsISvsIA=; b=vKptyYmZHnV0Ol62wKikAonNELQlWPriyuJOUdBXCaevQISogVIrAv8ZzEqEw2ldB7d4 h7khNMfmaMKN8lFrFsp285a9l6EEGiMkxwgbF431RBL/tRDVvP/fYu5xOGzA+OtbpSYHH qVqf5uTYO1nyTzso3mp2PfLaZUQQFKUN86yd7i8dP/PsRUsflZSSoDaKNbugrjgMcmz6B jt0RCJRgV+PHtIjOVqtPKv3IHZjshAC4hApmqLrAHCfVkfkjCmNfMOrrSzdRyNqWb+Ej2 O1aQDO3y7pIfuQD48e3ZQBJbRghmRAfZwEOs1lvp9tuUVfuMqDMZChDb1Ilkm4eJ1Xg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=amazon.com; spf=pass smtp.mailfrom=amazon.de; dkim=pass header.d=amazon.com header.i=@amazon.com header.a=rsa-sha256 header.s=amazoncorp2 header.b=hQpP5Rbj; arc=none smtp.remote-ip=52.26.1.71 Received: from pdx-out-006.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-006.esa.us-west-2.outbound.mail-perimeter.amazon.com [52.26.1.71]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D762606A31C; Sun, 29 Nov 2026 18:23:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9D762606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.a=rsa-sha256 header.s=amazoncorp2 header.b=hQpP5Rbj DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1795976627; x=1827512627; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s/f15TlOSe7ye3TxZrNREh6cCcaBH4jfENlzsISvsIA=; b=hQpP5RbjPD3HyWJUX/DXXBXROYleqZ6kUpqPSnIjx0tnOFTl/IA5tZgE 1BHrhzZZxPslpmk//MV8mRPT9hV8uvaKfp/AX0Gf+1/6kW7jVab6bNRMx nFdwtOnlkUZnrdGrL6IBVQslBl0azdCCSGa0nhrIp1Z5xx7xdlPOn2xWH F5XcKZE+yhWfXEnDD9OYsRX1qJVmA2dv5Qq3w1PKaesnXi6a81hLNUH/Z XWza/qwNkTrrp8HdLkeRNXoAfKRzTqrx4Qr6Ovll+shtt/nIgBZkzTZe5 MIG8OpvEgpvzdBBEuoRhG/geAq8DaajTKE+ISEjPDgVU5QPgghGM/84A8 A==; X-CSE-ConnectionGUID: /X5I1IjJS0+G9L7zBpxABQ== X-CSE-MsgGUID: +PkNYWJ9TJen/3jdY7lixA== X-IronPort-AV: E=Sophos;i="6.27,241,1787011200"; d="scan'208";a="35472540" Received: from ip-10-5-12-219.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.12.219]) by internal-pdx-out-006.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2026 18:23:43 +0000 Received: from EX19MTAUWA001.ant.amazon.com [205.251.233.182:19281] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.30.201:2525] with esmtp (Farcaster) id 8763eb20-d959-4c12-8a77-7aea6a9efdb6; Sun, 29 Nov 2026 18:23:43 +0000 (UTC) X-Farcaster-Flow-ID: 8763eb20-d959-4c12-8a77-7aea6a9efdb6 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWA001.ant.amazon.com (10.250.64.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.57; Sun, 29 Nov 2026 18:23:43 +0000 Received: from ip-10-253-83-51.amazon.com (172.19.99.218) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.57; Sun, 29 Nov 2026 18:23:39 +0000 From: Alexander Graf To: Greg Kroah-Hartman , Arnd Bergmann CC: The AWS Nitro Enclaves Team , , Paolo Bonzini , "Stefano Garzarella" , Stefan Hajnoczi , Marek Szyprowski , Robin Murphy , Andrew Morton , "David Hildenbrand" , Mike Rapoport , "Jonathan Corbet" , Shuah Khan , "Randy Dunlap" , , , , , , , , , Subject: [PATCH v2 03/23] nitro_enclaves: Request write access to enclave memory regions Date: Sun, 29 Nov 2026 18:21:32 +0000 Message-ID: X-Mailer: git-send-email 2.47.1 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EX19D031UWA004.ant.amazon.com (10.13.139.19) To EX19D001UWA001.ant.amazon.com (10.13.138.214) NE_SET_USER_MEMORY_REGION takes its page references with get_user_pages_unlocked() and plain FOLL_GET, which only asks for read access. The Nitro Enclaves device then writes to those pages for as long as the enclave owns them. So we accept regions that the calling process cannot write itself, for example a PROT_READ mapping. Enclave memory has to be writable by the process that owns it, because the device writes it. Pass FOLL_WRITE as well, so that get_user_pages_unlocked() faults the pages in for writing and fails with -EFAULT when the mapping does not allow writes. User space can see this change: a region without write permission used to be accepted and now fails with -EFAULT. Callers that map enclave memory PROT_READ | PROT_WRITE, like samples/nitro_enclaves/ne_ioctl_sample.c, are not affected. Fixes: 7dc9d4309fdb ("nitro_enclaves: Add logic for setting an enclave memory region") Cc: stable@vger.kernel.org Signed-off-by: Alexander Graf --- drivers/virt/nitro_enclaves/ne_misc_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c b/drivers/virt/nitro_enclaves/ne_misc_dev.c index a50dc4f737b55..bb16a35f82fc0 100644 --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c @@ -961,7 +961,7 @@ static int ne_set_user_memory_region_ioctl(struct ne_enclave *ne_enclave, } gup_rc = get_user_pages_unlocked(mem_region.userspace_addr + memory_size, 1, - ne_mem_region->pages + i, FOLL_GET); + ne_mem_region->pages + i, FOLL_GET | FOLL_WRITE); if (gup_rc != 1) { rc = gup_rc < 0 ? gup_rc : -EFAULT; -- 2.47.1