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

error return value of listxattr when buffer is not large enough

Details

    • Bug
    • Resolution: Fixed
    • Major
    • Lustre 2.5.0
    • Lustre 2.3.0, Lustre 1.8.9
    • 3
    • 8420

    Description

      According to the standard, listxattr(2) should return -1 and errno should be set to ERANGE if the size of the list buffer is too small to hold the result. However ll_listxattr() will return a value bigger than the size of buffer in some cases.

      Let's assume listxattr(2) returns SIZE when it is called with a large enough list buffer. If it's called with a list buffer whose size is smaller than SIZE but bigger than (SIZE - 12), then listxattr(2) will return SIZE too. I believe it is not a correct result.

      Attached file 'read_xattr.c' is the code which can reproduce the problem. It runs perfectly on normal file system, but fails on Lustre.

      Attached file 'listxattr.patch' is the patch that fixed the problem. The program of 'read_xattr.c' runs well when the patch is applied.

      Attachments

        1. listxattr.patch
          0.5 kB
          Li Xi
        2. read_xattr.c
          1 kB
          Li Xi

        Activity

          [LU-3403] error return value of listxattr when buffer is not large enough

          Patches have landed to Master. Please let me know if more work is needed in this ticket and I will reopen.

          jlevi Jodi Levi (Inactive) added a comment - Patches have landed to Master. Please let me know if more work is needed in this ticket and I will reopen.

          I have added a test for this issue. It is dependant on the fix.

          It can be seen here: http://review.whamcloud.com/6594

          keith Keith Mannthey (Inactive) added a comment - I have added a test for this issue. It is dependant on the fix. It can be seen here: http://review.whamcloud.com/6594

          We can use the test program like this:

          gcc read_xattr.c -o read_xattr
          ./read_xattr /mnt/lustre/some_file

          When it is run on Lustre without the fix patch, it will compain and exit. When it is run on Lustre with the patch, everything is OK.

          lixi Li Xi (Inactive) added a comment - We can use the test program like this: gcc read_xattr.c -o read_xattr ./read_xattr /mnt/lustre/some_file When it is run on Lustre without the fix patch, it will compain and exit. When it is run on Lustre with the patch, everything is OK.

          Perhaps we can add this test as well. How should your program be used to detect this error?

          keith Keith Mannthey (Inactive) added a comment - Perhaps we can add this test as well. How should your program be used to detect this error?
          pjones Peter Jones added a comment -

          Thanks Li Xi!

          Keith

          Can you please review this patch and in particular whether a similar issue exists on master

          Thanks

          Peter

          pjones Peter Jones added a comment - Thanks Li Xi! Keith Can you please review this patch and in particular whether a similar issue exists on master Thanks Peter

          I've pushed the patch into gerrit. http://review.whamcloud.com/#change,6463

          lixi Li Xi (Inactive) added a comment - I've pushed the patch into gerrit. http://review.whamcloud.com/#change,6463
          pjones Peter Jones added a comment -

          ok thanks li xi!

          pjones Peter Jones added a comment - ok thanks li xi!

          Hi Peter,

          Sure. I'm pushing the patch to the gerrit. It will be finished soon.

          And I'm sorry if the 'blocker' option bothers you. The bug affected an application months ago. But we walked aroud it. So I'd like to change it if it's possible to.

          Thanks
          Li Xi

          lixi Li Xi (Inactive) added a comment - Hi Peter, Sure. I'm pushing the patch to the gerrit. It will be finished soon. And I'm sorry if the 'blocker' option bothers you. The bug affected an application months ago. But we walked aroud it. So I'd like to change it if it's possible to. Thanks Li Xi
          pjones Peter Jones added a comment -

          Hi Li Xi

          I know that you are familiar with gerrit because I saw you upload a patch there recently. Please can you upload any patches you would like us to review into gerrit? This both allows our automated testing to verify the patch and also serves as the signoff permission for us to land the patch into the Lustre tree.

          Thanks

          Peter

          PS/ Also, I am unclear why you have marked this as a blocker. Could you please elaborate?

          pjones Peter Jones added a comment - Hi Li Xi I know that you are familiar with gerrit because I saw you upload a patch there recently. Please can you upload any patches you would like us to review into gerrit? This both allows our automated testing to verify the patch and also serves as the signoff permission for us to land the patch into the Lustre tree. Thanks Peter PS/ Also, I am unclear why you have marked this as a blocker. Could you please elaborate?

          People

            keith Keith Mannthey (Inactive)
            lixi Li Xi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: