From 615872968712e5b5e2ba7c9ddbb86ebf972b3c83 Mon Sep 17 00:00:00 2001 From: ian Date: Mon, 16 Mar 2015 19:18:45 +0000 Subject: [PATCH] Use a regular sbuf + SYSCTL_OUT() rather than sbuf_new_for_sysctl() with auto-draining, to avoid a potential copyout fault while holding a lock. Pointed out by: jhb Pointy hat to: ian --- sys/kern/kern_fail.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_fail.c b/sys/kern/kern_fail.c index e455c3c943ea..3737aa3cf32f 100644 --- a/sys/kern/kern_fail.c +++ b/sys/kern/kern_fail.c @@ -394,10 +394,12 @@ fail_point_sysctl(SYSCTL_HANDLER_ARGS) int error; /* Retrieving */ - sbuf_new_for_sysctl(&sb, NULL, 128, req); + sbuf_new(&sb, NULL, 128, SBUF_AUTOEXTEND | SBUF_INCLUDENUL); fail_point_get(fp, &sb); sbuf_trim(&sb); error = sbuf_finish(&sb); + if (error == 0) + error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb)); sbuf_delete(&sb); /* Setting */