pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for driver noexec mappings+upcall init opt, 2024-05-15
Posted by Anonymous on Thu 16th May 2024 13:59
raw | new post

  1. From 7db6599772eade9267645389b68d06f424afbdf5 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Wed, 15 May 2024 15:38:33 +0200
  4. Subject: [PATCH 1/2] sys: nfs41_driver.sys should use non-executable
  5.  memory+mappings
  6.  
  7. nfs41_driver.sys should use non-executable memory (|NonPagedPoolNx|)
  8. and mappings (|MdlMappingNoExecute|, not NOT for read/write buffers!).
  9.  
  10. Reported-by: Martin Wege <martin.l.wege@gmail.com>
  11. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  12. ---
  13. sys/nfs41_driver.c | 26 ++++++++++++++------------
  14.  1 file changed, 14 insertions(+), 12 deletions(-)
  15.  
  16. diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c
  17. index 665745f..f35793d 100644
  18. --- a/sys/nfs41_driver.c
  19. +++ b/sys/nfs41_driver.c
  20. @@ -752,7 +752,8 @@ NTSTATUS marshal_nfs41_open(
  21.          if (entry->u.Open.EaMdl) {
  22.              entry->u.Open.EaBuffer =
  23.                  MmMapLockedPagesSpecifyCache(entry->u.Open.EaMdl,
  24. -                    UserMode, MmCached, NULL, TRUE, NormalPagePriority);
  25. +                    UserMode, MmCached, NULL, TRUE,
  26. +                    NormalPagePriority|MdlMappingNoExecute);
  27.              if (entry->u.Open.EaBuffer == NULL) {
  28.                  print_error("marshal_nfs41_open: "
  29.                      "MmMapLockedPagesSpecifyCache() failed to "
  30. @@ -1012,7 +1013,8 @@ NTSTATUS marshal_nfs41_dirquery(
  31.      __try {
  32.          entry->u.QueryFile.mdl_buf =
  33.              MmMapLockedPagesSpecifyCache(entry->u.QueryFile.mdl,
  34. -                UserMode, MmCached, NULL, TRUE, NormalPagePriority);
  35. +                UserMode, MmCached, NULL, TRUE,
  36. +                NormalPagePriority|MdlMappingNoExecute);
  37.          if (entry->u.QueryFile.mdl_buf == NULL) {
  38.              print_error("marshal_nfs41_dirquery: "
  39.                  "MmMapLockedPagesSpecifyCache() failed to map pages\n");
  40. @@ -1514,7 +1516,7 @@ NTSTATUS nfs41_UpcallCreate(
  41.      SECURITY_SUBJECT_CONTEXT sec_ctx;
  42.      SECURITY_QUALITY_OF_SERVICE sec_qos;
  43.  
  44. -    entry = RxAllocatePoolWithTag(NonPagedPool, sizeof(nfs41_updowncall_entry),
  45. +    entry = RxAllocatePoolWithTag(NonPagedPoolNx, sizeof(nfs41_updowncall_entry),
  46.                  NFS41_MM_POOLTAG_UP);
  47.      if (entry == NULL) {
  48.          status = STATUS_INSUFFICIENT_RESOURCES;
  49. @@ -1835,7 +1837,7 @@ NTSTATUS unmarshal_nfs41_open(
  50.          *buf += sizeof(USHORT);
  51.          cur->u.Open.symlink.Length = cur->u.Open.symlink.MaximumLength -
  52.              sizeof(WCHAR);
  53. -        cur->u.Open.symlink.Buffer = RxAllocatePoolWithTag(NonPagedPool,
  54. +        cur->u.Open.symlink.Buffer = RxAllocatePoolWithTag(NonPagedPoolNx,
  55.              cur->u.Open.symlink.MaximumLength, NFS41_MM_POOLTAG);
  56.          if (cur->u.Open.symlink.Buffer == NULL) {
  57.              cur->status = STATUS_INSUFFICIENT_RESOURCES;
  58. @@ -1944,7 +1946,7 @@ NTSTATUS unmarshal_nfs41_getacl(
  59.  
  60.      RtlCopyMemory(&buf_len, *buf, sizeof(DWORD));
  61.      *buf += sizeof(DWORD);
  62. -    cur->buf = RxAllocatePoolWithTag(NonPagedPool,
  63. +    cur->buf = RxAllocatePoolWithTag(NonPagedPoolNx,
  64.          buf_len, NFS41_MM_POOLTAG_ACL);
  65.      if (cur->buf == NULL) {
  66.          cur->status = status = STATUS_INSUFFICIENT_RESOURCES;
  67. @@ -1990,7 +1992,7 @@ NTSTATUS nfs41_downcall(
  68.  
  69.      print_hexbuf(0, (unsigned char *)"downcall buffer", buf, in_len);
  70.  
  71. -    tmp = RxAllocatePoolWithTag(NonPagedPool, sizeof(nfs41_updowncall_entry),
  72. +    tmp = RxAllocatePoolWithTag(NonPagedPoolNx, sizeof(nfs41_updowncall_entry),
  73.              NFS41_MM_POOLTAG_DOWN);
  74.      if (tmp == NULL) goto out;
  75.  
  76. @@ -2653,7 +2655,7 @@ NTSTATUS _nfs41_CreateSrvCall(
  77.      }
  78.  
  79.      /* Let's create our own representation of the server */
  80. -    pServerEntry = (PNFS41_SERVER_ENTRY)RxAllocatePoolWithTag(NonPagedPool,
  81. +    pServerEntry = (PNFS41_SERVER_ENTRY)RxAllocatePoolWithTag(NonPagedPoolNx,
  82.          sizeof(NFS41_SERVER_ENTRY), NFS41_MM_POOLTAG);
  83.      if (pServerEntry == NULL) {
  84.          status = STATUS_INSUFFICIENT_RESOURCES;
  85. @@ -3145,7 +3147,7 @@ NTSTATUS nfs41_CreateVNetRoot(
  86.      pNetRoot->MRxNetRootState = MRX_NET_ROOT_STATE_GOOD;
  87.      pNetRoot->DeviceType = FILE_DEVICE_DISK;
  88.  
  89. -    Config = RxAllocatePoolWithTag(NonPagedPool,
  90. +    Config = RxAllocatePoolWithTag(NonPagedPoolNx,
  91.              sizeof(NFS41_MOUNT_CONFIG), NFS41_MM_POOLTAG);
  92.      if (Config == NULL) {
  93.          status = STATUS_INSUFFICIENT_RESOURCES;
  94. @@ -3346,7 +3348,7 @@ NTSTATUS nfs41_CreateVNetRoot(
  95.      if (!found_existing_mount) {
  96.          /* create a new mount entry and add it to the list */
  97.          nfs41_mount_entry *entry;
  98. -        entry = RxAllocatePoolWithTag(NonPagedPool, sizeof(nfs41_mount_entry),
  99. +        entry = RxAllocatePoolWithTag(NonPagedPoolNx, sizeof(nfs41_mount_entry),
  100.              NFS41_MM_POOLTAG_MOUNT);
  101.          if (entry == NULL) {
  102.              status = STATUS_INSUFFICIENT_RESOURCES;
  103. @@ -3980,7 +3982,7 @@ retry_on_link:
  104.          AbsPath.Length = DeviceObject->DeviceName.Length +
  105.              VNetRootPrefix->Length + entry->u.Open.symlink.Length;
  106.          AbsPath.MaximumLength = AbsPath.Length + sizeof(UNICODE_NULL);
  107. -        AbsPath.Buffer = RxAllocatePoolWithTag(NonPagedPool,
  108. +        AbsPath.Buffer = RxAllocatePoolWithTag(NonPagedPoolNx,
  109.              AbsPath.MaximumLength, NFS41_MM_POOLTAG);
  110.          if (AbsPath.Buffer == NULL) {
  111.              status = STATUS_INSUFFICIENT_RESOURCES;
  112. @@ -4155,7 +4157,7 @@ retry_on_link:
  113.              DbgP("nfs41_Create: received no delegations: srv_open=%p "
  114.                  "ctime=%llu\n", SrvOpen, entry->ChangeTime);
  115.  #endif
  116. -            oentry = RxAllocatePoolWithTag(NonPagedPool,
  117. +            oentry = RxAllocatePoolWithTag(NonPagedPoolNx,
  118.                  sizeof(nfs41_fcb_list_entry), NFS41_MM_POOLTAG_OPEN);
  119.              if (oentry == NULL) {
  120.                  status = STATUS_INSUFFICIENT_RESOURCES;
  121. @@ -6099,7 +6101,7 @@ void enable_caching(
  122.  #ifdef DEBUG_TIME_BASED_COHERENCY
  123.          DbgP("enable_caching: delegation recalled: srv_open=%p\n", SrvOpen);
  124.  #endif
  125. -        oentry = RxAllocatePoolWithTag(NonPagedPool,
  126. +        oentry = RxAllocatePoolWithTag(NonPagedPoolNx,
  127.              sizeof(nfs41_fcb_list_entry), NFS41_MM_POOLTAG_OPEN);
  128.          if (oentry == NULL) return;
  129.          oentry->fcb = SrvOpen->pFcb;
  130. --
  131. 2.43.0
  132.  
  133. From bd3598400d674ec4e71bd981dfcebda21dbaad75 Mon Sep 17 00:00:00 2001
  134. From: Roland Mainz <roland.mainz@nrubsig.org>
  135. Date: Wed, 15 May 2024 17:34:37 +0200
  136. Subject: [PATCH 2/2] daemon: |upcall_parse()| should only init data which are
  137.  actually used
  138.  
  139. |upcall_parse()| should only init data which are actually used,
  140. otherwise we init huge chunks of memory which are not even touched
  141. elsewhere in the code.
  142.  
  143. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  144. ---
  145. daemon/acl.c       | 14 ++++++++------
  146.  daemon/ea.c        | 14 ++++++++------
  147.  daemon/getattr.c   |  7 ++++---
  148.  daemon/lock.c      | 14 ++++++++------
  149.  daemon/mount.c     | 14 ++++++++------
  150.  daemon/open.c      | 18 +++++++++---------
  151.  daemon/readdir.c   |  7 ++++---
  152.  daemon/readwrite.c | 14 ++++++++------
  153.  daemon/setattr.c   |  7 ++++---
  154.  daemon/symlink.c   |  7 ++++---
  155.  daemon/upcall.c    | 45 +++++++++++++++++++++++++++++++++------------
  156.  daemon/upcall.h    |  1 +
  157.  daemon/volume.c    |  7 ++++---
  158.  13 files changed, 103 insertions(+), 66 deletions(-)
  159.  
  160. diff --git a/daemon/acl.c b/daemon/acl.c
  161. index b93c319..d5d2fe1 100644
  162. --- a/daemon/acl.c
  163. +++ b/daemon/acl.c
  164. @@ -412,9 +412,10 @@ out:
  165.  }
  166.  
  167.  const nfs41_upcall_op nfs41_op_getacl = {
  168. -    parse_getacl,
  169. -    handle_getacl,
  170. -    marshall_getacl
  171. +    .parse = parse_getacl,
  172. +    .handle = handle_getacl,
  173. +    .marshall = marshall_getacl,
  174. +    .arg_size = sizeof(getacl_upcall_args)
  175.  };
  176.  
  177.  static int parse_setacl(unsigned char *buffer, uint32_t length,
  178. @@ -922,7 +923,8 @@ static int marshall_setacl(unsigned char *buffer, uint32_t *length, nfs41_upcall
  179.  }
  180.  
  181.  const nfs41_upcall_op nfs41_op_setacl = {
  182. -    parse_setacl,
  183. -    handle_setacl,
  184. -    marshall_setacl
  185. +    .parse = parse_setacl,
  186. +    .handle = handle_setacl,
  187. +    .marshall = marshall_setacl,
  188. +    .arg_size = sizeof(setacl_upcall_args)
  189.  };
  190. diff --git a/daemon/ea.c b/daemon/ea.c
  191. index f941e59..f9dd3e8 100644
  192. --- a/daemon/ea.c
  193. +++ b/daemon/ea.c
  194. @@ -681,13 +681,15 @@ out:
  195.  
  196.  
  197.  const nfs41_upcall_op nfs41_op_setexattr = {
  198. -    parse_setexattr,
  199. -    handle_setexattr,
  200. -    marshall_setexattr
  201. +    .parse = parse_setexattr,
  202. +    .handle = handle_setexattr,
  203. +    .marshall = marshall_setexattr,
  204. +    .arg_size = sizeof(setexattr_upcall_args)
  205.  };
  206.  
  207.  const nfs41_upcall_op nfs41_op_getexattr = {
  208. -    parse_getexattr,
  209. -    handle_getexattr,
  210. -    marshall_getexattr
  211. +    .parse = parse_getexattr,
  212. +    .handle = handle_getexattr,
  213. +    .marshall = marshall_getexattr,
  214. +    .arg_size = sizeof(getexattr_upcall_args)
  215.  };
  216. diff --git a/daemon/getattr.c b/daemon/getattr.c
  217. index 7668a9b..9dc6f36 100644
  218. --- a/daemon/getattr.c
  219. +++ b/daemon/getattr.c
  220. @@ -249,7 +249,8 @@ out:
  221.  
  222.  
  223.  const nfs41_upcall_op nfs41_op_getattr = {
  224. -    parse_getattr,
  225. -    handle_getattr,
  226. -    marshall_getattr
  227. +    .parse = parse_getattr,
  228. +    .handle = handle_getattr,
  229. +    .marshall = marshall_getattr,
  230. +    .arg_size = sizeof(getattr_upcall_args)
  231.  };
  232. diff --git a/daemon/lock.c b/daemon/lock.c
  233. index 9bf2868..bd99199 100644
  234. --- a/daemon/lock.c
  235. +++ b/daemon/lock.c
  236. @@ -358,12 +358,14 @@ static int handle_unlock(void *daemon_context, nfs41_upcall *upcall)
  237.  
  238.  
  239.  const nfs41_upcall_op nfs41_op_lock = {
  240. -    parse_lock,
  241. -    handle_lock,
  242. -    NULL,
  243. -    cancel_lock
  244. +    .parse = parse_lock,
  245. +    .handle = handle_lock,
  246. +    .cancel = cancel_lock,
  247. +    .arg_size = sizeof(lock_upcall_args)
  248.  };
  249. +
  250.  const nfs41_upcall_op nfs41_op_unlock = {
  251. -    parse_unlock,
  252. -    handle_unlock
  253. +    .parse = parse_unlock,
  254. +    .handle = handle_unlock,
  255. +    .arg_size = sizeof(unlock_upcall_args)
  256.  };
  257. diff --git a/daemon/mount.c b/daemon/mount.c
  258. index de9bdb8..f0fa866 100644
  259. --- a/daemon/mount.c
  260. +++ b/daemon/mount.c
  261. @@ -209,10 +209,11 @@ static void cancel_mount(IN nfs41_upcall *upcall)
  262.  }
  263.  
  264.  const nfs41_upcall_op nfs41_op_mount = {
  265. -    parse_mount,
  266. -    handle_mount,
  267. -    marshall_mount,
  268. -    cancel_mount
  269. +    .parse = parse_mount,
  270. +    .handle = handle_mount,
  271. +    .marshall = marshall_mount,
  272. +    .cancel = cancel_mount,
  273. +    .arg_size = sizeof(mount_upcall_args)
  274.  };
  275.  
  276.  
  277. @@ -234,6 +235,7 @@ static int handle_unmount(void *daemon_context, nfs41_upcall *upcall)
  278.  }
  279.  
  280.  const nfs41_upcall_op nfs41_op_unmount = {
  281. -    parse_unmount,
  282. -    handle_unmount
  283. +    .parse = parse_unmount,
  284. +    .handle = handle_unmount,
  285. +    .arg_size = 0
  286.  };
  287. diff --git a/daemon/open.c b/daemon/open.c
  288. index 57dd53f..fe7e35a 100644
  289. --- a/daemon/open.c
  290. +++ b/daemon/open.c
  291. @@ -1203,15 +1203,15 @@ static void cleanup_close(nfs41_upcall *upcall)
  292.  
  293.  
  294.  const nfs41_upcall_op nfs41_op_open = {
  295. -    parse_open,
  296. -    handle_open,
  297. -    marshall_open,
  298. -    cancel_open
  299. +    .parse = parse_open,
  300. +    .handle = handle_open,
  301. +    .marshall = marshall_open,
  302. +    .cancel = cancel_open,
  303. +    .arg_size = sizeof(open_upcall_args)
  304.  };
  305.  const nfs41_upcall_op nfs41_op_close = {
  306. -    parse_close,
  307. -    handle_close,
  308. -    NULL,
  309. -    NULL,
  310. -    cleanup_close
  311. +    .parse = parse_close,
  312. +    .handle = handle_close,
  313. +    .cleanup = cleanup_close,
  314. +    .arg_size = sizeof(close_upcall_args)
  315.  };
  316. diff --git a/daemon/readdir.c b/daemon/readdir.c
  317. index c34eb64..83d266b 100644
  318. --- a/daemon/readdir.c
  319. +++ b/daemon/readdir.c
  320. @@ -882,7 +882,8 @@ static int marshall_readdir(unsigned char *buffer, uint32_t *length, nfs41_upcal
  321.  
  322.  
  323.  const nfs41_upcall_op nfs41_op_readdir = {
  324. -    parse_readdir,
  325. -    handle_readdir,
  326. -    marshall_readdir
  327. +    .parse = parse_readdir,
  328. +    .handle = handle_readdir,
  329. +    .marshall = marshall_readdir,
  330. +    .arg_size = sizeof(readdir_upcall_args)
  331.  };
  332. diff --git a/daemon/readwrite.c b/daemon/readwrite.c
  333. index 3c716cc..e93eef3 100644
  334. --- a/daemon/readwrite.c
  335. +++ b/daemon/readwrite.c
  336. @@ -316,12 +316,14 @@ out:
  337.  
  338.  
  339.  const nfs41_upcall_op nfs41_op_read = {
  340. -    parse_rw,
  341. -    handle_read,
  342. -    marshall_rw
  343. +    .parse = parse_rw,
  344. +    .handle = handle_read,
  345. +    .marshall = marshall_rw,
  346. +    .arg_size = sizeof(readwrite_upcall_args)
  347.  };
  348.  const nfs41_upcall_op nfs41_op_write = {
  349. -    parse_rw,
  350. -    handle_write,
  351. -    marshall_rw
  352. +    .parse = parse_rw,
  353. +    .handle = handle_write,
  354. +    .marshall = marshall_rw,
  355. +    .arg_size = sizeof(readwrite_upcall_args)
  356.  };
  357. diff --git a/daemon/setattr.c b/daemon/setattr.c
  358. index 5a951e8..5540d87 100644
  359. --- a/daemon/setattr.c
  360. +++ b/daemon/setattr.c
  361. @@ -522,7 +522,8 @@ static int marshall_setattr(unsigned char *buffer, uint32_t *length, nfs41_upcal
  362.  
  363.  
  364.  const nfs41_upcall_op nfs41_op_setattr = {
  365. -    parse_setattr,
  366. -    handle_setattr,
  367. -    marshall_setattr
  368. +    .parse = parse_setattr,
  369. +    .handle = handle_setattr,
  370. +    .marshall = marshall_setattr,
  371. +    .arg_size = sizeof(setattr_upcall_args)
  372.  };
  373. diff --git a/daemon/symlink.c b/daemon/symlink.c
  374. index 6903eb7..a015f4c 100644
  375. --- a/daemon/symlink.c
  376. +++ b/daemon/symlink.c
  377. @@ -293,7 +293,8 @@ out:
  378.  
  379.  
  380.  const nfs41_upcall_op nfs41_op_symlink = {
  381. -    parse_symlink,
  382. -    handle_symlink,
  383. -    marshall_symlink
  384. +    .parse = parse_symlink,
  385. +    .handle = handle_symlink,
  386. +    .marshall = marshall_symlink,
  387. +    .arg_size = sizeof(symlink_upcall_args)
  388.  };
  389. diff --git a/daemon/upcall.c b/daemon/upcall.c
  390. index eef5530..a2e3520 100644
  391. --- a/daemon/upcall.c
  392. +++ b/daemon/upcall.c
  393. @@ -83,8 +83,19 @@ int upcall_parse(
  394.      int status;
  395.      const nfs41_upcall_op *op;
  396.      DWORD version;
  397. +    uint32_t upcall_upcode = 0;
  398. +
  399. +    /*
  400. +     * Init generic |upcall| data
  401. +     * (Note that the |upcall->args| will be initialized before
  402. +     * |op->parse()| below)
  403. +     */
  404. +    upcall->opcode = 0;
  405. +    upcall->status = 0;
  406. +    upcall->last_error = 0;
  407. +    upcall->root_ref = NULL;
  408. +    upcall->state_ref = NULL;
  409.  
  410. -    ZeroMemory(upcall, sizeof(nfs41_upcall));
  411.      if (!length) {
  412.          eprintf("empty upcall\n");
  413.          upcall->status = status = 102;
  414. @@ -102,7 +113,6 @@ int upcall_parse(
  415.      status = safe_read(&buffer, &length, &upcall->xid, sizeof(uint64_t));
  416.      if (status) goto out;
  417.      /* |sizeof(enum)| might not be the same as |sizeof(uint32_t)| */
  418. -    uint32_t upcall_upcode = 0;
  419.      status = safe_read(&buffer, &length, &upcall_upcode, sizeof(uint32_t));
  420.      if (status) goto out;
  421.      upcall->opcode = upcall_upcode;
  422. @@ -112,7 +122,7 @@ int upcall_parse(
  423.      if (status) goto out;
  424.  
  425.      DPRINTF(2, ("time=%ld version=%d xid=%d opcode='%s' session=0x%x open_state=0x%x\n",
  426. -        time(NULL), version, upcall->xid, opcode2string(upcall->opcode), upcall->root_ref,
  427. +        time(NULL), version, upcall->xid, opcode2string(upcall_upcode), upcall->root_ref,
  428.          upcall->state_ref));
  429.      if (version != NFS41D_VERSION) {
  430.          eprintf("received version %d expecting version %d\n", version, NFS41D_VERSION);
  431. @@ -121,8 +131,8 @@ int upcall_parse(
  432.      }
  433.      if (upcall_upcode >= g_upcall_op_table_size) {
  434.          status = ERROR_NOT_SUPPORTED;
  435. -        eprintf("upcall_parse: unrecognized upcall opcode %d!\n",
  436. -            upcall->opcode);
  437. +        eprintf("upcall_parse: unrecognized upcall opcode %u!\n",
  438. +            (unsigned int)upcall_upcode);
  439.          goto out;
  440.      }
  441.  
  442. @@ -133,9 +143,9 @@ int upcall_parse(
  443.      if (upcall->state_ref != INVALID_HANDLE_VALUE) {
  444.          if (!isvalidnfs41_open_state_ptr(upcall->state_ref)) {
  445.              eprintf("upcall_parse: Error accessing "
  446. -                "upcall->state_ref(=0x%p), opcode %d; "
  447. +                "upcall->state_ref(=0x%p), opcode %u; "
  448.                  "returning ERROR_INVALID_PARAMETER\n",
  449. -                upcall->state_ref, upcall->opcode);
  450. +                upcall->state_ref, (unsigned int)upcall_upcode);
  451.              /*
  452.               * Set |upcall->state_ref| to |INVALID_HANDLE_VALUE|
  453.               * so that we do not try to dereference it
  454. @@ -147,8 +157,8 @@ int upcall_parse(
  455.  
  456.          if (upcall->state_ref->ref_count == 0) {
  457.              eprintf("upcall_parse: upcall->state_ref(=0x%p).ref_count == 0, "
  458. -                "opcode %d; returning ERROR_INVALID_PARAMETER\n",
  459. -                upcall->state_ref, upcall->opcode);
  460. +                "opcode %u; returning ERROR_INVALID_PARAMETER\n",
  461. +                upcall->state_ref, (unsigned int)upcall_upcode);
  462.              /*
  463.               * Set |upcall->state_ref| to |INVALID_HANDLE_VALUE|
  464.               * so that we do not try to dereference it
  465. @@ -164,16 +174,27 @@ int upcall_parse(
  466.          nfs41_open_state_ref(upcall->state_ref);
  467.  
  468.      /* parse the operation's arguments */
  469. -    op = g_upcall_op_table[upcall->opcode];
  470. +    op = g_upcall_op_table[upcall_upcode];
  471. +
  472. +    if (op) {
  473. +        /* |NFS41_UNMOUNT| has 0 payload */
  474. +        if (upcall_upcode != NFS41_UNMOUNT) {
  475. +            EASSERT_MSG(op->arg_size >= sizeof(void*),
  476. +                ("upcall->opcode=%u\n", (unsigned int)upcall_upcode));
  477. +        }
  478. +        (void)memset(&upcall->args, 0, op->arg_size);
  479. +    }
  480. +
  481.      if (op && op->parse) {
  482.          /* |NFS41_UNMOUNT| has 0 payload */
  483. -        if (upcall->opcode != NFS41_UNMOUNT) {
  484. +        if (upcall_upcode != NFS41_UNMOUNT) {
  485.              EASSERT(length > 0);
  486.          }
  487. +
  488.          status = op->parse(buffer, length, upcall);
  489.          if (status) {
  490.              eprintf("parsing of upcall '%s' failed with %d.\n",
  491. -                opcode2string(upcall->opcode), status);
  492. +                opcode2string(upcall_upcode), status);
  493.              goto out;
  494.          }
  495.      }
  496. diff --git a/daemon/upcall.h b/daemon/upcall.h
  497. index f8d608e..c0bbe8f 100644
  498. --- a/daemon/upcall.h
  499. +++ b/daemon/upcall.h
  500. @@ -242,6 +242,7 @@ typedef struct __nfs41_upcall_op {
  501.      upcall_marshall_proc    marshall;
  502.      upcall_cancel_proc      cancel;
  503.      upcall_cleanup_proc     cleanup;
  504. +    size_t                  arg_size;
  505.  } nfs41_upcall_op;
  506.  
  507.  
  508. diff --git a/daemon/volume.c b/daemon/volume.c
  509. index 50ac051..3793da8 100644
  510. --- a/daemon/volume.c
  511. +++ b/daemon/volume.c
  512. @@ -170,7 +170,8 @@ out:
  513.  
  514.  
  515.  const nfs41_upcall_op nfs41_op_volume = {
  516. -    parse_volume,
  517. -    handle_volume,
  518. -    marshall_volume
  519. +    .parse = parse_volume,
  520. +    .handle = handle_volume,
  521. +    .marshall = marshall_volume,
  522. +    .arg_size = sizeof(volume_upcall_args)
  523.  };
  524. --
  525. 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