summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authorcsjp <csjp@FreeBSD.org>2008-01-08 14:58:41 +0000
committercsjp <csjp@FreeBSD.org>2008-01-08 14:58:41 +0000
commit856850f5787d6581931217cb7ad3c2f03d3b009f (patch)
tree7cb5e0eaa0e162dda833a86a46edcd88207b9b60 /sys/vm
parent60c8b505d8964a8e39142ca0e3b55d953c519dd9 (diff)
downloadFreeBSD-src-856850f5787d6581931217cb7ad3c2f03d3b009f.zip
FreeBSD-src-856850f5787d6581931217cb7ad3c2f03d3b009f.tar.gz
When MAC is enabled in the kernel, fix a panic triggered by a locking
assertion hit in swapoff_one() when we un-mount a swap partition. We should be using curthread where we used thread0 before. This change also replaces the thread argument with a credential argument, as the MAC framework only requires the cred. It should be noted that this allows the machine to be rebooted without panicing with "cannot differ from curthread or NULL" when MAC is enabled. Submitted by: rwatson Reviewed by: attilio MFC after: 2 weeks
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/swap_pager.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 0e87b86..97acee3 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -237,7 +237,7 @@ static void swp_sizecheck(void);
static void swp_pager_async_iodone(struct buf *bp);
static int swapongeom(struct thread *, struct vnode *);
static int swaponvp(struct thread *, struct vnode *, u_long);
-static int swapoff_one(struct swdevt *sp, struct thread *td);
+static int swapoff_one(struct swdevt *sp, struct ucred *cred);
/*
* Swap bitmap functions
@@ -2100,7 +2100,7 @@ swapoff(struct thread *td, struct swapoff_args *uap)
error = EINVAL;
goto done;
}
- error = swapoff_one(sp, td);
+ error = swapoff_one(sp, td->td_ucred);
done:
swdev_syscall_active = 0;
wakeup_one(&swdev_syscall_active);
@@ -2109,7 +2109,7 @@ done:
}
static int
-swapoff_one(struct swdevt *sp, struct thread *td)
+swapoff_one(struct swdevt *sp, struct ucred *cred)
{
u_long nblks, dvbase;
#ifdef MAC
@@ -2118,9 +2118,9 @@ swapoff_one(struct swdevt *sp, struct thread *td)
mtx_assert(&Giant, MA_OWNED);
#ifdef MAC
- (void) vn_lock(sp->sw_vp, LK_EXCLUSIVE | LK_RETRY, td);
- error = mac_system_check_swapoff(td->td_ucred, sp->sw_vp);
- (void) VOP_UNLOCK(sp->sw_vp, 0, td);
+ (void) vn_lock(sp->sw_vp, LK_EXCLUSIVE | LK_RETRY, curthread);
+ error = mac_system_check_swapoff(cred, sp->sw_vp);
+ (void) VOP_UNLOCK(sp->sw_vp, 0, curthread);
if (error != 0)
return (error);
#endif
@@ -2153,7 +2153,7 @@ swapoff_one(struct swdevt *sp, struct thread *td)
*/
swap_pager_swapoff(sp);
- sp->sw_close(td, sp);
+ sp->sw_close(curthread, sp);
sp->sw_id = NULL;
mtx_lock(&sw_dev_mtx);
TAILQ_REMOVE(&swtailq, sp, sw_list);
@@ -2189,7 +2189,7 @@ swapoff_all(void)
devname = sp->sw_vp->v_rdev->si_name;
else
devname = "[file]";
- error = swapoff_one(sp, &thread0);
+ error = swapoff_one(sp, thread0.td_ucred);
if (error != 0) {
printf("Cannot remove swap device %s (error=%d), "
"skipping.\n", devname, error);
OpenPOWER on IntegriCloud