From patchwork Wed Sep 8 23:20:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12482003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84D07C433F5 for ; Wed, 8 Sep 2021 23:21:05 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 50CDE60295 for ; Wed, 8 Sep 2021 23:21:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 50CDE60295 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.182411.329988 (Exim 4.92) (envelope-from ) id 1mO6sE-0006yb-1O; Wed, 08 Sep 2021 23:20:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 182411.329988; Wed, 08 Sep 2021 23:20:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mO6sD-0006yQ-Su; Wed, 08 Sep 2021 23:20:57 +0000 Received: by outflank-mailman (input) for mailman id 182411; Wed, 08 Sep 2021 23:20:56 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mO6sC-0006qz-06 for xen-devel@lists.xenproject.org; Wed, 08 Sep 2021 23:20:56 +0000 Received: from us-smtp-delivery-124.mimecast.com (unknown [170.10.133.124]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 6aa80e62-10fb-11ec-b18c-12813bfff9fa; Wed, 08 Sep 2021 23:20:55 +0000 (UTC) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-120-R6zlE6tdNA-tMDGhi21A2g-1; Wed, 08 Sep 2021 19:20:51 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5-20020a1c00050000b02902e67111d9f0so4241wma.4 for ; Wed, 08 Sep 2021 16:20:51 -0700 (PDT) Received: from x1w.. (21.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.21]) by smtp.gmail.com with ESMTPSA id c3sm30713wrd.34.2021.09.08.16.20.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 16:20:50 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6aa80e62-10fb-11ec-b18c-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631143255; 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: in-reply-to:in-reply-to:references:references; bh=p6u3sclI6JBi/0aQ8m/8uYmNWK6u/Efc+CTX33mwcn4=; b=UAbntxhNMDLfhVBJUanQ/nbNFX8SsAgORd8PabEo0ooHKj4cGHZLtZJV1Ap4C+4U+v4W1m 9JXqOZLnbflNIhvAsLodB2QDw6saRyC5xk4oXokL4grrM0ug0kgsIlLCH43ermB775L6GW OxaKR8ypL7bHx7uyTyNf2AXNhuX1iS8= X-MC-Unique: R6zlE6tdNA-tMDGhi21A2g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p6u3sclI6JBi/0aQ8m/8uYmNWK6u/Efc+CTX33mwcn4=; b=sT9ulG+ZLywii1VxtIiObwE6Cfz6u6/yBn70EPuwbVCw6/ZfKA7qU6gdGHNv+JLu4O xlNFhV2PQQmkq3Ag8ta/I/6EmwPQXwbfwYBp4TwLJzPK4Ya5gMyGCHwxZcdADwRphnPo ZMz0xm+EBplM2vappXNzHx52zdCcBrGNbpKrcbsOLUPBmfbPnmudlQ8a/FudIlvcfhoE 9uAoRPeUjJTuaNaFnRG/XrJBd/pjvFcFQwa8bdVkI8v9Vbmqhrkf7dIADSo/nSKlawVI wsNSYxohSKxP/6aKtAx2qd6p37SER7F1rBI67QD/mQrHWPtaD/5iLGcAjXST6f5Bs6KP YBlA== X-Gm-Message-State: AOAM533FLPUp4ly/iDks+MJ/+x1m+bKmxFUHVLy/dT6Ux8hPMnJStnIi MakxHz1GfiQpUmSh/Tj+/OZTLTNAXNjqcEYY6kZeLBdqbnkenuQsMrM8bKjPAoWJPpC+zj1xuL8 mwPT2FIrR3Klpf1KaWlgBJty5t08= X-Received: by 2002:adf:fb8d:: with SMTP id a13mr108073wrr.164.1631143250631; Wed, 08 Sep 2021 16:20:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrh/n5wSnZqfaTQvrzl6IJ2DKh1pSXkkHEuOdKtVrOvCH+TWDpEiwg1GoyEgBtyhNoco5QeA== X-Received: by 2002:adf:fb8d:: with SMTP id a13mr108055wrr.164.1631143250497; Wed, 08 Sep 2021 16:20:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Prasad J Pandit , "Michael S. Tsirkin" , Markus Armbruster , Paolo Bonzini , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Daniel?= =?utf-8?q?_P=2E_Berrang=C3=A9?= , Eric Blake , Richard Henderson , qemu-block@nongnu.org, Peter Maydell , xen-devel@lists.xenproject.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [RFC PATCH 05/10] block/null: Mark 'read-zeroes=off' option as unsafe Date: Thu, 9 Sep 2021 01:20:19 +0200 Message-Id: <20210908232024.2399215-6-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908232024.2399215-1-philmd@redhat.com> References: <20210908232024.2399215-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com See commit b317006a3f1 ("docs/secure-coding-practices: Describe how to use 'null-co' block driver") for rationale. Signed-off-by: Philippe Mathieu-Daudé --- block/null.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block/null.c b/block/null.c index cc9b1d4ea72..11e428f3cc2 100644 --- a/block/null.c +++ b/block/null.c @@ -99,6 +99,13 @@ static int null_file_open(BlockDriverState *bs, QDict *options, int flags, return ret; } +static bool null_taints_security_policy(BlockDriverState *bs) +{ + BDRVNullState *s = bs->opaque; + + return !s->read_zeroes; +} + static int64_t null_getlength(BlockDriverState *bs) { BDRVNullState *s = bs->opaque; @@ -283,6 +290,7 @@ static BlockDriver bdrv_null_co = { .bdrv_parse_filename = null_co_parse_filename, .bdrv_getlength = null_getlength, .bdrv_get_allocated_file_size = null_allocated_file_size, + .bdrv_taints_security_policy = null_taints_security_policy, .bdrv_co_preadv = null_co_preadv, .bdrv_co_pwritev = null_co_pwritev,