Received: by 10.223.185.116 with SMTP id b49csp224869wrg; Mon, 19 Feb 2018 20:57:56 -0800 (PST) X-Google-Smtp-Source: AH8x2246mVcnx6OHLsVlABfy21IRe7UpihF0VfnipqwxOma3vS85N6gXTaP2eJdqzZKTY4JjkCwO X-Received: by 10.98.224.208 with SMTP id d77mr3989441pfm.194.1519102676419; Mon, 19 Feb 2018 20:57:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519102676; cv=none; d=google.com; s=arc-20160816; b=giAN+FK0Z98/VoGtOOfVGYv1BaLRbhRqby+7euSP8w3O3WASZdiGB4BAstvJjEreWG 7YZwPN4o7PyBl1pv866iSfEFqM8b7CKz3xWakGaG8K9teIOR/5E0UUiswPqJswv9b3RP mnvtU6DRaBlDm/6MBKZJ/ijc73aBTyNmy53E5n2OjwGwktyKsiDeNmRKcOYZvVvzOAVi KOEz1ZAy22YeCIL+0L5p1sHiBnFvte2v3Joz0pryBNXmdqWpGwcsmH67bOTkPrdf1Bno uI6EmphHOxAtlzQZHz0Vuag829SlgjEB9mStxh3Gdbs1Tr4qhbArX/l2RToR1a2Hzl4p 2klQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:mime-version:date:message-id :from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=8KHr/CQ/eLVMYUtuuHXgu0BPRKB05QRDk3R13C0HaFk=; b=0Kpmn8dam5LvdCVdUcye/djGyrnzlZLwnjsXEDgQF/ZDLzRbApLy8pTExBC6z024PK gMGfwiWDTeWnJ3UvtWkbv30muF9EYQoTzvWiaUOMB9UgDBjYtNKsc0Bgy6+LuwRp6FhB BP8zFI4FQNWBtJY56zdna868rzsUwDQ+k9OkqvT2yVwp8Km7qxwJNI3d4IVAAM4uHa/q 7IqGkPtflqU4BbxjhrzTIZcWVLgCe2/cXtqIdMSugPsDIXUGrv0JJmJBsKcpvV0keuA9 n3ufyKeOlJax2BQiPFLRsGb+z9zek8NHTL9LnjXJPx1DFDDHZXYAKmQrJW9S6xF/A7d5 RDuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=hPnviPu+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si7051764plo.230.2018.02.19.20.57.41; Mon, 19 Feb 2018 20:57:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=hPnviPu+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751252AbeBTE46 (ORCPT + 99 others); Mon, 19 Feb 2018 23:56:58 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:56425 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750858AbeBTE45 (ORCPT ); Mon, 19 Feb 2018 23:56:57 -0500 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 313FC20FA8; Mon, 19 Feb 2018 23:56:55 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Mon, 19 Feb 2018 23:56:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=8KHr/CQ/eLVMYUtuuHXgu0BPRKB05 QRDk3R13C0HaFk=; b=hPnviPu+uexSXfhka07bH62lc9UeglLV+dRzRCxR+T+Wx aLBeniYXYEYig+bgcyylbSJzsvbBRHil02ENEst+Lb6tm5ouS/tX4ywQICpSulm4 RSyDS/guFyQYQmpjsloIUpKvdQnbaVThlCkRvEu/XGDK7genuhCpC4GClPbheYHw 3qOOraaNYeEG4a253aagLDpcsDjZpBD3OgABdFDMmG3FgUQozE22vekwSZhvVNIs cjyZ6YtnRyCzmb+87PhnwZBSVlDZgPkuWjc6CDHH2M9Tl6FoFScNf+wEumMybSwH g1eQHDAn6yd6x116CL3bvypv4Y9SIj1QU6BNwAAGw== X-ME-Sender: Received: from [127.0.0.1] (tor-exit1-readme.dfri.se [171.25.193.77]) by mail.messagingengine.com (Postfix) with ESMTPA id 425B7245F1; Mon, 19 Feb 2018 23:56:52 -0500 (EST) Subject: Re: [PATCH 1/2] xen: xenbus_dev_frontend: Fix XS_TRANSACTION_END handling To: Juergen Gross , xen-devel@lists.xenproject.org Cc: stable@vger.kernel.org, Boris Ostrovsky , linux-kernel@vger.kernel.org References: <20180207222236.7434-1-simon@invisiblethingslab.com> <1fbf69f9-f835-897e-144f-8c6f8b94cd26@suse.com> From: Simon Gaiser Message-ID: <1d10edc6-8ad6-bc58-432c-d1867f0ab57a@invisiblethingslab.com> Date: Tue, 20 Feb 2018 04:56:00 +0000 MIME-Version: 1.0 In-Reply-To: <1fbf69f9-f835-897e-144f-8c6f8b94cd26@suse.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BCNRGoU7u99MhOmENERYQD81uMIzqsj9q" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --BCNRGoU7u99MhOmENERYQD81uMIzqsj9q Content-Type: multipart/mixed; boundary="UrcEycLHHCAXawABUXRgY4RJQDH6yYJTM"; protected-headers="v1" From: Simon Gaiser To: Juergen Gross , xen-devel@lists.xenproject.org Cc: stable@vger.kernel.org, Boris Ostrovsky , linux-kernel@vger.kernel.org Message-ID: <1d10edc6-8ad6-bc58-432c-d1867f0ab57a@invisiblethingslab.com> Subject: Re: [PATCH 1/2] xen: xenbus_dev_frontend: Fix XS_TRANSACTION_END handling References: <20180207222236.7434-1-simon@invisiblethingslab.com> <1fbf69f9-f835-897e-144f-8c6f8b94cd26@suse.com> In-Reply-To: <1fbf69f9-f835-897e-144f-8c6f8b94cd26@suse.com> --UrcEycLHHCAXawABUXRgY4RJQDH6yYJTM Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Juergen Gross: > On 07/02/18 23:22, Simon Gaiser wrote: >> Commit fd8aa9095a95 ("xen: optimize xenbus driver for multiple >> concurrent xenstore accesses") made a subtle change to the semantic of= >> xenbus_dev_request_and_reply() and xenbus_transaction_end(). >> >> Before on an error response to XS_TRANSACTION_END >> xenbus_dev_request_and_reply() would not decrement the active >> transaction counter. But xenbus_transaction_end() has always counted t= he >> transaction as finished regardless of the response. >=20 > Which is correct now. Xenstore will free all transaction related > data regardless of the response. A once failed transaction can't > be repaired, it has to be repeated completely. So if xenstore frees the transaction why should we keep it in the list with pending transaction in xenbus_dev_frontend? That's exactly what this patch fixes by always removing it from the list, not only on a successful response (See below for the EINVAL case). [...] >> But xenbus_dev_frontend tries to end a transaction on closing of the >> device if the XS_TRANSACTION_END failed before. Trying to close the >> transaction twice corrupts the reference count. So fix this by also >> considering a transaction closed if we have sent XS_TRANSACTION_END on= ce >> regardless of the return code. >=20 > A transaction in the list of transactions should not considered to be > finished. Either it is not on the list or it is still pending. With "considering a transaction closed" I mean "take the code path which removes the transaction from the list with pending transactions". =46rom the follow-up mail: >>> The new behavior is that xenbus_dev_request_and_reply() and >>> xenbus_transaction_end() will always count the transaction as finishe= d >>> regardless the response code (handled in xs_request_exit()). >> >> ENOENT should not decrement the transaction counter, while all >> other responses to XS_TRANSACTION_END should still do so. >=20 > Sorry, I stand corrected: the ENOENT case should never happen, as this > case is tested in xenbus_write_transaction(). It doesn't hurt to test > for ENOENT, though. >=20 > What should be handled is EINVAL: this would happen if a user specified= > a string different from "T" and "F". Ok, I will handle those cases in xs_request_exit(). Although I don't like that this depends on the internals of xenstore (At least to me it's not obvious why it should only return ENOENT or EINVAL in this case). In the xenbus_write_transaction() case checking the string before sending the transaction (like the transaction itself is verified) would avoid this problem. --UrcEycLHHCAXawABUXRgY4RJQDH6yYJTM-- --BCNRGoU7u99MhOmENERYQD81uMIzqsj9q Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE3E8ezGzG3N1CTQ//kO9xfO/xly8FAlqLqp8ACgkQkO9xfO/x ly+XExAApdIgnsM6xkHjK8kBhDK57fz+xLyU6htNsOgamX4c94ZroOG3GhHXVGq0 zdyy/p/UCMwV/ySUfENZtbzzIj7uY+XJkgDBb5l/h39baok5AXGvBxch7AiFDTVp MtgcgPYuBZwgtuIJiwF7HdrHyCQ+DurHQ9MRIxBeDesoJRNYfYHeady7QrPtBk4I fZZ0n7SfTepI73h8mpnht8NWkwt8KgGFT6iJxItr7oqjbEC09lFRwvOddtX2zs5e BGaDlgUAarrf8lFhy03BBJisGA8iWnlrxLRoLY1mS4WrBZDwyuLLSt1oswLE5J/w yVYb3mnyABoEjZMw6nHnVBQmtPKzkyt9i/CSZFc31cqE+sPIvBBtoFZaS08m06Op MHueVEaf1Gaa8LWZpen7vUhDd7bbxS/MioHu7Z354L1H7fRBEzLY59zMyvQPlpvw 5F6WPrFngrb1Q1qzH3FXt81MI8bnzGZj85SJXm5EOqxszMizHvpoF38aEI4p+Dv9 mRWKlNJC+GK93LAI8Bb6MclDb+F0cxlSWO32d4GDokJGJ45ZjRxJrZ5B9yWWalBp 3xsszLTBLx8+CH+IK09n2fCSqmUU4G17zSJqNiNciswpbpEmSNt4xyh44l/zHs9X nWakkPtyXGuCbsY5ey0DpEk/gp/p8U+mwHrivWjuDI81mkwKBdo= =3Gxv -----END PGP SIGNATURE----- --BCNRGoU7u99MhOmENERYQD81uMIzqsj9q--