FreeBSD Bugzilla – Attachment 183566 Details for
Bug 220076
[patch] [panic] [netgraph] repeatable kernel panic due to a race in ng_iface(4)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
protect ng_iface private data
ng_iface.c.diff (text/plain), 2.26 KB, created by
Eugene Grosbein
on 2017-06-17 08:44:42 UTC
(
hide
)
Description:
protect ng_iface private data
Filename:
MIME Type:
Creator:
Eugene Grosbein
Created:
2017-06-17 08:44:42 UTC
Size:
2.26 KB
patch
obsolete
>--- sys/netgraph/ng_iface.c.orig 2017-02-15 13:05:35.564006000 +0700 >+++ sys/netgraph/ng_iface.c 2017-06-17 04:41:46.200314000 +0700 >@@ -112,9 +112,15 @@ struct ng_iface_private { > int unit; /* Interface unit number */ > node_p node; /* Our netgraph node */ > hook_p hooks[NUM_FAMILIES]; /* Hook for each address family */ >+ struct rwlock lock; /* Protect private data changes */ > }; > typedef struct ng_iface_private *priv_p; > >+#define PRIV_RLOCK(priv) rw_rlock(&priv->lock) >+#define PRIV_RUNLOCK(priv) rw_runlock(&priv->lock) >+#define PRIV_WLOCK(priv) rw_wlock(&priv->lock) >+#define PRIV_WUNLOCK(priv) rw_wunlock(&priv->lock) >+ > /* Interface methods */ > static void ng_iface_start(struct ifnet *ifp); > static int ng_iface_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); >@@ -448,7 +454,9 @@ ng_iface_send(struct ifnet *ifp, struct > > /* Send packet. If hook is not connected, mbuf will get freed. */ > NG_OUTBOUND_THREAD_REF(); >+ PRIV_RLOCK(priv); > NG_SEND_DATA_ONLY(error, *get_hook_from_iffam(priv, iffam), m); >+ PRIV_RUNLOCK(priv); > NG_OUTBOUND_THREAD_UNREF(); > > /* Update stats. */ >@@ -516,6 +524,8 @@ ng_iface_constructor(node_p node) > return (ENOMEM); > } > >+ rw_init(&priv->lock, "ng_iface private mutex"); >+ > /* Link them together */ > ifp->if_softc = priv; > priv->ifp = ifp; >@@ -562,16 +572,19 @@ static int > ng_iface_newhook(node_p node, hook_p hook, const char *name) > { > const iffam_p iffam = get_iffam_from_name(name); >+ const priv_p priv = NG_NODE_PRIVATE(node); > hook_p *hookptr; > > if (iffam == NULL) > return (EPFNOSUPPORT); >- hookptr = get_hook_from_iffam(NG_NODE_PRIVATE(node), iffam); >+ PRIV_WLOCK(priv); >+ hookptr = get_hook_from_iffam(priv, iffam); > if (*hookptr != NULL) > return (EISCONN); > *hookptr = hook; > NG_HOOK_HI_STACK(hook); > NG_HOOK_SET_TO_INBOUND(hook); >+ PRIV_WUNLOCK(priv); > return (0); > } > >@@ -730,6 +743,7 @@ ng_iface_shutdown(node_p node) > CURVNET_RESTORE(); > priv->ifp = NULL; > free_unr(V_ng_iface_unit, priv->unit); >+ rw_destroy(&priv->lock); > free(priv, M_NETGRAPH_IFACE); > NG_NODE_SET_PRIVATE(node, NULL); > NG_NODE_UNREF(node); >@@ -748,7 +762,9 @@ ng_iface_disconnect(hook_p hook) > > if (iffam == NULL) > panic("%s", __func__); >+ PRIV_WLOCK(priv); > *get_hook_from_iffam(priv, iffam) = NULL; >+ PRIV_WUNLOCK(priv); > return (0); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 220076
:
183566
|
183625
|
183627
|
184119
|
186781