Whamcloud - gitweb
LU-14740 quota: reject invalid project id on server side 39/44339/2
authorWang Shilong <wshilong@ddn.com>
Mon, 19 Jul 2021 07:14:43 +0000 (15:14 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 10 Aug 2021 08:07:59 +0000 (08:07 +0000)
do sanity check before transfer project ID, reject invalid
project id if it comes from some older clients.

Test-parameters: trivial testlist=sanity-quota

Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: If89e320c7808d188e615f5f0923c2322774b2ceb
Reviewed-on: https://review.whamcloud.com/44339
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-zfs/osd_object.c

index 3b46322..f2fedaa 100644 (file)
@@ -3088,6 +3088,8 @@ static int osd_quota_transfer(struct inode *inode, const struct lu_attr *attr,
        /* Handle project id transfer here properly */
        if (attr->la_valid & LA_PROJID &&
            attr->la_projid != i_projid_read(inode)) {
+               if (!projid_valid(make_kprojid(&init_user_ns, attr->la_projid)))
+                       return -EINVAL;
 #ifdef HAVE_PROJECT_QUOTA
                rc = osd_transfer_project(inode, attr->la_projid, handle);
 #else
index 464e0d6..ffec3d3 100644 (file)
@@ -1204,6 +1204,9 @@ static int osd_declare_attr_set(const struct lu_env *env,
                        if (!osd->od_projectused_dn)
                                GOTO(out, rc = -EOPNOTSUPP);
 
+                       if (!projid_valid(make_kprojid(&init_user_ns, attr->la_projid)))
+                               GOTO(out, rc = -EINVAL);
+
                        /* Usually, if project quota is upgradable for the
                         * device, then the upgrade will be done before or when
                         * mount the device. So when we come here, this project