pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: SetupExeNotStarting, SysUserAPCLoop, WinSGRefix+misc, 2024-05-27
Posted by Anonymous on Mon 27th May 2024 16:13
raw | new post

  1. From feff77f103c9cf51ff08be404c3a49cd0ccf2659 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Mon, 27 May 2024 11:31:29 +0200
  4. Subject: [PATCH 1/4] cygwin,tests: Add newgrp(1)/sg(1)-style "winsg" util to
  5.  switch primary group [refix]
  6.  
  7. Add missing Makefile for "winsg" utility
  8.  
  9. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  10. ---
  11. tests/winsg/Makefile | 23 +++++++++++++++++++++++
  12.  1 file changed, 23 insertions(+)
  13.  create mode 100644 tests/winsg/Makefile
  14.  
  15. diff --git a/tests/winsg/Makefile b/tests/winsg/Makefile
  16. new file mode 100644
  17. index 0000000..19f96db
  18. --- /dev/null
  19. +++ b/tests/winsg/Makefile
  20. @@ -0,0 +1,23 @@
  21. +#
  22. +# Makefile for winsg
  23. +#
  24. +
  25. +# POSIX Makefile
  26. +
  27. +all: winsg.i686.exe winsg.x86_64.exe winsg.exe
  28. +
  29. +winsg.i686.exe: winsg.c
  30. +       clang -target i686-pc-windows-gnu -Wall -DUNICODE=1 -D_UNICODE=1 -g winsg.c -o winsg.i686.exe
  31. +
  32. +winsg.x86_64.exe: winsg.c
  33. +       clang -target x86_64-pc-windows-gnu -Wall -DUNICODE=1 -D_UNICODE=1 -g winsg.c -o winsg.x86_64.exe
  34. +
  35. +winsg.exe: winsg.x86_64.exe
  36. +       ln -s winsg.x86_64.exe winsg.exe
  37. +
  38. +clean:
  39. +       rm -fv \
  40. +               winsg.i686.exe \
  41. +               winsg.x86_64.exe \
  42. +               winsg.exe \
  43. +# EOF.
  44. --
  45. 2.43.0
  46.  
  47. From 4e8f4e6892691682d795f11d6e423dc9c7589cd0 Mon Sep 17 00:00:00 2001
  48. From: Roland Mainz <roland.mainz@nrubsig.org>
  49. Date: Mon, 27 May 2024 15:31:46 +0200
  50. Subject: [PATCH 2/4] sys,tests: Cannot run Cygwin setup.exe on NFSv4.1 share
  51.  
  52. Fix the problem that Cygwin setup.exe could not start from
  53. a NFSv4.1 share.
  54.  
  55. |SeCreateClientSecurityFromSubjectContext()| had |ServerIsRemote|
  56. set to |TRUE|, which caused "Activation Context" creation to fail
  57. in our driver code in |SeCreateClientSecurityFromSubjectContext()|
  58. with |STATUS_BAD_IMPERSONATION_LEVEL|, as Cygwin setup.exe
  59. does some impersonation stunts itself.
  60.  
  61. The fix switches |ServerIsRemote=FALSE| + we add
  62. a testcase entry to tests/manual_testing.txt
  63.  
  64. Reported-by: Martin Wege <martin.l.wege@gmail.com>
  65. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  66. ---
  67. sys/nfs41_driver.c       | 30 ++++++++++++++++++++++++++----
  68.  tests/manual_testing.txt |  8 ++++++++
  69.  2 files changed, 34 insertions(+), 4 deletions(-)
  70.  
  71. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  72. index 57dac0a..2f512c2 100644
  73. --- a/sys/nfs41_driver.c
  74. +++ b/sys/nfs41_driver.c
  75. @@ -1545,8 +1545,15 @@ NTSTATUS nfs41_UpcallCreate(
  76.          sec_qos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
  77.          sec_qos.EffectiveOnly = 0;
  78.          entry->psec_ctx = &entry->sec_ctx;
  79. +        /*
  80. +         * Arg |ServerIsRemote| must be |FALSE|, otherwise processes
  81. +         * like Cygwin setup-x86_64.exe can fail during "Activation
  82. +         * Context" creation in
  83. +         * |SeCreateClientSecurityFromSubjectContext()| with
  84. +         * |STATUS_BAD_IMPERSONATION_LEVEL|
  85. +         */
  86.          status = SeCreateClientSecurityFromSubjectContext(&sec_ctx, &sec_qos,
  87. -                    1, entry->psec_ctx);
  88. +                    FALSE, entry->psec_ctx);
  89.          if (status != STATUS_SUCCESS) {
  90.              print_error("nfs41_UpcallCreate: "
  91.                  "SeCreateClientSecurityFromSubjectContext failed with %x\n",
  92. @@ -3045,8 +3052,15 @@ NTSTATUS nfs41_GetLUID(
  93.      sec_qos.ImpersonationLevel = SecurityIdentification;
  94.      sec_qos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
  95.      sec_qos.EffectiveOnly = 0;
  96. -    status = SeCreateClientSecurityFromSubjectContext(&sec_ctx, &sec_qos, 1,
  97. -                &clnt_sec_ctx);
  98. +    /*
  99. +     * Arg |ServerIsRemote| must be |FALSE|, otherwise processes
  100. +     * like Cygwin setup-x86_64.exe can fail during "Activation
  101. +     * Context" creation in
  102. +     * |SeCreateClientSecurityFromSubjectContext()| with
  103. +     * |STATUS_BAD_IMPERSONATION_LEVEL|
  104. +     */
  105. +    status = SeCreateClientSecurityFromSubjectContext(&sec_ctx, &sec_qos,
  106. +        FALSE, &clnt_sec_ctx);
  107.      if (status) {
  108.          print_error("nfs41_GetLUID: SeCreateClientSecurityFromSubjectContext "
  109.               "failed %x\n", status);
  110. @@ -3078,7 +3092,15 @@ NTSTATUS nfs41_get_sec_ctx(
  111.      sec_qos.ImpersonationLevel = level;
  112.      sec_qos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
  113.      sec_qos.EffectiveOnly = 0;
  114. -    status = SeCreateClientSecurityFromSubjectContext(&ctx, &sec_qos, 1, out_ctx);
  115. +    /*
  116. +     * Arg |ServerIsRemote| must be |FALSE|, otherwise processes
  117. +     * like Cygwin setup-x86_64.exe can fail during "Activation
  118. +     * Context" creation in
  119. +     * |SeCreateClientSecurityFromSubjectContext()| with
  120. +     * |STATUS_BAD_IMPERSONATION_LEVEL|
  121. +     */
  122. +    status = SeCreateClientSecurityFromSubjectContext(&ctx, &sec_qos,
  123. +        FALSE, out_ctx);
  124.      if (status != STATUS_SUCCESS) {
  125.          print_error("SeCreateClientSecurityFromSubjectContext "
  126.              "failed with %x\n", status);
  127. diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
  128. index 50029e0..7ce7c2f 100644
  129. --- a/tests/manual_testing.txt
  130. +++ b/tests/manual_testing.txt
  131. @@ -271,4 +271,12 @@ autoreconf
  132.  make -j8 all
  133.  
  134.  
  135. +#
  136. +# Run Cygwin installer from NFSv4.1 share
  137. +#
  138. +wget 'https://www.cygwin.com/setup-x86_64.exe'
  139. +chmod a+rx setup-x86_64.exe
  140. +# check whether this will open the Cygwin installer window
  141. +./setup-x86_64 --no-admin
  142. +
  143.  # EOF.
  144. --
  145. 2.43.0
  146.  
  147. From 5ef218798d5fc376e5d56a764e949127f15c464b Mon Sep 17 00:00:00 2001
  148. From: Roland Mainz <roland.mainz@nrubsig.org>
  149. Date: Mon, 27 May 2024 15:44:31 +0200
  150. Subject: [PATCH 3/4] sys: Endless loop in |nfs41_UpcallWaitForReply()| with
  151.  |STATUS_USER_APC|
  152.  
  153. Fix an endless loop in |nfs41_UpcallWaitForReply()| where
  154. |KeWaitForSingleObject()| is always interrupted with |STATUS_USER_APC|.
  155. This happens if cygwin1.dll and the binary which uses it is on
  156. an NFSv4.1 share.
  157.  
  158. Reported-by: Martin Wege <martin.l.wege@gmail.com>
  159. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  160. ---
  161. sys/nfs41_driver.c | 2 +-
  162.  1 file changed, 1 insertion(+), 1 deletion(-)
  163.  
  164. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  165. index 2f512c2..d05025c 100644
  166. --- a/sys/nfs41_driver.c
  167. +++ b/sys/nfs41_driver.c
  168. @@ -1612,7 +1612,7 @@ NTSTATUS nfs41_UpcallWaitForReply(
  169.      timeout.QuadPart = RELATIVE(SECONDS(secs));
  170.  retry_wait:
  171.      status = KeWaitForSingleObject(&entry->cond, Executive,
  172. -                UserMode, TRUE, &timeout);
  173. +                UserMode, FALSE, &timeout);
  174.  
  175.      if (status == STATUS_TIMEOUT)
  176.              status = STATUS_NETWORK_UNREACHABLE;
  177. --
  178. 2.43.0
  179.  
  180. From ff9933cbdd530829d0e894823135faf6a3d54faa Mon Sep 17 00:00:00 2001
  181. From: Roland Mainz <roland.mainz@nrubsig.org>
  182. Date: Mon, 27 May 2024 15:52:26 +0200
  183. Subject: [PATCH 4/4] cygwin: Fixup permissions for binaries in /bin too
  184.  
  185. Fixup permissions (chmod a+rx *.exe) for binaries in /bin too
  186.  
  187. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  188. ---
  189. cygwin/Makefile.install | 1 +
  190.  1 file changed, 1 insertion(+)
  191.  
  192. diff --git a/cygwin/Makefile.install b/cygwin/Makefile.install
  193. index aa0e9df..5aa2cc1 100644
  194. --- a/cygwin/Makefile.install
  195. +++ b/cygwin/Makefile.install
  196. @@ -92,6 +92,7 @@ installdest:
  197.                 cp '/cygdrive/c/Program Files (x86)/Windows Kits/10/bin/x86/ucrt/ucrtbased.dll' $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/. ; \
  198.         fi
  199.         @ printf "# Set file flags\n"
  200. +       (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/bin/ && chmod a+rx *.exe)
  201.         (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/ && chmod a+rx *.exe *.dll)
  202.         (cd $(DESTDIR)/$(CYGWIN_BASEPATH)/lib/msnfs41client/ && chmod a+rx *.dll)
  203.         @printf "\n#\n# TEST sbin dir is %s\n#\n" "$(DESTDIR)/$(CYGWIN_BASEPATH)/sbin/"
  204. --
  205. 2.43.0

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