Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp1309122imk; Sun, 3 Jul 2022 23:49:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1taMtvh/iL/HY8dTZpjBnEOL8RX2GnbDOVUtlC2MSNyCHeSg8Ai0szQuMMxwGmyGaZ/umue X-Received: by 2002:a17:906:8501:b0:711:bf65:2a47 with SMTP id i1-20020a170906850100b00711bf652a47mr27587077ejx.150.1656917361063; Sun, 03 Jul 2022 23:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656917361; cv=none; d=google.com; s=arc-20160816; b=N9rLEUNc5WtSKN9pYJ+/MsQGfE1/8VJsgPAkRUZ3Y9Lcx4h44eU0rj5uzyf0s1ZegB hD0o/QdVLogQSxpgLljNvKh4gHGAv0K1mNmQNc8NTLOtjt+O95W7jJIFFwnxG2XhivtK fOI0/SW/XjKPXBGbWzvad3qAfiDXOkcyK1OObo/XXgV2L6gs9Z/DgFuGi8eqhlAp9ZN9 92juzTJOSkZDDmWFU/Djt0XwwIURv/5j3TMQ6PIT7soRdaw8hQCgRMos6zrE8vkwcDQ5 xvfaw6RUX1U1eQdd38ilA3DiDbbPJe1HIwlYhrltScIRYISIwkYbeoV2bBdcGL9buLgs MJ1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qMOEw4DkVDPn98Rjv4lUmJsvQgI5ankcWzzn5AvogbY=; b=HuyFJmqtD0el9g2SyJJvTGAC8BeptCaWcPq7mvYyZaHIBPE0+c74BSw0KNCgc7EBX/ EMGVdY8FIdAEsUbCHoYn+fvD0WFf1orvFzuwI2Sq1WlH1A1P4AitcqJI2tSs2Cf8eGsN E0dt2Ih6udeABAUswYIe8ZAGN/9bg2MnzI7xmgy3rx+8Hrmr0DXfweA8z6x63rZb7VN0 LqlT7wF3N7N3M+O3LcdUBA2r/yoEdW1Tp5G5sSjwn5SGtgzeLmjayqzTDOg1Lj6SlGzu u/OsjPIcoGHYlFWZ9CLDSxJuop/w7ETujfCdUfhFfgzPD36WpNniWakjo2gdO8g/S3RB X/jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M7nO6uEN; 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 ck9-20020a170906c44900b00711dd35ed99si6681273ejb.652.2022.07.03.23.48.56; Sun, 03 Jul 2022 23:49:21 -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=M7nO6uEN; 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 S232938AbiGDGkg (ORCPT + 99 others); Mon, 4 Jul 2022 02:40:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232685AbiGDGkd (ORCPT ); Mon, 4 Jul 2022 02:40:33 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7E05138A1 for ; Sun, 3 Jul 2022 23:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656916831; 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: in-reply-to:in-reply-to:references:references; bh=qMOEw4DkVDPn98Rjv4lUmJsvQgI5ankcWzzn5AvogbY=; b=M7nO6uEN5DxBFYmwWbE71uTRVH+cQHNbTSmzCfUG9k1ErSnxvVEIC+Pu3DLeie2Vnjaac8 Cxk7pnE05j5pwkwIEQCz41o5VHa19ZzAeOFAf5vNvOhofI3tDRMkC6GqiX6BZeadzO0lau 5AHtNfRNZJUbqwSsUa8WpuWrWw2aNVo= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-444-Zb1gnL01Pf-UOwuJF-NPKg-1; Mon, 04 Jul 2022 02:40:29 -0400 X-MC-Unique: Zb1gnL01Pf-UOwuJF-NPKg-1 Received: by mail-lj1-f200.google.com with SMTP id k6-20020a2e9206000000b0025a8ce1a22eso2432445ljg.9 for ; Sun, 03 Jul 2022 23:40:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qMOEw4DkVDPn98Rjv4lUmJsvQgI5ankcWzzn5AvogbY=; b=1s+HDu83LQShFx7ieuaB9L3lvmSjjtCxwBY1F0RmtQNB2IaIJq9d6oQHEf98okTycO hut07SOlVQCRWmsi+gikbm1nraoLHbcHH3uGq8xq+GeTZ7QG3uMA35JARfaR7Mx262tE EkymeS27Tc9ru8wvJT0WQfxE+CF0z8nhdzKIqHYNl9xxgZ1BGpGD9Zg50QG2Z3wK9Aaj laOJ57bMwyQMUs4qAdiUf0NYjXxGXTuMvAVvjT0eDqCn7DI4WGCLKqp8Wtr7vY8EfRef AvwRILK3DVyPJQ2mqdzq5apeM2cM1QsvgExB4CcZ7CEvpWqAlgfuZs7FjWHiYv7aoJX6 zTbA== X-Gm-Message-State: AJIora++3aIbr8jqsxatvNsaHvdS14PNGSNHuqIu1IGLnWNnPmVTnpyI 9+bK5VWXjN1+/Pik0EsiEDBEKCeM8KDSib+gUeyL5LFyruLGlssuZcRAbMJ+YUbpWGlhrnQ4iUO ORS/seBdw61xkr1F2P4vdsE3enxZ+T1T6tLXvgnAL X-Received: by 2002:a05:6512:3f0f:b0:47f:6f89:326 with SMTP id y15-20020a0565123f0f00b0047f6f890326mr16831242lfa.124.1656916827637; Sun, 03 Jul 2022 23:40:27 -0700 (PDT) X-Received: by 2002:a05:6512:3f0f:b0:47f:6f89:326 with SMTP id y15-20020a0565123f0f00b0047f6f890326mr16831229lfa.124.1656916827448; Sun, 03 Jul 2022 23:40:27 -0700 (PDT) MIME-Version: 1.0 References: <20220629022223-mutt-send-email-mst@kernel.org> <20220629030600-mutt-send-email-mst@kernel.org> <20220629044514-mutt-send-email-mst@kernel.org> <20220630043219-mutt-send-email-mst@kernel.org> <20220704021950-mutt-send-email-mst@kernel.org> In-Reply-To: <20220704021950-mutt-send-email-mst@kernel.org> From: Jason Wang Date: Mon, 4 Jul 2022 14:40:16 +0800 Message-ID: Subject: Re: [PATCH V3] virtio: disable notification hardening by default To: "Michael S. Tsirkin" Cc: Cornelia Huck , Halil Pasic , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Alexander Gordeev , linux-s390@vger.kernel.org, virtualization , kvm , linux-kernel , Ben Hutchings , David Hildenbrand Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Mon, Jul 4, 2022 at 2:22 PM Michael S. Tsirkin wrote: > > On Mon, Jul 04, 2022 at 12:23:27PM +0800, Jason Wang wrote: > > > So if there are not examples of callbacks not ready after kick > > > then let us block callbacks until first kick. That is my idea. > > > > Ok, let me try. I need to drain my queue of fixes first. > > > > Thanks > > If we do find issues, another option is blocking callbacks until the > first add. A bit higher overhead as add is a more common operation > but it has even less of a chance to introduce regressions. So I understand that the case of blocking until first kick but if we block until add it means for drivers: virtqueue_add() virtio_device_ready() virtqueue_kick() We probably enlarge the window in this case. Thanks > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >I couldn't ... except maybe bluetooth > > > > > > > > > > > > but that's just maintainer nacking fixes saying he'll fix it > > > > > > > > > > > > his way ... > > > > > > > > > > > > > > > > > > > > > > > > > And during remove(), we get another window: > > > > > > > > > > > > > > > > > > > > > > > > > > subsysrem_unregistration() > > > > > > > > > > > > > /* the window */ > > > > > > > > > > > > > virtio_device_reset() > > > > > > > > > > > > > > > > > > > > > > > > Same here. > > > > > > > > > > > > > > > > > > > > Basically for the drivers that set driver_ok before registration, > > > > > > > > > > > > > > > > > > I don't see what does driver_ok have to do with it. > > > > > > > > > > > > > > > > I meant for those driver, in probe they do() > > > > > > > > > > > > > > > > virtio_device_ready() > > > > > > > > subsystem_register() > > > > > > > > > > > > > > > > In remove() they do > > > > > > > > > > > > > > > > subsystem_unregister() > > > > > > > > virtio_device_reset() > > > > > > > > > > > > > > > > for symmetry > > > > > > > > > > > > > > Let's leave remove alone for now. I am close to 100% sure we have *lots* > > > > > > > of issues around it, but while probe is unavoidable remove can be > > > > > > > avoided by blocking hotplug. > > > > > > > > > > > > Unbind can trigger this path as well. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > so > > > > > > > > > > we have a lot: > > > > > > > > > > > > > > > > > > > > blk, net, mac80211_hwsim, scsi, vsock, bt, crypto, gpio, gpu, i2c, > > > > > > > > > > iommu, caif, pmem, input, mem > > > > > > > > > > > > > > > > > > > > So I think there's no easy way to harden the notification without > > > > > > > > > > auditing the driver one by one (especially considering the driver may > > > > > > > > > > use bh or workqueue). The problem is the notification hardening > > > > > > > > > > depends on a correct or race-free probe/remove. So we need to fix the > > > > > > > > > > issues in probe/remove then do the hardening on the notification. > > > > > > > > > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > > > > > So if drivers kick but are not ready to get callbacks then let's fix > > > > > > > > > that first of all, these are racy with existing qemu even ignoring > > > > > > > > > spec compliance. > > > > > > > > > > > > > > > > Yes, (the patches I've posted so far exist even with a well-behaved device). > > > > > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > patches you posted deal with DRIVER_OK spec compliance. > > > > > > > I do not see patches for kicks before callbacks are ready to run. > > > > > > > > > > > > Yes. > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > > MST > > > > > > > > > > > > > > > > > > > > > > > > >