mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 22:01:31 +02:00
MINOR: connection: use the srv pointer for the srv conn hash
The pointer of the target server is used as a first parameter for the server connection hash calcul. This prevents the hash to be null when no specific parameters are present, and can serve as a simple defense against an attacker trying to reuse a non-conform connection.
This commit is contained in:
parent
81c6f76d3e
commit
1a58aca84e
@ -487,6 +487,7 @@ enum conn_hash_params_t {
|
|||||||
* connection hash.
|
* connection hash.
|
||||||
*/
|
*/
|
||||||
struct conn_hash_params {
|
struct conn_hash_params {
|
||||||
|
struct server *srv;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This structure describes a connection with its methods and data.
|
/* This structure describes a connection with its methods and data.
|
||||||
|
@ -1251,6 +1251,11 @@ int connect_server(struct stream *s)
|
|||||||
|
|
||||||
/* first, set unique connection parameters and then calculate hash */
|
/* first, set unique connection parameters and then calculate hash */
|
||||||
memset(&hash_params, 0, sizeof(hash_params));
|
memset(&hash_params, 0, sizeof(hash_params));
|
||||||
|
|
||||||
|
srv = objt_server(s->target);
|
||||||
|
hash_params.srv = srv;
|
||||||
|
|
||||||
|
if (srv)
|
||||||
hash = conn_calculate_hash(&hash_params);
|
hash = conn_calculate_hash(&hash_params);
|
||||||
|
|
||||||
/* This will catch some corner cases such as lying connections resulting from
|
/* This will catch some corner cases such as lying connections resulting from
|
||||||
@ -1258,8 +1263,6 @@ int connect_server(struct stream *s)
|
|||||||
*/
|
*/
|
||||||
si_release_endpoint(&s->si[1]);
|
si_release_endpoint(&s->si[1]);
|
||||||
|
|
||||||
srv = objt_server(s->target);
|
|
||||||
|
|
||||||
/* do not reuse if mode is http or if avail list is not allocated */
|
/* do not reuse if mode is http or if avail list is not allocated */
|
||||||
if ((s->be->mode != PR_MODE_HTTP) || (srv && !srv->available_conns_tree))
|
if ((s->be->mode != PR_MODE_HTTP) || (srv && !srv->available_conns_tree))
|
||||||
goto skip_reuse;
|
goto skip_reuse;
|
||||||
|
@ -1421,6 +1421,8 @@ XXH64_hash_t conn_calculate_hash(const struct conn_hash_params *params)
|
|||||||
|
|
||||||
buf = trash.area;
|
buf = trash.area;
|
||||||
|
|
||||||
|
conn_hash_update(buf, &idx, ¶ms->srv, sizeof(params->srv), &hash_flags, 0);
|
||||||
|
|
||||||
hash = conn_hash_digest(buf, idx, hash_flags);
|
hash = conn_hash_digest(buf, idx, hash_flags);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user