Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3920296pxj; Mon, 21 Jun 2021 09:23:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxC3rMA1/2P3YmzSnUPp/2DjttdMvHq7OHwAzA9FaIiyhpT/LD4AzKsOX96iASyFIwyyZwB X-Received: by 2002:a92:d448:: with SMTP id r8mr17273667ilm.109.1624292607473; Mon, 21 Jun 2021 09:23:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292607; cv=none; d=google.com; s=arc-20160816; b=dDxGmO5kZHfyLP1HYsJnG3eibYFjWaAbEmwgjcPtXBoBshuJ6/sDAVFTNI4iavHRIi uyXjrxWGj6t9ZTVzky96xzg294tbmgEuoVBEXNwdP1cSlcsAvF9L5TUywQvkFRf/9RTi hT8TeMeJSey0C0R/2d8J6VIA22PhOYBbznbrKyJY58BTU3p9flQEJke8QGc9b8nygzIX YNQ/NjtcKDR3L1EBed4LRQV8PH/+DoZMFLW1iP4FYvG+5W1ciyKu+GyT9HhcCtbODA+y ExC7TUUPRBi6VZE2rbRJi0T6B5B94T/xw+VHo7t8blNi0mdGyd0+CecgHc/eaP2Gblac c53g== 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=oMYD9pGSLFnwf+Ik3LkGCixpeOgNXMr7dP0ZRqbVo4Q=; b=i6V8l5tMXSd916o2QJCt0C0GobP+rPHHY1nuqTLxNwuDfAASvw5buciz8JTSFHexxs uchWFzDP9YnCjwIQWYNWTJ+nyrmgjgKIJZOr0z45J81XTsbS3cuI+rxy++AD7khYBJHo dlcsNtT9VpUP2voWvJ2QXDuc7xIKP/yXMzqSL6AfL0d7l2F+OmTAsUIWyYaz2lC68PrF vWjce1rqYp4fc17Neszubzk3PElbZDgDi88coR9WioU74e4kTFM8VZNHZkbihuosNv+Y n4ZZMCQReDKBY26lNtVZLguc4LDVsLcutJbH4CHVTcMcfaveTY41VVaqg1f8W1vnfnQ+ 7FqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="VJ/Y0X9x"; 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 a21si24701588jab.23.2021.06.21.09.23.15; Mon, 21 Jun 2021 09:23:27 -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="VJ/Y0X9x"; 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 S231512AbhFUQY1 (ORCPT + 99 others); Mon, 21 Jun 2021 12:24:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:42736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231461AbhFUQWw (ORCPT ); Mon, 21 Jun 2021 12:22:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9FEA561380; Mon, 21 Jun 2021 16:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292418; bh=sO6GshCURRShh06c22Br7xjKQjBKp8JCcmikypymkVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VJ/Y0X9xXieOqT2g+W+h6tkR8qMOM8tMp7JLbL6BkHv41a7dAyo149YWQgkbGKDW6 zEvu+N/7tDOVm9MqmR+1eF8KN/GlyEAUIHE7GBrWMjj9om9972XAbGk7Qk3ibSPZIq ERHF+Vogj4GtxhEJoxHHczq8lG1URDx7J2yn1IA8= 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.4 84/90] KVM: arm/arm64: Fix KVM_VGIC_V3_ADDR_TYPE_REDIST read Date: Mon, 21 Jun 2021 18:15:59 +0200 Message-Id: <20210621154906.999752006@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154904.159672728@linuxfoundation.org> References: <20210621154904.159672728@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 --- virt/kvm/arm/vgic/vgic-kvm-device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/virt/kvm/arm/vgic/vgic-kvm-device.c +++ b/virt/kvm/arm/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