Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3570965rdg; Tue, 17 Oct 2023 21:50:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIngNh0sFhAMKvVyPsElNH2Mkwyu5RpjSW/nXCOerAAdHZLawAgdV5g3k1EBzvhmCDsQZh X-Received: by 2002:a05:6a20:9155:b0:14d:e075:fc5d with SMTP id x21-20020a056a20915500b0014de075fc5dmr4147631pzc.40.1697604655108; Tue, 17 Oct 2023 21:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697604655; cv=none; d=google.com; s=arc-20160816; b=buF15KSZM7R1czB88n2F5xJJeCLLIaBNKfa5gc08WpZAhFOPn0ZKcJzVxhyyWMHKnn SrFduA2+rwi7jrTMeCKubY0JcygaOSWgK1Mn8udaEWEFTkra26WVekTtFvqjGlq5/ScU bF661oOlZvn6B7orTmKPimYW2DNxEd9zAu4Np6RUhHlZ65PYpg6/gRPXhmoKYF2t/8v3 aaZm1Si/dTPV/A4ZrY6ki+Olgo2QFPByQXdCpX12keV4o2Fn5TWsmelCAzgrahtlDAjU 1FOjmSaJDo2V+0fWIxHwgbj0aslms1Xg1xaGx3agEPu6KULQFzwkB7ZQAF0x58doktQi EZ6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Y8dpzAxGNF7xYyh9/OYskro2jVdKfTdZh6TOwIkr3gQ=; fh=tYCw2osvo7TJxnOwO7l5aU8f8zwDge49fdIoGMbSeYE=; b=UI5vGq2J2eZ+3j7pTfwAFyisSU7uOdhgSiLwCG7Z2zn4FNo2YxFkJW8KZgeDoCCiOP TpTlc6S96Y65sKdLvVwUqJcEmH7lHFpPF66DX+MnljHpPTvt5gEwq5mUclb+1GFsjyH5 IY2thW/9E7pNP5Pm+vedvc/pRPP1w2d/UlH6HC9sGZzIJL7NtcWq+pvV4yz6hS+r0Ghq d+Qh9UQA7WyKPOjC6thtYSSIkKsBtQmhAJASRO7lCoOsRMFxX3fWlMaDkPP6KiVHYBWl AtBj7JvfEozMWjnuJaMHRwhdCbmOd2o2SMzpsLPl89bXaHoq0WS0quqg6MjLyOUfDpT8 r3xQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id e6-20020a170902cf4600b001ca336f48bdsi3021742plg.556.2023.10.17.21.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 21:50:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id CF67A80BF4C1; Tue, 17 Oct 2023 21:50:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235137AbjJREun (ORCPT + 99 others); Wed, 18 Oct 2023 00:50:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235148AbjJREuc (ORCPT ); Wed, 18 Oct 2023 00:50:32 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7543A59DF; Tue, 17 Oct 2023 21:43:39 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id DD76567373; Wed, 18 Oct 2023 06:43:33 +0200 (CEST) Date: Wed, 18 Oct 2023 06:43:33 +0200 From: Christoph Hellwig To: Rick Edgecombe Cc: x86@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, luto@kernel.org, peterz@infradead.org, kirill.shutemov@linux.intel.com, elena.reshetova@intel.com, isaku.yamahata@intel.com, seanjc@google.com, Michael Kelley , thomas.lendacky@amd.com, decui@microsoft.com, sathyanarayanan.kuppuswamy@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Christoph Hellwig , Marek Szyprowski , Robin Murphy , iommu@lists.linux.dev Subject: Re: [PATCH 04/10] swiotlb: Use free_decrypted_pages() Message-ID: <20231018044333.GA15759@lst.de> References: <20231017202505.340906-1-rick.p.edgecombe@intel.com> <20231017202505.340906-5-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231017202505.340906-5-rick.p.edgecombe@intel.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 17 Oct 2023 21:50:53 -0700 (PDT) On Tue, Oct 17, 2023 at 01:24:59PM -0700, Rick Edgecombe wrote: > On TDX it is possible for the untrusted host to cause > set_memory_encrypted() or set_memory_decrypted() to fail such that an > error is returned and the resulting memory is shared. Callers need to take > care to handle these errors to avoid returning decrypted (shared) memory to > the page allocator, which could lead to functional or security issues. > > Swiotlb could free decrypted/shared pages if set_memory_decrypted() fails. > Use the recently added free_decrypted_pages() to avoid this. > > In swiotlb_exit(), check for set_memory_encrypted() errors manually, > because the pages are not nessarily going to the page allocator. Whatever recently introduced it didn't make it to my mailbox. Please always CC everyone on every patch in a series, everything else is impossible to review.