From nobody Tue Nov 18 22:49:06 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613053634; cv=none; d=zohomail.com; s=zohoarc; b=dE8nbweoFq78CAdVDLesaCbtKIzcedrjY/JQThunOXwXdXiK55Zh6jyjDde3MPvl8HYeg7SzqF9Vib9/6A5hC6YmvnUoOWy3oibvN7dd5sn+ez3rkhgve1CMho/0zkvxKPuj/srXt4wkYXQLxLp91z4wOEObG2j8Nx4ysWPylMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613053634; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=D4Z11FEsaA36rEKX69D+N+Q14103WaLLz/9eqppF61E=; b=L07d1oh/CoMGlNt7p428cfJ35GKQjTJU3Ckd8Ryo5i/6xykeJzPLDZzghrmTimrkFjwJKgoc7JqAEMO9UCS8CX1anNAdrlYF2OfdyzoVHQ5eOryJk9+cIKENLNrGqzALIejSX54ZnSxiwseYKI2tIHKj49bEpHQaJ7/ZXz7VYuQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1613053634288608.3945731740694; Thu, 11 Feb 2021 06:27:14 -0800 (PST) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-NkLvrEDJNvGLoA6LMxT7Sg-1; Thu, 11 Feb 2021 09:27:11 -0500 Received: by mail-ej1-f70.google.com with SMTP id jz15so4929117ejc.12 for ; Thu, 11 Feb 2021 06:27:11 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id a1sm4200072edj.6.2021.02.11.06.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Feb 2021 06:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613053633; 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=D4Z11FEsaA36rEKX69D+N+Q14103WaLLz/9eqppF61E=; b=A6DZUW7HbhhEMmZtQRkOdy9WgbmsMGHn6byvhCTiY69gf+sRIdJz/M/miTpK0spZYtkedf qylGUyucFZpjhkLVo8At3CSpVBNKuqPjuP+W7U9tY3wx+KjpZbKTu9sJUtTaUZr5316Dae 6m7OrRdSvjwP/ji0b9nC60aDvQDkdbU= X-MC-Unique: NkLvrEDJNvGLoA6LMxT7Sg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D4Z11FEsaA36rEKX69D+N+Q14103WaLLz/9eqppF61E=; b=qgAWHZJITEc4QWF8O+Y2YdLDTkAL5dsYyxsvHEbPHgun4lLzfZuPgVa+hwfxejf+34 TtxbfSElL/OB1rdVbkR6oKGbRiYFd/SLChZ0W87fSTQ2hTX3ktSQaDQi6x8pAec8IFwg m72Xqxmxc/NHVVugxv4scUu+vpGAlr0bzgdWKRXNPeESnzrayOBT307Oee+i6KKuxiWX w1TQXjdsfkc7T7/aFVbwvR48j+zx4owBXliR1Gqh9r7UHZ5ebBeZzC4+j3D9YOu5IgxD FXSbNOSAWvrhEwK2+txz1+cfMVurQWqjonLUz4ow0QXl3PGqqvsV4CdUwIkDDysecWzv WcIQ== X-Gm-Message-State: AOAM530uFBps7efFxQI0eIhEOZGCEcvEwPZ6+71KEprr1JBWSpo8OXQa H9FigIPrPiR5Z8RkrJ+1gdYIJbACz7Xg+jSe6fz0+tiDaH48COHJeF4S+DgLMMua2RVa2xymW/M YAPHuk/AMru9d1g== X-Received: by 2002:a17:906:408b:: with SMTP id u11mr8523580ejj.299.1613053630416; Thu, 11 Feb 2021 06:27:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxTsxge7qfxvilOLXgRfz6yd/hySRzdzhsu+1Qs/hC1oL61bxA20D36PYGirQR8/XKsUlc6w== X-Received: by 2002:a17:906:408b:: with SMTP id u11mr8523565ejj.299.1613053630258; Thu, 11 Feb 2021 06:27:10 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Cleber Rosa , Thomas Huth , Fam Zheng , Paolo Bonzini , Laurent Vivier , Bandan Das , Markus Armbruster , qemu-block@nongnu.org, Max Reitz , Eric Blake , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Kevin Wolf , Alexander Bulekov , Wainer dos Santos Moschetta Subject: [PATCH v2 2/2] block/null: Enable 'read-zeroes' mode by default Date: Thu, 11 Feb 2021 15:26:56 +0100 Message-Id: <20210211142656.3818078-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210211142656.3818078-1-philmd@redhat.com> References: <20210211142656.3818078-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The null-co driver is meant for (performance) testing. By default, read operation does nothing, the provided buffer is not filled with zero values and its content is unchanged. This performance 'feature' becomes an issue from a security perspective. For example, using the default null-co driver, buf[] is uninitialized, the blk_pread() call succeeds and we then access uninitialized memory: static int guess_disk_lchs(BlockBackend *blk, int *pcylinders, int *pheads, int *psectors) { uint8_t buf[BDRV_SECTOR_SIZE]; ... if (blk_pread(blk, 0, buf, BDRV_SECTOR_SIZE) < 0) { return -1; } /* test msdos magic */ if (buf[510] !=3D 0x55 || buf[511] !=3D 0xaa) { return -1; } We could audit all the uninitialized buffers and the bdrv_co_preadv() handlers, but it is simpler to change the default of this testing driver. Performance tests will have to adapt and use 'null-co,read-zeroes=3Doff'. Suggested-by: Max Reitz Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- block/null.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/null.c b/block/null.c index cc9b1d4ea72..f9658fd70ac 100644 --- a/block/null.c +++ b/block/null.c @@ -93,7 +93,7 @@ static int null_file_open(BlockDriverState *bs, QDict *op= tions, int flags, error_setg(errp, "latency-ns is invalid"); ret =3D -EINVAL; } - s->read_zeroes =3D qemu_opt_get_bool(opts, NULL_OPT_ZEROES, false); + s->read_zeroes =3D qemu_opt_get_bool(opts, NULL_OPT_ZEROES, true); qemu_opts_del(opts); bs->supported_write_flags =3D BDRV_REQ_FUA; return ret; --=20 2.26.2