netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] mpls: fix possible use after free of device
@ 2015-06-05 17:54 Robert Shearman
  2015-06-05 19:08 ` Eric W. Biederman
  2015-06-08  2:37 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Robert Shearman @ 2015-06-05 17:54 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, ebiederm, roopa, Robert Shearman

The mpls device is used in an RCU read context without a lock being
held. As the memory is freed without waiting for the RCU grace period
to elapse, the freed memory could still be in use.

Address this by using kfree_rcu to free the memory for the mpls device
after the RCU grace period has elapsed.

Fixes: 03c57747a702 ("mpls: Per-device MPLS state")
Signed-off-by: Robert Shearman <rshearma@brocade.com>
---
 net/mpls/af_mpls.c  | 2 +-
 net/mpls/internal.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 7b3f732269e4..bff427f31924 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -541,7 +541,7 @@ static void mpls_ifdown(struct net_device *dev)
 
 	RCU_INIT_POINTER(dev->mpls_ptr, NULL);
 
-	kfree(mdev);
+	kfree_rcu(mdev, rcu);
 }
 
 static int mpls_dev_notify(struct notifier_block *this, unsigned long event,
diff --git a/net/mpls/internal.h b/net/mpls/internal.h
index b064c345042c..8cabeb5a1cb9 100644
--- a/net/mpls/internal.h
+++ b/net/mpls/internal.h
@@ -16,6 +16,7 @@ struct mpls_dev {
 	int			input_enabled;
 
 	struct ctl_table_header *sysctl;
+	struct rcu_head		rcu;
 };
 
 struct sk_buff;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] mpls: fix possible use after free of device
  2015-06-05 17:54 [PATCH net] mpls: fix possible use after free of device Robert Shearman
@ 2015-06-05 19:08 ` Eric W. Biederman
  2015-06-08  2:37 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Eric W. Biederman @ 2015-06-05 19:08 UTC (permalink / raw)
  To: Robert Shearman; +Cc: netdev, David S. Miller, roopa

Robert Shearman <rshearma@brocade.com> writes:

> The mpls device is used in an RCU read context without a lock being
> held. As the memory is freed without waiting for the RCU grace period
> to elapse, the freed memory could still be in use.
>
> Address this by using kfree_rcu to free the memory for the mpls device
> after the RCU grace period has elapsed.

Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>


> Fixes: 03c57747a702 ("mpls: Per-device MPLS state")
> Signed-off-by: Robert Shearman <rshearma@brocade.com>
> ---
>  net/mpls/af_mpls.c  | 2 +-
>  net/mpls/internal.h | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
> index 7b3f732269e4..bff427f31924 100644
> --- a/net/mpls/af_mpls.c
> +++ b/net/mpls/af_mpls.c
> @@ -541,7 +541,7 @@ static void mpls_ifdown(struct net_device *dev)
>  
>  	RCU_INIT_POINTER(dev->mpls_ptr, NULL);
>  
> -	kfree(mdev);
> +	kfree_rcu(mdev, rcu);
>  }
>  
>  static int mpls_dev_notify(struct notifier_block *this, unsigned long event,
> diff --git a/net/mpls/internal.h b/net/mpls/internal.h
> index b064c345042c..8cabeb5a1cb9 100644
> --- a/net/mpls/internal.h
> +++ b/net/mpls/internal.h
> @@ -16,6 +16,7 @@ struct mpls_dev {
>  	int			input_enabled;
>  
>  	struct ctl_table_header *sysctl;
> +	struct rcu_head		rcu;
>  };
>  
>  struct sk_buff;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] mpls: fix possible use after free of device
  2015-06-05 17:54 [PATCH net] mpls: fix possible use after free of device Robert Shearman
  2015-06-05 19:08 ` Eric W. Biederman
@ 2015-06-08  2:37 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2015-06-08  2:37 UTC (permalink / raw)
  To: rshearma; +Cc: netdev, ebiederm, roopa

From: Robert Shearman <rshearma@brocade.com>
Date: Fri, 5 Jun 2015 18:54:45 +0100

> The mpls device is used in an RCU read context without a lock being
> held. As the memory is freed without waiting for the RCU grace period
> to elapse, the freed memory could still be in use.
> 
> Address this by using kfree_rcu to free the memory for the mpls device
> after the RCU grace period has elapsed.
> 
> Fixes: 03c57747a702 ("mpls: Per-device MPLS state")
> Signed-off-by: Robert Shearman <rshearma@brocade.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-08  2:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-05 17:54 [PATCH net] mpls: fix possible use after free of device Robert Shearman
2015-06-05 19:08 ` Eric W. Biederman
2015-06-08  2:37 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).