From patchwork Fri Oct 14 04:20:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 2494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4f06:0:0:0:0:0 with SMTP id c6csp10760wru; Thu, 13 Oct 2022 21:34:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4pwh0zxMDIh4TFyFFa8lJIA9CSlHL8MZepJ8re/pIqLRZGVHYJ5nEqhbl/RQcYexuBqN3v X-Received: by 2002:a05:6a02:186:b0:431:25fb:f1fe with SMTP id bj6-20020a056a02018600b0043125fbf1femr3056937pgb.130.1665722050112; Thu, 13 Oct 2022 21:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665722050; cv=none; d=google.com; s=arc-20160816; b=vFHwEpaU4TebaXMYszJjLNEA39Jxx2rs3eqd24hPeG5IX14IlOPVa7ARec4ClMzKVJ JS2CA9tGq/ndI3ubdvVEZod6DA8Cb0Vcj9ASnW82HH8oHeTE2uT2xNN45N+g32XfdtH5 6AhY5gyzKBKUS4u/vwz8nvH4u3KZAk3/cvIECXnm3p3Uo60Lu49lF3dW4WaXHvbj6Tyl ai0jq/KIqO3Qk/IhEEWlK8M5rKK9ZwtyKLNKIrmPtRgx5SAl4Lxy2HqqX9LeVcKCmNHx SnVfHgqIBk3XhQ7NVg/TSzi5+dNhUdk/bj6Io67eEtfV+1h+d0nH6hFxQSm0j6HBBcHr IU1Q== 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=HnSURpZm+VRo/jWoSn4Tgay2ffXUBOQESxlPLKKSxGM=; b=fBdaI0/W7VKFXJDSTlQgLobfi7Qvo7adV8sdHsJKvbRdPCKUkSiiyZBUg8lQ6TYv9d hXgwDxD7q3gMbyCutXA8o+/dfJKwAUHbtZJ5c+54yq9UnosmRsAPw+QqEY/ERy3U6BBA EbzvG+COVxMSWXAknAd2JVh4KGk+gBFM286fvHJK1YJZfis64cbflPXUB82iqdmLUcri W4QlWJUVAhINIM8I+kKVbnvf/Ru+3C7QR8CG5X6R8cNyaz7U6ITbT0F1tI8iMYtuTtaF Aq6VL83e8S/hRAn/6lnJhEtyXqn7b8DS8jFhJLwJnsA921Pm7HFAsezcXZSJl0SVZdOE BoEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RcSLPPj9; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w15-20020a637b0f000000b004412f1207b9si1404773pgc.96.2022.10.13.21.33.56; Thu, 13 Oct 2022 21:34:10 -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=RcSLPPj9; 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 S229843AbiJNEU5 (ORCPT + 99 others); Fri, 14 Oct 2022 00:20:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbiJNEUy (ORCPT ); Fri, 14 Oct 2022 00:20:54 -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 ESMTPS id 12CD917651A for ; Thu, 13 Oct 2022 21:20:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665721249; 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=HnSURpZm+VRo/jWoSn4Tgay2ffXUBOQESxlPLKKSxGM=; b=RcSLPPj9uiXffeHi+HgP6gQOCBpiU3EqGZqRnISWELClcFRUnG89CuDWhehTkXKca1FFpQ CFBgJVpk9vf+irIrc9kz33p05NPivndklXGgP7+SIzTOkta4AbQ03bw4CubBfQVdRFUPVj dhXN/0qh2wukbYvel9pDVtF5CV+Bnvc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-574-h_Ui7k8wPmmjl_qv7bpchw-1; Fri, 14 Oct 2022 00:20:46 -0400 X-MC-Unique: h_Ui7k8wPmmjl_qv7bpchw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 30B34185A794; Fri, 14 Oct 2022 04:20:46 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-249.pek2.redhat.com [10.72.12.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7ED081121320; Fri, 14 Oct 2022 04:20:39 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, corbet@lwn.net Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, mikelley@microsoft.com, vkuznets@redhat.com, liuwe@microsoft.com, kkashanjat@microsoft.com, cohuck@redhat.com, otubo@redhat.com, andavis@redhat.com, aadam@redhat.com, stefanha@redhat.com, sgarzare@redhat.com, virtualization@lists.linux-foundation.org Subject: [RFC PATCH] virtio: document virtio hardening status and TODO Date: Fri, 14 Oct 2022 12:20:37 +0800 Message-Id: <20221014042037.23639-1-jasowang@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746636164842781614?= X-GMAIL-MSGID: =?utf-8?q?1746636164842781614?= This patch summarizes the status of hardening and TODO of hardening virtio core and drivers. Signed-off-by: Jason Wang --- Documentation/security/virtio/core.rst | 49 ++++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 50 insertions(+) create mode 100644 Documentation/security/virtio/core.rst diff --git a/Documentation/security/virtio/core.rst b/Documentation/security/virtio/core.rst new file mode 100644 index 000000000000..b8baa104d7c8 --- /dev/null +++ b/Documentation/security/virtio/core.rst @@ -0,0 +1,49 @@ +================ +Virtio hardening +================ + +The virtio core and drivers should not trust the devices. This means +all kinds of input from the device must be validated before being +used. This document summarizes the current status and TODO for this +validation/hardening efforts. + + +Status +====== + +The virtio core and drivers has done some basic hardening: + +* Config callback hardening: The core makes sure the config interrupt + callbacks are enabled after the driver is ready and disable before + the driver is removed. + +* Descriptor ring hardening: The metadata of a descriptor were copied + and stored in a driver private memory that can not be accessed by the + device. The eliminates the device triggerable behaviours through the + descriptor ring. + +* Device configuration space validation: Some of the virtio drivers + validates the fields of device configuration space before try to use + them. + + +TODO +==== + +* Input buffer length validation: The virtio core needs to validate + the input buffer length validation before passing them to individual + virtio drivers. + +* Virtqueue callback hardening: The virtio core (or with the help of + the drivers) should guarantee that the virtqueue callbacks should not + be triggered before the driver is ready or after the driver is + removed. + +* Transport specific data validation: The virtio transport driver should + validate the virtio transport specific data provided by the device + before trying to use them in the probing. + +* Device specific validation: Driver should validate the device specific + metadata before being used by a specific subsystem. + + diff --git a/MAINTAINERS b/MAINTAINERS index 673b9f9b8d8a..b33cc5c751c1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21516,6 +21516,7 @@ S: Maintained F: Documentation/ABI/testing/sysfs-bus-vdpa F: Documentation/ABI/testing/sysfs-class-vduse F: Documentation/devicetree/bindings/virtio/ +F: Documentation/security/virtio/core.rst F: drivers/block/virtio_blk.c F: drivers/crypto/virtio/ F: drivers/net/virtio_net.c