diff options
author | Andrey V. Elsukov <ae@FreeBSD.org> | 2018-11-27 09:04:06 +0000 |
---|---|---|
committer | Andrey V. Elsukov <ae@FreeBSD.org> | 2018-11-27 09:04:06 +0000 |
commit | a716ad4a35627bfe68d6681e1a4bb0c1e922325d (patch) | |
tree | 9c17cc7f296353ee8b12b6006b194b8272f8ab6a /sys/net/if.c | |
parent | 71cf0a4e290b4cabf4b89b9b46caefed3d1b29fa (diff) | |
download | src-a716ad4a35627bfe68d6681e1a4bb0c1e922325d.tar.gz src-a716ad4a35627bfe68d6681e1a4bb0c1e922325d.zip |
Fix possible panic during ifnet detach in rtsock.
The panic can happen, when some application does dump of routing table
using sysctl interface. To prevent this, set IFF_DYING flag in
if_detach_internal() function, when ifnet under lock is removed from
the chain. In sysctl_rtsock() take IFNET_RLOCK_NOSLEEP() to prevent
ifnet detach during routes enumeration. In case, if some interface was
detached in the time before we take the lock, add the check, that ifnet
is not DYING. This prevents access to memory that could be freed after
ifnet is unlinked.
PR: 227720, 230498, 233306
Reviewed by: bz, eugen
MFC after: 1 week
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D18338
Notes
Notes:
svn path=/head/; revision=341008
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 15b4d7c12d1e..98e313f1508f 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1068,6 +1068,8 @@ if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp) CK_STAILQ_FOREACH(iter, &V_ifnet, if_link) if (iter == ifp) { CK_STAILQ_REMOVE(&V_ifnet, ifp, ifnet, if_link); + if (!vmove) + ifp->if_flags |= IFF_DYING; found = 1; break; } |