Received: by 10.213.65.68 with SMTP id h4csp1382091imn; Wed, 14 Mar 2018 19:48:59 -0700 (PDT) X-Google-Smtp-Source: AG47ELvJQLu1blM9N0svZB8zDqBndZOrCGbAZUMmD0hJudO9l2AA6wIuCemd9D/FCBtawaTOVhZ1 X-Received: by 10.98.198.146 with SMTP id x18mr6338048pfk.22.1521082139359; Wed, 14 Mar 2018 19:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521082139; cv=none; d=google.com; s=arc-20160816; b=Q9zW7NRerA0PdIupop0mVO9pv9rojWCA8+C8bWP327gc8csk8ESUxKnxM+tXJN4AzI KlqNHiAg1CCo5SUWk3qIyAmVWaniw6gvXERXAfnsclw0jsgKRwCAWX523nW69LXNkzWp ZBwkbi9lb9/4uMNkyvKLEGFlaN7zkqj1KtJ4CQ01gBIT8TvYr5XYPFYTIrurC5MxiEPV pnua/uIHVn9dAoBKr8wG8cJ3FpdjH/bUN0fryB7e+Tzva+ZSdkDrBDpjWu95WloESWu/ TWdLfCPUrhAweZz7IboWmMxdBOTt/ZY1uA1S9/f1TUpMFMNTbZHrEXvYSkdELIYTPBGH i8eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=YzPjxsRj1cOqG366HSHYiWXmvPpoT6bb2pB0U2o8M+c=; b=WXuXmbdP8PYJFdhBhG7cRtYKtTVGoHN1KoZ4xRvgz4rCcXbzPo5YkTayE1ZTRS00ss qYyyL4BZXwaI6r/WCvMut9op5ZKCj3imIo4g6g/5qYF7Q0FSRVwMs26JPzQ0cp3z7i+s 57getWLePIFfhdDOfTUf/eSAQOB7tiCYFACCnEpSWpvs1gg0EPCtb556Ifx+hQ6xkhrr tzzqsIde4BukgWQQaLl+SW4cpp/bp3ouzxUSEX0rOeZNjalb7yiOOjv/MprBnv/XeshI QC0m1+xXCudqqxdS0y7YFWDm3aOGPH7jTlrSrCq8luYQvXh+uOPDumLti3/URo9ZfadK OysQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=PgYZwUPA; 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 u1-v6si3015901pls.488.2018.03.14.19.48.45; Wed, 14 Mar 2018 19:48:59 -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; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=PgYZwUPA; 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 S1752209AbeCOCqe (ORCPT + 99 others); Wed, 14 Mar 2018 22:46:34 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:43181 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751666AbeCOCqc (ORCPT ); Wed, 14 Mar 2018 22:46:32 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 8C4D22115D; Wed, 14 Mar 2018 22:46:31 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Wed, 14 Mar 2018 22:46:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=YzPjxsRj1cOqG366HSHYiWXmvPpoT6bb2pB0U2o8M+c=; b=PgYZwUPA 5GnlkeE4QAOvbBZDhhSHdTmsxKfioa8/4KiCJj8pu+GLaStBuZZtbHNjjYCkLWNu +idKR5V5GCN2axwgvEUQcDJw0lYwiBBzJ+IuZKLNgRncVtNo3SNI28PXgQ7Hs7zt sUzvKK5VNUtxHI4Mps3TjaIJKhGTuUBaNhAcchV9kgrDqfqWn6byRkmaIxU4X6B2 aaTUx0RwgQiz1p2gputMB2X7jkZwjTJczzo0e6cX9XdIaZLv8/l957WWUcgN2Vww OfPujccrIv1dLCp9cKsLGNCDAIxuN4bpEJuE62busV2BokHdHZXRon00UQHeItx4 ZuoesNtdJJjC0A== X-ME-Sender: Received: from localhost (unknown [185.220.101.0]) by mail.messagingengine.com (Postfix) with ESMTPA id 57F692424F; Wed, 14 Mar 2018 22:46:27 -0400 (EDT) From: Simon Gaiser To: xen-devel@lists.xenproject.org Cc: Simon Gaiser , Boris Ostrovsky , Juergen Gross , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] xen: xenbus_dev_frontend: Verify body of XS_TRANSACTION_END Date: Thu, 15 Mar 2018 03:43:22 +0100 Message-Id: <20180315024322.27429-3-simon@invisiblethingslab.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180315024322.27429-1-simon@invisiblethingslab.com> References: <20180315024322.27429-1-simon@invisiblethingslab.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By guaranteeing that the argument of XS_TRANSACTION_END is valid we can assume that the transaction has been closed when we get an XS_ERROR response from xenstore (Note that we already verify that it's a valid transaction id). Signed-off-by: Simon Gaiser --- drivers/xen/xenbus/xenbus_dev_frontend.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c index 81a84b3c1c50..0d6d9264d6a9 100644 --- a/drivers/xen/xenbus/xenbus_dev_frontend.c +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c @@ -429,6 +429,10 @@ static int xenbus_write_transaction(unsigned msg_type, { int rc; struct xenbus_transaction_holder *trans = NULL; + struct { + struct xsd_sockmsg hdr; + char body[]; + } *msg = (void *)u->u.buffer; if (msg_type == XS_TRANSACTION_START) { trans = kzalloc(sizeof(*trans), GFP_KERNEL); @@ -437,11 +441,15 @@ static int xenbus_write_transaction(unsigned msg_type, goto out; } list_add(&trans->list, &u->transactions); - } else if (u->u.msg.tx_id != 0 && - !xenbus_get_transaction(u, u->u.msg.tx_id)) + } else if (msg->hdr.tx_id != 0 && + !xenbus_get_transaction(u, msg->hdr.tx_id)) return xenbus_command_reply(u, XS_ERROR, "ENOENT"); + else if (msg_type == XS_TRANSACTION_END && + !(msg->hdr.len == 2 && + (!strcmp(msg->body, "T") || !strcmp(msg->body, "F")))) + return xenbus_command_reply(u, XS_ERROR, "EINVAL"); - rc = xenbus_dev_request_and_reply(&u->u.msg, u); + rc = xenbus_dev_request_and_reply(&msg->hdr, u); if (rc && trans) { list_del(&trans->list); kfree(trans); -- 2.16.2