summaryrefslogtreecommitdiffstats
path: root/sys/netinet/cc
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2014-10-30 08:04:48 +0000
committerhselasky <hselasky@FreeBSD.org>2014-10-30 08:04:48 +0000
commit1d17f744c7fc351c6163d4e1a9862bef78a632d5 (patch)
treeb10daf90a34256f49336c4827661577d2b1339d3 /sys/netinet/cc
parent2b4fb093044897c573e0f1cfe28d235e8c83db08 (diff)
downloadFreeBSD-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/netinet/cc')
-rw-r--r--sys/netinet/cc/cc.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/sys/netinet/cc/cc.c b/sys/netinet/cc/cc.c
index 19d84ab..9f18833 100644
--- a/sys/netinet/cc/cc.c
+++ b/sys/netinet/cc/cc.c
@@ -92,33 +92,33 @@ cc_default_algo(SYSCTL_HANDLER_ARGS)
{
char default_cc[TCP_CA_NAME_MAX];
struct cc_algo *funcs;
- int err, found;
-
- err = found = 0;
-
- if (req->newptr == NULL) {
- /* Just print the current default. */
- CC_LIST_RLOCK();
- strlcpy(default_cc, CC_DEFAULT()->name, TCP_CA_NAME_MAX);
- CC_LIST_RUNLOCK();
- err = sysctl_handle_string(oidp, default_cc, 0, req);
- } else {
- /* Find algo with specified name and set it to default. */
- CC_LIST_RLOCK();
- STAILQ_FOREACH(funcs, &cc_list, entries) {
- if (strncmp((char *)req->newptr, funcs->name,
- TCP_CA_NAME_MAX) == 0) {
- found = 1;
- V_default_cc_ptr = funcs;
- }
- }
- CC_LIST_RUNLOCK();
+ int error;
- if (!found)
- err = ESRCH;
- }
+ /* Get the current default: */
+ CC_LIST_RLOCK();
+ strlcpy(default_cc, CC_DEFAULT()->name, sizeof(default_cc));
+ CC_LIST_RUNLOCK();
- return (err);
+ error = sysctl_handle_string(oidp, default_cc, sizeof(default_cc), req);
+
+ /* Check for error or no change */
+ if (error != 0 || req->newptr == NULL)
+ goto done;
+
+ error = ESRCH;
+
+ /* Find algo with specified name and set it to default. */
+ CC_LIST_RLOCK();
+ STAILQ_FOREACH(funcs, &cc_list, entries) {
+ if (strncmp(default_cc, funcs->name, sizeof(default_cc)))
+ continue;
+ V_default_cc_ptr = funcs;
+ error = 0;
+ break;
+ }
+ CC_LIST_RUNLOCK();
+done:
+ return (error);
}
/*
OpenPOWER on IntegriCloud