Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp1308128imk; Sun, 3 Jul 2022 23:47:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uBlw1JyLDDFPrdWi8pME1BZPOlKyHDfUk1REWwSlS6MId8d3UzGRXz2gJYwlCaKj9dvmQ1 X-Received: by 2002:a05:6402:3047:b0:435:9af7:7af3 with SMTP id bs7-20020a056402304700b004359af77af3mr37762799edb.252.1656917228425; Sun, 03 Jul 2022 23:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656917228; cv=none; d=google.com; s=arc-20160816; b=aLB0+fXYlY5eZRwFCPXTgq4lSLkhmzoOLYR2dBa49m6R8oqfXLGW7E1HEYMCRceONE O1WD8ewyNraHa91Tc98wUX8Qk/m8bHS5C+hGYrTSYGLQlCy2ZmWjL4Po8Q3VWV02HtNj ILk1QQEAmwZRbdWDzDAQDa0mRL9/7/iSTFaFWHQD1vkECn+/Vkn6wyqvvDsp59gzIVtJ I0YjYRsrEGmGIjt++5ZohyCBX6bKM2Nu+/Y+4R8TXfaN+BqSE1mviGHdfbii8g0nsE7W WnjYmPt0Vs6ltS2tJ5C7mZfCLzANOhZU7DHuWPAEhHsmQtFqM8aDkaY2X1O952MJ+51r AXpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=w4yN5Zty763Hq+nXi9QxVE0HKoTohjtCixEdlzzySCo=; b=uYCggPOVGsgfJisWgPTdOimIlgh623Nzm1BJSai2m2WKp8LxAfycR+D/evuajExUL1 m694uXYKebaFjyr4TkDReeOsZExeyHvSVeji/TVvR4e9EspHZHqlTwlePafCdHzjxXKk ApGEJgYNXbEaVTaY7VWqWNrPdY75wTjOy2Q/D60ZvHVjgQ0JcFNNjlwmlY/TIYjVUM8L x4VHwvHJiSRyso0yY3gDIHmZjY55Nr+n9kur+JLxt84TiUmuanwi4GYlkj9Ew7BGnoA4 EOT5O0kqJfeVyr9iW3wRhoxcwIJWxUGAIQ1xZ3mLLZ1ThG2dgbgxznc35VQDm5LwaV1E Nk4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=h3lsq+Xq; 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 oz35-20020a1709077da300b0072629ece5e2si17844840ejc.61.2022.07.03.23.46.43; Sun, 03 Jul 2022 23:47:08 -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=h3lsq+Xq; 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 S232911AbiGDGWQ (ORCPT + 99 others); Mon, 4 Jul 2022 02:22:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbiGDGWP (ORCPT ); Mon, 4 Jul 2022 02:22:15 -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 ESMTP id 3B9DB6333 for ; Sun, 3 Jul 2022 23:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656915733; 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=w4yN5Zty763Hq+nXi9QxVE0HKoTohjtCixEdlzzySCo=; b=h3lsq+Xq4IIZOZtHsYN6DX07wJofeyn0GurRN/ONoKaUyJv/uV1b3j5BGsHn+e7hKLnt8Y jxUMQ2nAmdnAd+adx8o+TXbzBRR3xNaaf80KJZ5ROIeqImeGOa+8N4GPqDM181h1o3MgDv emRst/WxSToSZ3Zzb35t1QgGLStSrdI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-187-eGY2J5s-OVKyd5XwzbNV5g-1; Mon, 04 Jul 2022 02:22:12 -0400 X-MC-Unique: eGY2J5s-OVKyd5XwzbNV5g-1 Received: by mail-wr1-f72.google.com with SMTP id s7-20020adfbc07000000b0021a558c09b4so1125005wrg.4 for ; Sun, 03 Jul 2022 23:22:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=w4yN5Zty763Hq+nXi9QxVE0HKoTohjtCixEdlzzySCo=; b=1zFWwu8SMOsXWU86dlfMNLatT/sOElSSvlHIFdIsm9N1R9Hyif5qGu1fBXLQwiM1ji vF9f/+b5T+fcaiF/IlHjGTHjprIG0RGhg2dYy5UYl/gwVHgW0W/VKld35lnTYIzrSQHl lFRVWuoQ59BlmCK20jALTGWak++XlrdJ5ggVJh66aAaGIgWGqQMSSDSwJhv2qkdARQQ7 hZ0L/tOGpTRxmm6nVl1FVDC+GwWwUdfYephRdWSfOaegaREx/xXxBpLNVvhhxmziMqNo XeDAUo8aq0cPtNtwND5ld3VOp3t3Ir5lFSv7klkJ8n+MRe0RAGu6IL643IQSs6LQ6GS/ ws8Q== X-Gm-Message-State: AJIora/E33Zobj0zftsJYv9o0O6ZZx/czlzQIw1W4eAwS0b1hmQws3HZ 6a2gR3u0bm2dvqd0tUnTbFLtSL7Of+8DnXH60+Y/sVU++RHWNl16Vq/pbnd/DZXkj2Qg8YMEPlW Pu1D2cQzuNboWgyjmZzlqxs1X X-Received: by 2002:a5d:4387:0:b0:21d:6983:13fc with SMTP id i7-20020a5d4387000000b0021d698313fcmr3928714wrq.696.1656915731018; Sun, 03 Jul 2022 23:22:11 -0700 (PDT) X-Received: by 2002:a5d:4387:0:b0:21d:6983:13fc with SMTP id i7-20020a5d4387000000b0021d698313fcmr3928689wrq.696.1656915730781; Sun, 03 Jul 2022 23:22:10 -0700 (PDT) Received: from redhat.com ([2.55.3.188]) by smtp.gmail.com with ESMTPSA id g3-20020a05600c140300b0039c96b97359sm18771641wmi.37.2022.07.03.23.22.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 23:22:09 -0700 (PDT) Date: Mon, 4 Jul 2022 02:22:04 -0400 From: "Michael S. Tsirkin" To: Jason Wang 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 Subject: Re: [PATCH V3] virtio: disable notification hardening by default Message-ID: <20220704021950-mutt-send-email-mst@kernel.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, 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 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. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >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 > > > > > > > > > > > > > > > > > > > >