Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp120920pxp; Fri, 11 Mar 2022 00:19:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyJX0kRibTHm1WqluNheowtjWjs163Yrf5Um9pE431N6BPbqoxiXogS1ZmQ6GDQYM+GgP7 X-Received: by 2002:a17:903:234d:b0:151:bff9:9217 with SMTP id c13-20020a170903234d00b00151bff99217mr9054148plh.39.1646986790398; Fri, 11 Mar 2022 00:19:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646986790; cv=none; d=google.com; s=arc-20160816; b=QNMySpjkrb+oKKQwYsT4xqTwHhdssTAWqNLVqEd0/P9TN+EHBY+FuuCaeXs4wb9Fn6 DCB4e4A/Y4PfeLLv+sP4xHyLqAThMB5t/ZXavJjRDnGRgd9oUEJjg0FlYF+eBS2OLgEg AgsMspr0GG9SeoVVGVyDxRZR7BsKk5VAh9nUTXiLUI2CbdHzqltKMPVvDq9PIzxEvDb4 /DoYlIl/Jp8gvNxYIiHjoZf2Tz2X26P2pTvh5qgY6yCmjCr5mOMPTVgkdbjUJD2dKK9H ZwVeNOJRw3lnNIFi7yH7t4UsUfwqTzV3XPzJUe1TAFF0hABmMZojC4L0fiPNj8958iEi QUaQ== 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=VAb5rV2omd4Mlz8GZDPBSuG+KUsCLnQPyDxq1Ex7Gzg=; b=0cJoG1eDiNIlhCxpJjxasBzf1NlX9dZnkDgJui5yQgUgLUf985hnTRgh6H1O8xD8r0 YFj1unxeAGFpNr/8TkVmqlJ/uEML7RjH8Y2+G9qLGl/LIGMpKFQfP10T7f5wdrJw2jww +qDwZhd5HoCXc5PmGBb/aaWHoTLSAQ1AAgWmwlUvNwcTHj46nY7gbF2ibEr5u1QjI3De 4n6t2uj9WCck1E5rWQk51qX37HZC2SewIebt2C9ZWjt0qJfckA0iylgzIo5nrO/cW2eu t/YGK+Mu3MpLQpc346ko+5Qoc0dxxJIMN12FHKP0dOPndFhOGQoqOHVJr0sSOuVuXt2c lGZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="sVZK/4W9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c10-20020a63ea0a000000b00378b203eb09si7129013pgi.586.2022.03.11.00.19.35; Fri, 11 Mar 2022 00:19:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="sVZK/4W9"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243237AbiCJOQK (ORCPT + 99 others); Thu, 10 Mar 2022 09:16:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243115AbiCJOPO (ORCPT ); Thu, 10 Mar 2022 09:15:14 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 709BA158E80; Thu, 10 Mar 2022 06:12:23 -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 F1A9A61C0D; Thu, 10 Mar 2022 14:12:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B490C340F4; Thu, 10 Mar 2022 14:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646921542; bh=CDNfl4IGoyFCsE3oBTqgf51g83179xk1H8jlgFCafWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sVZK/4W9Tzf1C9yquZ9j5FDzN7Rn4l5ULoZlSiCv2QHgJ9ckE5v8oTzlu+IT6aalh CmFLx2ChdwFjKw38LqT47zpfRAoGGSxSgWKSK7FbOeyZqAMGDtHITJKvyrWsMp8qi5 8AKVJQJLS1ldYgnc51CqSqD3eynrI7tMOiWpIjv8= 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 5.16 45/53] xen/netfront: dont use gnttab_query_foreign_access() for mapped status Date: Thu, 10 Mar 2022 15:09:50 +0100 Message-Id: <20220310140813.131056734@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220310140811.832630727@linuxfoundation.org> References: <20220310140811.832630727@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=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 @@ -424,14 +424,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;