Deny client requests and ignore server responses that have
logInterMessagePeriod outside of [-30..30] to avoid undefined
integer shifts in calculation of the interval.

Signed-off-by: Miroslav Lichvar <mlich...@redhat.com>
---
 unicast_client.c  | 6 ++++++
 unicast_service.c | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/unicast_client.c b/unicast_client.c
index d7b7243..0843554 100644
--- a/unicast_client.c
+++ b/unicast_client.c
@@ -454,6 +454,12 @@ void unicast_client_grant(struct port *p, struct 
ptp_message *m,
                }
                return;
        }
+       if (abs(g->logInterMessagePeriod) > 30) {
+               pr_warning("%s: ignore bogus unicast message interval 2^%d",
+                          p->log_name, g->logInterMessagePeriod);
+               return;
+       }
+
        pr_debug("%s: unicast %s granted for %u sec",
                 p->log_name, msg_type_string(mtype), g->durationField);
 
diff --git a/unicast_service.c b/unicast_service.c
index 1078041..687468c 100644
--- a/unicast_service.c
+++ b/unicast_service.c
@@ -327,6 +327,10 @@ int unicast_service_add(struct port *p, struct ptp_message 
*m,
                return SERVICE_DENIED;
        }
 
+       if (abs(req->logInterMessagePeriod) > 30) {
+               return SERVICE_DENIED;
+       }
+
        LIST_FOREACH(itmp, &p->unicast_service->intervals, list) {
                /*
                 * Remember the interval of interest.
-- 
2.39.0



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to