Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4584627pxj; Wed, 12 May 2021 08:41:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDaQfW2eWP12rOiYKNccGHzwidIql7nHEPmTKQ77pt+t9FYMLguudxOQeOcEfKUoncSIIO X-Received: by 2002:aca:aa12:: with SMTP id t18mr3986810oie.141.1620834100949; Wed, 12 May 2021 08:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834100; cv=none; d=google.com; s=arc-20160816; b=UFQPdUI6P2dbVrWKwWrnKVdv/vZFzldqu0Z/DhWw23kBAoV6G41PYwHOO4YnsL/c/S tt4CeKwd5speCDJOhpuQlOBSHnEz7AYa15WxlV2ybkSlr2pBsKencLdYuPjhX2Z9Xim2 7jIFVWaCnClIcqjFYZ3mQRXxXffPRbBN36b+2HYF5amW8psGwSczfSoj66FjLg2LfbYe 93/VPIijaHgnY3zIOgx69emN8RO+/oSXznm18n8uCiz/aT0THB6Uy0dIW0WL3NgcGB4e LbwA5QMeaYKwmD/AxfgBVoG+/bJNYltFjIXATiqBA1Wl4Uo7k7o0iczk6U9EbFJpLoBX aLXA== 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=n/Gl5/zdhHhbLBZ3aXLf/iCrSFJNP7/bPah61oy5epE=; b=LPNNL7CpBp/h7kuAxyj/p+ZvBQSdkg8QsQ8TpiA8bSZdT4ubyPd5cFZabi+b4YyaoW OZkmB1ILnECGzl37R7GoBzdQnIE6AJjO+NGf61T+75a/RHQxWuiEZ3g9zPiLr/Bzovfu joWwhRzZuHJegQyAdw2zD/hvqnF7C0RXQgqhpWleI8y19BtZMfUhaIFK40by+m2LCtmJ grdkfF9/PcvxQmafba8Df68vekroS2RFjGPvzrkgwuZRrPxA2yzU5YMEdqsvWftWH97G RsQFJQ9xDDsALBxhaJy0oiByagomew6nzzImXRKMCNy7R+YDzAwqSGjDtGyRsA96yVNa yupw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=evQkdYUn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x13si271337oif.140.2021.05.12.08.41.27; Wed, 12 May 2021 08:41:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=evQkdYUn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236387AbhELPhu (ORCPT + 99 others); Wed, 12 May 2021 11:37:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:50484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234401AbhELPQr (ORCPT ); Wed, 12 May 2021 11:16:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A4226199F; Wed, 12 May 2021 15:06:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832001; bh=ggCQpBeM2JRKY7bpvBaPrhmFbtbPgeDzF/fRmH+Asxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=evQkdYUnvz/22wgd4I7pMf2ub2wDCJMFMa3kC9rgzvEbTp5IlcRos3AsGWMLimriS J905iXCw585X+70dTrEmC0o9WRfidl4h6uWKZvnQhsxZOKWfYhCs2SHBUBl3Xd8Xiu FVVxXd5bnQcPhH4cujFqwa4kHq8YJlxJavUI8L6k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Auger , Gavin Shan , Marc Zyngier , Stable@vger.kernel.org Subject: [PATCH 5.10 100/530] KVM: arm/arm64: Fix KVM_VGIC_V3_ADDR_TYPE_REDIST read Date: Wed, 12 May 2021 16:43:30 +0200 Message-Id: <20210512144823.087154304@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Auger commit 94ac0835391efc1a30feda6fc908913ec012951e upstream. When reading the base address of the a REDIST region through KVM_VGIC_V3_ADDR_TYPE_REDIST we expect the redistributor region list to be populated with a single element. However list_first_entry() expects the list to be non empty. Instead we should use list_first_entry_or_null which effectively returns NULL if the list is empty. Fixes: dbd9733ab674 ("KVM: arm/arm64: Replace the single rdist region by a list") Cc: # v4.18+ Signed-off-by: Eric Auger Reported-by: Gavin Shan Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20210412150034.29185-1-eric.auger@redhat.com Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/vgic/vgic-kvm-device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/arm64/kvm/vgic/vgic-kvm-device.c +++ b/arch/arm64/kvm/vgic/vgic-kvm-device.c @@ -87,8 +87,8 @@ int kvm_vgic_addr(struct kvm *kvm, unsig r = vgic_v3_set_redist_base(kvm, 0, *addr, 0); goto out; } - rdreg = list_first_entry(&vgic->rd_regions, - struct vgic_redist_region, list); + rdreg = list_first_entry_or_null(&vgic->rd_regions, + struct vgic_redist_region, list); if (!rdreg) addr_ptr = &undef_value; else