Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2289161iof; Wed, 8 Jun 2022 01:32:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjStgrp1BKahIBUO0EpEJthRBVMdLUusQBDRm3Ulg1FY/7WFHQq6u8gs+3e4gyXAvlwu34 X-Received: by 2002:a17:902:e54c:b0:166:6322:e747 with SMTP id n12-20020a170902e54c00b001666322e747mr27380041plf.151.1654677135912; Wed, 08 Jun 2022 01:32:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654677135; cv=none; d=google.com; s=arc-20160816; b=AtdQ0VYMqexDxfyXwBoHa6PrA85EeJuhIwfOHm3kVIPBVd3bl3jmFdMjrS04LngcAc TmEwUkz0SP0Y1bbkMXl2pkLPRWLsi7jo6nj/uFvzoEMGqWyQCU85/aroZbPEq155sKRl 8WfD/8SpHlJDMhVbcPCqv4EOTEZqDUtD7HafPjzp0IpiFT82BpOr9xFtgrdOzCLokqXU s4l5iPrs6V2npn9hfHby0KPeUDyhwwxUp/Z+r1L13s3c6mCzSYo4lUOwvjRi081WjyZx WzzSRyVMlf0PMG8OPlTXnOE1bHlLhQLTQ8IlgB7mvXAUphf/VLaurAWWDG51D7StUQ7y rzvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=WgWKGhriuZ/b08VwpIQ7c/Jw4pb896/SIme7WzVP+jY=; b=qTQ3bXBqiyzmB5IRQbC8iSMCp97oZDT8qisysqNSx8SJ3Uwz4pbpJV0jpLqVLRBPTF fPrSvf7su6SbTjigH79M1exaDlnMxZhX1TAXDvFMbRG8kWniiK7lYVcpnWvzaAKn8Fti Q/Dv7CfosyJ//nhJISu+cPsw8Kg2W2W0Jl3FhcuIPpHoZPNzubb72yjtsbv2tFyH7N8N gcd9WV/LdvVAYKuFk3bO+Dkn6losSu3U64SAbHjT++zU8eXFyKl6eG8/9INzwfdK1RxL JgaLK9ZBf2Y0l3IrDaq3MxmjX2i2AVZ7Ld1kWp+fzj2jiVUz8syULLRMrtmdLT+XvR9F 7XrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="TGEAv/zH"; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 202-20020a6302d3000000b003fcc5108169si17305391pgc.445.2022.06.08.01.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:32:15 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="TGEAv/zH"; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2A83A21488D; Wed, 8 Jun 2022 01:00:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230519AbiFHGxt (ORCPT + 99 others); Wed, 8 Jun 2022 02:53:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354591AbiFHGTl (ORCPT ); Wed, 8 Jun 2022 02:19:41 -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 642B1B1FF for ; Tue, 7 Jun 2022 23:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654668889; 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; bh=WgWKGhriuZ/b08VwpIQ7c/Jw4pb896/SIme7WzVP+jY=; b=TGEAv/zHrzrfdHSK9ZffSwM6MS1Eq0jbYFJxyesVPQVLeRgzSnGdIN2cuM+n8xGn+OJ0FQ 1dkcYwruzZaR2SBNb1TOVPZih7VfW8o4JzCXEdKmTdHj4SoP7hxm3NCpE/b3Ir6L8pDdVJ ZpK6WycmDI2LViBeNXwEW6oIwYdai84= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-324-jMlX7HzrOBWmWzfaYQeWtA-1; Wed, 08 Jun 2022 02:14:48 -0400 X-MC-Unique: jMlX7HzrOBWmWzfaYQeWtA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 206043804518; Wed, 8 Jun 2022 06:14:34 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-97.pek2.redhat.com [10.72.13.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id B808F2166B26; Wed, 8 Jun 2022 06:14:25 +0000 (UTC) From: Jason Wang To: mst@redhat.com, mpm@selenic.com, herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, lvivier@redhat.com, Jason Wang , syzbot+5b59d6d459306a556f54@syzkaller.appspotmail.com Subject: [PATCH] virtio-rng: make device ready before making request Date: Wed, 8 Jun 2022 14:14:22 +0800 Message-Id: <20220608061422.38437-1-jasowang@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_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-crypto@vger.kernel.org Current virtio-rng does a entropy request before DRIVER_OK, this violates the spec and kernel will ignore the interrupt after commit 8b4ec69d7e09 ("virtio: harden vring IRQ"). Fixing this by making device ready before the request. Fixes: 8b4ec69d7e09 ("virtio: harden vring IRQ") Reported-and-tested-by: syzbot+5b59d6d459306a556f54@syzkaller.appspotmail.com Signed-off-by: Jason Wang --- drivers/char/hw_random/virtio-rng.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index e856df7e285c..a6f3a8a2aca6 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c @@ -159,6 +159,8 @@ static int probe_common(struct virtio_device *vdev) goto err_find; } + virtio_device_ready(vdev); + /* we always have a pending entropy request */ request_entropy(vi); -- 2.25.1