Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10426770ybi; Wed, 24 Jul 2019 23:01:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqweVwfC2dJP7rUqAqfzR+KzTrXhTAP3ly/vRuAVRZWVI4SaQfWb/67n73b5zU84Pi6wLQxH X-Received: by 2002:a17:902:44e:: with SMTP id 72mr89296230ple.326.1564034504723; Wed, 24 Jul 2019 23:01:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034504; cv=none; d=google.com; s=arc-20160816; b=zRwISlcCm7hORjQRcNjf5jsYaop9CTH0nR/nN2bhZ+JFtb7lJh6lC58q7uSYl2yhbI N0kSmeiFxvNl/Im1XTd0SKXR+K2njbxOv6y+GDZ62LIX/6Vt3uMxcVC5byd1SWWZ9+xx 2gxIIZkuSlE7EUbua0UEtu84dExm5DnR6GImsKvSV4Kykm0laxmqhvAyUYGHuxkTlDhR ioqcaKtntAQEs3F/6Q06/ThKAck7uxAF0ByXON3WeYbTo94FYbPj5cT70NLV1L65Mhtq RTvxcsQOFOcUKKls4I/HYcLw2uy4WY/P0xBJM598fncYRLa8A6f0iqorXtmTh1++/m1v eWBQ== 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=L5/vkB+x6fxQ/unfAvP0CymoBklohj/RXVrC3jcVnLFprR22+rZHFHGw007L4q+oYu vBAjDhdoaYA1NerSySev2zjxHD/T/fT8PoUb1lFP/nTrA78b24aTAOc9pEbrYOWBMwLY 17URbb6DlDpN1yG55y6uFwd8mVGuzpyEsopvucxr7I/LsWYdTmXmms8LF/YvgOr0NVNE gvfOF+sZHP0TXHjM/3q2T7Pibw9NW/+a/UkOxrhHix+4WU4IOYtOFvl0bZ/c8Z4qHlCH m60SQ7BcKOmQRkY6+rXUZ7KlTKckp23Z53Fz5qzuSQd9G+h+aAuF9xxBygjBCCWjnoYi l1Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="wmBxkW/n"; 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 w10si18134419pfq.115.2019.07.24.23.01.30; Wed, 24 Jul 2019 23:01:44 -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="wmBxkW/n"; 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 S2405213AbfGYFpc (ORCPT + 99 others); Thu, 25 Jul 2019 01:45:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:60952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405187AbfGYFp3 (ORCPT ); Thu, 25 Jul 2019 01:45:29 -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 BA66022BEB; Thu, 25 Jul 2019 05:45:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033528; bh=90uT0hQzl2ry1AVARiOZO395TTaUxfa8Y/uH8XxG6uI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wmBxkW/n0ABkOnfTgu1ot+W5PhXsAli7xskcomXQXTLe7Lnoxqhx+XLaSkb+fBGAf PNAFMqSDVO2MNBRrvUi6RvBNHUFK9SmzArPGuHB0S5GNI2iMnOBZYIK9cx6D1MpqcQ drKZTdVg2LT7mQklUQlSDrP5j0M5yX5d5/cOCf2E= 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 212/271] media: videobuf2-dma-sg: Prevent size from overflowing Date: Wed, 24 Jul 2019 21:21:21 +0200 Message-Id: <20190724191713.256429890@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 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;