From 5f99bbe6c79d0479804bfa0f9565174964b55c3b Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" Date: Thu, 18 Sep 2014 18:51:59 -0700 Subject: [PATCH] LU-5150 mdc: Handle empty but non-zero acl xattr We have found that posix_acl_access can have a value of \002\000\000\000. In that case body->aclsize is non-zero, but the there are no actuall acls stored in the xattr. In mdc_unpack_acl(), it only checks IS_ERR() on the pointer returned by posix_acl_from_xattr(), it does not check for NULL. Because of the above situation, the xattr aclsize can be non-zero, but posic_acl_from_xattr() still returns NULL. Passing NULL to posix_acl_valid() crashes the kernel. We add a check to properly handle the NULL return value. This patch is back-ported from the following one: Lustre-commit: 867e301972278e397b57094810821ff884092fd8 Lustre-change: http://review.whamcloud.com/10620 Signed-off-by: Christopher J. Morrone Change-Id: I76fb2198e7233261ee65c6527d4f2b78f27022bc Reviewed-on: http://review.whamcloud.com/11989 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: Bob Glossman Reviewed-by: Oleg Drokin --- lustre/mdc/mdc_request.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 0aca920..4cfcf9a 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -489,6 +489,8 @@ static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md) RETURN(-EPROTO); acl = posix_acl_from_xattr(&init_user_ns, buf, body->aclsize); + if (acl == NULL) + RETURN(0); if (IS_ERR(acl)) { rc = PTR_ERR(acl); CERROR("convert xattr to acl: %d\n", rc); -- 1.8.3.1