Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp583167pxb; Wed, 27 Jan 2021 15:50:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrC6MmUeL6AyT1OlZPsPTjFgb3eixa6Y/nu0M1Zg/k2cRLuncUSbzBA1uPWVj2dFQU6dnQ X-Received: by 2002:a50:8757:: with SMTP id 23mr11144406edv.294.1611791445510; Wed, 27 Jan 2021 15:50:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611791445; cv=none; d=google.com; s=arc-20160816; b=QxYIrtf+yxvlgjWGFubXO6gy6bwuXvnwh/P0WiRikwx2yBId/5pYhPqWV8yT7yQo+e z1Mb8bsofp2cD7fVC8acZrYwc6+D84C+z0eR8dMOX0eglx4IBUXdnodyakIDltUyhDXy 73fjEmrBS2D68esT2XuOmGHdHSMiCFXPTSdrs2WAKC22nDQBMqboeVwvFaZDNcJfVpdk EoZ3evZl3AW/2XfenwDsvVP06ltyAl3BuFmxawREXO5rRVLC/84KJI2hwTB8/x1brnz/ bpK4AMEHXSo8W+fh3UrKpB+FPjKvqPYOiv75HLQ3gK86rrJMt5YxD6VoK86xzN87xA3A ZaKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=sTPfmJYS9K4cDzIeVmkm+0vr0eBqdm0Bp1Q5Z9yBMa0=; b=jm+sjUjB/h+CLbg8z1nzkkIykctuODy53Rhf7y+ta7yVF+A5Od+/7vnZJwqpmT2tRq 2RN5BXEfQkAj9zifaPf2Tqu9oM0T78Q9h+J604en5OKxUamV5AR1yLjpmp8J/KqptaN3 iZTFrcHhykzJ07qQbGdSRpXBR7rbEeUSKEwVrUkCPVY9odGJsrjhN0nj4V8jgZl+sV0/ leygfnY70I3U3+8pyDIXhHUy5DXdALGCJYlJ839FgPKlJP01FlFa2dRhM+3bmWl5K2+n q7yA0r0BUBszFh2GEjp8GBKcIzR9YSFcsC/e0uFQJqi5Nd2g+91g+T1SEpd7VVlbn6ia 18/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=tcWvnXzV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si1816920edp.379.2021.01.27.15.50.20; Wed, 27 Jan 2021 15:50:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=tcWvnXzV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236496AbhA0LWk (ORCPT + 99 others); Wed, 27 Jan 2021 06:22:40 -0500 Received: from mx2.suse.de ([195.135.220.15]:38602 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236185AbhA0LVY (ORCPT ); Wed, 27 Jan 2021 06:21:24 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611746437; h=from:from:reply-to: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=sTPfmJYS9K4cDzIeVmkm+0vr0eBqdm0Bp1Q5Z9yBMa0=; b=tcWvnXzV4MLZ+DQuecYXmwdrTwr8uC8U2uXoOm24fc/K3CAM+orKakcfguyxzw9PYjOlwA GKpQUDgv4GaECfg1CsitVK8kMnElzq4jqkXaScoIK/Ais7a6rdPx+u2ft4p7Pqqji8cfj3 MXtgHuDvQ1tUyjyJEkgI3MzJjgEnPN8= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 078F5AD26; Wed, 27 Jan 2021 11:20:37 +0000 (UTC) Subject: Re: [PATCH] xen-blkback: fix compatibility bug with single page rings To: paul@xen.org Cc: 'Paul Durrant' , 'Konrad Rzeszutek Wilk' , =?UTF-8?B?J1JvZ2VyIFBhdSBNb25uw6kn?= , 'Jens Axboe' , 'Dongli Zhang' , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, xen-devel@lists.xenproject.org References: <20210127103034.2559-1-paul@xen.org> <026001d6f49c$eab982b0$c02c8810$@xen.org> From: Jan Beulich Message-ID: Date: Wed, 27 Jan 2021 12:20:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <026001d6f49c$eab982b0$c02c8810$@xen.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27.01.2021 12:09, Paul Durrant wrote: >> -----Original Message----- >> From: Jan Beulich >> Sent: 27 January 2021 10:57 >> To: Paul Durrant >> Cc: Paul Durrant ; Konrad Rzeszutek Wilk ; Roger Pau >> Monné ; Jens Axboe ; Dongli Zhang ; >> linux-kernel@vger.kernel.org; linux-block@vger.kernel.org; xen-devel@lists.xenproject.org >> Subject: Re: [PATCH] xen-blkback: fix compatibility bug with single page rings >> >> On 27.01.2021 11:30, Paul Durrant wrote: >>> From: Paul Durrant >>> >>> Prior to commit 4a8c31a1c6f5 ("xen/blkback: rework connect_ring() to avoid >>> inconsistent xenstore 'ring-page-order' set by malicious blkfront"), the >>> behaviour of xen-blkback when connecting to a frontend was: >>> >>> - read 'ring-page-order' >>> - if not present then expect a single page ring specified by 'ring-ref' >>> - else expect a ring specified by 'ring-refX' where X is between 0 and >>> 1 << ring-page-order >>> >>> This was correct behaviour, but was broken by the afforementioned commit to >>> become: >>> >>> - read 'ring-page-order' >>> - if not present then expect a single page ring >>> - expect a ring specified by 'ring-refX' where X is between 0 and >>> 1 << ring-page-order >>> - if that didn't work then see if there's a single page ring specified by >>> 'ring-ref' >>> >>> This incorrect behaviour works most of the time but fails when a frontend >>> that sets 'ring-page-order' is unloaded and replaced by one that does not >>> because, instead of reading 'ring-ref', xen-blkback will read the stale >>> 'ring-ref0' left around by the previous frontend will try to map the wrong >>> grant reference. >>> >>> This patch restores the original behaviour. >> >> Isn't this only the 2nd of a pair of fixes that's needed, the >> first being the drivers, upon being unloaded, to fully clean up >> after itself? Any stale key left may lead to confusion upon >> re-use of the containing directory. > > In a backend we shouldn't be relying on, nor really expect IMO, a frontend to clean up after itself. Any backend should know *exactly* what xenstore nodes it’s looking for from a frontend. But the backend can't know whether a node exists because the present frontend has written it, or because an earlier instance forgot to delete it. It can only honor what's there. (In fact the other day I was wondering whether some of the writes of boolean "false" nodes wouldn't better be xenbus_rm() instead.) Jan