ws1004 uploaded patch set #2 to this change.
gb: ns2: clamp embedded NS PDU to msgb tailroom
Per TS 48.016 9.2.7.2 an NS-STATUS PDU embeds the PDU that caused the
error. reject_status_msg() copies it in without any length check, and
ns2_tx_status() clamps it against nsvc->bind->mtu only, not against
the space left in the reply msgb.
For an NS-over-IP bind that MTU is 65527 (gprs_ns2_udp.c:344), while
the STATUS msgb from ns2_msgb_alloc() offers 3052 usable bytes
(NS_ALLOC_SIZE 3072 minus NS_ALLOC_HEADROOM 20), of which 3048 remain
after the NS header and the Cause IE. A received PDU of 3046 bytes or
more therefore makes msgb_tvlv_put() -> msgb_put() hit MSGB_ABORT,
which aborts the process. No NS-VC, handshake or credentials are
needed to reach either site.
Clamp against the msgb tailroom in both places, and use a saturating
clamp instead of a subtraction on an unsigned (the old form could
underflow if the MTU were smaller than the message built so far).
bssgp_tx_status() in the same tree already does this correctly via
OSMO_MIN(..., msgb_tailroom(msg) - 3).
Fixes: 6a161497cfd8cacfef10c2e81cff85a45447e107
Change-Id: Iac1c5c15875f30f34d0f7e9fc74264530a02b6ae
---
M src/gb/gprs_ns2.c
M src/gb/gprs_ns2_message.c
2 files changed, 28 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/38/44138/2
To view, visit change 44138. To unsubscribe, or for help writing mail filters, visit settings.