Skip to content

Commit 8885bb0

Browse files
peilin-yedavem330
authored andcommitted
AX.25: Prevent out-of-bounds read in ax25_sendmsg()
Checks on `addr_len` and `usax->sax25_ndigis` are insufficient. ax25_sendmsg() can go out of bounds when `usax->sax25_ndigis` equals to 7 or 8. Fix it. It is safe to remove `usax->sax25_ndigis > AX25_MAX_DIGIS`, since `addr_len` is guaranteed to be less than or equal to `sizeof(struct full_sockaddr_ax25)` Signed-off-by: Peilin Ye <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f659173 commit 8885bb0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/ax25/af_ax25.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,8 @@ static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
15091509
struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)usax;
15101510

15111511
/* Valid number of digipeaters ? */
1512-
if (usax->sax25_ndigis < 1 || usax->sax25_ndigis > AX25_MAX_DIGIS) {
1512+
if (usax->sax25_ndigis < 1 || addr_len < sizeof(struct sockaddr_ax25) +
1513+
sizeof(ax25_address) * usax->sax25_ndigis) {
15131514
err = -EINVAL;
15141515
goto out;
15151516
}

0 commit comments

Comments
 (0)