Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177456376
D61402.1794451011.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
7 KB
Referenced Files
None
Subscribers
None
D61402.1794451011.diff
View Options
diff --git a/sys/netinet/tcp_fastopen.h b/sys/netinet/tcp_fastopen.h
--- a/sys/netinet/tcp_fastopen.h
+++ b/sys/netinet/tcp_fastopen.h
@@ -72,7 +72,7 @@
struct tcp_fastopen_ccache {
uma_zone_t zone;
- struct tcp_fastopen_ccache_bucket *base;
+ struct tcp_fastopen_ccache_bucket * __counted_by(buckets) base;
unsigned int bucket_limit;
unsigned int buckets;
unsigned int mask;
@@ -85,12 +85,12 @@
void tcp_fastopen_destroy(void);
unsigned int *tcp_fastopen_alloc_counter(void);
void tcp_fastopen_decrement_counter(unsigned int *);
-int tcp_fastopen_check_cookie(struct in_conninfo *, uint8_t *, unsigned int,
- uint64_t *);
+int tcp_fastopen_check_cookie(struct in_conninfo *,
+ uint8_t * __counted_by(len) cookie, unsigned int len, uint64_t *);
void tcp_fastopen_connect(struct tcpcb *);
void tcp_fastopen_disable_path(struct tcpcb *);
-void tcp_fastopen_update_cache(struct tcpcb *, uint16_t, uint8_t,
- uint8_t *);
+void tcp_fastopen_update_cache(struct tcpcb *, uint16_t, uint8_t cookie_len,
+ uint8_t * __counted_by(cookie_len) cookie);
#else
static __inline void
tcp_fastopen_init(void)
diff --git a/sys/netinet/tcp_fastopen.c b/sys/netinet/tcp_fastopen.c
--- a/sys/netinet/tcp_fastopen.c
+++ b/sys/netinet/tcp_fastopen.c
@@ -244,8 +244,8 @@
static struct tcp_fastopen_ccache_entry *tcp_fastopen_ccache_lookup(
struct in_conninfo *, struct tcp_fastopen_ccache_bucket **);
static struct tcp_fastopen_ccache_entry *tcp_fastopen_ccache_create(
- struct tcp_fastopen_ccache_bucket *, struct in_conninfo *, uint16_t, uint8_t,
- uint8_t *);
+ struct tcp_fastopen_ccache_bucket *, struct in_conninfo *, uint16_t,
+ uint8_t cookie_len, uint8_t * __counted_by_or_null(cookie_len) cookie);
static void tcp_fastopen_ccache_bucket_trim(struct tcp_fastopen_ccache_bucket *,
unsigned int);
static void tcp_fastopen_ccache_entry_drop(struct tcp_fastopen_ccache_entry *,
@@ -381,7 +381,8 @@
void
tcp_fastopen_init(void)
{
- unsigned int i;
+ struct tcp_fastopen_ccache *cc;
+ unsigned int buckets, i;
V_counter_zone = uma_zcreate("tfo", sizeof(unsigned int),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
@@ -401,17 +402,17 @@
/* May already be non-zero if kernel tunable was set */
if ((V_tcp_fastopen_ccache_buckets == 0) ||
!powerof2(V_tcp_fastopen_ccache_buckets))
- V_tcp_fastopen_ccache.buckets =
- TCP_FASTOPEN_CCACHE_BUCKETS_DEFAULT;
+ buckets = TCP_FASTOPEN_CCACHE_BUCKETS_DEFAULT;
else
- V_tcp_fastopen_ccache.buckets = V_tcp_fastopen_ccache_buckets;
+ buckets = V_tcp_fastopen_ccache_buckets;
- V_tcp_fastopen_ccache.mask = V_tcp_fastopen_ccache.buckets - 1;
+ V_tcp_fastopen_ccache.mask = buckets - 1;
V_tcp_fastopen_ccache.secret = arc4random();
- V_tcp_fastopen_ccache.base = malloc(V_tcp_fastopen_ccache.buckets *
- sizeof(struct tcp_fastopen_ccache_bucket), M_TCP_FASTOPEN_CCACHE,
- M_WAITOK | M_ZERO);
+ cc = &V_tcp_fastopen_ccache;
+ cc->base = malloc(buckets * sizeof(struct tcp_fastopen_ccache_bucket),
+ M_TCP_FASTOPEN_CCACHE, M_WAITOK | M_ZERO);
+ cc->buckets = buckets;
for (i = 0; i < V_tcp_fastopen_ccache.buckets; i++) {
TAILQ_INIT(&V_tcp_fastopen_ccache.base[i].ccb_entries);
@@ -466,7 +467,7 @@
unsigned int *
tcp_fastopen_alloc_counter(void)
{
- unsigned int *counter;
+ unsigned int * __single counter;
counter = uma_zalloc(V_counter_zone, M_NOWAIT);
if (counter)
*counter = 1;
@@ -483,7 +484,7 @@
}
static void
-tcp_fastopen_addkey_locked(uint8_t *key)
+tcp_fastopen_addkey_locked(uint8_t key[TCP_FASTOPEN_KEY_LEN])
{
V_tcp_fastopen_keys.newest++;
@@ -496,7 +497,7 @@
}
static void
-tcp_fastopen_addpsk_locked(uint8_t *psk)
+tcp_fastopen_addpsk_locked(uint8_t psk[TCP_FASTOPEN_KEY_LEN])
{
V_tcp_fastopen_keys.newest_psk++;
@@ -520,7 +521,7 @@
static void
tcp_fastopen_autokey_callout(void *arg)
{
- struct tcp_fastopen_callout *ctx = arg;
+ struct tcp_fastopen_callout * __single ctx = arg;
CURVNET_SET(ctx->v);
tcp_fastopen_autokey_locked();
@@ -555,7 +556,8 @@
}
static uint64_t
-tcp_fastopen_make_psk_cookie(uint8_t *psk, uint8_t *cookie, uint8_t cookie_len)
+tcp_fastopen_make_psk_cookie(uint8_t psk[TCP_FASTOPEN_KEY_LEN],
+ void * __sized_by(cookie_len) cookie, uint8_t cookie_len)
{
SIPHASH_CTX ctx;
uint64_t psk_cookie;
@@ -569,7 +571,8 @@
}
static int
-tcp_fastopen_find_cookie_match_locked(uint8_t *wire_cookie, uint64_t *cur_cookie)
+tcp_fastopen_find_cookie_match_locked(
+ uint8_t wire_cookie[TCP_FASTOPEN_COOKIE_LEN], uint64_t *cur_cookie)
{
unsigned int i, psk_index;
uint64_t psk_cookie;
@@ -580,7 +583,7 @@
psk_cookie =
tcp_fastopen_make_psk_cookie(
V_tcp_fastopen_keys.psk[psk_index],
- (uint8_t *)cur_cookie,
+ cur_cookie,
TCP_FASTOPEN_COOKIE_LEN);
if (memcmp(wire_cookie, &psk_cookie,
@@ -605,8 +608,9 @@
* 1 the cookie is valid and the latest cookie has been returned
*/
int
-tcp_fastopen_check_cookie(struct in_conninfo *inc, uint8_t *cookie,
- unsigned int len, uint64_t *latest_cookie)
+tcp_fastopen_check_cookie(struct in_conninfo *inc,
+ uint8_t * __counted_by(len) cookie, unsigned int len,
+ uint64_t *latest_cookie)
{
struct rm_priotracker tracker;
unsigned int i, key_index;
@@ -866,7 +870,7 @@
tcp_fastopen_connect(struct tcpcb *tp)
{
struct inpcb *inp = tptoinpcb(tp);
- struct tcp_fastopen_ccache_bucket *ccb;
+ struct tcp_fastopen_ccache_bucket * __single ccb;
struct tcp_fastopen_ccache_entry *cce;
sbintime_t now;
uint16_t server_mss;
@@ -953,7 +957,7 @@
tcp_fastopen_disable_path(struct tcpcb *tp)
{
struct in_conninfo *inc = &tptoinpcb(tp)->inp_inc;
- struct tcp_fastopen_ccache_bucket *ccb;
+ struct tcp_fastopen_ccache_bucket * __single ccb;
struct tcp_fastopen_ccache_entry *cce;
cce = tcp_fastopen_ccache_lookup(inc, &ccb);
@@ -976,10 +980,10 @@
void
tcp_fastopen_update_cache(struct tcpcb *tp, uint16_t mss,
- uint8_t cookie_len, uint8_t *cookie)
+ uint8_t cookie_len, uint8_t * __counted_by(cookie_len) cookie)
{
struct in_conninfo *inc = &tptoinpcb(tp)->inp_inc;
- struct tcp_fastopen_ccache_bucket *ccb;
+ struct tcp_fastopen_ccache_bucket * __single ccb;
struct tcp_fastopen_ccache_entry *cce;
cce = tcp_fastopen_ccache_lookup(inc, &ccb);
@@ -1046,9 +1050,10 @@
static struct tcp_fastopen_ccache_entry *
tcp_fastopen_ccache_create(struct tcp_fastopen_ccache_bucket *ccb,
- struct in_conninfo *inc, uint16_t mss, uint8_t cookie_len, uint8_t *cookie)
+ struct in_conninfo *inc, uint16_t mss, uint8_t cookie_len,
+ uint8_t * __counted_by_or_null(cookie_len) cookie)
{
- struct tcp_fastopen_ccache_entry *cce;
+ struct tcp_fastopen_ccache_entry * __single cce;
/*
* 1. Create a new entry, or
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -894,7 +894,8 @@
u_char * __sized_by(to_nsacks * TCPOLEN_SACK)
to_sacks; /* pointer to the first SACK blocks */
u_char *to_signature; /* pointer to the TCP-MD5 signature */
- u_int8_t *to_tfo_cookie; /* pointer to the TFO cookie */
+ u_int8_t * __counted_by(to_tfo_len)
+ to_tfo_cookie; /* pointer to the TFO cookie */
u_int16_t to_mss; /* maximum segment size */
u_int8_t to_wscale; /* window scaling */
u_int8_t to_nsacks; /* number of SACK blocks */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 12, 2:36 AM (4 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41664657
Default Alt Text
D61402.1794451011.diff (7 KB)
Attached To
Mode
D61402: tcp: build tcp_fastopen.c under bounds-safety
Attached
Detach File
Event Timeline