LU-17784 build: improve wiretest for flexible arrays
Flexible array checking can additionally probe that the size
of the array element is correct.
Lustre-change: https://review.whamcloud.com/54929
Lustre-commit:
339b585c257d7f47d0c9b74f9d940fd20b8c04a3
Was-Change-Id: Ib7de3d156a2e77dfaf2e9ab1df8fab524c073610
LU-17504 libcfs: safer LIBCFS_ALLOC
Make the LIBCFS_ALLOC() family of macros safer by adding
parenthesis around arguments such as (size) to avoid uninteded
expansion.
CoverityID: 415056 ("Integer handling issues")
Lustre-change: https://review.whamcloud.com/55015
Lustre-commit:
0d3a9607655adc8f9dd4ae1c341bde0b57fe88bf
Was-Change-Id: I9701f87025bc5ce038a6bf34413b64a3f019d998
Fixes:
718e3f3e68 ("LU-17504 build: fix gcc-13 [-Werror=stringop-overread] error")
LU-17504 build: fix lock_handle array-index-out-of-bounds
After Linux kernel patch "ubsan: Tighten UBSAN_BOUNDS on GCC"
(commit v6.4-rc2-1-g2d47c6956ab3), flexible trailing arrays
declared like 'lock_handle[2]' will generate warnings when
CONFIG_UBSAN & co. is enabled:
UBSAN: array-index-out-of-bounds in ldlm_request.c:1282:18
index 2 is out of range for type 'lustre_handle [2]'
The declaration lock_handle[LDLM_LOCKREQ_HANDLES] confuses the
compiler into thinking there are only two fields in lock_handle,
but the caller often allocates extra fields beyond this for more
locks to be cancelled due to Early Lock Cancellation or from LRU.
Rather than have a second flexible array after lustre_handle[2],
declare the whole array as flexible, and fix up the few sites
that are allocating this array to ensure LDLM_LOCKREQ_HANDLES
fields are allocated at a minimum.
This subtly changes the checks in wiretest.c due to the removal
of the 2 "base" handles in ldlm_request, but I believe this is not
changing the wire protocol because it still allocates those handles
directly, and I have verified interoperability with a 2.14.0 server.
Lustre-change: https://review.whamcloud.com/54926
Lustre-commit:
e3a9d87370c4ccc58d1d3a97ea1b221d88f9e57a
Was-Change-Id: I9695fb44f1b5c84bb750d2983cdd8b939e3ebbe5
Test-Parameters: testlist=runtests clientversion=2.14
Test-Parameters: testlist=runtests serverversion=2.14
Test-Parameters: testlist=runtests clientversion=2.15
Test-Parameters: testlist=runtests serverversion=2.15
Test-Parameters: testlist=runtests clientversion=EXA5
Test-Parameters: testlist=runtests serverversion=EXA5
Test-Parameters: testlist=runtests clientversion=EXA6
Test-Parameters: testlist=runtests serverversion=EXA6
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
LU-17504 build: fix gcc-13 [-Werror=stringop-overread] error
This patch fixes the following [-Werror=stringop-overread] and
[-Werror=attribute-warning] errors detected by gcc 13:
lustre/mgc/mgc_request.c:190:21: error: 'strcmp' reading 1 or
more bytes from a region of size 0 [-Werror=stringop-overread]
190 | if (strcmp(logname, cld->cld_logname) == 0) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function 'fortify_memcpy_chk',
inlined from 'class_handle_ioctl' at
/root/lustre-release/lustre/obdclass/class_obd.c:381:3:
include/linux/fortify-string.h:528:25: error:
call to '__write_overflow_field' declared with attribute warning:
detected write beyond size of field (1st parameter);
maybe use struct_group()? [-Werror=attribute-warning]
528 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lustre-change: https://review.whamcloud.com/54834
Lustre-commit:
718e3f3e680f422d865a15890ac60e66dcd9e240
Was-Change-Id: I59f5a88b4cd64c9f4e67e568546baada371543b1
Signed-off-by: Jian Yu <yujian@whamcloud.com>
LU-17504 build: fix array-index-out-of-bounds warning
On Linux kernel 6.5, due to commit
2d47c6956ab3
("ubsan: Tighten UBSAN_BOUNDS on GCC"), flexible
trailing arrays declared like 'lc_array_sum[1];'
will generate warnings when CONFIG_UBSAN & co. is
enabled:
UBSAN: array-index-out-of-bounds in lprocfs_status.c:1609:17
index 1 is out of range for type '__s64 [1]'
Since LPROCFS_STATS_FLAG_IRQ_SAFE flag is only used
in one place - obd_memory() counter, we can just
remove it and change obd_memory over to a regular
percpu_counter. This would both simplify the
lprocfs_counter() code, move over to using more
kernel functionality instead of libcfs, as well as
reduce overhead slightly for the memory accounting code.
Lustre-change: https://review.whamcloud.com/54365
Lustre-commit:
b698abd415bc4a810f307611fe984e50e007581e
Was-Change-Id: Ic461c4b30317bfd2b1e9f5b6be84c4a7fb4e3eb9
Signed-off-by: Jian Yu <yujian@whamcloud.com>
LU-16363 build: fiemap flexible array
Linux commit v5.19-rc2-1-g94dfc73e7cf4
treewide: uapi: Replace zero-length arrays with flexible-array
members
Adjust wiretest to handle flexible array when
sizeof(fiemap->fm_extents) is undefined.
Lustre-change: https://review.whamcloud.com/49305
Lustre-commit:
fedf1e8bd70ccb2aaa64cb90111a7298d9bb2bf7
Was-Change-Id: Ia2692d126a871b43e9144e5d151215166604702d
HPE-bug-id: LUS-11388
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: Ib7de3d156a2e77dfaf2e9ab1df8fab524c073610
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59303
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>