Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2030072pxp; Thu, 10 Mar 2022 17:57:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLCcLC1cmihTz3eQYoqaMM4jG4ORmfb5YwXR0y1M96ms05oQh8Jv7CMKLzpHMwYhmGirWW X-Received: by 2002:a17:903:22c5:b0:151:f12c:da59 with SMTP id y5-20020a17090322c500b00151f12cda59mr8031748plg.115.1646963852098; Thu, 10 Mar 2022 17:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646963852; cv=none; d=google.com; s=arc-20160816; b=p1OwT9wNeY2EuuxZiUAdoz8215XRx6Ze5X7DUtP+6ZKLq+kq7+/HT8Hd+/413aqYN/ Qc2uovlhlQQlA2qfcQNLChy9IuS1Wtz8Hm26IhczkqPTMNBDHl5Q6TEp9971syw0uuKp XCowP19nrgOQ/8KD2+GERuGQCR0NfNdoIU5KYSWE8yyg8jtPQUzxQ2rVbrm1dszjQi+y fMOAhGftqOtyp9TF+nLgTTEnAi96miOnA6Eb3Z+ZpUHpFY4wY04DbEdWrrElHVm4MNbL eZ9HPXTOnK+p7RpC3QSH9HdW5k5iYqMPylRzgxYL8EIFFexPEqDwpcUOgTz5LWOIqHrn l1iA== 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=7C3ONbW+IHCsy57aJ+P7t5PGC962pINJsh69wU9sBhA=; b=f0K16QzosQsDI9tcc1AYYyeK3KsQmQ/9VQOuM3k1s7lonpTYYJ7uWgWqgekq1Xoasx AIiEvTPREiBCkXR7iUhNMs4z9nQAUeaRNsxiDzGt173nqHraAempzXSRuQDZh7NFy8Xv IYy3lW2TOXN4HrCfRzv1MScQ97HZzOluaY8y731bhHtcpAbrAo2Xl4WNkezBuO1+Nk/+ UKr6HHzn0BCxBLA2CWxDxsiQQn0IgU06R/Pb4vd6cl9Q9bzR0Q51lnKIFBoT6ZCO28os GY5t7d/uQRYNqA3HxZMS/jPy+WsE884Pvg1u8ek4cHhe47clVHNja4Afnshiw7YMC/CV GiPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kJ9W5+bn; 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 b8-20020a056a00114800b004f3faea4748si6545697pfm.33.2022.03.10.17.57.14; Thu, 10 Mar 2022 17:57:32 -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=kJ9W5+bn; 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 S243706AbiCJOZN (ORCPT + 99 others); Thu, 10 Mar 2022 09:25:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244620AbiCJOTo (ORCPT ); Thu, 10 Mar 2022 09:19:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 754E517775B; Thu, 10 Mar 2022 06:16:38 -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 D2474B825A7; Thu, 10 Mar 2022 14:15:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E3C3C340E8; Thu, 10 Mar 2022 14:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646921727; bh=xEM7bM1MS3ZnvwOhutZQEBGhLFXWiu3krUw3+5mpfAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kJ9W5+bn0p7yck8GMsz0pgg1KWz1zylVgFPVP3nQDw1XZMvRpJyB+wdRHcidjlRcE BRzSQCkKblQ1GYrwlXJHuuJkuDKrbB3loZqZhYm34Nx5bqtAtgV4HyH6oWwQK6Wh3d n8sGWz9QJTqTMA0txgf8eUW0Ffp1YceujFIo3UdM= 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 34/38] xen/scsifront: dont use gnttab_query_foreign_access() for mapped status Date: Thu, 10 Mar 2022 15:13:47 +0100 Message-Id: <20220310140809.129519975@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=-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 @@ -210,12 +210,11 @@ static void scsifront_gnttab_done(struct return; for (i = 0; i < s->nr_grants; i++) { - if (unlikely(gnttab_query_foreign_access(s->gref[i]) != 0)) { + if (unlikely(!gnttab_try_end_foreign_access(s->gref[i]))) { shost_printk(KERN_ALERT, info->host, KBUILD_MODNAME "grant still in use by backend\n"); BUG(); } - gnttab_end_foreign_access(s->gref[i], 0, 0UL); } kfree(s->sg);