Whamcloud - gitweb
LU-18170 obdclass: replace round_up(*_inllenX*) with ALIGN 54/57354/2
authorEtienne AUJAMES <etienne.aujames@cea.fr>
Tue, 10 Dec 2024 11:11:50 +0000 (12:11 +0100)
committerOleg Drokin <green@whamcloud.com>
Wed, 22 Jan 2025 18:42:55 +0000 (18:42 +0000)
commit4a7db8f29b7f3e9962b5260b3bd51a4f3685dcbb
treec5c7f414926639d52d1a8c85756f5276f394877e
parent627c4b2b93484818f13c3e7158593ae0c097bf6c
LU-18170 obdclass: replace round_up(*_inllenX*) with ALIGN

This patch fixes the following Coverity error:

2648      bufs = ioc_data->ioc_inllen4 +
2649      round_up(ioc_data->ioc_inllen1, 8) +
   CID 451715:  Integer handling issues  (INTEGER_OVERFLOW)
   Expression "ioc_data->ioc_inllen2 - 1U", which is equal to
4294967295,
   where "ioc_data->ioc_inllen2" is known to be equal to 0, underflows
   the type that receives it, an unsigned integer 32 bits wide.
2650      round_up(ioc_data->ioc_inllen2, 8) +
2651      round_up(ioc_data->ioc_inllen3, 8);

ioc_inllenX are unsigned so round_up() macro can underflow if the
value is set to 0.

#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)

So this patch replaces round_up() with ALIGN() to align ioctl buffer
sizes to 8 bytes.

Fixes: 5ad117fc6f ("LU-18170 obdclass: fix llog_print_cb()")
Signed-off-by: Etienne AUJAMES <eaujames@ddn.com>
Change-Id: I47e42f581aa76b71c23c7cfec42b9f2589f23f2b
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57354
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/module.c
lustre/lod/lod_dev.c
lustre/obdclass/class_obd.c
lustre/obdclass/llog_ioctl.c