Summary: | Page fault in ip6_setpktopts when syncthing is started with pflog loaded | ||
---|---|---|---|
Product: | Base System | Reporter: | Dimitry Andric <dim> |
Component: | kern | Assignee: | Dimitry Andric <dim> |
Status: | Closed FIXED | ||
Severity: | Affects Some People | CC: | ae, emaste |
Priority: | --- | Keywords: | patch |
Version: | CURRENT | Flags: | dim:
mfc-stable11+
dim: mfc-stable10- |
Hardware: | Any | ||
OS: | Any |
Description
Dimitry Andric
![]() ![]() Bisection shows this was introduced by r271396 [1]. Specifically, this part that was added: 2572 if (ifp != NULL && ( 2573 ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED)) 2574 return (ENETDOWN); The problem is that ND_IFINFO(ifp) dereferences ifp->if_afdata[AF_INET6] unconditionally, so if that is NULL, a page fault occurs. Maybe a good fix is just the following? Index: sys/netinet6/ip6_output.c =================================================================== --- sys/netinet6/ip6_output.c (revision 271396) +++ sys/netinet6/ip6_output.c (working copy) @@ -2569,7 +2569,7 @@ if (ifp == NULL) return (ENXIO); } - if (ifp != NULL && ( + if (ifp != NULL && ifp->if_afdata[AF_INET6] != NULL && ( ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED)) return (ENETDOWN); [1] https://svnweb.freebsd.org/base?view=revision&revision=271396 I prefer this patch, can you test? --- ip6_output.c (revision 302315) +++ ip6_output.c (working copy) @@ -2659,8 +2659,8 @@ ip6_setpktopt(int optname, u_char *buf, int len, s if (ifp == NULL) return (ENXIO); } - if (ifp != NULL && ( - ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED)) + if (ifp != NULL && (ifp->if_afdata[AF_INET6] == NULL || + (ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) != 0)) return (ENETDOWN); if (ifp != NULL && (In reply to Andrey V. Elsukov from comment #2) > I prefer this patch, can you test? Yes, that works fine too. So Andrey, shall I commit your version from comment 2, with "Reviewed by: ae"? A commit references this bug: Author: dim Date: Wed Jul 13 19:41:19 UTC 2016 New revision: 302784 URL: https://svnweb.freebsd.org/changeset/base/302784 Log: Fix a page fault in ip6_setpktopt(), occurring when the pflog module is loaded, and syncthing is started, which uses setsockopt(IPV6_PKGINFO). This is because pflog interfaces do not normally have an IPv6 address, causing the ND_IFINFO() macro to dereference a NULL pointer. Reviewed by: ae PR: 210943 MFC after: 3 days Changes: head/sys/netinet6/ip6_output.c Assign to committer that resolved. Re-open for MFC to stable/11, stable/10 Please set flag mfc-stable* to + if/when committed, or - if not appropriate with comment A commit references this bug: Author: dim Date: Sat Jul 16 10:50:28 UTC 2016 New revision: 302934 URL: https://svnweb.freebsd.org/changeset/base/302934 Log: MFC r302784: Fix a page fault in ip6_setpktopt(), occurring when the pflog module is loaded, and syncthing is started, which uses setsockopt(IPV6_PKGINFO). This is because pflog interfaces do not normally have an IPv6 address, causing the ND_IFINFO() macro to dereference a NULL pointer. Approved by: re (kib) Reviewed by: ae PR: 210943 Changes: _U stable/11/ stable/11/sys/netinet6/ip6_output.c Merged to stable/11 in time for 11.0-RELEASE. Not applicable to stable/10. |