Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp137179pxa; Fri, 21 Aug 2020 03:27:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4tSGMelq6+I4EZ1NRA10CrPPkUQjolusd1GREa6cDAs0n6WEW0j+O9S4mrEgAIYWwZ/HX X-Received: by 2002:a17:906:f847:: with SMTP id ks7mr2360623ejb.402.1598005643125; Fri, 21 Aug 2020 03:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598005643; cv=none; d=google.com; s=arc-20160816; b=hLTKEuxWVvrmWkw/8uN7W5n6t3NLTcgvc/OzWhnmMexmkRWUxFNpKxvbbpPgoUI0+6 Z2FC/XVb0YsQeCDFU7qo8o8uWDriFvQHzlV1a7omeUhJlOuVgcKWL51LXnjbenI9qgDU HfVrhoUzZsiGIyuwa7RJXTPjnWKihTrawcEX51tGvoK7gvLVC4p35eNRbMl+yQSbw3QX kEuVmkUlLNKDyhHe6zREgWxdvH9hyFm+naB40+SDso1HZXHfY0tWnxTA25TT+17BA/Bp AkIJnvzETEJE6nrdRLE+vY65GP8zsmnv0/rq+CUh/wV3jAYxB/Z+qQ4Y1vaxKyY1z/8X ScVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=EDYP1Th9SUcoctkxgo3VQaPnbnmkI7OqEYMxoTvtHN0=; b=0G1v8Cm5CbEtU0ib/oteVZWgaCz35/fBjdNksY+U1BsDvWn03Y7qCxQ3xPdiKoGb3J lp8QMFOUnquvuZVeE++uOodknwBfUkSobsq4Envu6Y0aiTw6NrJoeb0oeUs1yMFuL5ID 2KpBWZ4P2O7MeZYXksnda5A5MOWGAaYi9SHYrS2oOB12ZG3IXRVcGOimbsvS6VSrRq1g fmscMmjcy9m7woZDPLoK80ZZy9zPY4ICQFKsxBMi6LkLpJHtxnlq22VMV3wXRoO3xqwi oALkiMe4rf7MOVgCYj8i5AWVZ2mWKL7EBFq1++SVL5KvXzRHNHqzpQq91hLxh+N3ErWB lCUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tZUcqQk4; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f26si546280edj.290.2020.08.21.03.27.00; Fri, 21 Aug 2020 03:27:23 -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=@gmail.com header.s=20161025 header.b=tZUcqQk4; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728602AbgHUK0Z (ORCPT + 99 others); Fri, 21 Aug 2020 06:26:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728442AbgHUK0Y (ORCPT ); Fri, 21 Aug 2020 06:26:24 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA8FFC061385; Fri, 21 Aug 2020 03:26:24 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id g15so682940plj.6; Fri, 21 Aug 2020 03:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=EDYP1Th9SUcoctkxgo3VQaPnbnmkI7OqEYMxoTvtHN0=; b=tZUcqQk4OxfAKx4yXlUjLq+S42J/dpi6hvKmcCzI7IOMFgXO22q8ZpOubAhZVhTkWT aSQmB1e0K2G2oiTgh0Jvi76L758pJSsbReHvXNc7DWEnXicLnC/wYxrJRkb1Z73wXQ2a vtnv+OsXzqtK3iUEduj5O+B1sA6VgK8M3/U4QvtO37i8XbtUzYVQKweCEFkQpPfDCosT vOpOpxUE8hwCgsOoFilXxhA7Ou47ncykW0t4gif9aGMl9TnGYIKCguP681X0e5iAbae9 w68BzZm9t69S75hyC++oITJJAH952IURlQQ4wntJnTU1m1mj2qGH7nV4TBx6IYlkInP4 viOw== 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=EDYP1Th9SUcoctkxgo3VQaPnbnmkI7OqEYMxoTvtHN0=; b=IlLRmQZ5DMACqetqhpiXJcE7NScJMlScI+D/UaibjHxJkoyKmYT2yk1mG6ElyahGGp e9uYq5lI4JSeeySFpii/lXBDSQ27zNhuPiwUX/mUTu9908KbBohZ/p+B2QXl9ij0Gb1I G2ESguzGi5uWbu73avVroXFWdtgJ7L8b2Eg8sBub7T3wNPoBcCHBeGksTNrGI6bkTJmL q08UToUXHohaIZdnf66CU1DCRw58omz6a8TgL72Po0hKaOZDUeTriPTHw7J2qCaREd5H DLlX7voKKwpDx036X8Gt6lOukjK2j5PEd3Yzub4UdyzlpWzQD1GQ4DjywLKJG0KxVtkc gG5g== X-Gm-Message-State: AOAM533tdLD74I1az2olbPgzok9ipIjaEsA3h0kqZepeKq3Gx+G0ZOot 3Q7DoWgu4nmywOvs+0qcqw== X-Received: by 2002:a17:902:a412:: with SMTP id p18mr1756333plq.283.1598005584196; Fri, 21 Aug 2020 03:26:24 -0700 (PDT) Received: from PWN ([2600:3c01::f03c:91ff:fe6e:64cd]) by smtp.gmail.com with ESMTPSA id v11sm1634230pgs.22.2020.08.21.03.26.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 03:26:23 -0700 (PDT) Date: Fri, 21 Aug 2020 06:26:14 -0400 From: Peilin Ye To: Hans Verkuil Cc: Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: [Linux-kernel-mentees] [PATCH] v4l2-tpg: Fix global-out-of-bounds read in precalculate_color() Message-ID: <20200821102614.GA490417@PWN> References: <20200810050532.640075-1-yepeilin.cs@gmail.com> <774bcf2d-c8eb-086a-3569-c7e530d8a63d@xs4all.nl> <20200821094813.GB480216@PWN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 21, 2020 at 12:12:28PM +0200, Hans Verkuil wrote: > Arrgh! I know what this is. /dev/video6 corresponds to the Metadata output > device of vivid, and that metadata format sets brightness, contrast, > saturation and hue: > > struct vivid_meta_out_buf { > u16 brightness; > u16 contrast; > u16 saturation; > s16 hue; > }; > > vivid_meta_out_process() calls tpg_s_* functions to set these values. But > this is wrong, it should set the corresponding V4L2 controls instead since > calling these tpg_s_* functions bypasses all range checks. It also will > not update the controls themselves, so they are out-of-sync with the actual > values. I.e. the test pattern generator uses different values compared to > the values in the controls. > > So two patches are needed: > > 1) a patch for include/media/tpg/v4l2-tpg.h where tpg_s_hue will clamp the > hue value to the valid range. This to prevent anyone else from setting invalid > hue values in the tpg. > > 2) a patch for drivers/media/test-drivers/vivid/vivid-meta-out.c where, > instead of calling the tpg_s_* functions in vivid_meta_out_process(), it > calls instead: > > v4l2_ctrl_s_ctrl(dev->brightness, meta->brightness); > v4l2_ctrl_s_ctrl(dev->contrast, meta->contrast); > etc. > > Do patch 2 first and test with syzkaller to check that by going through the > controls this issue is resolved. Since with that approach the tpg should > always get valid hue values. Ah, now it all makes sense! Thank you! I will do them now. Peilin