Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4652401rwb; Mon, 31 Jul 2023 10:01:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlFvTs3Ef2P0S/R68etU6Hxu6UUCQQkbotz8I5QVWat95LGwV1KUwO1iGP5KVKnyas5tbuNz X-Received: by 2002:a17:90a:9515:b0:262:e564:3ecb with SMTP id t21-20020a17090a951500b00262e5643ecbmr8758258pjo.36.1690822911771; Mon, 31 Jul 2023 10:01:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690822911; cv=none; d=google.com; s=arc-20160816; b=ZfDpsqJLS6AUSXB1O+ATpnkn45vB4lV5PWG4UW/SsUrdxeMibu6BrXZeEGnfevMEWH 1WMNYetjABTGqdhuQegqLcwwIZLfrB5vO3B9Z9F3BH7RGTo+FDisUs++JWF+Lu5MtiIR dQnTuqt1LUjIiwT7VsT414F+qCCpPL/LQmst53OrOOWBlbNtH11oeYLEsKIbNigWPd/i u6eiP6BPzs5UosFR4G2V504cf+vuM1HEiyNBpy6hci9mKRlF2DQAH/MtssBk8Oj2lYiK 8W+Q7KHU5w12FONie1Ln0MMNxHTRoP+SilmWU6xnMIoi0RvdgGNSkHxFtjVwqDVjLKVR b4zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=4fe6hbS0UUlu2v7dj0yh2sFuv9miEav3h35iCM+LzrA=; fh=KcKuUSKElbAL2egpvFiHitpvIoc3rI+3+eUcENTN9UQ=; b=0q48YVkXroCA+PPkUh/z7/0fOrnaGmk2omScCS+BGTycPlQFD1/+O7xWTAxB4yeq0g VjZNb8P4/aL0SifROfHgdkA5+0f1T+19XdedLFku4UT4MRnJtBkKtQiIISpApYBufR/6 HrBLrMX3kmnEr/tfrwpCAL0FqzkD6eEnE7NDSLzi05ntKB30C2uswXflKZTkQVjbUFjr ZmPCPnnbww3J3b38/tSxR8AASuWwzQHMsLQ/oYHDHQtwuPeBJ4YtTBa5xklC6EvjOL1T KTbaBkzp2V8dOy/6vazulVqIAumKeDaZsm9Q5JA/1HD01MA+joX/K61vZtjCAnjimFzE rrxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aUQq25fV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a17090a39c700b00262c7b59f4esi3206947pjf.188.2023.07.31.10.01.38; Mon, 31 Jul 2023 10:01:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aUQq25fV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233121AbjGaP7D (ORCPT + 99 others); Mon, 31 Jul 2023 11:59:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233024AbjGaP66 (ORCPT ); Mon, 31 Jul 2023 11:58:58 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 177A31721 for ; Mon, 31 Jul 2023 08:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690819094; h=from:from:reply-to:subject:subject: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=4fe6hbS0UUlu2v7dj0yh2sFuv9miEav3h35iCM+LzrA=; b=aUQq25fVqVWRGJcq14zax3WJWOdERpcRUDxaubSMjuwjb4gcPLAOGJbyxtCDwkniCKlJ3A 34Ri8Ndk4IgrJ6ACHR9Izl47SEjcAo7ESiNsQo6KC2L9xOGNOPqpvy7Vg35yslyEbhA5Ms /snhZhML6Csfbsbcb9TXSuqmd5USAgY= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-487-3AKa9B-0P9W7TE3lABdOBg-1; Mon, 31 Jul 2023 11:58:12 -0400 X-MC-Unique: 3AKa9B-0P9W7TE3lABdOBg-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-99bfe6a531bso158725066b.1 for ; Mon, 31 Jul 2023 08:58:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690819091; x=1691423891; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4fe6hbS0UUlu2v7dj0yh2sFuv9miEav3h35iCM+LzrA=; b=Bf/BxKr2/2EEUBLn2lFvWu+rRtExXci31aT/nXUEC9a6URLmrIKNRSEY9CjmFogPWj scDtD/zTrbWwmCpVvD1aq5vLl8aUcOXV2aWi550uQDjlvtKLTvRruwNl4gXcMOmW6Jgp j5MA6yW344EGEhqCT4nD2pHm+OAdkKin9mP3rp+jgCD3m6ZY/Qu3iIEhn73KSLf7VRhL gc3ureamed4NlQUWehzCXEQ4C/zsduP3DVKUqg4MX3KBJNks5oiECIGB9eDIjdoNuVfT RqpE5eZ3AJkUOsGdnaBleFjZ0bpufrA/lAr6V5DHh9h7jvSm1OBqteL8yk8DU6NH5bCm HABg== X-Gm-Message-State: ABy/qLbSjmK8GHBfq6pRlTFjn8ZZyc9taFjRM54pCj2LKlfhwK0sRapc fNxl/6CD6G31hISxdAl81ahegC0NSGIXUYgsGOVvrLh2Jzi1j2H/Qyg/XVl/O8SKFnRQnA0UPwR fG9EWNVTa7/zIchWMmRU3dJpu X-Received: by 2002:a17:906:11:b0:993:f744:d235 with SMTP id 17-20020a170906001100b00993f744d235mr164005eja.6.1690819091656; Mon, 31 Jul 2023 08:58:11 -0700 (PDT) X-Received: by 2002:a17:906:11:b0:993:f744:d235 with SMTP id 17-20020a170906001100b00993f744d235mr163994eja.6.1690819091362; Mon, 31 Jul 2023 08:58:11 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:9af8:e5f5:7516:fa89? ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.googlemail.com with ESMTPSA id f21-20020a170906139500b00992dcae806bsm6371003ejc.5.2023.07.31.08.58.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Jul 2023 08:58:10 -0700 (PDT) Message-ID: Date: Mon, 31 Jul 2023 17:58:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US To: Sean Christopherson , Quentin Perret Cc: Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Matthew Wilcox (Oracle)" , Andrew Morton , Paul Moore , James Morris , "Serge E. Hallyn" , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Peng , Fuad Tabba , Jarkko Sakkinen , Yu Zhang , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , Vlastimil Babka , David Hildenbrand , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" References: <20230718234512.1690985-1-seanjc@google.com> <20230718234512.1690985-7-seanjc@google.com> From: Paolo Bonzini Subject: Re: [RFC PATCH v11 06/29] KVM: Introduce KVM_SET_USER_MEMORY_REGION2 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/29/23 02:03, Sean Christopherson wrote: > KVM would need to do multiple uaccess reads, but that's not a big > deal. Am I missing something, or did past us just get too clever and > miss the obvious solution? You would have to introduce struct kvm_userspace_memory_region2 anyway, though not a new ioctl, for two reasons: 1) the current size of the struct is part of the userspace API via the KVM_SET_USER_MEMORY_REGION #define, so introducing a new struct is the easiest way to preserve this 2) the struct can (at least theoretically) enter the ABI of a shared library, and such mismatches are really hard to detect and resolve. So it's better to add the padding to a new struct, and keep struct kvm_userspace_memory_region backwards-compatible. As to whether we should introduce a new ioctl: doing so makes KVM_SET_USER_MEMORY_REGION's detection of bad flags a bit more robust; it's not like we cannot introduce new flags at all, of course, but having out-of-bounds reads as a side effect of new flags is a bit nasty. Protecting programs from their own bugs gets into diminishing returns very quickly, but introducing a new ioctl can make exploits a bit harder when struct kvm_userspace_memory_region is on the stack and adjacent to an attacker-controlled location. Paolo