Whamcloud - gitweb
LU-3048 llapi: make lfs getstripe less crashy, more correct
authorJohn L. Hammond <john.hammond@intel.com>
Wed, 3 Apr 2013 20:57:05 +0000 (15:57 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 23 Apr 2013 05:20:49 +0000 (01:20 -0400)
commit9c554459451b9002a83f6f6639737b98e3514fd9
treed7197a30bfee070383d79b1fd36f830d979f65dc
parent784fca771a663c1cbd7f56575be7302df52d9072
LU-3048 llapi: make lfs getstripe less crashy, more correct

Use of get_param_obdvar() in get_mds_md_size() could cause the
max_easize param from the wrong filesystem to be read, possibly
preventing userspace from allocating a sufficiently large buffer to
receive the results of the IOC_MDC_GETFILESTRIPE ioctl() and causing a
buffer overrun in copy_to_user().  Add internal functions
get_param_{cli,llite,lmv,lov}() which finds the correct params for the
filesystem containing the path argument.

In common_param_init() the lum buffer used for IOC_MDC_GETFILESTRIPE
is sized based on the return of get_mds_md_size().  For file systems
with a small number of OSTs this buffer may be too small to hold a
path component.  Fix this by ensuring that the allocated buffer has
size at least PATH_MAX + 1.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I9847a1414cb4306f4bce5f7c30d1d1cddfab8621
Reviewed-on: http://review.whamcloud.com/5934
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/include/lustre/lustreapi.h
lustre/utils/liblustreapi.c