Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp56111pxf; Tue, 9 Mar 2021 23:42:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbM1V4kkD349SOyb/InflPGVGdIkOoXMKT+ns1Ak8MdkYYPUZ0uwKSnqdmTLzmHjQAOatU X-Received: by 2002:a17:907:778d:: with SMTP id ky13mr2270192ejc.291.1615362132599; Tue, 09 Mar 2021 23:42:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615362132; cv=none; d=google.com; s=arc-20160816; b=PzWyYpFPrZyUwFBhhIwXs3dlpZrJRTJ3a/NLwrp4Gr9QhsLuup6wMQdKvZZwPYHmBQ 2HhdNU4+EDTSyU+QwjwoGupC5QrphPFd1dfQizQ2RpTIbFGfpEPqaMbz6YoRfExs/FaR ++6SWa9Du2BnANC9NGhW4e8Ue0FvnF2FIaTI31+diCHpSo5HQM6fVi86mpGXoLBObswl NCKsPUjWhdod90+b9TSBmoypCgitAr7SocgNEVWQnAc0UrZzgXPOoFbFQwi9Qbfb5tSW 2J8AsrJSMrzVQxxhF1qWonYCRu66IK/+a4kekN80RfxDKgTAYbfn7jHSsQYyv8wM8/7L ZvCg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=7htfKEWj4A1mHYbOJujhEP8fr6drS4OtZ91jlFV3ApY=; b=FffKTTHb1r+MoQht4Xd/fxG7OVXtWqDnCacvK765WS9eg+QFizL5h8irq1pc8W8yKe d05wz8q/N3UxuQ26rpUiega2PP6MpML8swAdqL4yGcdV10kFltGrOnJjLivVGfGPK83R /qPfzyansw6fGxdhDWs42lItqnyvlxVPmx9Uz2Q9WOx5yMMa8io0Q/4z90NbOsserNUw qbXfxLeczbt/rNOJ3aGCdCc3DyQnM0U2tNsIh8fq2tZLd49U+elmj9/onufv1nBcAFjw l+pFZz0A3r9TsinhM6bXeiR1dzBF7RJC4CPrIZ3gvPPrxdw/I61xZWnHSI3BqFmwWwKj /6RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lc1dhv1v; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x26si11334899ejj.525.2021.03.09.23.41.50; Tue, 09 Mar 2021 23:42:12 -0800 (PST) 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=@chromium.org header.s=google header.b=lc1dhv1v; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231815AbhCJHkp (ORCPT + 99 others); Wed, 10 Mar 2021 02:40:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229828AbhCJHkh (ORCPT ); Wed, 10 Mar 2021 02:40:37 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1A79C06174A for ; Tue, 9 Mar 2021 23:40:36 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id hs11so36553819ejc.1 for ; Tue, 09 Mar 2021 23:40:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7htfKEWj4A1mHYbOJujhEP8fr6drS4OtZ91jlFV3ApY=; b=lc1dhv1vlFR8xg17tISMV9ljgonYRYnKCI/dV2TYIoLjzvNOCNBnM2dcg6GR99RUV7 6olqwk9R6ELu+/8U7cxQSYQFhTp2YEHQ67u9v4N45SJR2Gr9705iihIiaWE1MY65yLEv 1kJgIT1Du4xtvS4SsKPll30rFeGxpvFFPkg4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7htfKEWj4A1mHYbOJujhEP8fr6drS4OtZ91jlFV3ApY=; b=VIdDpGEd3T/Cp33882eyGw/Ln8V8DYhWH9MFWan7ZBqNQg7u0iHEvSdlz+dm0m5TL/ AS8EmtIM8Egzfv5zRdsTtxR400pzpz/QXvX/zrIanojEt546/EbpWGSYGG9SRDCUuQac R+QR6UqAE4qF7EK4y9mSHtxFh5NMKPI9ZGHog5ZXFlpWljI48iKVIlbCfDhcVGWbMW3H LZoX+HArpQJyI8ubpgOCb5YOg5JdRoTjT2FUBzYTOMK9nibw/vC0BIQkPauJmSXTn+8d 0HyuO4bx057CpF+hoNiCcbh7HQu/JV5rCXMX2NTpeViWECkMptAmkS4N1oKfCkFnLNto 1WWw== X-Gm-Message-State: AOAM531TUUJY8tPJIxiYo2pmP8oIA53MMUFi+4JQ3rkl0SAmK7i1ln7B 39IJjZEDG1s96z7SJFhkCzbz8g== X-Received: by 2002:a17:906:cd05:: with SMTP id oz5mr2232468ejb.345.1615362029874; Tue, 09 Mar 2021 23:40:29 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id a12sm10253646edx.91.2021.03.09.23.40.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 23:40:29 -0800 (PST) From: Ricardo Ribalda To: Tomasz Figa , Marek Szyprowski , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda , Sergey Senozhatsky , stable@vger.kernel.org Subject: [PATCH] media: videobuf2: Fix integer overrun in vb2_mmap Date: Wed, 10 Mar 2021 08:40:28 +0100 Message-Id: <20210310074028.1042475-1-ribalda@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The plane_length is an unsigned integer. So, if we have a size of 0xffffffff bytes we incorrectly allocate 0 bytes instead of 1 << 32. Suggested-by: Sergey Senozhatsky Cc: stable@vger.kernel.org Fixes: 7f8414594e47 ("[media] media: videobuf2: fix the length check for mmap") Signed-off-by: Ricardo Ribalda --- drivers/media/common/videobuf2/videobuf2-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 543da515c761..876db5886867 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -2256,7 +2256,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) * The buffer length was page_aligned at __vb2_buf_mem_alloc(), * so, we need to do the same here. */ - length = PAGE_ALIGN(vb->planes[plane].length); + length = PAGE_ALIGN((unsigned int)vb->planes[plane].length); if (length < (vma->vm_end - vma->vm_start)) { dprintk(q, 1, "MMAP invalid, as it would overflow buffer length\n"); -- 2.30.1.766.gb4fecdf3b7-goog