linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] drm/kmb: fix potential integer overflow on multiplication
@ 2020-11-13 12:37 Colin King
  2020-11-13 17:56 ` kernel test robot
  2020-11-13 18:16 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2020-11-13 12:37 UTC (permalink / raw)
  To: Anitha Chrisanthus, Edmund Dea, David Airlie, Daniel Vetter,
	Sam Ravnborg, dri-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

There is a potential integer overflow when multiplying various sized
integers that are cast to u32 integers using u32 multiplication and
then assigning the result to a u64. Fix this by casting MIPI_TX_BPP
to a u64 to force the multiplication to use u64 math and hence avoid
any potential overflows.

Addresses-Coverity: ("Unintentional integer overflow")
Fixes: 98521f4d4b4c ("drm/kmb: Mipi DSI part of the display driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/kmb/kmb_dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/kmb/kmb_dsi.c b/drivers/gpu/drm/kmb/kmb_dsi.c
index 4b5d82af84b3..6c3081356bd9 100644
--- a/drivers/gpu/drm/kmb/kmb_dsi.c
+++ b/drivers/gpu/drm/kmb/kmb_dsi.c
@@ -1369,7 +1369,7 @@ int kmb_dsi_mode_set(struct kmb_dsi *kmb_dsi, struct drm_display_mode *mode,
 	 */
 	data_rate = ((((u32)mode->crtc_vtotal *	(u32)mode->crtc_htotal) *
 			(u32)(drm_mode_vrefresh(mode)) *
-			MIPI_TX_BPP) / mipi_tx_init_cfg.active_lanes) /	1000000;
+			(u64)MIPI_TX_BPP) / mipi_tx_init_cfg.active_lanes) / 1000000;
 
 	dev_dbg(kmb_dsi->dev, "data_rate=%u active_lanes=%d\n",
 		(u32)data_rate, mipi_tx_init_cfg.active_lanes);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] drm/kmb: fix potential integer overflow on multiplication
  2020-11-13 12:37 [PATCH][next] drm/kmb: fix potential integer overflow on multiplication Colin King
@ 2020-11-13 17:56 ` kernel test robot
  2020-11-13 18:16 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-11-13 17:56 UTC (permalink / raw)
  To: Colin King, Anitha Chrisanthus, Edmund Dea, David Airlie,
	Daniel Vetter, Sam Ravnborg, dri-devel
  Cc: kbuild-all, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1563 bytes --]

Hi Colin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20201112]
[cannot apply to linus/master v5.10-rc3 v5.10-rc2 v5.10-rc1 v5.10-rc3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Colin-King/drm-kmb-fix-potential-integer-overflow-on-multiplication/20201113-203903
base:    a60b1e1fe9ca5f9d9a79e89a8d71228a8e04d35c
config: i386-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/bb25aac8771c57130ea5a2a016790e3b7c62e283
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Colin-King/drm-kmb-fix-potential-integer-overflow-on-multiplication/20201113-203903
        git checkout bb25aac8771c57130ea5a2a016790e3b7c62e283
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   ld: drivers/gpu/drm/kmb/kmb_dsi.o: in function `kmb_dsi_mode_set':
   kmb_dsi.c:(.text+0x13b7): undefined reference to `__udivdi3'
>> ld: kmb_dsi.c:(.text+0x13ca): undefined reference to `__udivdi3'

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 76172 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] drm/kmb: fix potential integer overflow on multiplication
  2020-11-13 12:37 [PATCH][next] drm/kmb: fix potential integer overflow on multiplication Colin King
  2020-11-13 17:56 ` kernel test robot
@ 2020-11-13 18:16 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-11-13 18:16 UTC (permalink / raw)
  To: Colin King, Anitha Chrisanthus, Edmund Dea, David Airlie,
	Daniel Vetter, Sam Ravnborg, dri-devel
  Cc: kbuild-all, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1726 bytes --]

Hi Colin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20201112]
[cannot apply to linus/master v5.10-rc3 v5.10-rc2 v5.10-rc1 v5.10-rc3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Colin-King/drm-kmb-fix-potential-integer-overflow-on-multiplication/20201113-203903
base:    a60b1e1fe9ca5f9d9a79e89a8d71228a8e04d35c
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/bb25aac8771c57130ea5a2a016790e3b7c62e283
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Colin-King/drm-kmb-fix-potential-integer-overflow-on-multiplication/20201113-203903
        git checkout bb25aac8771c57130ea5a2a016790e3b7c62e283
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "__udivdi3" [drivers/gpu/drm/kmb/kmb-drm.ko] undefined!
>> ERROR: modpost: "__divdi3" [drivers/gpu/drm/kmb/kmb-drm.ko] undefined!

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 59060 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-13 18:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 12:37 [PATCH][next] drm/kmb: fix potential integer overflow on multiplication Colin King
2020-11-13 17:56 ` kernel test robot
2020-11-13 18:16 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).