FreeBSD Bugzilla – Attachment 151584 Details for
Bug 172675
[netinet] [patch] sysctl_tcp_hc_list (net.inet.tcp.hostcache.list) race condition causing memory corruption
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
sbuf_hc_list.patch
file_172675.txt (text/plain), 2.10 KB, created by
John Baldwin
on 2015-01-13 20:58:07 UTC
(
hide
)
Description:
sbuf_hc_list.patch
Filename:
MIME Type:
Creator:
John Baldwin
Created:
2015-01-13 20:58:07 UTC
Size:
2.10 KB
patch
obsolete
>Index: tcp_hostcache.c >=================================================================== >--- tcp_hostcache.c (revision 277075) >+++ tcp_hostcache.c (working copy) >@@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); > #include <sys/lock.h> > #include <sys/mutex.h> > #include <sys/malloc.h> >+#include <sys/sbuf.h> > #include <sys/socket.h> > #include <sys/socketvar.h> > #include <sys/sysctl.h> >@@ -595,23 +596,20 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_m > static int > sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) > { >- int bufsize; > int linesize = 128; >- char *p, *buf; >- int len, i, error; >+ struct sbuf sb; >+ int i, error; > struct hc_metrics *hc_entry; > #ifdef INET6 > char ip6buf[INET6_ADDRSTRLEN]; > #endif > >- bufsize = linesize * (V_tcp_hostcache.cache_count + 1); >+ sbuf_new(&sb, NULL, linesize * (V_tcp_hostcache.cache_count + 1), >+ SBUF_FIXEDLEN); > >- p = buf = (char *)malloc(bufsize, M_TEMP, M_WAITOK|M_ZERO); >- >- len = snprintf(p, linesize, >- "\nIP address MTU SSTRESH RTT RTTVAR BANDWIDTH " >+ sbuf_printf(&sb, >+ "\nIP address MTU SSTRESH RTT RTTVAR BANDWIDTH " > " CWND SENDPIPE RECVPIPE HITS UPD EXP\n"); >- p += len; > > #define msec(u) (((u) + 500) / 1000) > for (i = 0; i < V_tcp_hostcache.hashsize; i++) { >@@ -618,7 +616,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) > THC_LOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); > TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket, > rmx_q) { >- len = snprintf(p, linesize, >+ sbuf_printf(&sb, > "%-15s %5lu %8lu %6lums %6lums %9lu %8lu %8lu %8lu " > "%4lu %4lu %4i\n", > hc_entry->ip4.s_addr ? inet_ntoa(hc_entry->ip4) : >@@ -640,13 +638,13 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS) > hc_entry->rmx_hits, > hc_entry->rmx_updates, > hc_entry->rmx_expire); >- p += len; > } > THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); > } > #undef msec >- error = SYSCTL_OUT(req, buf, p - buf); >- free(buf, M_TEMP); >+ sbuf_finish(&sb); >+ error = SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb)); >+ sbuf_delete(&sb); > return(error); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 172675
:
128794
| 151584