netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] gtp: minor enhancements
@ 2020-08-28 13:30 Nicolas Dichtel
  2020-08-28 13:30 ` [PATCH net-next 1/2] gtp: remove useless rcu_read_lock() Nicolas Dichtel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nicolas Dichtel @ 2020-08-28 13:30 UTC (permalink / raw)
  To: davem, kuba, pablo, laforge, osmocom-net-gprs; +Cc: netdev

The first patch removes a useless rcu lock and the second relax alloc
constraints when a PDP context is added.

 drivers/net/gtp.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments are welcomed,
Nicolas



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

* [PATCH net-next 1/2] gtp: remove useless rcu_read_lock()
  2020-08-28 13:30 [PATCH net-next 0/2] gtp: minor enhancements Nicolas Dichtel
@ 2020-08-28 13:30 ` Nicolas Dichtel
  2020-08-28 13:30 ` [PATCH net-next 2/2] gtp: relax alloc constraint when adding a pdp Nicolas Dichtel
  2020-08-31 19:24 ` [PATCH net-next 0/2] gtp: minor enhancements David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Dichtel @ 2020-08-28 13:30 UTC (permalink / raw)
  To: davem, kuba, pablo, laforge, osmocom-net-gprs; +Cc: netdev, Nicolas Dichtel

The rtnl lock is taken just the line above, no need to take the rcu also.

Fixes: 1788b8569f5d ("gtp: fix use-after-free in gtp_encap_destroy()")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 drivers/net/gtp.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index c84a10569388..6f871ec31393 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -1071,7 +1071,6 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info)
 	}
 
 	rtnl_lock();
-	rcu_read_lock();
 
 	gtp = gtp_find_dev(sock_net(skb->sk), info->attrs);
 	if (!gtp) {
@@ -1100,7 +1099,6 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info)
 	}
 
 out_unlock:
-	rcu_read_unlock();
 	rtnl_unlock();
 	return err;
 }
-- 
2.26.2


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

* [PATCH net-next 2/2] gtp: relax alloc constraint when adding a pdp
  2020-08-28 13:30 [PATCH net-next 0/2] gtp: minor enhancements Nicolas Dichtel
  2020-08-28 13:30 ` [PATCH net-next 1/2] gtp: remove useless rcu_read_lock() Nicolas Dichtel
@ 2020-08-28 13:30 ` Nicolas Dichtel
  2020-08-31 19:24 ` [PATCH net-next 0/2] gtp: minor enhancements David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Dichtel @ 2020-08-28 13:30 UTC (permalink / raw)
  To: davem, kuba, pablo, laforge, osmocom-net-gprs; +Cc: netdev, Nicolas Dichtel

When a PDP context is added, the rtnl lock is held, thus no need to force
a GFP_ATOMIC.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 drivers/net/gtp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 6f871ec31393..2ed1e82a8ad8 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -1036,7 +1036,7 @@ static void pdp_context_delete(struct pdp_ctx *pctx)
 	call_rcu(&pctx->rcu_head, pdp_context_free);
 }
 
-static int gtp_tunnel_notify(struct pdp_ctx *pctx, u8 cmd);
+static int gtp_tunnel_notify(struct pdp_ctx *pctx, u8 cmd, gfp_t allocation);
 
 static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info)
 {
@@ -1094,7 +1094,7 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info)
 	if (IS_ERR(pctx)) {
 		err = PTR_ERR(pctx);
 	} else {
-		gtp_tunnel_notify(pctx, GTP_CMD_NEWPDP);
+		gtp_tunnel_notify(pctx, GTP_CMD_NEWPDP, GFP_KERNEL);
 		err = 0;
 	}
 
@@ -1166,7 +1166,7 @@ static int gtp_genl_del_pdp(struct sk_buff *skb, struct genl_info *info)
 		netdev_dbg(pctx->dev, "GTPv1-U: deleting tunnel id = %x/%x (pdp %p)\n",
 			   pctx->u.v1.i_tei, pctx->u.v1.o_tei, pctx);
 
-	gtp_tunnel_notify(pctx, GTP_CMD_DELPDP);
+	gtp_tunnel_notify(pctx, GTP_CMD_DELPDP, GFP_ATOMIC);
 	pdp_context_delete(pctx);
 
 out_unlock:
@@ -1220,12 +1220,12 @@ static int gtp_genl_fill_info(struct sk_buff *skb, u32 snd_portid, u32 snd_seq,
 	return -EMSGSIZE;
 }
 
-static int gtp_tunnel_notify(struct pdp_ctx *pctx, u8 cmd)
+static int gtp_tunnel_notify(struct pdp_ctx *pctx, u8 cmd, gfp_t allocation)
 {
 	struct sk_buff *msg;
 	int ret;
 
-	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, allocation);
 	if (!msg)
 		return -ENOMEM;
 
-- 
2.26.2


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

* Re: [PATCH net-next 0/2] gtp: minor enhancements
  2020-08-28 13:30 [PATCH net-next 0/2] gtp: minor enhancements Nicolas Dichtel
  2020-08-28 13:30 ` [PATCH net-next 1/2] gtp: remove useless rcu_read_lock() Nicolas Dichtel
  2020-08-28 13:30 ` [PATCH net-next 2/2] gtp: relax alloc constraint when adding a pdp Nicolas Dichtel
@ 2020-08-31 19:24 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-08-31 19:24 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: kuba, pablo, laforge, osmocom-net-gprs, netdev

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date: Fri, 28 Aug 2020 15:30:54 +0200

> The first patch removes a useless rcu lock and the second relax alloc
> constraints when a PDP context is added.

Series applied, thanks.

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

end of thread, other threads:[~2020-08-31 19:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 13:30 [PATCH net-next 0/2] gtp: minor enhancements Nicolas Dichtel
2020-08-28 13:30 ` [PATCH net-next 1/2] gtp: remove useless rcu_read_lock() Nicolas Dichtel
2020-08-28 13:30 ` [PATCH net-next 2/2] gtp: relax alloc constraint when adding a pdp Nicolas Dichtel
2020-08-31 19:24 ` [PATCH net-next 0/2] gtp: minor enhancements 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).