[COPY OF #24434] pp_accept: fix potential out-of-bounds read on oversized accept() addrlen#24447
[COPY OF #24434] pp_accept: fix potential out-of-bounds read on oversized accept() addrlen#24447crystarm wants to merge 1 commit into
Conversation
|
Readers note that a number of relevant comments in #24434 when it was closed which now still need addressing. (GitHub will not allow re-opening that PR, unfortunately, otherwise we would have done so; instead it is on readers here to take note of the comments there.) |
|
There's two issues I see:
|
3e22b26 to
f6a5a48
Compare
|
I added a |
| * supplied buffer. */ | ||
| if (len > namesize) { | ||
| ck_warner(packWARN(WARN_IO), | ||
| "Socket address truncated in %s()", opname); |
There was a problem hiding this comment.
You don't need to setup opname like this, you can use OP_NAME(PL_op) to get the operator name.
f6a5a48 to
d12c210
Compare
COPY OF #24434
Summary: This PR fixes a potential out-of-bounds read in
pp_accept(pp_sys.c).Problem:
PerlSock_accept_cloexec()(viaaccept()/accept4()) can return anaddrlenlarger than the supplied buffer size when the peer address is truncated. The previous code used the returnedlendirectly inPUSHp(namebuf, len).Fix: Clamp
lentosizeof(namebuf)before callingPUSHp.Impact: No behavior change for valid lengths. Prevents reading past
namebufwhenaddrlenis oversized.Context: Change was motivated by static analysis finding. BUFFER_OVERFLOW.PROC pp_sys.c:[2631:10].log
This set of changes does not require a perldelta entry.