mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
Validate IPv6 socket options more carefully to avoid a panic.
PR: kern/61513 Reviewed by: cperciva, nectar
This commit is contained in:
parent
3d7fb10b5f
commit
a5d1aae31a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=127463
@ -213,6 +213,7 @@ struct ip6_frag {
|
||||
|
||||
#define IPV6_MMTU 1280 /* minimal MTU and reassembly. 1024 + 256 */
|
||||
#define IPV6_MAXPACKET 65535 /* ip6 max packet size without Jumbo payload*/
|
||||
#define IPV6_MAXOPTHDR 2048 /* max option header size, 256 64-bit words */
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
|
@ -1780,12 +1780,48 @@ do { \
|
||||
break;
|
||||
}
|
||||
|
||||
optbuf = sopt->sopt_val;
|
||||
switch (optname) {
|
||||
case IPV6_HOPOPTS:
|
||||
case IPV6_DSTOPTS:
|
||||
case IPV6_RTHDRDSTOPTS:
|
||||
case IPV6_NEXTHOP:
|
||||
if (!privileged)
|
||||
error = EPERM;
|
||||
break;
|
||||
}
|
||||
if (error)
|
||||
break;
|
||||
|
||||
switch (optname) {
|
||||
case IPV6_PKTINFO:
|
||||
optlen = sizeof(struct in6_pktinfo);
|
||||
break;
|
||||
case IPV6_NEXTHOP:
|
||||
optlen = SOCK_MAXADDRLEN;
|
||||
break;
|
||||
default:
|
||||
optlen = IPV6_MAXOPTHDR;
|
||||
break;
|
||||
}
|
||||
if (sopt->sopt_valsize > optlen) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
optlen = sopt->sopt_valsize;
|
||||
optbuf = malloc(optlen, M_TEMP, M_WAITOK);
|
||||
error = sooptcopyin(sopt, optbuf, optlen,
|
||||
optlen);
|
||||
if (error) {
|
||||
free(optbuf, M_TEMP);
|
||||
break;
|
||||
}
|
||||
|
||||
optp = &in6p->in6p_outputopts;
|
||||
error = ip6_pcbopt(optname,
|
||||
optbuf, optlen,
|
||||
optp, privileged, uproto);
|
||||
free(optbuf, M_TEMP);
|
||||
break;
|
||||
}
|
||||
#undef OPTSET
|
||||
|
Loading…
Reference in New Issue
Block a user