svn commit: r206660 - stable/8/sys/netgraph

Alexander Motin mav at FreeBSD.org
Thu Apr 15 12:41:37 UTC 2010


Author: mav
Date: Thu Apr 15 12:41:36 2010
New Revision: 206660
URL: http://svn.freebsd.org/changeset/base/206660

Log:
  MFC r206017:
  Make ng_ksocket fulfill lower protocol stack layers alignment requirements
  on platforms with strict alignment constraints.
  This fixes kernel panics on arm and probably other architectures.
  
  PR:             sparc64/80410, sparc/118932, sparc/113556

Modified:
  stable/8/sys/netgraph/ng_ksocket.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/netgraph/ng_ksocket.c
==============================================================================
--- stable/8/sys/netgraph/ng_ksocket.c	Thu Apr 15 12:40:33 2010	(r206659)
+++ stable/8/sys/netgraph/ng_ksocket.c	Thu Apr 15 12:41:36 2010	(r206660)
@@ -902,12 +902,24 @@ ng_ksocket_rcvdata(hook_p hook, item_p i
 	struct sockaddr *sa = NULL;
 	int error;
 	struct mbuf *m;
+#ifdef ALIGNED_POINTER
+	struct mbuf *n;
+#endif /* ALIGNED_POINTER */
 	struct sa_tag *stag;
 
 	/* Extract data */
 	NGI_GET_M(item, m);
 	NG_FREE_ITEM(item);
-
+#ifdef ALIGNED_POINTER
+	if (!ALIGNED_POINTER(mtod(m, caddr_t), uint32_t)) {
+		n = m_defrag(m, M_NOWAIT);
+		if (n == NULL) {
+			m_freem(m);
+			return (ENOBUFS);
+		}
+		m = n;
+	}
+#endif /* ALIGNED_POINTER */
 	/*
 	 * Look if socket address is stored in packet tags.
 	 * If sockaddr is ours, or provided by a third party (zero id),


More information about the svn-src-stable mailing list