Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177530686
D61403.1794642973.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
D61403.1794642973.diff
View Options
diff --git a/sys/netinet/tcp_syncache.h b/sys/netinet/tcp_syncache.h
--- a/sys/netinet/tcp_syncache.h
+++ b/sys/netinet/tcp_syncache.h
@@ -74,7 +74,8 @@
#endif
struct label *sc_label; /* MAC label reference */
struct ucred *sc_cred; /* cred cache for jail checks */
- void *sc_tfo_cookie; /* for TCP Fast Open response */
+ void * __sized_by_or_null(sizeof(uint64_t))
+ sc_tfo_cookie; /* for TCP Fast Open response */
uint32_t sc_flowtype; /* flowid from SYN packet .. */
uint32_t sc_flowid; /* .. or calculated by RSS */
};
@@ -120,7 +121,7 @@
#define TCP_SYNCACHE_MAX_BACKOFF 6 /* 16 minutes */
struct tcp_syncache {
- struct syncache_head *hashbase;
+ struct syncache_head * __counted_by_or_null(hashmask + 1) hashbase;
uma_zone_t zone;
u_int hashsize;
u_int hashmask;
diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c
--- a/sys/netinet/tcp_syncache.c
+++ b/sys/netinet/tcp_syncache.c
@@ -131,7 +131,7 @@
static void syncache_timer(void *);
static uint32_t syncookie_mac(struct in_conninfo *, tcp_seq, uint8_t,
- uint8_t *, uintptr_t);
+ uint8_t [SYNCOOKIE_SECRET_SIZE], uintptr_t);
static tcp_seq syncookie_generate(struct syncache_head *, struct syncache *);
static bool syncookie_expand(struct in_conninfo *,
const struct syncache_head *, struct syncache *,
@@ -249,6 +249,7 @@
void
syncache_init(void)
{
+ struct tcp_syncache *tsc;
int i;
V_tcp_syncache.hashsize = TCP_SYNCACHE_HASHSIZE;
@@ -265,7 +266,6 @@
printf("WARNING: syncache hash size is not a power of 2.\n");
V_tcp_syncache.hashsize = TCP_SYNCACHE_HASHSIZE;
}
- V_tcp_syncache.hashmask = V_tcp_syncache.hashsize - 1;
/* Set limits. */
V_tcp_syncache.cache_limit =
@@ -274,8 +274,10 @@
&V_tcp_syncache.cache_limit);
/* Allocate the hash table. */
- V_tcp_syncache.hashbase = malloc(V_tcp_syncache.hashsize *
- sizeof(struct syncache_head), M_SYNCACHE, M_WAITOK | M_ZERO);
+ tsc = &V_tcp_syncache;
+ tsc->hashbase = malloc(tsc->hashsize * sizeof(struct syncache_head),
+ M_SYNCACHE, M_WAITOK | M_ZERO);
+ tsc->hashmask = tsc->hashsize - 1;
#ifdef VIMAGE
V_tcp_syncache.vnet = curvnet;
@@ -620,7 +622,7 @@
syncache_chkrst(struct in_conninfo *inc, struct tcphdr *th, uint16_t port)
{
struct syncache *sc;
- struct syncache_head *sch;
+ struct syncache_head * __single sch;
char *s = NULL;
if (syncache_cookiesonly())
@@ -724,7 +726,7 @@
syncache_unreach(struct in_conninfo *inc, tcp_seq th_seq, uint16_t port)
{
struct syncache *sc;
- struct syncache_head *sch;
+ struct syncache_head * __single sch;
if (syncache_cookiesonly())
return;
@@ -1069,7 +1071,7 @@
struct socket **lsop, struct mbuf *m, uint16_t port)
{
struct syncache *sc;
- struct syncache_head *sch;
+ struct syncache_head * __single sch;
struct syncache scs;
char *s;
bool locked;
@@ -1401,9 +1403,9 @@
{
struct tcpcb *tp;
struct socket *rv = NULL;
- struct syncache *sc = NULL;
+ struct syncache * __single sc = NULL;
struct ucred *cred;
- struct syncache_head *sch;
+ struct syncache_head * __single sch;
struct mbuf *ipopts = NULL;
u_int ltflags;
int win, ip_ttl, ip_tos;
@@ -1412,7 +1414,7 @@
int autoflowlabel = 0;
#endif
#ifdef MAC
- struct label *maclabel = NULL;
+ struct label * __single maclabel = NULL;
#endif
struct syncache scs;
uint64_t tfo_response_cookie;
@@ -2212,7 +2214,7 @@
*/
static uint32_t
syncookie_mac(struct in_conninfo *inc, tcp_seq irs, uint8_t flags,
- uint8_t *secbits, uintptr_t secmod)
+ uint8_t secbits[SYNCOOKIE_SECRET_SIZE], uintptr_t secmod)
{
SIPHASH_CTX ctx;
uint32_t siphash[2];
@@ -2438,7 +2440,7 @@
static void
syncookie_reseed(void *arg)
{
- struct tcp_syncache *sc = arg;
+ struct tcp_syncache * __single sc = arg;
uint8_t *secbits;
int secbit;
@@ -2466,7 +2468,7 @@
syncache_pause(struct in_conninfo *inc)
{
time_t delta;
- const char *s;
+ char *s;
/* XXX:
* 2. Add sysctl read here so we don't get the benefit of this
@@ -2520,12 +2522,12 @@
if (inc != NULL)
s = tcp_log_addrs(inc, NULL, NULL, NULL);
else
- s = (const char *)NULL;
+ s = NULL;
log(LOG_WARNING, "TCP syncache overflow detected; using syncookies for "
"the next %lld seconds%s%s%s\n", (long long)delta,
(s != NULL) ? " (last SYN: " : "", (s != NULL) ? s : "",
(s != NULL) ? ")" : "");
- free(__DECONST(void *, s), M_TCPLOG);
+ free(s, M_TCPLOG);
/* Use the calculated delta to set a new pause time. */
V_tcp_syncache.pause_until = time_uptime + delta;
@@ -2538,7 +2540,7 @@
static void
syncache_unpause(void *arg)
{
- struct tcp_syncache *sc;
+ struct tcp_syncache * __single sc;
time_t delta;
sc = arg;
diff --git a/sys/netinet/tcp_timer.h b/sys/netinet/tcp_timer.h
--- a/sys/netinet/tcp_timer.h
+++ b/sys/netinet/tcp_timer.h
@@ -167,7 +167,7 @@
extern int tcp_rexmit_max;
extern int tcp_rexmit_slop;
extern int tcp_ttl; /* time to live for TCP segs */
-extern int tcp_backoff[];
+extern int tcp_backoff[TCP_MAXRXTSHIFT + 1];
extern int tcp_totbackoff;
extern int tcp_rexmit_drop_options;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 14, 7:56 AM (3 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41696513
Default Alt Text
D61403.1794642973.diff (4 KB)
Attached To
Mode
D61403: tcp: build tcp_syncache.c under bounds-safety
Attached
Detach File
Event Timeline