Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10752747ybi; Thu, 25 Jul 2019 04:44:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqz83bRZKvvxX2g0CImMcInNCg9tiwZDi39F/R63yncHMdcSmCnrW2FUDx1NIo9ipRD2xVTu X-Received: by 2002:a63:e20a:: with SMTP id q10mr84391014pgh.24.1564055078070; Thu, 25 Jul 2019 04:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564055078; cv=none; d=google.com; s=arc-20160816; b=rU5QXow1r8rB8fGAqG+nD64JskZbOwMOLJkLQwJHaTN4gmNSA0iQbFmlbyfHAGPfDw 5y9U3mP8Ny22taPcpszTc3+IPjX2fKHwx7pIonuyN1Pt1EEqs2pWhCuXsRx2arj1uo54 SRXC4NUJCtE5EjDauWQYyMfCfTOu26nptH9lh1A9yyJ6atRfSvLgKvyeiHIm1NE2PHEr MDqG+MN37DQYecm/3zmOoHlKsjTrDP++he5KWfEHLaK/YalF2MOw7bRDyKYbfjNUJFRT 46gq0jqxMaykHTawVenpl0OPQ2mS9veszxUa8vRvo4qyvBSupVk+9mHXQqp8Qi+twnqK C2rg== 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=ExmdOR0/8/73gKMXrVaZpEPRcY1pNwJdMRnT9VGUeW8=; b=Sh77JqjETCoOgnvFC8sQTIxOwU+omWAqX8FFtYRoV/r1GZBEZdZq4iVxAt0hhZ0AuA JLsHD4DiSwi1+xL7wi1rJVpUHPnVf8Zifk4u9xXfIExC9JI1Odz7nT0vAKFWZmKrXBpo BFw3n3ZpULi44T57Bcs513uQJcx7p5CiontbW4DZ8FvSCUjCZ+IVdd4Znksg8AGUyWuy 79Zp70pKhTabM8fz2UXAaO5OvXcFUsxeir1pzk7zilXJ+2LO+V10dyrf1DqCzHJU/ECO L5sBMmpL5eC42JRdpdy7loi8FLB/cleE+HsTBTeFOLtFuEmG0qr8j6L9FUttyPmBatQx ZOvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="y/A76aSm"; 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 l97si16393343pje.6.2019.07.25.04.44.20; Thu, 25 Jul 2019 04:44:38 -0700 (PDT) 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="y/A76aSm"; 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 S2391285AbfGYFo4 (ORCPT + 99 others); Thu, 25 Jul 2019 01:44:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:60198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389267AbfGYFoy (ORCPT ); Thu, 25 Jul 2019 01:44:54 -0400 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 98C0421880; Thu, 25 Jul 2019 05:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033494; bh=x5cBvB+ePUbEneL3+6RDnFsAOd6tOD2Z+cdqbyRCV1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y/A76aSmEf6vQoHOT3Mz0ISW/0CXLXH+/POUGgsh1McHfGOOs4Wnr9CZWiA4nDa9l s62ViNTpgZdvB0WZx5zbo4gKXGtpBK/oYym5NtWmbubi6/7eCTh6Ceb01nL4LJh+Bw 51z3nuS1rndMinZUIxlB6cmHfCQrvIjPsds8A6J8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sakari Ailus , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 4.19 211/271] media: videobuf2-core: Prevent size alignment wrapping buffer size to 0 Date: Wed, 24 Jul 2019 21:21:20 +0200 Message-Id: <20190724191713.170404340@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@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: Sakari Ailus commit defcdc5d89ced780fb45196d539d6570ec5b1ba5 upstream. PAGE_ALIGN() may wrap the buffer size around to 0. Prevent this by checking that the aligned value is not smaller than the unaligned one. Note on backporting to stable: the file used to be under drivers/media/v4l2-core, it was moved to the current location after 4.14. Signed-off-by: Sakari Ailus Cc: stable@vger.kernel.org Reviewed-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/common/videobuf2/videobuf2-core.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -207,6 +207,10 @@ static int __vb2_buf_mem_alloc(struct vb for (plane = 0; plane < vb->num_planes; ++plane) { unsigned long size = PAGE_ALIGN(vb->planes[plane].length); + /* Did it wrap around? */ + if (size < vb->planes[plane].length) + goto free; + mem_priv = call_ptr_memop(vb, alloc, q->alloc_devs[plane] ? : q->dev, q->dma_attrs, size, q->dma_dir, q->gfp_flags);