Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-11108

mdt_getxattr() may clobber errors from mo_xattr_get()

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • Lustre 2.12.0
    • None
    • 3
    • 9223372036854775807

    Description

      In mdt_getxattr() we have the following:

              if (valid == OBD_MD_FLXATTR) {
                      const char *xattr_name = req_capsule_client_get(info->mti_pill,
                                                                      &RMF_NAME);
                      rc = mo_xattr_get(info->mti_env, next, buf, xattr_name);
                      rc = mdt_nodemap_map_acl(info, buf->lb_buf, rc, xattr_name,
                                               NODEMAP_FS_TO_CLIENT);
              } ...
      

      If rc is negative then when passed to the size_t size parameter of mdt_nodemap_map_acl() it becomes very large and may be replaced with -ERANGE.

      static int mdt_nodemap_map_acl(struct mdt_thread_info *info, void *buf,
                                     size_t size, const char *name,
                                     enum nodemap_tree_type tree_type)
      {
              struct lu_nodemap      *nodemap;
              struct obd_export      *exp = info->mti_exp;
              int                     rc = size;
      
              ENTRY;
      
              if (strcmp(name, XATTR_NAME_ACL_ACCESS) == 0 ||
                  strcmp(name, XATTR_NAME_ACL_DEFAULT) == 0) {
                      if (size > info->mti_mdt->mdt_max_ea_size ||
                           (!exp_connect_large_acl(exp) &&
                            size > LUSTRE_POSIX_ACL_MAX_SIZE_OLD))
                              GOTO(out, rc = -ERANGE);
      
                      nodemap = nodemap_get_from_exp(exp);
                      if (IS_ERR(nodemap))
                              GOTO(out, rc = PTR_ERR(nodemap));
      
                      rc = nodemap_map_acl(nodemap, buf, size, tree_type);
                      nodemap_putref(nodemap);
                      if (rc < 0)
                              GOTO(out, rc);
              }
      out:
              RETURN(rc);
      }
      

      I noticed this while looking at LU-11074 but this is not the underlying cause of that bug.

      Attachments

        Activity

          [LU-11108] mdt_getxattr() may clobber errors from mo_xattr_get()
          pjones Peter Jones made changes -
          Fix Version/s New: Lustre 2.12.0 [ 13495 ]
          Resolution New: Fixed [ 1 ]
          Status Original: In Progress [ 3 ] New: Resolved [ 5 ]
          jhammond John Hammond made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          jhammond John Hammond made changes -
          Assignee Original: WC Triage [ wc-triage ] New: John Hammond [ jhammond ]
          jhammond John Hammond created issue -

          People

            jhammond John Hammond
            jhammond John Hammond
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: