fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-remsim/+/44181?usp=email ) Change subject: bankd: fix stack buffer overflow in blocking_ipa_read() ...................................................................... bankd: fix stack buffer overflow in blocking_ipa_read() worker_transceive_loop() passes a 65536 byte buffer to blocking_ipa_read(), which reads the 3 byte IPA header and then receives as many bytes as indicated by its 16 bit length field into the remaining space, without checking whether they actually fit. A length of 65534 or 65535 makes recv() write up to 2 bytes past the end of the on-stack buffer. This can be triggered by any TCP peer, even before it has identified itself. Check that the whole IPA message fits into the given buffer and bail out otherwise. Change-Id: Ib4dc4d3cdc3e17ec0724caaafc4e6f855a6a931a --- M src/bankd/bankd_main.c 1 file changed, 5 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/81/44181/1 diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c index c85f678..fdd2865 100644 --- a/src/bankd/bankd_main.c +++ b/src/bankd/bankd_main.c @@ -666,6 +666,11 @@ return -2; len = ntohs(hh->len); + if (sizeof(*hh) + len > buf_size) { + LOGW(worker, "IPA message too long (%u + %u > %u bytes)\n", + (unsigned int) sizeof(*hh), len, buf_size); + return -8; + } needed = len; //- sizeof(*hh); restart_body: -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/44181?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: Ib4dc4d3cdc3e17ec0724caaafc4e6f855a6a931a Gerrit-Change-Number: 44181 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>