]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
nfsd: Fix a use after free when vnet prisons are deleted
authorRick Macklem <rmacklem@FreeBSD.org>
Fri, 24 Feb 2023 15:36:28 +0000 (07:36 -0800)
committerRick Macklem <rmacklem@FreeBSD.org>
Thu, 18 May 2023 23:10:58 +0000 (16:10 -0700)
commitc71535c29df0ed25b879b42b0ffe2fd5386fa94e
treeebff66a3bfcdeb6aca387ff28f9e4ec6236f4fe9
parentb4098b4fd6d63d88abba265b06bf4aa39174b7be
nfsd: Fix a use after free when vnet prisons are deleted

The Kasan tests show the nfsrvd_cleancache() results
in a modify after free. I think this occurs because the
nfsrv_cleanup() function gets executed after nfs_cleanup()
which free's the nfsstatsv1_p.

This patch makes them use the same subsystem and sets
SI_ORDER_FIRST for nfs_cleanup(), so that it will be called
after nfsrv_cleanup() via VNET_SYSUNINIT().

The patch also sets nfsstatsv1_p NULL after free'ng it,
so that a crash will result if it is used after free'ng.

(cherry picked from commit 4036fcb8053adf3ac54c8428eef0dd076dfc1718)
sys/fs/nfs/nfs_commonport.c