Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1055687pxj; Fri, 4 Jun 2021 05:08:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa/wXhIchk5YfzjZLSJfPBPKrMI/D43X5TGRBmYzkEzaAj97F4KoXaooMz32qvOvNe1HMj X-Received: by 2002:a17:907:1117:: with SMTP id qu23mr3849233ejb.71.1622808512197; Fri, 04 Jun 2021 05:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622808512; cv=none; d=google.com; s=arc-20160816; b=cMCB6ISh1W1fhc/hFdmlf7t9LKX1LF+KN2D888zPsR9yoG+SfVuOVrDCdnnP347uzl D7ckpr/y66fXB9ny+8A7JGm4LUzrLyoqqz4YEwPnKJdpSkdtIPmWz2kRkuTRfmIThV3m z41fkZtpeh6DXQP3GGUs6AzUGTAhSSNuc3ZPzWBM9H4567tdgbsDhzrpNtDy20rkevFL /G5+D8MgAJgA0X5HSxDi1PQ4wZk3IJB6ljBkvXZ8a6CMoPEo2WSevLqdouwxCdFLOP8f Y5SuTivvHlYPSNzwnsHchT8EBcKLPCondOnrc8dV8qfoSBTwKoO9WHBBJtvx94ir/oWz mREg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QoSl/BIvVPZGOeDCr86CVcF0x26xO1jLabInCM7wFNY=; b=SBuxcmeTLwNF1AigFqKKWkkpsxNM4e0XFaF/EKskT1tKkZQoXAzGPK7Q3T3NwEsvUR Ilg58YhTMhoomxpwzy6Eufn6RDln0AcvvFV5m+pUa2/K4lYWhfwz1G5frSK0DDRDRv1g r+hw8/FEwDVN1SysC6a0FZmLrSwR/sLARKusugiroWTlvEqt+nQ+QKqmXno1Or4/R6qq Q2xjfZ47k7Wj+xHoC1qsZyclF4YKuHC/GXwFBwLkR0FQGdl1spuWc82VWZoo7Qx7NeSL 6Viuqu/QyJ6IcYB/xL54SZM/4DI1daWc9fxbXE7Cvy5Uh10HKDDAPR73/qyhBCjKrDu8 dLmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KZTdfWqR; 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 g4si4540217ejo.319.2021.06.04.05.08.06; Fri, 04 Jun 2021 05:08:32 -0700 (PDT) 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=KZTdfWqR; 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 S230289AbhFDMGf (ORCPT + 99 others); Fri, 4 Jun 2021 08:06:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229740AbhFDMGf (ORCPT ); Fri, 4 Jun 2021 08:06:35 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4854CC06174A for ; Fri, 4 Jun 2021 05:04:33 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id g6-20020a17090adac6b029015d1a9a6f1aso5032455pjx.1 for ; Fri, 04 Jun 2021 05:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=QoSl/BIvVPZGOeDCr86CVcF0x26xO1jLabInCM7wFNY=; b=KZTdfWqRcq02+8YDMhNT+EBDtYiqt16K26DYvoLBoxkw9kCC5CaTuMkZlPlBxmTtfb CjPcp6JI7zHcoAa0yAVfCZG+9gZkhpr3Vnqbrt3DR0EHz8ixR6cOFCTYL47b8gu37EiU 24gUF3sEIxF24mKW1vxb2CzMzQ+vlwraPqwO8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=QoSl/BIvVPZGOeDCr86CVcF0x26xO1jLabInCM7wFNY=; b=sGB6GxF8Fu3WPVUWxsQf1CSW3kWvgLa2fumg1oQ31SYf3DKpf9ASiLmBEUeH8sMPHk exveYLjRcFAy0GfUO0bLuXBW2Vofwm3QQltoTRC5E5iXdeGqi6p8aohF6xw6WnDT5ta4 Gg+qG6j+jxAHwJq1kcDpo1Gh1QgF/ZOPJB3blj43cIayp9JqZXrh1uiL9Cd6sidqKatM 34mFVRQ4hyMoJH16u0o1DIV/cdi9/QB5Osodld3a6aDkPbQlArj1sC2mmvoIEe/U0rev EsIfKBrV+b50jXmEc0eYhJZ4FkoMZQmP+c8o23RAo2dDR2grBnVUaHnH9J8yLvkBnnal +PkA== X-Gm-Message-State: AOAM530ljFJ7Ah3CkJeLzsM8SG/vW8houN/CZqf7h7d4jRGrxeeQQmXh WjyTpHqkwoy0cAbvF7j2euI7Tg== X-Received: by 2002:a17:90b:2250:: with SMTP id hk16mr16079413pjb.95.1622808272875; Fri, 04 Jun 2021 05:04:32 -0700 (PDT) Received: from chromium.org ([2401:fa00:8f:203:dbd1:4208:a05f:3593]) by smtp.gmail.com with ESMTPSA id u24sm1681564pfn.31.2021.06.04.05.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 05:04:32 -0700 (PDT) Date: Fri, 4 Jun 2021 21:04:29 +0900 From: Tomasz Figa To: Ricardo Ribalda Cc: Marek Szyprowski , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby , Sergey Senozhatsky , stable@vger.kernel.org Subject: Re: [PATCH v2] media: videobuf2: Fix integer overrun in vb2_mmap Message-ID: References: <20210310075127.1045556-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210310075127.1045556-1-ribalda@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 10, 2021 at 08:51:27AM +0100, Ricardo Ribalda wrote: > 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") > Reviewed-by: Sergey Senozhatsky > 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..89c8bacb94a7 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 long)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 > Acked-by: Tomasz Figa Best regards, Tomasz