Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2611651rda; Wed, 25 Oct 2023 07:39:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFicll63C5r5hH8IkVKrRWcsDdvWYH0QSvMjj3dDAHcYHDv8CX1tFR0+jEgsqUOBg41TC9z X-Received: by 2002:a05:690c:16:b0:5a7:b973:db3c with SMTP id bc22-20020a05690c001600b005a7b973db3cmr16799248ywb.34.1698244794303; Wed, 25 Oct 2023 07:39:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698244794; cv=none; d=google.com; s=arc-20160816; b=cBqGWDwDuSVRUK5TDPdhmOIOXW9FQ+hbLOgxKebaQn/6u4db87R6yEAiC5acZgnbK8 4bGFtxeP2aFiEKRNblZpR3A3ueG0o46yvFlVcpPk77sY7nTfjVpH8kdsHMYnAq0VGcCy fVYIuSjySxqu/sW8VZ7eLQvlhpDCX+MuN4KHQgSlnN4hoCuWqBgMO/bkz93Z2W55ORFz tuLz9MInX27EjbXNFjXGC00+4dGYt1GwIwPTHm2nr96A+wIFCXUZ8Oyv2cfMXeUTRcW9 HGIFU21DSykCd0jtgKpRBQ49hSxrElqZsVPhIQN6QIJcdoeC8oM9RRWUIFwL7aEkWqXO cEhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=sq/7jbI//tPSUdJ8eoGURH5pS4j1r+AIB4XYpbcVvmU=; fh=hr7Ar57RY8FccGRqB722gwCFOJze0t2BkGuFb1gy0NU=; b=f8poKE1GZV2ydgEMAWavQTrdSdwK1ucGY11/dUnhQ0deFNdO3hlHs30vNVSqjPUG/G UU/SsSTbejUUqfRCVVM1zrJa8k0oq3dY7vS0JLSjKs62TfRIkwNjig2tQVTtr0DCwUxe dkRevfeHRq1IBTHZ14mMS9AoDEzgIYi7hjj9+CJPlBBeqcD+MrRn77TK/bPGZRjTkIRw OHHkqL8hbbLTNu/wScVkf7JerCFm0yoCPoeJGJrl68gVcXzrzwNL7a4xcbicmTzR3Pm9 QYp/o2VmolR58K4m/yf8RQuEUK+2R1CTmhrnkopJ/Tiql1erCMAqVWEu7eQMu5CDcSel vZ7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cZvK9yba; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a135-20020a0dd88d000000b005a7afbfc65csi12058433ywe.126.2023.10.25.07.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 07:39:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cZvK9yba; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7C09381067A8; Wed, 25 Oct 2023 07:39:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235001AbjJYNK7 (ORCPT + 99 others); Wed, 25 Oct 2023 09:10:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234967AbjJYNKy (ORCPT ); Wed, 25 Oct 2023 09:10:54 -0400 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFAC3130 for ; Wed, 25 Oct 2023 06:10:49 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id EBCA11C000D; Wed, 25 Oct 2023 13:10:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1698239448; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=sq/7jbI//tPSUdJ8eoGURH5pS4j1r+AIB4XYpbcVvmU=; b=cZvK9ybagNGJ5x27CZPb5DKTSJsJ1Gfn/y1eO8ofA5QCvz7vY5PfiPr9dcxyvQuaBq3QZf BuGiailwe4f+lxc7K2yfuXEZlfLhLZyLLKR1yljcxxF7PFp3gfK4ixinp7xELv4luvrkpp hlijvM3HcgbzhprIoT+Jcpgx6MfnN5KBcdPqHfWxDBreDiAXFq0Oct8/oW2MYcDIGaK75x B77omtU7lf9bRzW8ortwSy+fH9mE64XREkFokLyY5zp3YuH43hGfX2Bk+rMilinSSMVIyP Jx1vpB/WzGQrf5EtE8TOjDG/4osdygMNIYGEsn/CfSt7THXeaB3kLmqRA4Jpog== From: Paul Kocialkowski To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Paul Kocialkowski , David Airlie , Daniel Vetter , Maxime Ripard , Dan Carpenter Subject: [PATCH 1/2] drm/logicvc: Avoid possible overflow in layer buffer setup variables Date: Wed, 25 Oct 2023 15:09:45 +0200 Message-ID: <20231025130946.119957-1-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: paul.kocialkowski@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 25 Oct 2023 07:39:52 -0700 (PDT) The buffer_sel, voffset and hoffset values are calculated from u32 values and might overflow under certain conditions. Move them to u32 definitions instead of u8/u16 to avoid the issue. Signed-off-by: Paul Kocialkowski Reported-by: Dan Carpenter Fixes: efeeaefe9be5 ("drm: Add support for the LogiCVC display controller") --- drivers/gpu/drm/logicvc/logicvc_layer.c | 6 +++--- drivers/gpu/drm/logicvc/logicvc_layer.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/logicvc/logicvc_layer.c b/drivers/gpu/drm/logicvc/logicvc_layer.c index 464000aea765..eea22379d042 100644 --- a/drivers/gpu/drm/logicvc/logicvc_layer.c +++ b/drivers/gpu/drm/logicvc/logicvc_layer.c @@ -268,9 +268,9 @@ int logicvc_layer_buffer_find_setup(struct logicvc_drm *logicvc, u32 layer_stride = layer_bytespp * logicvc->config.row_stride; u32 base_offset = layer->config.base_offset * layer_stride; u32 buffer_offset = layer->config.buffer_offset * layer_stride; - u8 buffer_sel = 0; - u16 voffset = 0; - u16 hoffset = 0; + u32 buffer_sel = 0; + u32 voffset = 0; + u32 hoffset = 0; phys_addr_t fb_addr; u32 fb_offset; u32 gap; diff --git a/drivers/gpu/drm/logicvc/logicvc_layer.h b/drivers/gpu/drm/logicvc/logicvc_layer.h index 4a4b02e9b819..a06feeda3abf 100644 --- a/drivers/gpu/drm/logicvc/logicvc_layer.h +++ b/drivers/gpu/drm/logicvc/logicvc_layer.h @@ -18,9 +18,9 @@ #define LOGICVC_LAYER_ALPHA_PIXEL 1 struct logicvc_layer_buffer_setup { - u8 buffer_sel; - u16 voffset; - u16 hoffset; + u32 buffer_sel; + u32 voffset; + u32 hoffset; }; struct logicvc_layer_config { -- 2.42.0