From patchwork Mon Feb 5 15:23:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anastasia Belova X-Patchwork-Id: 196883 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp964293dyb; Mon, 5 Feb 2024 07:54:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/JZFt6CObTEI8hFT6ANXC/Hk48c+lfp5CDpVQ5KspgltcI3GtLCKklY6pOTA/eHJ1vmsk X-Received: by 2002:a17:903:22cd:b0:1d9:5b75:4602 with SMTP id y13-20020a17090322cd00b001d95b754602mr13057950plg.7.1707148487787; Mon, 05 Feb 2024 07:54:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707148487; cv=pass; d=google.com; s=arc-20160816; b=myZi1URloSrgJ8wUKguZ0/y3Tc2XJSin25YcDxKdekeZSiyKrrFjKtYY+exuOt45x1 QGBECDcVP/yuVyINHr5QInuOyEYObVfcaV47ho81BzAez0pE4hBVIPUGjQ5Efqhty79/ nIoNUph7ftdWiNUBwoLFJCq2iv6ht8j/eRFrJLjGM1xTAOgIMSauRRwElUxI9MMsAFGo +vvA/RGaKkS7mH4A1cw7TwXgUSOnM+jB9GYd49cTvuBAR05q/oR3vnoGQcKJAwQUH0pw YEumMddhpkpfQGpLL/hkhE1HBVyflCG4Tw3oIijxrWPJZT4Z0/G/YItiaPAQKB9bnKG4 fcHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=roUGpgQDfKNVf2hA2nfHz02s4kD9yCtRBap5AoR+dV0=; fh=eqz7N630ixnm5L2LxBDKGFm3tUEzdpP+++/cRVyPAHw=; b=yHcq6PfQXfDoED+To+mdIhVOzuqbJvtl4HMj7FO3fmeZ1BeuuBqGzW41KZXdWpuVb3 5khuBsPJtLIN8NBD6f43ps7DRn19R7+Z5H5NXKQtChjIqBBXIJ59c2KM3VYEHK7HrqBl 4MLeDCLFwlfRWf9lSrB0FBYZHtcPN604OHIgOGfz7+1MXWj/rVmWhhvI2UWPiWJByML3 dSu8uw/aaarGwN6Uf2lIB+8kzExtSV+eLRUXDILqs9HB/fa9nd0OfdTPVKbs0+odgJyv gk9gm/8WFDZvn2xQwQNYZJ9Sgp5gYwD6qijriS9VgvI7e2KjBbRdpPvpucQU2hGP81LX 3LBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=astralinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-52898-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52898-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCW2zPykEjC7tKm46i3iUqCnCs4Qh/xOFlQW8QbByB9dOVeOF9F5Sik1NEFJky8+M3G1WM8NQaoP7Tz/cPoSz37nn0UjZg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 21-20020a170902e9d500b001d4e7ad3810si17515plk.604.2024.02.05.07.54.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 07:54:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52898-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=astralinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-52898-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52898-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D10CFB24EF0 for ; Mon, 5 Feb 2024 15:25:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A02A32C6C; Mon, 5 Feb 2024 15:24:46 +0000 (UTC) Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 872022C85C; Mon, 5 Feb 2024 15:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.74.38.119 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707146684; cv=none; b=pB1/9jwwVUJSQOVdP/a1k3KaBKRCWgn9xY4AEPwb2/+tGPBjMGXUyzuxOmc83KiQVtwjyOFa03lH0fbyxM8rEKf0xhBMR8L889cyKY3HgCOdrnNNdqTrtEC/dC5QQ2CiKzZ3p8FonCq3IiuH0OEPGwyPh3KnFC3plPd/TpKOpys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707146684; c=relaxed/simple; bh=fEE6msD4XdTRoTXofN5+urjqqiYv6m5CX0D62N32MYg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=FJ5uaGIeU2pE3AzMKIaFv+wOO2xo6PWun6BRqq6/rPhmvgdT5Mb38yZAzEwwX9d/EmeYQWJ05rSe9f/8q+Mvf2j+G3onwultatKSfsDR7+/vnbq6aiTEABRDaUiIzPvK15LDJeNBzQgGPtGz1PjSxNl7DdGQDEFjMQhL/6IJkJo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=astralinux.ru; spf=pass smtp.mailfrom=astralinux.ru; arc=none smtp.client-ip=217.74.38.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=astralinux.ru Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 2E9C31865695; Mon, 5 Feb 2024 18:24:31 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id VQTBXYzT9CdU; Mon, 5 Feb 2024 18:24:30 +0300 (MSK) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id CC8F1186563B; Mon, 5 Feb 2024 18:24:30 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id kfOHWGwef5L5; Mon, 5 Feb 2024 18:24:30 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.20.58]) by mail.astralinux.ru (Postfix) with ESMTPSA id 1C40A18639A5; Mon, 5 Feb 2024 18:24:30 +0300 (MSK) From: Anastasia Belova To: Philipp Zabel Cc: Anastasia Belova , Mauro Carvalho Chehab , Kamil Debski , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] media: coda: cast an operand of multiplication to a larger type Date: Mon, 5 Feb 2024 18:23:50 +0300 Message-Id: <20240205152350.22547-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790074932925023000 X-GMAIL-MSGID: 1790074932925023000 If width and height are 0xffff (or close), the result of multiplication overflow. Add casting to a larger type to avoid undefined behavior. Such values are possible in CODA7, but unlikely. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 918c66fd4126 ("[media] coda: add CODA7541 decoding support") Signed-off-by: Anastasia Belova --- drivers/media/platform/chips-media/coda/coda-bit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/chips-media/coda/coda-bit.c b/drivers/media/platform/chips-media/coda/coda-bit.c index ed47d5bd8d61..84ded154adfe 100644 --- a/drivers/media/platform/chips-media/coda/coda-bit.c +++ b/drivers/media/platform/chips-media/coda/coda-bit.c @@ -585,7 +585,7 @@ static int coda_alloc_context_buffers(struct coda_ctx *ctx, if (!ctx->slicebuf.vaddr && q_data->fourcc == V4L2_PIX_FMT_H264) { /* worst case slice size */ - size = (DIV_ROUND_UP(q_data->rect.width, 16) * + size = (unsigned long)(DIV_ROUND_UP(q_data->rect.width, 16) * DIV_ROUND_UP(q_data->rect.height, 16)) * 3200 / 8 + 512; ret = coda_alloc_context_buf(ctx, &ctx->slicebuf, size, "slicebuf");