You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2026/10/26 12:38:53 UTC

(mynewt-core) 07/07: net/lora: Ignore MAC commands in multicast frames

This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 60a17d6168e64e232772556ff97e7b162513dd81
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Sun Oct 25 21:59:00 2026 +0100

    net/lora: Ignore MAC commands in multicast frames
    
    MAC commands in multicast frames, both in FOpts and in port 0 payload,
    were processed as for unicast frames. LoRaWAN does not allow MAC
    commands in multicast frames, and processing them allowed any holder
    of multicast group keys to change device MAC configuration.
    
    Drop multicast frames with FOpts or port 0 payload.
    
    Assisted-by: Claude:claude-opus-5-5
---
 net/lora/node/src/mac/LoRaMac.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/lora/node/src/mac/LoRaMac.c b/net/lora/node/src/mac/LoRaMac.c
index 6ed73f171..579f42624 100644
--- a/net/lora/node/src/mac/LoRaMac.c
+++ b/net/lora/node/src/mac/LoRaMac.c
@@ -1118,6 +1118,14 @@ lora_mac_process_radio_rx(struct os_event *ev)
             if (multicast == 1) {
                 rxi->pkt_type = MCPS_MULTICAST;
 
+                /* Multicast frames must not carry MAC commands */
+                if ((fCtrl.Bits.FOptsLen > 0) ||
+                    ((appPayloadStartIndex < size - LORAMAC_MFR_LEN) &&
+                     (payload[appPayloadStartIndex] == 0))) {
+                    STATS_INC(lora_mac_stats, rx_invalid);
+                    goto process_rx_done;
+                }
+
                 if((curMulticastParams->DownLinkCounter == downLinkCounter ) &&
                     (curMulticastParams->DownLinkCounter != 0)) {
                     /* XXX: I need to understand multicast. Are these sent