diff options
author | hselasky <hselasky@FreeBSD.org> | 2014-10-30 08:04:48 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2014-10-30 08:04:48 +0000 |
commit | 1d17f744c7fc351c6163d4e1a9862bef78a632d5 (patch) | |
tree | b10daf90a34256f49336c4827661577d2b1339d3 /sys/kern | |
parent | 2b4fb093044897c573e0f1cfe28d235e8c83db08 (diff) | |
download | FreeBSD-src-1d17f744c7fc351c6163d4e1a9862bef78a632d5.zip FreeBSD-src-1d17f744c7fc351c6163d4e1a9862bef78a632d5.tar.gz |
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
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_ffclock.c | 37 |
1 files changed, 20 insertions, 17 deletions
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); } |