Skip to content

Commit 17ad73e

Browse files
Dan Carpenterdavem330
Dan Carpenter
authored andcommitted
AX.25: Prevent integer overflows in connect and sendmsg
We recently added some bounds checking in ax25_connect() and ax25_sendmsg() and we so we removed the AX25_MAX_DIGIS checks because they were no longer required. Unfortunately, I believe they are required to prevent integer overflows so I have added them back. Fixes: 8885bb0 ("AX.25: Prevent out-of-bounds read in ax25_sendmsg()") Fixes: 2f2a7ff ("AX.25: Fix out-of-bounds read in ax25_connect()") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e6827d1 commit 17ad73e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/ax25/af_ax25.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ static int __must_check ax25_connect(struct socket *sock,
11881188
fsa->fsa_ax25.sax25_ndigis != 0) {
11891189
/* Valid number of digipeaters ? */
11901190
if (fsa->fsa_ax25.sax25_ndigis < 1 ||
1191+
fsa->fsa_ax25.sax25_ndigis > AX25_MAX_DIGIS ||
11911192
addr_len < sizeof(struct sockaddr_ax25) +
11921193
sizeof(ax25_address) * fsa->fsa_ax25.sax25_ndigis) {
11931194
err = -EINVAL;
@@ -1509,7 +1510,9 @@ static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
15091510
struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)usax;
15101511

15111512
/* Valid number of digipeaters ? */
1512-
if (usax->sax25_ndigis < 1 || addr_len < sizeof(struct sockaddr_ax25) +
1513+
if (usax->sax25_ndigis < 1 ||
1514+
usax->sax25_ndigis > AX25_MAX_DIGIS ||
1515+
addr_len < sizeof(struct sockaddr_ax25) +
15131516
sizeof(ax25_address) * usax->sax25_ndigis) {
15141517
err = -EINVAL;
15151518
goto out;

0 commit comments

Comments
 (0)