Skip to content

Commit

Permalink
MFC r343089:
Browse files Browse the repository at this point in the history
Limit the user-controllable amount of memory the kernel allocates
via IPPROTO_SCTP level socket options.

This issue was found by running syzkaller.
  • Loading branch information
tuexen committed Jan 25, 2019
1 parent 4a9fc73 commit 58e6efc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sys/netinet/sctp_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,9 @@ __FBSDID("$FreeBSD$");
((((uint8_t *)&(a)->s_addr)[0] == 169) && \
(((uint8_t *)&(a)->s_addr)[1] == 254))

/* Maximum size of optval for IPPROTO_SCTP level socket options. */
#define SCTP_SOCKET_OPTION_LIMIT (64 * 1024)


#if defined(_KERNEL)
#define SCTP_GETTIME_TIMEVAL(x) (getmicrouptime(x))
Expand Down
4 changes: 4 additions & 0 deletions sys/netinet/sctp_usrreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -6812,6 +6812,10 @@ sctp_ctloutput(struct socket *so, struct sockopt *sopt)
return (error);
}
optsize = sopt->sopt_valsize;
if (optsize > SCTP_SOCKET_OPTION_LIMIT) {
SCTP_LTRACE_ERR_RET(so->so_pcb, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOBUFS);
return (ENOBUFS);
}
if (optsize) {
SCTP_MALLOC(optval, void *, optsize, SCTP_M_SOCKOPT);
if (optval == NULL) {
Expand Down

0 comments on commit 58e6efc

Please sign in to comment.