From: Sebastien Buisson Date: Tue, 4 Apr 2017 09:51:00 +0000 (+0900) Subject: LU-9289 nodemap: fix fileset string length issue X-Git-Tag: 2.9.59~52 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=7a32eff39c8b4bd17f173a62293374c5b4ff04e1 LU-9289 nodemap: fix fileset string length issue In nodemap_fileset_seq_write(), it is necessary to allocate count+1 for nm_fileset in order to have a '0' at the end of the string got with copy_from_user(). Signed-off-by: Sebastien Buisson Change-Id: Id170e51648a8483c8d343d9f99f115bc04f798b3 Reviewed-on: https://review.whamcloud.com/26335 Reviewed-by: Andreas Dilger Reviewed-by: Emoly Liu Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/ptlrpc/nodemap_lproc.c b/lustre/ptlrpc/nodemap_lproc.c index c384785..6da0fd3 100644 --- a/lustre/ptlrpc/nodemap_lproc.c +++ b/lustre/ptlrpc/nodemap_lproc.c @@ -220,7 +220,8 @@ nodemap_fileset_seq_write(struct file *file, if (count > PATH_MAX) RETURN(-EINVAL); - OBD_ALLOC(nm_fileset, count); + OBD_ALLOC(nm_fileset, count + 1); + /* OBD_ALLOC zero-fills the buffer */ if (nm_fileset == NULL) RETURN(-ENOMEM); @@ -233,7 +234,7 @@ nodemap_fileset_seq_write(struct file *file, rc = count; out: - OBD_FREE(nm_fileset, count); + OBD_FREE(nm_fileset, count + 1); return rc; }