]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bridge: cfm: reject invalid CCM interval at configuration time
authorXiang Mei <xmei5@asu.edu>
Tue, 9 Jun 2026 06:51:16 +0000 (23:51 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 11 Jun 2026 22:16:12 +0000 (15:16 -0700)
ccm_tx_work_expired() re-arms itself via queue_delayed_work() using
the configured exp_interval converted by interval_to_us(). When
exp_interval is BR_CFM_CCM_INTERVAL_NONE or out of range,
interval_to_us() returns 0, causing the worker to fire immediately in
a tight loop that allocates skbs until OOM.

Fix this by validating exp_interval at configuration time:

 - Constrain IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL to the valid range
   [BR_CFM_CCM_INTERVAL_3_3_MS, BR_CFM_CCM_INTERVAL_10_MIN] in the
   netlink policy so userspace cannot set an invalid value.

 - Reject starting CCM TX in br_cfm_cc_ccm_tx() when exp_interval has
   not yet been configured (defaults to 0 from kzalloc).

Fixes: 2be665c3940d ("bridge: cfm: Netlink SET configuration Interface.")
Reported-by: Weiming Shi <bestswngs@gmail.com>
Signed-off-by: Xiang Mei <xmei5@asu.edu>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260609065116.2818837-1-xmei5@asu.edu
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/bridge/br_cfm.c
net/bridge/br_cfm_netlink.c

index 118c7ea48c351d96a3fa1ff09260aa8fb237bdc7..dea56fffa1c19fab589bc5ec799cdea5d35dd791 100644 (file)
@@ -805,6 +805,12 @@ int br_cfm_cc_ccm_tx(struct net_bridge *br, const u32 instance,
                goto save;
        }
 
+       if (!interval_to_us(mep->cc_config.exp_interval)) {
+               NL_SET_ERR_MSG_MOD(extack,
+                                  "Invalid CCM interval");
+               return -EINVAL;
+       }
+
        /* Start delayed work to transmit CCM frames. It is done with zero delay
         * to send first frame immediately
         */
index 2faab44652e7c03dfd911a660b852a1c0b27972c..91b9922dc3f25ef49c22234dcc39213161f7bccc 100644 (file)
@@ -34,7 +34,9 @@ br_cfm_cc_config_policy[IFLA_BRIDGE_CFM_CC_CONFIG_MAX + 1] = {
        [IFLA_BRIDGE_CFM_CC_CONFIG_UNSPEC]       = { .type = NLA_REJECT },
        [IFLA_BRIDGE_CFM_CC_CONFIG_INSTANCE]     = { .type = NLA_U32 },
        [IFLA_BRIDGE_CFM_CC_CONFIG_ENABLE]       = { .type = NLA_U32 },
-       [IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL] = { .type = NLA_U32 },
+       [IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL] =
+               NLA_POLICY_RANGE(NLA_U32, BR_CFM_CCM_INTERVAL_3_3_MS,
+                                BR_CFM_CCM_INTERVAL_10_MIN),
        [IFLA_BRIDGE_CFM_CC_CONFIG_EXP_MAID]     = {
        .type = NLA_BINARY, .len = CFM_MAID_LENGTH },
 };