From patchwork Wed Jun 8 06:14:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 12872915 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDFE1CCA481 for ; Wed, 8 Jun 2022 06:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230519AbiFHGxt (ORCPT ); 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 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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 Reviewed-by: Laurent Vivier --- 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);