Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1200008rdb; Fri, 16 Feb 2024 08:08:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVYYNF91ywFhYoP1eoa2+RlK/NVt0jx3pLVLfS+YWpawoXzMPQfqnYkpdw+c6GV4XJr80bblXFOd5ExjzkYT7/e/+yia/AhWQaq1hW8wQ== X-Google-Smtp-Source: AGHT+IEY01+DAQdsLpmHD/8tnMEFm+qNwhl4vYh1lkn5T5B13ySgB9I9MOeK1VUBN/bYITWV755W X-Received: by 2002:ac2:593a:0:b0:512:9130:cec1 with SMTP id v26-20020ac2593a000000b005129130cec1mr1924504lfi.62.1708099712129; Fri, 16 Feb 2024 08:08:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708099712; cv=pass; d=google.com; s=arc-20160816; b=YAEvOvov75ntkXhfR/7g3uH8nvLYU2RrOltnfn3Gddpes7YKZv+n7iDlUJYsa6FqOR R0CdI0TYMTzDIBXQHMVA1qPRqukiLeSrQrSoBkEm8AfbbOo0jyn3uBjgP3TCV5Br+xS0 4xc9SJ8SFC+GDMxv4arzBmxNmWVG87DtdGqABBm4QNTZwayVvzqm9XfAg8qFYTu0wkaL MlE3NF01lOqoaZ7gOHjB24gtZ6D4biRx/hnkZqS5mWXb1W2ZPZe22NL8+S+0iil6I462 GI3kvfZurdgJNDxqHQP9FkEBl6eXXCpn2sY+vWvoOaxlcJ+vu+2+MX0hYVkvJ0p/ra/L kDaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=DKX/6lJWnQLEOT1m3g58ZZW/atm/xKbGax5uWE14zqU=; fh=UggeJUkEKi2GCMUW9PssmRVHmts8HezqtgI+NI+YDfc=; b=KTikECfhgirEP+ZXVgHhNgrgtb1YJv76CwTIFnGWdHGIBJkKfi6doyPzg1o7AwchMj uCL8PxepWoC/4mjpY7G7xfAsxgqG/z00fyt8M1PDK8wLSZZKgbV0xYT8+niwFrJqReuQ rUmv99VwvRhIzB5TGOAQ1NawaK5dIP/2VcybdttJ+qCuJ+g8jXNteCTyzv3OniySSXrq bJK+SqCBRRw09eLydQjF3ubSec/3d7x36YisMsxoGTkrB1/qCuR58kWhruTstZD8j3Lf Q2GAF5pmIbWWs/1n2UARXuT8ykVlgC9V+nqRZ/w5VXwX6fAm8+823Hcev/Q695cB+zOr ulsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tesarici.cz header.s=mail header.b=Zcqc9q7K; arc=pass (i=1 spf=pass spfdomain=tesarici.cz dkim=pass dkdomain=tesarici.cz dmarc=pass fromdomain=tesarici.cz); spf=pass (google.com: domain of linux-kernel+bounces-68937-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68937-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tesarici.cz Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n22-20020a509356000000b00563948cbff6si85714eda.348.2024.02.16.08.08.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 08:08:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68937-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=@tesarici.cz header.s=mail header.b=Zcqc9q7K; arc=pass (i=1 spf=pass spfdomain=tesarici.cz dkim=pass dkdomain=tesarici.cz dmarc=pass fromdomain=tesarici.cz); spf=pass (google.com: domain of linux-kernel+bounces-68937-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68937-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tesarici.cz 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 D6ACF1F23699 for ; Fri, 16 Feb 2024 16:08:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34B5612FB15; Fri, 16 Feb 2024 16:08:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tesarici.cz header.i=@tesarici.cz header.b="Zcqc9q7K" Received: from bee.tesarici.cz (bee.tesarici.cz [77.93.223.253]) (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 173B778B5C; Fri, 16 Feb 2024 16:08:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=77.93.223.253 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708099702; cv=none; b=k4o3vH9MjVmRIPMpwYzqpiC6BjaaBhJ0SFMVqy6NJDCVpuy0zEAjG3cFslIZrH8DAzIGW5MBECr8YG5KB6VUjQrnx0QVwgMjC8xB+Ots4BDbq9M0rPHqv9ifT6CKxn88uWMLT566Se7MTduDVBC7lVC3ntkAe5BLzn21M+EYqsE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708099702; c=relaxed/simple; bh=XZFqH1AHH+zywN7bCiDB54cVqBQHS1vAHNy2hjesWnU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W9p/1cNVC8TaQuW5Z9YNk3ERdT2mu2cUs9CIf50zmno7mPjxS3eaTHLvK5qj9Ee9+y+MdGkqBtBJWpbKfCP13d4rPzi1ky3do6EtotgJoF2fCyXQV6qXSS3NL8UBhEbT0b6NiS42kGbotHbJmxFa32qhP/jB1sb3LE1KEsNGWhc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tesarici.cz; spf=pass smtp.mailfrom=tesarici.cz; dkim=pass (2048-bit key) header.d=tesarici.cz header.i=@tesarici.cz header.b=Zcqc9q7K; arc=none smtp.client-ip=77.93.223.253 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tesarici.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tesarici.cz Received: from meshulam.tesarici.cz (dynamic-2a00-1028-83b8-1e7a-4427-cc85-6706-c595.ipv6.o2.cz [IPv6:2a00:1028:83b8:1e7a:4427:cc85:6706:c595]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bee.tesarici.cz (Postfix) with ESMTPSA id 5AAA51A8CE2; Fri, 16 Feb 2024 17:08:07 +0100 (CET) Authentication-Results: mail.tesarici.cz; dmarc=fail (p=quarantine dis=none) header.from=tesarici.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tesarici.cz; s=mail; t=1708099687; bh=DKX/6lJWnQLEOT1m3g58ZZW/atm/xKbGax5uWE14zqU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Zcqc9q7KWchJwmvx0t4vSX1KyUPURQZe1OK75OB/21bUMdJEzk/HvdVz24nddVkD0 CNVRqHQo7B4zrf1kvFcF4tB/aOZSV6aairJvFO88QqAjAo3zFBmlkHbsZhNXlaV3t2 3BGih5r1MNlJeVPSsIhL7OwD7mgro5Ji5mLvxWoIUlSzHTjHQ65MAiJhJPwu86I/JH Y9FkETzAokazd09YWhYTQARYxGfZgBRA0iIZrGCwLBhekdPJObp8DVQRuVfWTYdf/Q rsLVpYSY13y+czJnxT7X7w7GUzCSq0Ui0Ej8FHtQilHx2Q0qlkgoAWtgp5Cr+ZX9PA N+eT8KYvOnZmw== Date: Fri, 16 Feb 2024 17:08:05 +0100 From: Petr =?UTF-8?B?VGVzYcWZw61r?= To: Dave Hansen Cc: Petr Tesarik , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , Andy Lutomirski , Oleg Nesterov , Peter Zijlstra , Xin Li , Arnd Bergmann , Andrew Morton , Rick Edgecombe , Kees Cook , "Masami Hiramatsu (Google)" , Pengfei Xu , Josh Poimboeuf , Ze Gao , "Kirill A. Shutemov" , Kai Huang , David Woodhouse , Brian Gerst , Jason Gunthorpe , Joerg Roedel , "Mike Rapoport (IBM)" , Tina Zhang , Jacob Pan , "open list:DOCUMENTATION" , open list , Roberto Sassu , David Howells , Petr Tesarik Subject: Re: [RFC 0/8] PGP key parser using SandBox Mode Message-ID: <20240216170805.0d0decd5@meshulam.tesarici.cz> In-Reply-To: References: <20240216152435.1575-1-petrtesarik@huaweicloud.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.39; x86_64-suse-linux-gnu) 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-Transfer-Encoding: 7bit On Fri, 16 Feb 2024 07:38:30 -0800 Dave Hansen wrote: > On 2/16/24 07:24, Petr Tesarik wrote: > > While I started working on my development branch to illustrate how > > SandBox Mode could be enhanced to allow dynamic memory allocation and > > other features necessary to convert some existing code, my colleague > > Roberto Sassu set out and adapted a PGP key parser to run in a sandbox. > > > > Disclaimer: > > > > The code had to be rearranged in order to avoid memory allocations > > and crypto operations in the sandbox. The code might contain errors. > > I'm confused by this. The kernel doesn't (appear to) have a PGP parser > today. So are you saying that it *should* have one and it's only > feasible if its confined in a sandbox? I'm sorry if this is confusing. Yes, your understanding is correct. This patch series demonstrates that SBM (even in the initial version that was submitted) allows to write a PGP parser which can survive memory safety bugs withoug compromising the rest of the kernel. > A much more powerful example would be to take something that the kernel > has already and put it in a sandbox. That would show us how difficult > it is to sandbox something versus just doing it _normally_ in the kernel. That's what I have also tested as a PoC with an earlier version of my patch series and a few quick hacks on top. As it happens, that code on top needs to be adapted for the current patch series, so I cannot post it just yet. Please, stay tuned. > As it stands, I fear this was just the largest chunk of sandbox code > that was laying around and it seemed like a good idea to just chuck > ~1400 lines of code over the wall at a huge cc list. You asked for some real-world scenarios, and this should be one. Another is on the way, but see above why it takes a bit of time. I am not trying to claim I'm the smartest person on this planet. I can accept it if there is a fundamental flaw in my approach. Yet, I'd be glad if somebody can make me a favor and at least hint at what exactly is the issue with it. I have to admit this thing is still not quite clear to me. I would be sad if I couldn't learn from this experience. Petr T