From 0cdd427e2f043cf667c9a921b48ce3b99a5f81fc Mon Sep 17 00:00:00 2001 From: James Simmons Date: Tue, 1 Jun 2021 19:00:58 -0400 Subject: [PATCH] LU-14732 utils: ensure hsm_user_request extent fields are zero Another patch changed the linking flags for liblustreapi which caused sanit-hsm 29c to fail. Debugging revealed the reason was the extent fields in hsm_user_request sent to the kernel was not zeroed out. For some reason the compiler flags hide this bug. I found this is easily reproduced by removing lhsmtool_posix_DEPENDENCIES which is not needed anyways since the build system can calculate those dependencies for us. Update the function llapi_hsm_user_request_alloc to zero out the struct hsm_user_request allocated. Change-Id: I02c1d6b5cec1ed3e89086a6a00e30ca81768409c Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/43893 Tested-by: jenkins Reviewed-by: Ben Evans Tested-by: Maloo Reviewed-by: Petros Koutoupis Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/utils/Makefile.am | 1 - lustre/utils/liblustreapi_hsm.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am index a806331..a69ed26 100644 --- a/lustre/utils/Makefile.am +++ b/lustre/utils/Makefile.am @@ -235,7 +235,6 @@ l_getidentity_DEPENDENCIES := $(top_builddir)/libcfs/libcfs/libcfs.la lhsmtool_posix_SOURCES = lhsmtool_posix.c pid_file.c pid_file.h lhsmtool_posix_LDADD := liblustreapi.la $(PTHREAD_LIBS) \ $(top_builddir)/lnet/utils/lnetconfig/liblnetconfig.la -lhsmtool_posix_DEPENDENCIES := liblustreapi.la l_getsepol_SOURCES = l_getsepol.c l_getsepol_LDADD := liblustreapi.la -lcrypto $(SELINUX) diff --git a/lustre/utils/liblustreapi_hsm.c b/lustre/utils/liblustreapi_hsm.c index ba99cd3..a053046 100644 --- a/lustre/utils/liblustreapi_hsm.c +++ b/lustre/utils/liblustreapi_hsm.c @@ -1576,7 +1576,7 @@ struct hsm_user_request *llapi_hsm_user_request_alloc(int itemcount, len += sizeof(struct hsm_user_item) * itemcount; len += data_len; - return (struct hsm_user_request *)malloc(len); + return (struct hsm_user_request *)calloc(1, len); } /** -- 1.8.3.1