From 1d17f744c7fc351c6163d4e1a9862bef78a632d5 Mon Sep 17 00:00:00 2001 From: hselasky Date: Thu, 30 Oct 2014 08:04:48 +0000 Subject: MFC r273733, r273740 and r273773: The SYSCTL data pointers can come from userspace and must not be directly accessed. Although this will work on some platforms, it can throw an exception if the pointer is invalid and then panic the kernel. Add a missing SYSCTL_IN() of "SCTP_BASE_STATS" structure. Sponsored by: Mellanox Technologies --- sys/kern/kern_ffclock.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/kern_ffclock.c b/sys/kern/kern_ffclock.c index 07441cd..c168325 100644 --- a/sys/kern/kern_ffclock.c +++ b/sys/kern/kern_ffclock.c @@ -203,26 +203,29 @@ static int sysctl_kern_sysclock_active(SYSCTL_HANDLER_ARGS) { char newclock[MAX_SYSCLOCK_NAME_LEN]; - int clk, error; + int error; + int clk; + + /* Return the name of the current active sysclock. */ + strlcpy(newclock, sysclocks[sysclock_active], sizeof(newclock)); + error = sysctl_handle_string(oidp, newclock, sizeof(newclock), req); - if (req->newptr == NULL) { - /* Return the name of the current active sysclock. */ - strlcpy(newclock, sysclocks[sysclock_active], sizeof(newclock)); - error = sysctl_handle_string(oidp, newclock, - sizeof(newclock), req); - } else { - /* Change the active sysclock to the user specified one. */ - error = EINVAL; - for (clk = 0; clk < NUM_SYSCLOCKS; clk++) { - if (strncmp((char *)req->newptr, sysclocks[clk], - strlen(sysclocks[clk])) == 0) { - sysclock_active = clk; - error = 0; - break; - } + /* Check for error or no change */ + if (error != 0 || req->newptr == NULL) + goto done; + + /* Change the active sysclock to the user specified one: */ + error = EINVAL; + for (clk = 0; clk < NUM_SYSCLOCKS; clk++) { + if (strncmp(newclock, sysclocks[clk], + MAX_SYSCLOCK_NAME_LEN - 1)) { + continue; } + sysclock_active = clk; + error = 0; + break; } - +done: return (error); } -- cgit v1.1