Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp744831pxp; Fri, 11 Mar 2022 14:01:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxq26BUumgw+0GI6urUQakQv9W3sJRnYacJuKnedTyFgkazfWQKQ/jfDo7vw8jo5Y3n7TTk X-Received: by 2002:a63:db53:0:b0:380:cf1d:4401 with SMTP id x19-20020a63db53000000b00380cf1d4401mr10193201pgi.504.1647036089125; Fri, 11 Mar 2022 14:01:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647036089; cv=none; d=google.com; s=arc-20160816; b=cT448EbHXgUQGTzuN9rw7cyLx08OExTKESnEY+ccjQ8OaUu/ClhUPkAT6HhAeCJuJO 9SnHu9mCQp0VEYdUb/9liwvzLxJ7byCXmm8cOuXkRF0aT8od4ju60Gw5BUbDtLMhcQJh 6ClZDnwkKvUip/TA00Z1h9s8D2wh09UJRkIqyd32+YPmPATbJqc7ZllddJnnMVvK0Bp7 7CNlTC2FaZCpR/ykbsjh+dKQ9OL6Z8SM1lcIKJr4BJ8kjP4B8EOScLUQRcBpMSNPOIO3 qAetfRWXM47tr2hjSgZ70dUtF39+fle6X8R5toFV6LM7FoxrkVnAA/jrQ8Yff2vaZw7l ih5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bBk9XwQIb0KD3Jp9St4JgL0fEjcIgEWTLBKWjsbsArw=; b=uTQ1ajkHC4k1N/lYeSvCmKK2IAd75yaWThTgSL48LZSHjfLMBDCuX0vBdKRnc5RoVI rx3UrTevUixsIh3mBM7Y9Ir/ZZWHKwk2OYXoDoZ/o34knvUKJWgUaW1JLCfAuvDvrLq2 4i7IUGkAvXppPDKdvDSesSZmO22ArBZcSVnzUsUyoRHlc+BMcNFio5AOkU8wK5ih0lGz hYrTK0OLff8ZydgUXa6ifkCpGOOABrQF0LrURTq7Zzi7/XWrcG7zwBRAvhTv+pkYuhKI cWnIv0O9P9XFaZRGfXZHlgAlc92yLFAwimPUWOfaMf1UM4LnM7lmwA2WbaQsdhmoPYNv KyKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vmyYVeel; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v12-20020a17090ae98c00b001bd14e030d2si5716973pjy.170.2022.03.11.14.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:01:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vmyYVeel; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ED833207C1F; Fri, 11 Mar 2022 13:18:31 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243262AbiCJOX2 (ORCPT + 99 others); Thu, 10 Mar 2022 09:23:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244056AbiCJOSn (ORCPT ); Thu, 10 Mar 2022 09:18:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C18D169229; Thu, 10 Mar 2022 06:15:26 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F2605B82615; Thu, 10 Mar 2022 14:15:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51E3AC340E8; Thu, 10 Mar 2022 14:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646921724; bh=+jYMK9ccxxirlSlYIOACAJmyJoUQsDEEQvIaAWiLdJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vmyYVeelPUyRvRDCF8pEJejs9yTWRR9dDKwHUb+fISZQOSdFBj9nWnt/aY2c/aK8e dEO9TPnZBwOsc4kCwazobwz5bvS+uiBcgr5ai7xp3qkeedlrH1PjooM4AfC66ub1xA Y+B+HGdJvOLwKrHS9v+mbnqSrkI8qRvB04BSzzK8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Demi Marie Obenour , Juergen Gross , Jan Beulich Subject: [PATCH 4.9 33/38] xen/netfront: dont use gnttab_query_foreign_access() for mapped status Date: Thu, 10 Mar 2022 15:13:46 +0100 Message-Id: <20220310140809.101922402@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220310140808.136149678@linuxfoundation.org> References: <20220310140808.136149678@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juergen Gross Commit 31185df7e2b1d2fa1de4900247a12d7b9c7087eb upstream. It isn't enough to check whether a grant is still being in use by calling gnttab_query_foreign_access(), as a mapping could be realized by the other side just after having called that function. In case the call was done in preparation of revoking a grant it is better to do so via gnttab_end_foreign_access_ref() and check the success of that operation instead. This is CVE-2022-23037 / part of XSA-396. Reported-by: Demi Marie Obenour Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich Signed-off-by: Greg Kroah-Hartman --- drivers/net/xen-netfront.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -413,14 +413,12 @@ static bool xennet_tx_buf_gc(struct netf queue->tx_link[id] = TX_LINK_NONE; skb = queue->tx_skbs[id]; queue->tx_skbs[id] = NULL; - if (unlikely(gnttab_query_foreign_access( - queue->grant_tx_ref[id]) != 0)) { + if (unlikely(!gnttab_end_foreign_access_ref( + queue->grant_tx_ref[id], GNTMAP_readonly))) { dev_alert(dev, "Grant still in use by backend domain\n"); goto err; } - gnttab_end_foreign_access_ref( - queue->grant_tx_ref[id], GNTMAP_readonly); gnttab_release_grant_reference( &queue->gref_tx_head, queue->grant_tx_ref[id]); queue->grant_tx_ref[id] = GRANT_INVALID_REF;