NetBSD Problem Report #40661

From www@NetBSD.org  Mon Feb 16 10:53:00 2009
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 98E4B63BB35
	for <gnats-bugs@gnats.netbsd.org>; Mon, 16 Feb 2009 10:53:00 +0000 (UTC)
Message-Id: <20090216105300.24A4463B8C3@narn.NetBSD.org>
Date: Mon, 16 Feb 2009 10:53:00 +0000 (UTC)
From: akr@fsij.org
Reply-To: akr@fsij.org
To: gnats-bugs@NetBSD.org
Subject: kernel: page fault trap by IPV6_PKTINFO
X-Send-Pr-Version: www-1.0

>Number:         40661
>Category:       kern
>Synopsis:       kernel crash: page fault trap by IPV6_PKTINFO
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 16 10:55:00 +0000 2009
>Closed-Date:    Sun Dec 04 17:17:01 +0000 2016
>Last-Modified:  Sun Dec 04 17:17:01 +0000 2016
>Originator:     Tanaka Akira
>Release:        NetBSD 4.0.1
>Organization:
AIST
>Environment:
NetBSD netbsd.tky.aist.go.jp 4.0.1 NetBSD 4.0.1 (GENERIC) #0: Tue Oct  7 21:00:39 PDT 2008  builds@wb28:/home/builds/ab/netbsd-4-0-1-RELEASE/amd64/200810080053Z-obj/home/builds/ab/netbsd-4-0-1-RELEASE/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
IPV6_PKTINFO causes "kernel: page fault trap".

uvm_fault(0xffffffff80aef340, 0xffff800085250000, 1) -> e
kernel: page fault trap, code=0
Stopped in pid 179.1 (a.out) at netbsd:ip6_setpktopts+0xe6:    movl    0(%r13),%r12d
db>

Note that IPV6_PKTINFO is described in RFC 3542.

>How-To-Repeat:
% cat tst.c 
#include <stdlib.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>

int main(int argc, char **argv)
{
  int s1, s2;
  int on = 1;
  struct sockaddr_in6 addr = { sizeof(addr), AF_INET6, 9999, 0, IN6ADDR_LOOPBACK_INIT, 0 };
  char buf[4096], cbuf[4096];
  struct sockaddr_storage ss;
  struct iovec iov;
  struct msghdr msg;
  int ret;

  s1 = socket(PF_INET6, SOCK_DGRAM, 0);
  if (s1 == -1) { perror("socket"); exit(1); }

  ret = setsockopt(s1, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, sizeof(on));
  if (ret == -1) { perror("setsockopt"); exit(1); }

  ret = bind(s1, (struct sockaddr *)&addr, sizeof(addr));
  if (ret == -1) { perror("bind"); exit(1); }

  s2 = socket(PF_INET6, SOCK_DGRAM, 0);
  if (s2 == -1) { perror("socket"); exit(1); }

  ret = sendto(s2, "a", 1, 0, (struct sockaddr *)&addr, sizeof(addr));
  if (ret == -1) { perror("sendto"); exit(1); }

  iov.iov_base = buf;
  iov.iov_len = sizeof(buf);

  msg.msg_name = (void *)&ss;
  msg.msg_namelen = sizeof(ss);
  msg.msg_iov = &iov;
  msg.msg_iovlen = 1;
  msg.msg_control = cbuf;
  msg.msg_controllen = sizeof(cbuf);
  msg.msg_flags = 0;

  ret = recvmsg(s1, &msg, 0);
  if (ret == -1) { perror("recvmsg"); exit(1); }

  msg.msg_iov->iov_len = ret;
  msg.msg_controllen = ((struct cmsghdr *)&cbuf)->cmsg_len;

  ret = sendmsg(s1, &msg, 0);
  if (ret == -1) { perror("sendmsg"); exit(1); }

  return 0;
}
% gcc -Wall tst.c 
% ./a.out 

>Fix:

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Sun, 04 Dec 2016 17:17:01 +0000
State-Changed-Why:
It appears this bug was fixed in the meantime by someone who did not see or respond to this report, the code
no longer causes a panic. Thanks for the report!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.41 2016/01/01 03:26:19 jakllsch Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2016 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.