From patchwork Fri Oct 18 01:16:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gax-c X-Patchwork-Id: 13840952 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D93DD3C53E for ; Fri, 18 Oct 2024 01:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=L+jeEzvzeBO0CSepYbmjdJpmL4Dx0CLgyilp0Lr7mac=; b=fOlEAC9rTGfXgiDychASdLoyaJ ydeXjH6ky736iYOkywhK3H35QX1YaA9tWf6Ibfi3Lb4y3BFmBnUpJMbl3VMocU3oPfEUmOFZ0IQ97 ovsEblBObiXJ2XclbA/u0wtP3fpTVQECrwbL9bwfwX5aHqKF4kePIYAloe9ttu5rDXsC7xMX+MjqE xn2WEZUfTwPCzeInFf6JrkS2BkznS8SFnIXHr2YTbO7GS77lKvGLwpkzNl+H43ngNdCDQ5soh80WU LSIrZGsqknYRI59JVLpb/Hl+cpAd+07wiJCK6sjy9ZFvF+1jrizjkmUXl7GojX/FLTCJpsEY2F7Zi 8VFNwe0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1beO-0000000GYVx-2AOS; Fri, 18 Oct 2024 01:19:32 +0000 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1bbh-0000000GYA3-0ON5 for linux-arm-kernel@lists.infradead.org; Fri, 18 Oct 2024 01:16:46 +0000 Received: by mail-qk1-x744.google.com with SMTP id af79cd13be357-7b152a23e9aso79947685a.0 for ; Thu, 17 Oct 2024 18:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729214203; x=1729819003; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=L+jeEzvzeBO0CSepYbmjdJpmL4Dx0CLgyilp0Lr7mac=; b=P+z9d8mvuSI7MJFSvj5FcJDa5jlUG0EnVv9c39EiLdMCQZVTtvYcvm4kvTpuf/TXXk Ha1gGGLkvQlOABeh2uzH8oH/ebbuY3jWBLTylw/BxCR3cWkq4QJ02KmgkfIVQwQ0MwME lXIutT1Bvru2bNjHt+cgQPSWjQRi/98vyrzxxjCUc1Zciy0xZg4NWzl9y1Y8eL9W+rQ0 jGVFbjQlIWmBUjJVDfvQ2oSPh7lyp2Iaho6c/i6xuben+Q6tVkeGOPqFG4AZUTnpj/WG bXEJUBjhWJ0kh4WQAl5OrhHVAooalk0PDr91ZLrdwxZtWXDLe5iqQkfQAwUZuwcc+vqt 0Kkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729214203; x=1729819003; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=L+jeEzvzeBO0CSepYbmjdJpmL4Dx0CLgyilp0Lr7mac=; b=aN3PPC0u32mVSn+Ghk+cXqrBnN8IB4RRYWS0cqBa/LmNxiqjxRDyErb5V2U5qo999J 89ilxR3ABlmyvfsgGVEKLoCVD7wKgr6EZKnhEs5V5tzuWEv2aXbOyEuSauiyZG0C48mW tT67nkPK8jV7Svvq3Ok78vushmiirPEFaAz18FiqHj0lnC+EJN2y0Dhnu7gjXsTurOG/ 1i+djqeVx+VLVqE5mWgucWlAUu/qX0OvoYcfpC2+4NzUA9qz7MR/MyhxL/MPXVSQP5rG o768BJGYJ/wbiLXXZE2GyjyutxKOqyp2cEGJcL94UTrIJcJ8wltdWlFWhCS2ahUjxNFf I2tQ== X-Forwarded-Encrypted: i=1; AJvYcCXDvBcnTHxTX5O7ACkWE08rjLCO3zh8nXMYLRJ+u1koLvQh+vIUsXG7mngpEYRazzTP6EXfM0eUMfnRmPLI17JC@lists.infradead.org X-Gm-Message-State: AOJu0YzUt3HKUgMMlVxxJpVP5P4B/J5DtWHIHEUUvjmn2rpBtVIhjsBU pihLXQOjHZDdYJf3Ej11Oegy2t1UamRUYbAJhztHv6oy3B3pcH1n X-Google-Smtp-Source: AGHT+IHHFnNKX+aO1kFP+z5fdwNhVe0jV7E5UYmQLhZyHyGqgaPqopnARtqKFCzaWvPE4BOI1xJEnw== X-Received: by 2002:a05:620a:1995:b0:7b1:50a8:3394 with SMTP id af79cd13be357-7b157b7d45dmr85250685a.36.1729214203021; Thu, 17 Oct 2024 18:16:43 -0700 (PDT) Received: from localhost.localdomain (mobile-130-126-255-54.near.illinois.edu. [130.126.255.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b156f9858esm24367585a.40.2024.10.17.18.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 18:16:42 -0700 (PDT) From: Gax-c To: inki.dae@samsung.com, sw0312.kim@samsung.com, kyungmin.park@samsung.com, airlied@gmail.com, simona@ffwll.ch, alim.akhtar@samsung.com Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, zzjas98@gmail.com, chenyuan0y@gmail.com, Zichen Xie Subject: [PATCH] drm/exynos: fix potential integer overflow in exynos_drm_gem_dumb_create() Date: Thu, 17 Oct 2024 20:16:05 -0500 Message-Id: <20241018011604.24875-1-zichenxie0106@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_181645_157804_12972109 X-CRM114-Status: GOOD ( 12.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Zichen Xie This was found by a static analyzer. There may be potential integer overflow issue in exynos_drm_gem_dumb_create(). args->size is defined as "__u64" while args->pitch and args->height are both defined as "__u32". The result of "args->pitch * args->height" will be limited to "__u32" without correct casting. Even if the overflow is quite difficult to happen, we still recommand adding an extra cast. Fixes: 7da5907c84f8 ("drm/exynos: fixed page align bug.") Signed-off-by: Zichen Xie --- drivers/gpu/drm/exynos/exynos_drm_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c index 638ca96830e9..de2126853d2c 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c @@ -337,7 +337,7 @@ int exynos_drm_gem_dumb_create(struct drm_file *file_priv, */ args->pitch = args->width * ((args->bpp + 7) / 8); - args->size = args->pitch * args->height; + args->size = (__u64)args->pitch * args->height; if (is_drm_iommu_supported(dev)) flags = EXYNOS_BO_NONCONTIG | EXYNOS_BO_WC;