Received: by 2002:ac2:48a3:0:0:0:0:0 with SMTP id u3csp552354lfg; Fri, 11 Mar 2022 13:02:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyttsSgWk3iNgQ7vhOiEHJ4RQAlVQ0ip+9VIqP1wJv7aX1phbFQBCMrdMFlha44SUz9xuUH X-Received: by 2002:a17:902:da8f:b0:151:d7d9:eb77 with SMTP id j15-20020a170902da8f00b00151d7d9eb77mr12265896plx.150.1647032556169; Fri, 11 Mar 2022 13:02:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647032556; cv=none; d=google.com; s=arc-20160816; b=SSBngGoV/OBjxwtqj51WTPfWg7a5vlf4W7TzCHx0N0M123qFNriSyu0vAjmFJy7TmS TKZuYNXWW4y8NtbatroDF9HJUg2vF9griYyCFlrIQ5XkYYfiOY9mU80A9PRhHs8+g07m e7S8SANYSVqJ3eR4kkhaLznlU0L6W9zCAEcPKX/iluea/YYIOquTJKragD+a4rEb7zub fL7YYhnFlqM/QlGuJs6tVsBxuIRrLIWoiM+6yuNd74R0Fmcz0db1bdsy6f64pRf6EKRn 5qamxVPxEUtFZhPF+fxlmqzO+4lj5tl04TwO+TRNSyaeVDfN3QRlqIf8tUWqiNq8hKFK lluA== 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=ZO52+3gUhSpNLS6f70xrGmUVm4BW3DSUv0YYXPM2d3o=; b=RKNLZJOUi6+GZ2QU16Ofd6dcu2HcF/GZLoHfbmVcNRqIFg9H8NgWe7z/iDgKdnoTPJ f0cQEKj0CQtyKTz4bT+axq+hf1gPkQNPA/qlq9qgPdwF5Lf0IaomYqfPkXjr1x5ASQkI 4YCHMb1Pl5pV/fk2CQ88reIm0gPSmqrV9YphA68p9zQRUNEhDGnzbWzkG721F+Bhb5bU l9h0hhOP0NwqcMezP7kO65ZlDEozd5ZJjfAWYRQYJFgaJp/KADkcqBKMMNSMFIghqtWW Am1Kpob5cR/0cEXXhLmOkIqkIcn/LRpQXdkrx1en67T1Q37Baw4qwxaUTmCYts4jylwu g5SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="yvDII2/e"; 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 bd4-20020a656e04000000b00346ca43c280si8819998pgb.791.2022.03.11.13.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 13:02:36 -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="yvDII2/e"; 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 DC3B9E6DB6; Fri, 11 Mar 2022 12:48:43 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244052AbiCJOcn (ORCPT + 99 others); Thu, 10 Mar 2022 09:32:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243877AbiCJO15 (ORCPT ); Thu, 10 Mar 2022 09:27:57 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5E9CA0BD5; Thu, 10 Mar 2022 06:22:50 -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 dfw.source.kernel.org (Postfix) with ESMTPS id A467061CFB; Thu, 10 Mar 2022 14:22:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE4CEC36AE2; Thu, 10 Mar 2022 14:22:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646922170; bh=mFLGwyxL60zb3gvRg16qJDVO+v5CSOIO6jNpfVxbb6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yvDII2/e35E7jzBfM7X9W2i1BQP0Jhlgzc7EmKaT1JKrSNkRFu9dzI5wnekL8LFb2 cQUet264KYNL7ncmRakYS0F03qF3gYhCqcecyYj1zSBKkpwj5XCJ0Q/eKh43B+JDus vvcmpx9J6cmQ74G8uE4TJUQkc7VYDg5xzsSqjUaY= 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.19 26/33] xen/netfront: dont use gnttab_query_foreign_access() for mapped status Date: Thu, 10 Mar 2022 15:18:53 +0100 Message-Id: <20220310140808.513218261@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220310140807.749164737@linuxfoundation.org> References: <20220310140807.749164737@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 @@ -414,14 +414,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;