Received: by 10.192.165.156 with SMTP id m28csp269957imm; Tue, 17 Apr 2018 09:52:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx48CzDhsvU7B2zCj2Xq+7l+6+9UPHX31vsw/zTw++zQr8ocCpW/XX+YHWKXYFZOuN5ZJWAKi X-Received: by 2002:a17:902:5a5:: with SMTP id f34-v6mr2699038plf.288.1523983935316; Tue, 17 Apr 2018 09:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523983935; cv=none; d=google.com; s=arc-20160816; b=RU2wusbD6HNk04NEo5cSw9+cYOuROpjkI3V5+Hd/xZZPG/FIEMl0j9eJwmmlOnO8p4 nEZ/i5uDMfnqsNNZDObssyY9mjefZaA5cbeywYj6Echnqmls3NJu8QmNYS1ZgWRK0kWj tHP0juF2rehi5oMLxuTz45O0HqldUO/1+hLaC7z6fhR6yGSXYDfMSIt6/uSO4ho6qGAv je06AzcOkoIxNiKPbJh4UZftoexGjmP/QuVxeGDTwY7Hfikv9zLNYEEMR8mierOi/0ij c+dsdKEh4AxtfPXxpsD42WQOrqu7cO8396Z/rHBK2a5cYx46vZyRo6u/eCJT3HxG0dfg wQQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=e2+Xvwf2XKWOYjqSRPZPH7tULDV19/IvU9pCPelrKZ8=; b=wVTJ2kTsUnsNCRR1t5bfq4rjRtydJo/J8rAwNpGaUH+iKqOOD2kQ+hgtCEUxe1wDGW NK7ymGKur72JRS26cMrNPqGs2uzRKfTM3bof3OFJg5O+VbSLBl2PnVB5AJYRzcJCF0A3 wqvMu4wp1Ni2ituXe2OxnDZLhDwKJ0GWQ2QEpNcnC0hqbz4xYl3PvHGEHDkDgF4IlQfj uNtELzVmnn4te6D6ShR5x/kQ4Bg5k0AieH4Mx7pKJMq1E3vABnT64fTJKyfrIQoNgxeN Qr2pfulvI9/XcADcMlzR+WWGnthoU9f3R2j3ln9VcfX/upAjSEZvQScWaf0JIVM7UzRH 9mFQ== ARC-Authentication-Results: i=1; mx.google.com; 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 r20si13428775pfk.224.2018.04.17.09.52.00; Tue, 17 Apr 2018 09:52:15 -0700 (PDT) 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; 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 S1754534AbeDQQEl (ORCPT + 99 others); Tue, 17 Apr 2018 12:04:41 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34240 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754497AbeDQQEh (ORCPT ); Tue, 17 Apr 2018 12:04:37 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 45FF0C49; Tue, 17 Apr 2018 16:04:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Simon Gaiser , Juergen Gross , Boris Ostrovsky Subject: [PATCH 4.15 34/53] xen: xenbus_dev_frontend: Fix XS_TRANSACTION_END handling Date: Tue, 17 Apr 2018 17:58:59 +0200 Message-Id: <20180417155724.802239811@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155723.091120060@linuxfoundation.org> References: <20180417155723.091120060@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Simon Gaiser commit 2a22ee6c3ab1d761bc9c04f1e4117edd55b82f09 upstream. 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 the transaction as finished regardless of the response. The new behavior is that xenbus_dev_request_and_reply() and xenbus_transaction_end() will always count the transaction as finished regardless the response code (handled in xs_request_exit()). 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 once regardless of the return code. Cc: # 4.11 Fixes: fd8aa9095a95 ("xen: optimize xenbus driver for multiple concurrent xenstore accesses") Signed-off-by: Simon Gaiser Reviewed-by: Juergen Gross Signed-off-by: Boris Ostrovsky Signed-off-by: Greg Kroah-Hartman --- drivers/xen/xenbus/xenbus_dev_frontend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/xen/xenbus/xenbus_dev_frontend.c +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c @@ -365,7 +365,7 @@ void xenbus_dev_queue_reply(struct xb_re if (WARN_ON(rc)) goto out; } - } else if (req->msg.type == XS_TRANSACTION_END) { + } else if (req->type == XS_TRANSACTION_END) { trans = xenbus_get_transaction(u, req->msg.tx_id); if (WARN_ON(!trans)) goto out;