From: Sebastien Buisson Date: Wed, 31 Jul 2019 16:12:40 +0000 (+0200) Subject: LU-12604 mdt: check field size of sec context name X-Git-Tag: 2.12.57~38 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=384cd84489c9a7aa3145560002eb7a053cf4b2db LU-12604 mdt: check field size of sec context name In request received from client, check that claimed size of RMF_FILE_SECCTX_NAME field is consistent with expected content, which is supposed to be an extended attribute name. Test-Parameters: clientselinux testlist=sanity,recovery-small,sanity-selinux envdefinitions=SANITY_EXCEPT="271f" Reported-by: Alibaba Cloud Signed-off-by: Sebastien Buisson Change-Id: Ice96f0e03f790b334fcdf64ae4becef2e39738f4 Reviewed-on: https://review.whamcloud.com/35655 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Patrick Farrell Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index a970511..a09997d 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -1068,6 +1068,9 @@ static int mdt_file_secctx_unpack(struct req_capsule *pill, if (name_size == 0) return 0; + if (name_size > XATTR_NAME_MAX + 1) + return -EPROTO; + name = req_capsule_client_get(pill, &RMF_FILE_SECCTX_NAME); if (strnlen(name, name_size) != name_size - 1) return -EPROTO;