Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9980156ybi; Wed, 24 Jul 2019 13:27:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuOmt/ulB5v+Gj69GJIF4q+GkTN40cw2Sleg7yDG8RmbKTd7YRHgglkMiwaEMv0+SqG+Z6 X-Received: by 2002:a17:902:7488:: with SMTP id h8mr12799353pll.168.1564000062946; Wed, 24 Jul 2019 13:27:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000062; cv=none; d=google.com; s=arc-20160816; b=TE1FGvu0noR6+20CkCaTczJW59cw5FpCsvpTqOOZMJ42Rk4skry30xduvuJujEffMI mfD9szuE8lQl0X0AnVGCXow0V6OENgLQfpqa+zUEXVhgbrHeAedgcbShsFjh7mQHtpC6 otVRDJUsCoktoYNkUHNJ5aBIh3C1ZE5gAymXdJQrdT4aQ8vn2nlR9Qxo/krWlYz0FzK4 hi68RegDgfHs4I2wJpciQPJzqijihxFmlgsNaKyQYykV/etyx3Dk+PRjlBRRMarEppVU XUJRd5c88eKaaMDhuDl6uJ2r6esBATbIZzEwZmVs8k/J+JPdZ6/YfTBwQT5cJEGyOZN6 tDBw== 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=Z+2+fFw6SdzEd8L7fVKf//QOuKN9IqjQMuXAWItY7Kg=; b=K3R1PFvUECP0yg0FgfkzYNIbNu94p85q+M5VVvlcKy59CAC8tzjArtm7amp/W5rvFE f5amJ2S7aFAtAWhQx2Qem7Z0CRqsbUPCa7Y0zvOq9L2pDeNb84Zcxyyx6iC18K2C0yHO fRuwQ/aog2GOep8CGAX+xqSTKB1capY/DKc24cuNUQS6JKYvANLFLiHSCo35dWcHrASx Om2K/7d1y5FAS6ohNcDmlYdeVSZdJG1K9zjPHUPAXLvOa9JkcIhMdwRMIV4cILcyr0U2 jtXDCreE8CaehzNhEif9/RYdfsD1NxZNFD3SaYV4Vov72qHb8gn4Ll9+Df5/ZpPwW5bE l5eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wiokfxlZ; 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 c76si15545285pfb.208.2019.07.24.13.27.28; Wed, 24 Jul 2019 13:27:42 -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=wiokfxlZ; 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 S2389656AbfGXTij (ORCPT + 99 others); Wed, 24 Jul 2019 15:38:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:39306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389786AbfGXTig (ORCPT ); Wed, 24 Jul 2019 15:38:36 -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 1A560214AF; Wed, 24 Jul 2019 19:38:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997115; bh=90uT0hQzl2ry1AVARiOZO395TTaUxfa8Y/uH8XxG6uI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wiokfxlZO0Fej6KELXuICW9XjxaY2+59ySFgv8iXIbRTkTNvF6PCkaOv083d4jUr7 QGHyM9MibMlljWgDqIgerGUydpUAzMqbKKCMLmOHKqC2jxO28C1M1d1JXzTcaI/sL3 5aHQyYwnj9pzruuyV1L1J35wnNgfhvi3RaunionM= 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 5.2 325/413] media: videobuf2-dma-sg: Prevent size from overflowing Date: Wed, 24 Jul 2019 21:20:16 +0200 Message-Id: <20190724191759.125108615@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 14f28f5cea9e3998442de87846d1907a531b6748 upstream. buf->size is an unsigned long; casting that to int will lead to an overflow if buf->size exceeds INT_MAX. Fix this by changing the type to unsigned long instead. This is possible as the buf->size is always aligned to PAGE_SIZE, and therefore the size will never have values lesser than 0. 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-dma-sg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c @@ -59,7 +59,7 @@ static int vb2_dma_sg_alloc_compacted(st gfp_t gfp_flags) { unsigned int last_page = 0; - int size = buf->size; + unsigned long size = buf->size; while (size > 0) { struct page *pages;