pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


0001-mount-sys-nfs41_driver-Unaligned-mount-data-can-lead.patch
Posted by Anonymous on Fri 15th Dec 2023 16:13
raw | new post

  1. From b850ea10692f8eb7c39b7015b42009c22d4868e1 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Fri, 15 Dec 2023 12:39:30 +0100
  4. Subject: [PATCH] mount,sys/nfs41_driver: Unaligned mount data can lead to
  5.  mount failure
  6.  
  7. Make sure |FILE_FULL_EA_INFORMATION| data is properly longword-aligned,
  8. (as mandated by
  9. https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ns-wdm-_file_full_ea_information)
  10.  
  11. Previously the alignment was only 32bit (|ULONG| for 32bit platform)
  12. aligned, which lead to random mount failures on 64bit platforms
  13. (where |ULONG| is a 64bit datatype).
  14.  
  15. The patch also adds |IoCheckEaBufferValidity()| to
  16. |nfs41_MountConfig_ParseOptions()|, to make sure we validate the
  17. mount data and get a proper error code if they are not valid.
  18.  
  19. Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
  20. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  21. ---
  22.  mount/options.c    |  2 +-
  23.  sys/nfs41_driver.c | 17 +++++++++++++++++
  24.  2 files changed, 18 insertions(+), 1 deletion(-)
  25.  
  26. diff --git a/mount/options.c b/mount/options.c
  27. index 73649cc..f254d6d 100644
  28. --- a/mount/options.c
  29. +++ b/mount/options.c
  30. @@ -86,7 +86,7 @@ static FORCEINLINE ULONG EaBufferSize(
  31.          + NameSize + ValueSize + sizeof(TCHAR);
  32.      /* extended attributes require ULONG alignment;
  33.       * see documentation for IoCheckEaBufferValidity() */
  34. -    return ( (Size + 3) / sizeof(ULONG) ) * sizeof(ULONG);
  35. +    return ( (Size + (sizeof(ULONG)-1)) / sizeof(ULONG) ) * sizeof(ULONG);
  36.  }
  37.  
  38.  static FORCEINLINE ULONG EaBufferNextOffset(
  39. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  40. index e2919b9..457ce03 100644
  41. --- a/sys/nfs41_driver.c
  42. +++ b/sys/nfs41_driver.c
  43. @@ -2760,6 +2760,17 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  44.      LPWSTR Name;
  45.      size_t NameLen;
  46.      UNICODE_STRING  usValue;
  47. +    ULONG error_offset;
  48. +
  49. +    status = IoCheckEaBufferValidity(EaBuffer, EaLength, &error_offset);
  50. +    if (status) {
  51. +        DbgP("status(=%d)=IoCheckEaBufferValidity"
  52. +            "(eainfo=%p, buflen=%lu, &(error_offset=%d)) failed\n",
  53. +            (int)status, (void *)EaBuffer, EaLength,
  54. +            (int)error_offset);
  55. +        goto out;
  56. +    }
  57. +
  58.      Option = EaBuffer;
  59.      while (status == STATUS_SUCCESS) {
  60.          DbgP("Option=%p\n", (void *)Option);
  61. @@ -2857,6 +2868,7 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
  62.              ((PBYTE)Option + Option->NextEntryOffset);
  63.      }
  64.  
  65. +out:
  66.      DbgP("<-- nfs41_MountConfig_ParseOptions, status=%ld\n", (long)status);
  67.      return status;
  68.  }
  69. @@ -4797,6 +4809,11 @@ NTSTATUS nfs41_SetEaInformation(
  70.          entry->u.SetEa.mode = 0;
  71.          status = IoCheckEaBufferValidity(eainfo, buflen, &error_offset);
  72.          if (status) {
  73. +            DbgP("nfs41_SetEaInformation: "
  74. +                "status(=%d)=IoCheckEaBufferValidity"
  75. +                "(eainfo=%p, buflen=%lu, &(error_offset=%d))\n",
  76. +                (int)status, (void *)eainfo, buflen,
  77. +                (int)error_offset);
  78.              RxFreePool(entry);
  79.              goto out;
  80.          }
  81. --
  82. 2.42.1

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at