Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp60990pxf; Tue, 9 Mar 2021 23:53:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOuSEywnT5kzjvgwe0cUfv7lIt18TzaNchCN7cF/jBDkgnm98a10V0UTTvHu3YDPpPUikD X-Received: by 2002:a17:906:380c:: with SMTP id v12mr2248405ejc.65.1615362779854; Tue, 09 Mar 2021 23:52:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615362779; cv=none; d=google.com; s=arc-20160816; b=VRtgOu7yjpr1s7wYyVRPki1gPSBiQWsapEqTQWw8WCYlcuWzE0ZpUKnbhMSGsLvzuy ZqkamzALbDcGdL7HF4h1OU7E80xLG/A/lI1nVBp9R/ASRflHLzG7q5Hgyx+6ojpL7e4x Zkwf5+ZbY2vaJBvfg71n+qr93Q2/B8DiwPFaAmUpCHfItusdds0/VjiXXwOFcH+ddWSX f9OhiVk0iJUHL6uIiq2WGIN0OvrBsY7SbiOr4D5Vb4KgJ+yuaK3ebVvXhlmOVkVsqUUX snbYdMx6TjqkiaZP/XwgGiEp1A0SmnZuwho7sl7ABIjntMY+5bceT3K7VFha8U+c0pS4 HOgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=nAmWx2KEyvwzUF+YbYDbLiK4iBYOe+fdbgAgbi/9hWE=; b=Jxo/s5sVRNIRSkeH678+et3ey7qAKwobrr486kSLW69VlAzM3MAWJLX6e0Vqil0mbb Tsnf24Ppf/GbS4PcpJ5ljXESTpCTCngNWeE2Bh9ZpjtjmqxOqr7yjJggeJuN6C6YI3vn BTkniUo9Pwt9Q4DRF8MFIy4wEeiyjxkmOvYx9NS9sI3iTerXEnVIPzJMnq/KIqIfKqub BEAfzDZhrzm0pVrIfsWM65eOqu8Vil5qa9LqS1rNOwstJ7IvxQoz8O8LOjLO9vQ6lsqa u3JQn7QyMjJGmwZ0UfsOrg10zAtom7mE4un2b9ZrWjcJDWXROPs8odkkdYxkoN4j84B+ VZjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VrgHTnjd; 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 gx21si10573664ejc.503.2021.03.09.23.52.37; Tue, 09 Mar 2021 23:52:59 -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=VrgHTnjd; 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 S232339AbhCJHtn (ORCPT + 99 others); Wed, 10 Mar 2021 02:49:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232322AbhCJHt2 (ORCPT ); Wed, 10 Mar 2021 02:49:28 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5220EC061761 for ; Tue, 9 Mar 2021 23:49:28 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id z9so14717528iln.1 for ; Tue, 09 Mar 2021 23:49:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nAmWx2KEyvwzUF+YbYDbLiK4iBYOe+fdbgAgbi/9hWE=; b=VrgHTnjdvrVZlvdxmmz/j5XVfeKy0Uq3iIoz2z/Kqo+9+BNwu7ecP+Pd/BL4bT531t V52aW0QYL4yJgWdyAerRr6MbYRF4/oL0YUvHLsc+7qJy0oFRa3NyBZ7xvZlNFRg9MOOs coDHEaZ+BNE8k34GsADAQx8XVH1GRexyikeK4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nAmWx2KEyvwzUF+YbYDbLiK4iBYOe+fdbgAgbi/9hWE=; b=S0kjBcuvP5JKGEXoSpOiqK1Wcq6H0gGUJ1cky1d/6ECArH3Q/rLRES8izBuGZmfp0I grZuZCsFRJxzT8nLqA6vKBxLmORHma2LtCUZleMbu4lqeLVqBq6dqJN2aLFGo3UH+/Qx kXy5OxJnZKLk4Kkb2C3oqNSjjFPSOxsuiQ+J3jRzCVeLbgKfO2C99RCHW9QGBx7o5l6p R81OLm/yx+dU/lI3oE1A6IQ8yQ28bh/mLhoflWH8Y2AEvh52yFNRjJQxqqIb/jRtLmmZ B8S1fsC4zE8BXQp2Fb1Xtqy+MxiAFHn9jWxEAAfxPyi5mZuHRleZmF8+RW08aOR4d1HM eLFQ== X-Gm-Message-State: AOAM531Cg5cTcSJXieWEYbHRzvhR9EzwRFDwOZK1LJh16op8l5exV8pK n3CRArIMrfQfSVk3MEl3Blh/LVJWbQTUgRyC X-Received: by 2002:a92:444b:: with SMTP id a11mr1663948ilm.291.1615362567583; Tue, 09 Mar 2021 23:49:27 -0800 (PST) Received: from mail-il1-f169.google.com (mail-il1-f169.google.com. [209.85.166.169]) by smtp.gmail.com with ESMTPSA id n7sm8493029ili.79.2021.03.09.23.49.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Mar 2021 23:49:27 -0800 (PST) Received: by mail-il1-f169.google.com with SMTP id k2so14698559ili.4 for ; Tue, 09 Mar 2021 23:49:27 -0800 (PST) X-Received: by 2002:a05:6e02:1bca:: with SMTP id x10mr1633282ilv.71.1615362566563; Tue, 09 Mar 2021 23:49:26 -0800 (PST) MIME-Version: 1.0 References: <20210310074028.1042475-1-ribalda@chromium.org> <48e8ffd7-7f42-8e22-bf9d-646d9bd89bd9@suse.cz> In-Reply-To: <48e8ffd7-7f42-8e22-bf9d-646d9bd89bd9@suse.cz> From: Ricardo Ribalda Date: Wed, 10 Mar 2021 08:49:15 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] media: videobuf2: Fix integer overrun in vb2_mmap To: Jiri Slaby Cc: Tomasz Figa , Marek Szyprowski , Linux Media Mailing List , Linux Kernel Mailing List , Sergey Senozhatsky , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 10, 2021 at 8:47 AM Jiri Slaby wrote: > > On 10. 03. 21, 8:40, 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") > > 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); > > Hi, > > I fail to see how case from uint to uint helps -- IOW, did you mean ulong? Ups... my bad :( Let me send a v2 > > regards, > -- > js > suse labs -- Ricardo Ribalda