Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4050897pxa; Sun, 9 Aug 2020 22:09:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTXOP/+quEB+UEX8xBuscSfYCFl11OW9tcsAaWW2Rp2bHjoS222k1C4aFgKcOECfO535wD X-Received: by 2002:a17:906:5902:: with SMTP id h2mr21215239ejq.423.1597036194169; Sun, 09 Aug 2020 22:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597036194; cv=none; d=google.com; s=arc-20160816; b=HYvVnpvcYlhHNaco2lD+ZWBf8U6qdzyH9KE03ylkjrp0kY/Or3u9ed/QK5QpSNBpZx ANtkjiYt0WXwtrD46dl+FsWFqNbYyiNXpm0OHN5J+B8rflJmxkiw9iPq5ZGZUW/m4E9C ZUzV1Inzm5wB5wjxvOdmglzjHtNJJydITIytMtLg4zmD54dEAQbsCdgcJasG/8F2zzNA 0onuOL4j0PZbsJMGPkLfTqzP83P/m0vh3iKKhLtFof1i0dvhxvEDeNiKa0MpDadwDBF7 ow03ukDepQ8GEyGkcXPN7i7xjjDuBQS7Hr9HPEKUsvYj4jk3/wCbplh/dcnyWbSVe7ah gl3Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=aPHXTL52nZ8TnYruo+TUHBbc33RfRH/y9aR6NOzaRVo=; b=AC7Mx7ISeHmT68jk/+ampXrO/Ar3ZOETIubumSOrrbKU9XsOhPdbgNUrRr92rAoI2T rgD/G1sb1otEcaa/Gs228HpzoWMd+oDLU2jhHP7MYiCylOfA1gxWAMIilhDlb2JSzqhZ LCdegrSVObxdUy0hW4qPuAqOjHW0aI0yUX5JBXMNxEWgoe+QTnejwpAyGs8VmftlK3kl /wGwX8QtTs2hAKPFrsruO1vl2M0UmTcXEQbwVJLsWZaJl48ccIo+YUlKWCu2cZpJF6ih dpD95/IqhflqVmO/GKINZYt0xKbKo8CIas7oSrVE5JVCXApXYeSr7BlESD+l9GZCKmhg GoyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UxHPO6Ru; 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 mf10si9834813ejb.611.2020.08.09.22.09.30; Sun, 09 Aug 2020 22:09:54 -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=UxHPO6Ru; 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 S1725858AbgHJFHu (ORCPT + 99 others); Mon, 10 Aug 2020 01:07:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbgHJFHu (ORCPT ); Mon, 10 Aug 2020 01:07:50 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBA71C061756; Sun, 9 Aug 2020 22:07:49 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id c12so5891897qtn.9; Sun, 09 Aug 2020 22:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aPHXTL52nZ8TnYruo+TUHBbc33RfRH/y9aR6NOzaRVo=; b=UxHPO6Ru8IFAHFgMeMWp54jGqzTiCihLYmV0zJhgBUaAyfmPsEx2LJAwXw2fLA0KG5 D6OBIvkJn0g+qtixsVSWnsCjzrD17UtQ2vDuWxkusNN8VNYdgH97X2zs0vSgRxY+vWw3 tMSsgwW2UHXCGWh/Puol387O+IctIO//VkkPqRZO3JICdKshwUwWUnmnANxLqsyLekQl gsknh7pR3vmTc8F3jfQ9r6mVvmf23C+Y5fCPZpE1CshJsxvNrp7uScL24EwAEc7WWBFI yePF2V597Y8LZKSPYmP+DUJIFgT+djJL7a+ax7YwAIu6SUfPHDI05nrBN57WQE4Wgw8h KNzA== 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=aPHXTL52nZ8TnYruo+TUHBbc33RfRH/y9aR6NOzaRVo=; b=Iru/vfuF21vxDMS2u2lBNwWmQjA9iZ8oQOC+FAhHuaff+/ep5SDgx9kE24X89dmcqv rjJEcfJd4BkEeSP0ulA6upi/1gucCBnYmu5/KpaclYXb0tHIw/Im65ISdrMNEdX+bXQU NvEquE/cBRLh2Mjv5EBxfbHClib7OwIk272zUrpnU5MXnyTverpemQohr0cC2WsKuJPg LY81iQ1x9MR23QWLV7ns5H0sNViOnuEdrh29lPt/fUd8LqGNfyD9s8vmy2HSPqtEa3ej bQ55unWDiNPZAdbLXSo+famSwZB2H3Mr9Ma0QipsTJFttL8bmGN7GCJL/al0EXIrgc5X mKXA== X-Gm-Message-State: AOAM531BzRwh0L5e6X+h9oX7UqJoOtFv+orLI3oVOKLNS41O8g5wL933 Sjl3U6hxUUKbz+xuYAOmug== X-Received: by 2002:ac8:1382:: with SMTP id h2mr25882364qtj.228.1597036068667; Sun, 09 Aug 2020 22:07:48 -0700 (PDT) Received: from localhost.localdomain (146-115-88-66.s3894.c3-0.sbo-ubr1.sbo.ma.cable.rcncustomer.com. [146.115.88.66]) by smtp.gmail.com with ESMTPSA id w20sm13125325qki.108.2020.08.09.22.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 22:07:48 -0700 (PDT) From: Peilin Ye To: Mauro Carvalho Chehab Cc: Peilin Ye , Hans Verkuil , Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org Subject: [Linux-kernel-mentees] [PATCH] v4l2-tpg: Fix global-out-of-bounds read in precalculate_color() Date: Mon, 10 Aug 2020 01:05:32 -0400 Message-Id: <20200810050532.640075-1-yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org precalculate_color() is reading out of `sin` since `tpg->hue` is not being properly checked. Fix it. `cos` is safe, as long as `tpg->hue` is higher than or equal to -192. Fixes: 63881df94d3e ("[media] vivid: add the Test Pattern Generator") Reported-and-tested-by: syzbot+02d9172bf4c43104cd70@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?id=db50123c788e2cc5a9d90de569c398b66293ee48 Signed-off-by: Peilin Ye --- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c index 50f1e0b28b25..52205fe096f7 100644 --- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c @@ -930,6 +930,9 @@ static void precalculate_color(struct tpg_data *tpg, int k) /* Implement these operations */ int tmp_cb, tmp_cr; + if (tpg->hue < -128 || tpg->hue > 128) + return; + /* First convert to YCbCr */ color_to_ycbcr(tpg, r, g, b, &y, &cb, &cr); -- 2.25.1