Received: from eggs.gnu.org ([2001:4830:134:3::10]:43528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlCnv-0006zS-Oy for qemu-devel@nongnu.org; Mon, 03 Nov 2014 03:16:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlCnp-0007f2-Ho for qemu-devel@nongnu.org; Mon, 03 Nov 2014 03:15:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46297) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlCnp-0007ew-Ac for qemu-devel@nongnu.org; Mon, 03 Nov 2014 03:15:53 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sA38FqcV004099 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 3 Nov 2014 03:15:52 -0500 From: Markus Armbruster References: <1414512220-19058-1-git-send-email-armbru@redhat.com> <1414512220-19058-3-git-send-email-armbru@redhat.com> <20141029101242.GA3719@noname.str.redhat.com> <877fzjc76v.fsf@blackfin.pond.sub.org> <20141030093040.GA9097@noname.str.redhat.com> <87oastzprh.fsf@blackfin.pond.sub.org> <5454110E.70809@redhat.com> Date: Mon, 03 Nov 2014 09:15:50 +0100 In-Reply-To: <5454110E.70809@redhat.com> (Eric Blake's message of "Fri, 31 Oct 2014 16:45:34 -0600") Message-ID: <87r3xk1yyx.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH RFC 2/2] block: Warn on insecure format probing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Kevin Wolf , jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Eric Blake writes: > On 10/30/2014 06:49 AM, Markus Armbruster wrote: > >> You either have to prevent *any* writing of the first 2048 bytes (the >> part that can be examined by a bdrv_probe() method, or your have to >> prevent writing anything a probe recognizes, or the user has to specify >> the format explicitly. >> >> If you do the former, you're way outside the realm of "theoretical". >> >> If you do the latter, the degree of "theoreticalness" depends on the >> union of the patterns you prevent. Issues: >> >> 1. Anthony's method of checking a few known signatures is fragile. The >> only obviously robust way to test "is probing going to find something >> other than 'raw'?" is running the probes. Feasible. >> >> 2. Whether the union of patterns qualifies as "theoretical" for all our >> targets is not obvious, and whether it'll remain "theoretical" for all >> future formats and target machines even less. > > This one scares me. The proof of concept patch you posted tests whether > a write to the first sector would result in the sector matching a > _currently known probe_ for the file formats that were compiled in at > configure time to the currently running binary. But this is NOT the set > of all possible binary formats that may be introduced in the future. By > extrapolation, if we pursue write blocking, then the only SAFE way to is > to reject ALL writes to the first sector, because we can't know which > writes will match some theoretical future probe - Yes! > but by the time you > get to that point, then we no longer match bare metal (rejecting ALL > writes to the first sector is ridiculous). > >> 3. A write access that works just fine in one QEMU version can be >> rejected by another version that recognizes more formats. Or probes the >> same formats differently. > > This is just a manifestation of my observation above, which can be > easily triggered now by having two qemu binaries built from the same > source but different compile options. Throw in loadable modules, and it may even depend on runtime configuration. >> 4. Rejecting a write fails *late*, and looks like hardware failure to >> the guest. With imperfect guest software, this risks data corruption. >> >> (4) is a deal breaker for me. > > It is mitigated somewhat by the fact that the proposed patch will NEVER > reject writes for a management app that always correctly passes in a > format and thus avoids probes. But that is still fragile. If I was content with a "specify format= explicitly and you'll be fine" argument, we wouldn't have this discussion :)