From 0135e5344d52939b5c2514ac0e86bc599aa50be5 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Fri, 28 Aug 2015 17:55:32 +0200 Subject: [PATCH] port: constrain the master's logMinDelayReqInterval. Buggy or mis-configured masters can place bogus logMessageInterval values in their delay response messages. This patch places reasonable limits on the range of values that we will accept. Signed-off-by: Richard Cochran --- port.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/port.c b/port.c index ef2686d..91bb4e9 100644 --- a/port.c +++ b/port.c @@ -1666,12 +1666,18 @@ static void process_delay_resp(struct port *p, struct ptp_message *m) clock_path_delay(p->clock, t3, t4c); - if (p->logMinDelayReqInterval != rsp->hdr.logMessageInterval) { - // TODO - validate the input. - p->logMinDelayReqInterval = rsp->hdr.logMessageInterval; - pr_notice("port %hu: minimum delay request interval 2^%d", - portnum(p), p->logMinDelayReqInterval); + if (p->logMinDelayReqInterval == rsp->hdr.logMessageInterval) { + return; } + if (rsp->hdr.logMessageInterval < -10 || + rsp->hdr.logMessageInterval > 22) { + pr_debug("port %hu: ignore bogus delay request interval 2^%d", + portnum(p), rsp->hdr.logMessageInterval); + return; + } + p->logMinDelayReqInterval = rsp->hdr.logMessageInterval; + pr_notice("port %hu: minimum delay request interval 2^%d", + portnum(p), p->logMinDelayReqInterval); } static void process_follow_up(struct port *p, struct ptp_message *m)