Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp174379pxp; Fri, 11 Mar 2022 01:48:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEHh13oYu3jXI4Ud/8kYcMrDuCpDGqBrdOGOR4udjxRFY1ltzboKY571m2TZPhY29W+sYe X-Received: by 2002:a17:907:d20:b0:6d7:1a45:c1ed with SMTP id gn32-20020a1709070d2000b006d71a45c1edmr7566007ejc.447.1646992098305; Fri, 11 Mar 2022 01:48:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646992098; cv=none; d=google.com; s=arc-20160816; b=ZpYPcGInZb2QM8USOflJWWE+N0Ca9WlRnceOjssDxoSPbb/Zrj4B/jMIuE8P20DLKT Je8f/Ke9pTtIkJM/yVMEV0wx8jSgiX4njb3i1QWMu3W4mE9ENKiUob5RMI/X2Ve9AAyu cOgmbZXonjx+uCeKbqGtDz3CRQaSIN6FJ15120CETEbSzAib4O3OjW3V297VPV65VQ4M U0G5Uo71rTUHYx1Zje6UvgMAHewlzwjHOd3kH6Do4wr8Lgsw01Vpyq+OiNrbsSb19E1k XRAsmKSyW+SMRkcjKnqhY1VTwmLBpCegpDxyy0/yTmfWHmgdYjbqMZU5hoa8iViAmyn8 kRfQ== 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=DNzIJldxyE5cr06m7ueNF55/8JzxtIOwsV+1ZjFWSjE=; b=WFVEYUyDKvbLR5g2NTC3KlL+Lj8s70aaRD3WM2fkAgQL35O1bcpKn/KQ3tSOOEA/1G uu9Tt7DZXlASgr7zJ/E7n6rntmrucI2bKyvEYe2SQqULFS32rQvmX045gDUzQHadfJ3/ ztXXrKx5S7Qu207Kfov6bJXoYl6F2MN9O/sbpHtVztvV0XY/N5Hh07KLq2g+DeU4QuFj Ioe2ozRttbasK/0yU2wBXuZsVscXjCFJweOl0iyqKMd6CyXmp4jb3xfmpo4q2ZGV71D9 pkBgJ49Tkv4LFC4ieo7GltDsgne7KbfoPzMxHeGJbdLljnmiajKAJLwmv6V8qQVD9gDR SxVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fFdXDkBA; 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 gt2-20020a170906f20200b006d16ffe1860si4381703ejb.718.2022.03.11.01.47.54; Fri, 11 Mar 2022 01:48:18 -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=fFdXDkBA; 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 S243194AbiCJOQT (ORCPT + 99 others); Thu, 10 Mar 2022 09:16:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243184AbiCJOPS (ORCPT ); Thu, 10 Mar 2022 09:15:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D480634C; Thu, 10 Mar 2022 06:12:27 -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 D8AED61B63; Thu, 10 Mar 2022 14:12:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDED7C340EB; Thu, 10 Mar 2022 14:12:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646921546; bh=a//jtcByFiHXOCJ+/M4jiKQWdvoAGv/83F2/7HhgSnI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fFdXDkBAlOrbcz1E0nO3nbCb/C0Ke8y99PPLyWqNZN9bY22RMjp4WsoRxSrUkTrEh tQ4ModFhzrdFGDTT5jjfj352GA2xZX7W2+qJhKYHUyKoSVFSmrWXvA1LMRnI7o0Z/u BdVZLmYdY6kfQArSTFCXlnDZFTBWoeTYbyPn4lP4= 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 46/53] xen/scsifront: dont use gnttab_query_foreign_access() for mapped status Date: Thu, 10 Mar 2022 15:09:51 +0100 Message-Id: <20220310140813.160215464@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 33172ab50a53578a95691310f49567c9266968b0 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_try_end_foreign_access() and check the success of that operation instead. This is CVE-2022-23038 / 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/scsi/xen-scsifront.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -233,12 +233,11 @@ static void scsifront_gnttab_done(struct return; for (i = 0; i < shadow->nr_grants; i++) { - if (unlikely(gnttab_query_foreign_access(shadow->gref[i]))) { + if (unlikely(!gnttab_try_end_foreign_access(shadow->gref[i]))) { shost_printk(KERN_ALERT, info->host, KBUILD_MODNAME "grant still in use by backend\n"); BUG(); } - gnttab_end_foreign_access(shadow->gref[i], 0, 0UL); } kfree(shadow->sg);