[177/622] lustre: obdclass: lu_dirent record length missing '0'
diff mbox series

Message ID 1582838290-17243-178-git-send-email-jsimmons@infradead.org
State New
Headers show
Series
  • lustre: sync closely to 2.13.52
Related show

Commit Message

James Simmons Feb. 27, 2020, 9:10 p.m. UTC
From: Lai Siyao <lai.siyao@whamcloud.com>

In lu_dirent packing, a '0' is appended after name, but it's not
counted in size calcuation, which may cause crash.

WC-bug-id: https://jira.whamcloud.com/browse/LU-11753
Lustre-commit: 77f01308c509 ("LU-11753 obdclass: lu_dirent record length missing '0'")
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/33865
Reviewed-by: Stephan Thiell <sthiell@stanford.edu>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 include/uapi/linux/lustre/lustre_idl.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/include/uapi/linux/lustre/lustre_idl.h b/include/uapi/linux/lustre/lustre_idl.h
index 599fe86..4236a43 100644
--- a/include/uapi/linux/lustre/lustre_idl.h
+++ b/include/uapi/linux/lustre/lustre_idl.h
@@ -480,10 +480,11 @@  static inline size_t lu_dirent_calc_size(size_t namelen, __u16 attr)
 	if (attr & LUDA_TYPE) {
 		const size_t align = sizeof(struct luda_type) - 1;
 
-		size = (sizeof(struct lu_dirent) + namelen + align) & ~align;
+		size = (sizeof(struct lu_dirent) + namelen + 1 + align) &
+		       ~align;
 		size += sizeof(struct luda_type);
 	} else {
-		size = sizeof(struct lu_dirent) + namelen;
+		size = sizeof(struct lu_dirent) + namelen + 1;
 	}
 
 	return (size + 7) & ~7;