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

usercopy exposure attempt detected in LL_IOC_LOV_GETSTRIPE ioctl

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • Lustre 2.14.0, Lustre 2.12.5
    • Upstream
    • None
    • CentOS 7.6.1810, starting with kernel 3.10.0-957
    • 3
    • 9223372036854775807

    Description

      Software like darshan are still using the old `ioctl` way to gather striping info for a file.

      The kernel BUG is easily triggered on a not-PFL striped file, using:

      lum->lmm_magic = LOV_USER_MAGIC;
      lum->lmm_stripe_count = LOV_MAX_STRIPE_COUNT;
      

      Any `lmm_stripe_count` greater than the actual file's stripe count will trigger the bug.

      Kernel side the issue appears to be in `lov_getstripe`: with a positive `lum_size`(line 409), `lmm_size` is set as `lum_size`(line 442) even if `lmm_magic != LOV_MAGIC_COMP_V1`(line 414), while instead the structure is just as big as `lmmk_size`:

      404         if (lum.lmm_magic == LOV_USER_MAGIC_V1 ||
      405             lum.lmm_magic == LOV_USER_MAGIC_V3)
      406                 lum_size = lov_user_md_size(lum.lmm_stripe_count,
      407                                             lum.lmm_magic);
      408 
      409         if (lum_size != 0) {
      410                 struct lov_mds_md *comp_md = lmmk;
      411 
      412                 /* Legacy app (ADIO for instance) treats the layout as V1/V3
      413                  * blindly, we'd return a reasonable V1/V3 for them. */
      414                 if (lmmk->lmm_magic == LOV_MAGIC_COMP_V1) {
      [...]
      439                 }
      440 
      441                 lmm = comp_md;
      442                 lmm_size = lum_size;
      443         } else {
      444                 lmm = lmmk;
      445                 lmm_size = lmmk_size;
      446         }
      447         /**
      448          * User specified limited buffer size, usually the buffer is
      449          * from ll_lov_setstripe(), and the buffer can only hold basic
      450          * layout template info.
      451          */
      452         if (size == 0 || size > lmm_size)
      453                 size = lmm_size;
      454         if (copy_to_user(lump, lmm, size))
      455                 GOTO(out_free, rc = -EFAULT);
      

      Please find as attachment the kernel trace and a reproducer, to be invoked as:

      $ gcc reproducer.c -o reproducer -W -Wall --pedantic
      $ ./reproducer <file_path>
      

      Attachments

        Issue Links

          Activity

            [LU-12580] usercopy exposure attempt detected in LL_IOC_LOV_GETSTRIPE ioctl
            adilger Andreas Dilger made changes -
            Link New: This issue is related to LU-14316 [ LU-14316 ]
            adilger Andreas Dilger made changes -
            Link New: This issue is duplicated by LU-13596 [ LU-13596 ]
            pjones Peter Jones made changes -
            Link Original: This issue is related to JFC-17 [ JFC-17 ]
            pjones Peter Jones made changes -
            Link New: This issue is related to JFC-20 [ JFC-20 ]
            pjones Peter Jones made changes -
            Labels Original: LTS12
            pjones Peter Jones made changes -
            Fix Version/s New: Lustre 2.12.5 [ 14696 ]

            Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/38051/
            Subject: LU-12580 lov: fix out of bound usercopy
            Project: fs/lustre-release
            Branch: b2_12
            Current Patch Set:
            Commit: d4dd52a3a1dea9e6117512889837e245fb983556

            gerrit Gerrit Updater added a comment - Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/38051/ Subject: LU-12580 lov: fix out of bound usercopy Project: fs/lustre-release Branch: b2_12 Current Patch Set: Commit: d4dd52a3a1dea9e6117512889837e245fb983556

            Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/38050/
            Subject: LU-12580 lov: fix typo in lov_comp_md_size
            Project: fs/lustre-release
            Branch: b2_12
            Current Patch Set:
            Commit: 13dc723aea39c60d8ed128a312fba1520921c792

            gerrit Gerrit Updater added a comment - Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/38050/ Subject: LU-12580 lov: fix typo in lov_comp_md_size Project: fs/lustre-release Branch: b2_12 Current Patch Set: Commit: 13dc723aea39c60d8ed128a312fba1520921c792

            Minh Diep (mdiep@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/38051
            Subject: LU-12580 lov: fix out of bound usercopy
            Project: fs/lustre-release
            Branch: b2_12
            Current Patch Set: 1
            Commit: b47ff3cd33984e72fc2f59032ad8147074628d28

            gerrit Gerrit Updater added a comment - Minh Diep (mdiep@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/38051 Subject: LU-12580 lov: fix out of bound usercopy Project: fs/lustre-release Branch: b2_12 Current Patch Set: 1 Commit: b47ff3cd33984e72fc2f59032ad8147074628d28

            Minh Diep (mdiep@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/38050
            Subject: LU-12580 lov: fix typo in lov_comp_md_size
            Project: fs/lustre-release
            Branch: b2_12
            Current Patch Set: 1
            Commit: 865177bca926efd4f69d4dcaa74624054a2a5aaf

            gerrit Gerrit Updater added a comment - Minh Diep (mdiep@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/38050 Subject: LU-12580 lov: fix typo in lov_comp_md_size Project: fs/lustre-release Branch: b2_12 Current Patch Set: 1 Commit: 865177bca926efd4f69d4dcaa74624054a2a5aaf

            People

              mgrossi Marco Grossi (Inactive)
              mgrossi Marco Grossi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: