Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1621089ybv; Fri, 21 Feb 2020 00:26:46 -0800 (PST) X-Google-Smtp-Source: APXvYqzFrkFcrSMFbNZxq2s55YowHr5cIsA+EhDYABclo0xBBJOmvQoZAvcz4t2kKUst2nSrhwY8 X-Received: by 2002:aca:f242:: with SMTP id q63mr1060744oih.72.1582273606161; Fri, 21 Feb 2020 00:26:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273606; cv=none; d=google.com; s=arc-20160816; b=bGA+ewh3B/tE1HPnDGMwj5yvBhM1NAN+iI4LePt/yWmj2GJm8SGys4iz0KlFgEXxrX l5Y3ydrFeNnBLJ0LH4M0Z7gGE7igAcQRl2AJ0C1W1P2BPzSM+50zEZnwN8TMfGLvUS77 E+/HTMAYtQQ8T0Z8g/Mlg/1+GoRso4T8UmPQDwc1YdYSPS2xq1ajr2NwuEjBrVJJ50wM ptXJzyNOUvgy8vV8FMrLT+bKLzjE91EmGbBukq+Mo7jzc4wU//HUGroa+GtBIO6/Gq6e yCBAb82JTuXXtKXOq+NNZwREuaBSu5AxXk6vCnP1x9QeKEZzxUupFIiQvklzgL0vH7Nh f9ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vXDMtdTMOqTuzf0ZOQXAPSXOOglwvuQohOxN6UNxRPM=; b=vxWxn0oSVR9TxdQlk0AgtxOOkfvTmVmvWbpoUPg6G0J8L7TKyfRZ9UshtmB0qJ93wb 5TsPysPsnRU20i3SazxxX53kRHPFV5tNa6pBhc3AW4Nn+Ww4nzSUnUbORTAMnRe/+FD7 Vn47eWePNKIibmlGNSz7xiHARI5umZiIUWi+X/LeJqfco44uFv/knMJwZfoqxjTzdiFU I5TAG1eITkgWzE2R0GZP26r8gneorjBP2CerQa+OGalBZmV60EwKyjKv90mGrttOUQyO lgaSqaigFQG0unf3s5DQEyfowfM9rphMs+QBIJPMeXki6/VSnGmJwgpOND+4lNSlIUF1 jJsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f4md70kg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16si1127023otk.193.2020.02.21.00.26.34; Fri, 21 Feb 2020 00:26:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f4md70kg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388717AbgBUIYz (ORCPT + 99 others); Fri, 21 Feb 2020 03:24:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:37398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388690AbgBUIYs (ORCPT ); Fri, 21 Feb 2020 03:24:48 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA655246A6; Fri, 21 Feb 2020 08:24:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273487; bh=QkWuP5eAMNL26mHFDAU6zKXyBGmWQWkMnXy5SCg3/fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4md70kgKOdFzC2lwL4TMVqXQRN2t/l5myUXP7DOetlCPV40GfWJhpCyQGS6GWoE7 dNyWbv33Ns140KrZURJIS9WtVFNK8DMZPXq4ycvHXTjj1M0y3lMBvlyGyWPorjt4t6 utE2OKPI+xGcPgVcoEQn4vb82zcMpNgiBuvQvYkY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Michael S. Tsirkin" , David Hildenbrand , Sasha Levin Subject: [PATCH 4.19 189/191] virtio_balloon: prevent pfn array overflow Date: Fri, 21 Feb 2020 08:42:42 +0100 Message-Id: <20200221072313.478061333@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael S. Tsirkin [ Upstream commit 6e9826e77249355c09db6ba41cd3f84e89f4b614 ] Make sure, at build time, that pfn array is big enough to hold a single page. It happens to be true since the PAGE_SHIFT value at the moment is 20, which is 1M - exactly 256 4K balloon pages. Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand Signed-off-by: Sasha Levin --- drivers/virtio/virtio_balloon.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 14ac36ca8fbd3..1afcbef397ab7 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -126,6 +126,8 @@ static void set_page_pfns(struct virtio_balloon *vb, { unsigned int i; + BUILD_BUG_ON(VIRTIO_BALLOON_PAGES_PER_PAGE > VIRTIO_BALLOON_ARRAY_PFNS_MAX); + /* * Set balloon pfns pointing at this page. * Note that the first pfn points at start of the page. -- 2.20.1