pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Fix endless retry loop waiting for an upcall, 2025-08-28
Posted by Anonymous on Fri 29th Aug 2025 11:58
raw | new post

  1. From d88c616aa24581241ffb6af0ab32c8e361a099a9 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Thu, 28 Aug 2025 13:45:38 +0200
  4. Subject: [PATCH] sys: Prevent endless retry loop in
  5.  |nfs41_UpcallWaitForReply()| in case of many APCs or thread termination
  6.  
  7. Prevent endless retry loop in |nfs41_UpcallWaitForReply()| in case of many
  8. APCs or thread termination.
  9.  
  10. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  11. ---
  12. sys/nfs41sys_updowncall.c | 30 ++++++++++++++++++++++--------
  13.  1 file changed, 22 insertions(+), 8 deletions(-)
  14.  
  15. diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
  16. index cf9e4cf..badb38c 100644
  17. --- a/sys/nfs41sys_updowncall.c
  18. +++ b/sys/nfs41sys_updowncall.c
  19. @@ -524,8 +524,14 @@ NTSTATUS nfs41_UpcallWaitForReply(
  20.      if (entry->async_op)
  21.          goto out;
  22.  
  23. +    const ULONG tickIncrement = KeQueryTimeIncrement();
  24. +
  25. +    LARGE_INTEGER startTicks, currTicks;
  26. +    KeQueryTickCount(&startTicks);
  27. +
  28.      LARGE_INTEGER timeout;
  29.      timeout.QuadPart = RELATIVE(SECONDS(secs));
  30. +
  31.  retry_wait:
  32.      status = KeWaitForSingleObject(&entry->cond, Executive,
  33.                  UserMode, FALSE, &timeout);
  34. @@ -542,14 +548,22 @@ retry_wait:
  35.          break;
  36.      case STATUS_USER_APC:
  37.      case STATUS_ALERTED:
  38. -        DbgP("nfs41_UpcallWaitForReply: KeWaitForSingleObject() "
  39. -            "returned status(=0x%lx), "
  40. -            "retry waiting for '%s' entry=0x%p xid=%lld\n",
  41. -            (long)status,
  42. -            ENTRY_OPCODE2STRING(entry),
  43. -            entry,
  44. -            (entry?entry->xid:-1LL));
  45. -        if (entry) {
  46. +        /*
  47. +         * Check for timeout here, because |KeWaitForSingleObject()| does not
  48. +         * decrement the timout value.
  49. +         * This prevents endless retry loops in case of APC storms or
  50. +         * that the calling thread is in the process of being terminated.
  51. +         */
  52. +        KeQueryTickCount(&currTicks);
  53. +        if (((currTicks.QuadPart - startTicks.QuadPart) * tickIncrement) <=
  54. +            SECONDS(secs)) {
  55. +            DbgP("nfs41_UpcallWaitForReply: KeWaitForSingleObject() "
  56. +                "returned status(=0x%lx), "
  57. +                "retry waiting for '%s' entry=0x%p xid=%lld\n",
  58. +                (long)status,
  59. +                ENTRY_OPCODE2STRING(entry),
  60. +                entry,
  61. +                entry->xid);
  62.              goto retry_wait;
  63.          }
  64.          /* fall-through */
  65. --
  66. 2.45.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