bridgestp: validate timer values in config BPDU

IEEE Std 802.1D-2004 Section 17.14 defines permitted ranges for timers.
Incoming BPDU messages should be checked against the permitted ranges.
The rest of 17.14 appears to be enforced already.

PR:		254924
Reviewed by:	kp, donner
Differential Revision:	https://reviews.freebsd.org/D29782
This commit is contained in:
Jonah Caplan 2021-04-15 11:28:42 +02:00 committed by Kristof Provost
parent 156da725d3
commit 0e4025bffa

View File

@ -597,6 +597,23 @@ bstp_received_bpdu(struct bstp_state *bs, struct bstp_port *bp,
return;
}
/* range checks */
if (cu->cu_message_age >= cu->cu_max_age) {
return;
}
if (cu->cu_max_age < BSTP_MIN_MAX_AGE ||
cu->cu_max_age > BSTP_MAX_MAX_AGE) {
return;
}
if (cu->cu_forward_delay < BSTP_MIN_FORWARD_DELAY ||
cu->cu_forward_delay > BSTP_MAX_FORWARD_DELAY) {
return;
}
if (cu->cu_hello_time < BSTP_MIN_HELLO_TIME ||
cu->cu_hello_time > BSTP_MAX_HELLO_TIME) {
return;
}
type = bstp_pdu_rcvtype(bp, cu);
switch (type) {