Whamcloud - gitweb
LU-12602 mdt: more EA size check in mdt_getxattr_pack_reply() 08/36208/3
authorEmoly Liu <emoly@whamcloud.com>
Mon, 9 Sep 2019 08:10:29 +0000 (16:10 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 23 Sep 2019 08:43:38 +0000 (08:43 +0000)
While the RMF_EAVALS field size can be arbitrary length,
the RMF_EAVALS_LENS field definition specifies
the RMF_F_STRUCT_ARRAY flag, so the passed size must be a multiple
of sizeof(__u32) or the internal LBUG() will trigger.

Lustre-change: https://review.whamcloud.com/36103
Lustre-commit: 4d8bc239c2c30a47e8833cf23db6ccd39ff61705

Signed-off-by: Emoly Liu <emoly@whamcloud.com>
Change-Id: I767e1b1496298e9a66274fc324f9c34daaed4a09
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/36208
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/mdt/mdt_xattr.c

index 4c362a3..82d94c7 100644 (file)
@@ -97,9 +97,11 @@ static int mdt_getxattr_pack_reply(struct mdt_thread_info * info)
                /* We could calculate accurate sizes, but this would
                 * introduce a lot of overhead, let's do it later... */
                size = info->mti_body->mbo_eadatasize;
-               if (size <= 0 || size > info->mti_mdt->mdt_max_ea_size) {
-                       CERROR("%s: invalid EA size(%d) for FLXATTRALL\n",
-                              mdt_obd_name(info->mti_mdt), size);
+               if (size <= 0 || size > info->mti_mdt->mdt_max_ea_size ||
+                   size & (sizeof(__u32) - 1)) {
+                       DEBUG_REQ(D_ERROR, req,
+                                 "%s: invalid EA size(%d) for FLXATTRALL\n",
+                                 mdt_obd_name(info->mti_mdt), size);
                        RETURN(-EINVAL);
                }
                req_capsule_set_size(pill, &RMF_EAVALS, RCL_SERVER, size);