Kernel oops in ip6t_LOG.c:ip6_nexthdr
Subsystems (3)
PATCH 1/1 Kernel oops in ip6t_LOG.c:ip6_nexthdr
Hi,
We just ran into a kernel oops after enabling ipv6 packet filtering. The machine would choke on the IGMPv6 packets sent out when the interface is taken up. The reason is this code:
/*stupid rfc2402 */
case IPPROTO_DSTOPTS:
case IPPROTO_ROUTING:
case IPPROTO_HOPOPTS:
nexthdr = **hdrptr;
hdrlen = *hdrptr[1] * 8 + 8;
^^^^^^^^^^ it dies here
*hdrptr = *hdrptr + hdrlen;
break;hdrptr is a u_int8_t **. What you really want to do here is look at (*hdrptr)[1], but what the expression does is look at *(hdrptr[1]). Unfortunately, hdrptr[1] is usually random garbage.
The attached patch fixes this.
Olaf
Signature · 3 lines
Olaf Kirch | The Hardware Gods hate me. [email protected] | ---------------+
Prevent oopses when logging IGMPv6 packets and similar.
net/ipv6/netfilter/ip6t_LOG.c +2 -2
@@ -55,7 +55,7 @@ static u_int8_t ip6_nexthdr(u_int8_t currepeatedly...with a large stick...no, an even LARGER stick...no, you're still not thinking big enough */ nexthdr = **hdrptr; - hdrlen = *hdrptr[1 ] *4 +8 ; + hdrlen = (*hdrptr)[1 ] *4 +8 ; *hdrptr = *hdrptr + hdrlen;break ;/*stupid rfc2402 */
@@ -63,7 +63,7 @@ static u_int8_t ip6_nexthdr(u_int8_t curcase IPPROTO_ROUTING :case IPPROTO_HOPOPTS : nexthdr = **hdrptr; - hdrlen = *hdrptr[1 ] *8 +8 ; + hdrlen = (*hdrptr)[1 ] *8 +8 ; *hdrptr = *hdrptr + hdrlen;break ;case IPPROTO_FRAGMENT :
In article <[email protected]> (at Thu, 26 Aug 2004 13:35:39 +0200), Olaf Kirch <[email protected]> says:
Quoted 8 lines
hdrlen = *hdrptr[1] * 8 + 8; ^^^^^^^^^^ it dies here *hdrptr = *hdrptr + hdrlen; break;hdrptr is a
u_int8_t**. What you really want to do here is look at (*hdrptr)[1], but what the expression does is look at *(hdrptr[1]). Unfortunately, hdrptr[1] is usually random garbage.
Agreed. Same bug also lives in 2.4.x.
--yoshfuji
Quoted 3 lines · On Thu, 26 Aug 2004 13:35:39 +0200 Olaf Kirch <[email protected]> wrote:
hdrptr is a
u_int8_t**. What you really want to do here is look at (*hdrptr)[1], but what the expression does is look at *(hdrptr[1]). Unfortunately, hdrptr[1] is usually random garbage.
Good catch, patch applied (to 2.4.x too).
Thanks Olaf.