Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp349914pxp; Fri, 11 Mar 2022 05:38:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzu6vbOIg91lzhJZ2P0nmfeeBN08nPSXF06DvVJVtvL5SBMYTNMlFyRq0ytZg9+ooLSTc1C X-Received: by 2002:a17:907:6e1b:b0:6db:30f5:980c with SMTP id sd27-20020a1709076e1b00b006db30f5980cmr8294975ejc.359.1647005904337; Fri, 11 Mar 2022 05:38:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647005904; cv=none; d=google.com; s=arc-20160816; b=1E2/APJfNqJSffPgxU4gQoBrXuX3jQgOQyVVLCNb9R0zleriq5ZQu51dcnRnusAKOT LzCcNKxqVld3kW3fk2KXRX6mlCx1f/cyHgJF/mVwiTXdf9wYesbHWWwzIMNkXIiltQtt LeHf01sDnIY+CK4Vwju+9c4AsShkoZIIoQVdaqerIlUIKSnW4Lk127Egkch0/xhWgahl 6sgGIWNf7JTcwcz/HwDp4XD4A7wNNdBtckHynPmptgMjuD8KcOokUCn5B4iucsqKPPDN pUfXj5e99SuSkZG4WvCHJGDmcm2hFgcDqjfXfbH0QZab7kSpLZQOnJgAoCRaBWD8OLwW /CIg== 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=pNRH0a9V/aZmalwnkvHaacdj8RcW9mG5akS3OrsbAz6QhffedK3AsaLgpKc0xJETeh YsT8MAJfB+zVInKL6kSYeYQHw1tFZbpGkbCmpjUviDrjkN/3sLwqRY9KHmeN0oy4Pssp AyDzChnUlkhf+AqjdAJ8rtSuD0YxMp2A56cggTjCKXYhOLdPZU8ll7LbZLQLaM2alIY1 9aQJu1hvmtJkVQvkUXKPIqPo2GHZjuPCosZdi6i9kNslDCog2Q5/q25MbWviRUZXoEiy ZwAUl2IlrUgC9A/YrHs0ysw8SQrCKNCjt3xozGH3C9suCWGseZRH9A/0qwXOJ+xRK6n5 0fqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NyYIpXOD; 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 h8-20020a1709067cc800b006cdf87b1234si4838577ejp.341.2022.03.11.05.38.00; Fri, 11 Mar 2022 05:38:24 -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=NyYIpXOD; 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 S242095AbiCJO1S (ORCPT + 99 others); Thu, 10 Mar 2022 09:27:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243446AbiCJOXT (ORCPT ); Thu, 10 Mar 2022 09:23:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8C0BC0848; Thu, 10 Mar 2022 06:21:19 -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 F166861B1F; Thu, 10 Mar 2022 14:21:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1F9EC340F3; Thu, 10 Mar 2022 14:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646922068; bh=a//jtcByFiHXOCJ+/M4jiKQWdvoAGv/83F2/7HhgSnI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NyYIpXODMGCgB8IrRaQr0BmaGqjxx6PXsVLObvVw7npUvhLAzOLVGdXb9PRtFvple zkIgRJ4956kfGlpKeWPfE7UBlUZh17NCDhk7T0FGS37wLPHQbOHJhezUBEEEvQJghl yfwE7c5Up2PaX9SrFqv7+x9PlNzi3QNb+H1ZdW5s= 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.14 26/31] xen/scsifront: dont use gnttab_query_foreign_access() for mapped status Date: Thu, 10 Mar 2022 15:18:39 +0100 Message-Id: <20220310140808.303290685@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220310140807.524313448@linuxfoundation.org> References: <20220310140807.524313448@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);