From 384cd84489c9a7aa3145560002eb7a053cf4b2db Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Wed, 31 Jul 2019 18:12:40 +0200 Subject: [PATCH] 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 --- lustre/mdt/mdt_lib.c | 3 +++ 1 file changed, 3 insertions(+) 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; -- 1.8.3.1