ipmr/ip6mr: Fix mr_mfc.unres.unresolved corruption.
Subsystems (3)
cover ipmr/ip6mr: Fix mr_mfc.unres.unresolved corruption.
ipmr_cache_resolve() / ip6mr_cache_resolve() dequeues skb from mr_mfc.unres.unresolved with no protection.
Patch 1 / 2 replace __skb_dequeue() with skb_dequeue() in ipmr_cache_resolve() / ip6mr_cache_resolve().
Kuniyuki Iwashima (2):
ipmr: Fix mr_mfc.unres.unresolved corruption in ipmr_cache_resolve().
ip6mr: Fix mr_mfc.unres.unresolved corruption in
ip6mr_cache_resolve().
net/ipv4/ipmr.c | 2 +- net/ipv6/ip6mr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.53.0.371.g1d285c8824-goog
PATCH 1/2 ipmr: Fix mr_mfc.unres.unresolved corruption in ipmr_cache_resolve().
mr_mfc.unres.unresolved is filled by skb_queue_tail() under spin_lock_bh(&mfc_unres_lock) in ipmr_cache_unresolved().
ipmr_cache_resolve() is called from ipmr_mfc_add() after releasing the spinlock, so nothing protects the queue.
Let's use skb_dequeue() instead.
--- net/ipv4/ipmr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/ipmr.c +1 -1
@@ -1002,7 +1002,7 @@ static void ipmr_cache_resolve(struct net *net, struct mr_table *mrt,struct nlmsgerr *e;/* Play the pending entries through our router */ -while ((skb =__skb_dequeue (&uc->_c.mfc_un.unres.unresolved))) { +while ((skb =skb_dequeue (&uc->_c.mfc_un.unres.unresolved))) {if (ip_hdr (skb)->version ==0 ) {struct nlmsghdr *nlh =skb_pull (skb,sizeof (struct iphdr ));
Signature · 1 line
2.53.0.371.g1d285c8824-goog
Re: [PATCH v1 net 1/2] ipmr: Fix mr_mfc.unres.unresolved corruption in ipmr_cache_resolve().
Quoted 29 lines · Kuniyuki Iwashima
mr_mfc.unres.unresolved is filled by
skb_queue_tail()underspin_lock_bh(&mfc_unres_lock)inipmr_cache_unresolved().
ipmr_cache_resolve()is called fromipmr_mfc_add()after releasing the spinlock, so nothing protects the queue.Let's use
skb_dequeue()instead.Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Kuniyuki Iwashima <[email protected]>--- net/ipv4/ipmr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/ipv4/ipmr.c +1
-2@@ -1002,7 +1002,7 @@ static void ipmr_cache_resolve(struct net *net, struct mr_table *mrt,struct nlmsgerr *e;/* Play the pending entries through our router */ -while ((skb =__skb_dequeue (&uc->_c.mfc_un.unres.unresolved))) { +while ((skb =skb_dequeue (&uc->_c.mfc_un.unres.unresolved))) {if (ip_hdr (skb)->version ==0 ) {struct nlmsghdr *nlh =skb_pull (skb,sizeof (struct iphdr )); --
Quoted 1 line
2.53.0.371.g1d285c8824-goog
Are you sure this is needed ?
ipmr_mfc_add()
..
if (found) {
ipmr_cache_resolve(net, mrt, uc, c);
ipmr_cache_resolve(net, mrt, uc, c); // This would still be racy}
My understanding of this code is that ipmr_mfc_add() removed uc from &mrt->mfc_unres_queue
under the mfc_unres_lock spinlock protection.
Re: [PATCH v1 net 1/2] ipmr: Fix mr_mfc.unres.unresolved corruption in ipmr_cache_resolve().
Quoted 37 lines · Eric Dumazet
Quoted 29 lines · Kuniyuki Iwashima
mr_mfc.unres.unresolved is filled by
skb_queue_tail()underspin_lock_bh(&mfc_unres_lock)inipmr_cache_unresolved().
ipmr_cache_resolve()is called fromipmr_mfc_add()after releasing the spinlock, so nothing protects the queue.Let's use
skb_dequeue()instead.Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Kuniyuki Iwashima <[email protected]>--- net/ipv4/ipmr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/ipv4/ipmr.c +1
-2@@ -1002,7 +1002,7 @@ static void ipmr_cache_resolve(struct net *net, struct mr_table *mrt,struct nlmsgerr *e;/* Play the pending entries through our router */ -while ((skb =__skb_dequeue (&uc->_c.mfc_un.unres.unresolved))) { +while ((skb =skb_dequeue (&uc->_c.mfc_un.unres.unresolved))) {if (ip_hdr (skb)->version ==0 ) {struct nlmsghdr *nlh =skb_pull (skb,sizeof (struct iphdr )); --Quoted 1 line
2.53.0.371.g1d285c8824-goog
Are you sure this is needed ?
ipmr_mfc_add()
..
Quoted 8 lines
if (found) { ipmr_cache_resolve(net, mrt, uc, c); ipmr_cache_resolve(net, mrt, uc, c); // This would still be racy}
My understanding of this code is that
ipmr_mfc_add()removed uc from&mrt->mfc_unres_queue
under themfc_unres_lockspinlock protection.
Ah you are right, maybe I missed the list_del() somehow.
Thank you!
PATCH 2/2 ip6mr: Fix mr_mfc.unres.unresolved corruption in ip6mr_cache_resolve().
In reply to Kuniyuki Iwashimamr_mfc.unres.unresolved is filled by skb_queue_tail() under spin_lock_bh(&mfc_unres_lock) in ip6mr_cache_unresolved().
ip6mr_cache_resolve() is called from ip6mr_mfc_add() after releasing the spinlock, so nothing protects the queue.
Let's use skb_dequeue() instead.
--- net/ipv6/ip6mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ip6mr.c +1 -1
@@ -1031,7 +1031,7 @@ static void ip6mr_cache_resolve(struct net *net, struct mr_table *mrt,* Play the pending entries through our router */ -while ((skb =__skb_dequeue (&uc->_c.mfc_un.unres.unresolved))) { +while ((skb =skb_dequeue (&uc->_c.mfc_un.unres.unresolved))) {if (ipv6_hdr (skb)->version ==0 ) {struct nlmsghdr *nlh =skb_pull (skb,sizeof (struct ipv6hdr ));
Signature · 1 line
2.53.0.371.g1d285c8824-goog