From nobody Fri May 17 11:05:41 2024 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=1612890093; cv=none; d=zohomail.com; s=zohoarc; b=oL4vRrjkw32lEAHYZRWvPUBh/yN8GcKba+kJw/VEpo075j19FCiFGGdndg+dLxw4Q5LbtF5Oy/RJ48rSt/lmekGvn6U+DE4EoZ8fchUPX0RL9fH7be5T90cp5xSVRf1z0AHvYCgwpaHB3HKZjHjb0TfX5wIzZS4sfAkegTud3yc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612890093; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=C8Xffz0J0Y47gvusmVO0935zMBbfmfZkBD6TpcslbUE=; b=aZv9QKtApYVYBnVngnOumjdYPsWNLLOfnZPbnjj12xiF9aX0lRVJtLLD6uRD7bwMsXkiZ1cY0rkxa88SRhivRygsyxz4LQX1da/1koVsM8dyYRvlyMo7hiOjz0byFQItEk4ujyREa+SJYBL/4r2IonwD+hL2jLKtlh+ld55ugWo= 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 161289009264835.256885345631076; Tue, 9 Feb 2021 09:01:32 -0800 (PST) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-543-SOJesJ5sNA-r02yx2gwILg-1; Tue, 09 Feb 2021 12:01:25 -0500 Received: by mail-ed1-f71.google.com with SMTP id a1so11419430edt.8 for ; Tue, 09 Feb 2021 09:01:25 -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 p16sm10976880eja.109.2021.02.09.09.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 09:01:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612890090; 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=C8Xffz0J0Y47gvusmVO0935zMBbfmfZkBD6TpcslbUE=; b=d+x4o+jtKu8iYQ51czu3iWudmqXGQ8cgIbt8rjWH2VvVGy4EtgqxNnRQP1x4m8KERJAraE f2gUIWnV0KC+Tr8qXNFgdH9TxZBShXqe8XRGuCNcJsDqdzh9I5itW9IVsi2EaYsUJo98UR R9o1WeIMy8Y8BusAGN87QLpC1aa4W20= X-MC-Unique: SOJesJ5sNA-r02yx2gwILg-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:mime-version :content-transfer-encoding; bh=C8Xffz0J0Y47gvusmVO0935zMBbfmfZkBD6TpcslbUE=; b=pJO4mihIdqBLfhUuYabJoZvmNe4rmltZ9/4sde7fgWMta0EoM2wU4GVKy5pNVhAMPG XiPfdc1V/vQoAQehkiwCg6Xs/SQKjvNIPFukaQnUQW2c9dLFtPA/8rXgB6/ewlsLNc6w bKToggrMU0XI+nSeOiQ6h6dFREl91cut1SpmOwf4kg+Wh6UC6L3JfF9cLsFmrWqdNzSJ xLOXFtNAEWnoZKeieLmrXF/Op/qpL1EoqQNdg6GtHSXYgB+pnNOGK7ENu+CIbtU13KLo 7EOVhU06S+Z7rZcbHhQM5LCTKpdvJ33ANjuL/U9mj1ordGfxoiGdhlh0dqtNnLApfzgj /75w== X-Gm-Message-State: AOAM5317kLWCp38GkA/t/71f8Q/Zq3yh72/N/cN08h9MtFu3Q9wQmKJ2 7CZwPXMp46OH4TyFc4paXoUgExGn6QxiTcSUDVIAe53l+2RF7jnrlwUyRM0nqiqOw7oVETvVu+m XUtbHhK7jmtikMw== X-Received: by 2002:a17:906:f6c7:: with SMTP id jo7mr24093819ejb.178.1612890084069; Tue, 09 Feb 2021 09:01:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJy7L/oKF6hCoEpdvC17xHchOJH18yqL/k+koXeETx2sLfzxz5bkz4boGwzxKbYxcRXXjizpSA== X-Received: by 2002:a17:906:f6c7:: with SMTP id jo7mr24093799ejb.178.1612890083789; Tue, 09 Feb 2021 09:01:23 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH] block/null: Use 'read-zeroes' mode by default Date: Tue, 9 Feb 2021 18:01:21 +0100 Message-Id: <20210209170121.3310151-1-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 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 can confuse security experts. 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=3Don'. Suggested-by: Max Reitz Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- RFC maybe a stricter approach is required? --- 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