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/netinet/siftr.c | |
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/netinet/siftr.c')
-rw-r--r-- | sys/netinet/siftr.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/sys/netinet/siftr.c b/sys/netinet/siftr.c index 886be06..a484481 100644 --- a/sys/netinet/siftr.c +++ b/sys/netinet/siftr.c @@ -266,6 +266,7 @@ static unsigned int siftr_pkts_per_log = 1; static unsigned int siftr_generate_hashes = 0; /* static unsigned int siftr_binary_log = 0; */ static char siftr_logfile[PATH_MAX] = "/var/log/siftr.log"; +static char siftr_logfile_shadow[PATH_MAX] = "/var/log/siftr.log"; static u_long siftr_hashmask; STAILQ_HEAD(pkthead, pkt_node) pkt_queue = STAILQ_HEAD_INITIALIZER(pkt_queue); LIST_HEAD(listhead, flow_hash_node) *counter_hash; @@ -297,7 +298,7 @@ SYSCTL_PROC(_net_inet_siftr, OID_AUTO, enabled, CTLTYPE_UINT|CTLFLAG_RW, "switch siftr module operations on/off"); SYSCTL_PROC(_net_inet_siftr, OID_AUTO, logfile, CTLTYPE_STRING|CTLFLAG_RW, - &siftr_logfile, sizeof(siftr_logfile), &siftr_sysctl_logfile_name_handler, + &siftr_logfile_shadow, sizeof(siftr_logfile_shadow), &siftr_sysctl_logfile_name_handler, "A", "file to save siftr log messages to"); SYSCTL_UINT(_net_inet_siftr, OID_AUTO, ppl, CTLFLAG_RW, @@ -1143,38 +1144,38 @@ siftr_sysctl_logfile_name_handler(SYSCTL_HANDLER_ARGS) struct alq *new_alq; int error; - if (req->newptr == NULL) - goto skip; + error = sysctl_handle_string(oidp, arg1, arg2, req); - /* If old filename and new filename are different. */ - if (strncmp(siftr_logfile, (char *)req->newptr, PATH_MAX)) { - - error = alq_open(&new_alq, req->newptr, curthread->td_ucred, - SIFTR_LOG_FILE_MODE, SIFTR_ALQ_BUFLEN, 0); + /* Check for error or same filename */ + if (error != 0 || req->newptr == NULL || + strncmp(siftr_logfile, arg1, arg2) == 0) + goto done; - /* Bail if unable to create new alq. */ - if (error) - return (1); + /* Filname changed */ + error = alq_open(&new_alq, arg1, curthread->td_ucred, + SIFTR_LOG_FILE_MODE, SIFTR_ALQ_BUFLEN, 0); + if (error != 0) + goto done; - /* - * If disabled, siftr_alq == NULL so we simply close - * the alq as we've proved it can be opened. - * If enabled, close the existing alq and switch the old - * for the new. - */ - if (siftr_alq == NULL) - alq_close(new_alq); - else { - alq_close(siftr_alq); - siftr_alq = new_alq; - } + /* + * If disabled, siftr_alq == NULL so we simply close + * the alq as we've proved it can be opened. + * If enabled, close the existing alq and switch the old + * for the new. + */ + if (siftr_alq == NULL) { + alq_close(new_alq); + } else { + alq_close(siftr_alq); + siftr_alq = new_alq; } -skip: - return (sysctl_handle_string(oidp, arg1, arg2, req)); + /* Update filename upon success */ + strlcpy(siftr_logfile, arg1, arg2); +done: + return (error); } - static int siftr_manage_ops(uint8_t action) { |