Whamcloud - gitweb
LU-10822 utils: stop bogus buffer overflow errors 22/31822/6
authorAndreas Dilger <andreas.dilger@intel.com>
Wed, 28 Mar 2018 21:42:06 +0000 (15:42 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 30 Mar 2018 22:05:31 +0000 (22:05 +0000)
commit7de178ba4afcf8c50c5430b861c9d0eeb84f800f
treebe1615bf025d3058fb8895aaa739802aa3bd1911
parent68be7b634d8e46c110f11916dd87b9f1c36a90e1
LU-10822 utils: stop bogus buffer overflow errors

Over-zealous Fortify checks assume that the buffer being used for
snprintf() in get_lmd_info() is sizeof(*lmd) when in fact a larger
buffer has been allocated.  This causes runtime checks to fail and
lfs to core dump:

   *** buffer overflow detected ***: /usr/bin/lfs terminated

Instead of printing directly into "struct lov_user_mds_data", use
a generic buffer to hold the filename passed into the ioctl and
the return data.

There are several places in the code which do the same operations,
namely cb_getstripe(), get_lmd_info(), and ct_md_getattr(), so
change them all to call get_lmd_info() or a new get_lmd_info_fd()
helper to consolidate common code.  Also check the return values
from snprintf() in case there are new callers of this code in the
future that do not actually pass large-enough buffers.

Test-Parameters: clientdistro=ubuntu1604 serverdistro=el7 testlist=sanity
Test-Parameters: trivial testlist=sanity-hsm
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I41b1fcba1f7937fbce3cc7180ed5d73d067cab07
Reviewed-on: https://review.whamcloud.com/31822
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/utils/liblustreapi.c
lustre/utils/liblustreapi_hsm.c
lustre/utils/lustreapi_internal.h