netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next 1/2] tipc: simplify trivial boolean return
@ 2020-03-13  3:18 hoang.h.le
  2020-03-13  3:18 ` [net-next 2/2] tipc: add NULL pointer check to prevent kernel oops hoang.h.le
  2020-03-15  7:07 ` [net-next 1/2] tipc: simplify trivial boolean return David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: hoang.h.le @ 2020-03-13  3:18 UTC (permalink / raw)
  To: ying.xue, netdev; +Cc: jmaloy, maloy, Hoang Le

From: Hoang Le <hoang.h.le@dektech.com.au>

Checking and returning 'true' boolean is useless as it will be
returning at end of function

Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au>
Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jmaloy@redhat.com>
---
 net/tipc/msg.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index 0d515d20b056..4d0e0bdd997b 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -736,9 +736,6 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err)
 	msg_set_destport(msg, dport);
 	*err = TIPC_OK;
 
-	if (!skb_cloned(skb))
-		return true;
-
 	return true;
 }
 
-- 
2.20.1


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

* [net-next 2/2] tipc: add NULL pointer check to prevent kernel oops
  2020-03-13  3:18 [net-next 1/2] tipc: simplify trivial boolean return hoang.h.le
@ 2020-03-13  3:18 ` hoang.h.le
  2020-03-15  7:07   ` David Miller
  2020-03-15  7:07 ` [net-next 1/2] tipc: simplify trivial boolean return David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: hoang.h.le @ 2020-03-13  3:18 UTC (permalink / raw)
  To: ying.xue, netdev; +Cc: jmaloy, maloy, Hoang Le

From: Hoang Le <hoang.h.le@dektech.com.au>

Calling:
tipc_node_link_down()->
   - tipc_node_write_unlock()->tipc_mon_peer_down()
   - tipc_mon_peer_down()
  just after disabling bearer could be caused kernel oops.

Fix this by adding a sanity check to make sure valid memory
access.

Acked-by: Jon Maloy <jmaloy@redhat.com>
Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au>
---
 net/tipc/monitor.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c
index 58708b4c7719..6dce2abf436e 100644
--- a/net/tipc/monitor.c
+++ b/net/tipc/monitor.c
@@ -322,9 +322,13 @@ static void mon_assign_roles(struct tipc_monitor *mon, struct tipc_peer *head)
 void tipc_mon_remove_peer(struct net *net, u32 addr, int bearer_id)
 {
 	struct tipc_monitor *mon = tipc_monitor(net, bearer_id);
-	struct tipc_peer *self = get_self(net, bearer_id);
+	struct tipc_peer *self;
 	struct tipc_peer *peer, *prev, *head;
 
+	if (!mon)
+		return;
+
+	self = get_self(net, bearer_id);
 	write_lock_bh(&mon->lock);
 	peer = get_peer(mon, addr);
 	if (!peer)
@@ -407,11 +411,15 @@ void tipc_mon_peer_up(struct net *net, u32 addr, int bearer_id)
 void tipc_mon_peer_down(struct net *net, u32 addr, int bearer_id)
 {
 	struct tipc_monitor *mon = tipc_monitor(net, bearer_id);
-	struct tipc_peer *self = get_self(net, bearer_id);
+	struct tipc_peer *self;
 	struct tipc_peer *peer, *head;
 	struct tipc_mon_domain *dom;
 	int applied;
 
+	if (!mon)
+		return;
+
+	self = get_self(net, bearer_id);
 	write_lock_bh(&mon->lock);
 	peer = get_peer(mon, addr);
 	if (!peer) {
-- 
2.20.1


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

* Re: [net-next 1/2] tipc: simplify trivial boolean return
  2020-03-13  3:18 [net-next 1/2] tipc: simplify trivial boolean return hoang.h.le
  2020-03-13  3:18 ` [net-next 2/2] tipc: add NULL pointer check to prevent kernel oops hoang.h.le
@ 2020-03-15  7:07 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2020-03-15  7:07 UTC (permalink / raw)
  To: hoang.h.le; +Cc: ying.xue, netdev, jmaloy, maloy

From: hoang.h.le@dektech.com.au
Date: Fri, 13 Mar 2020 10:18:02 +0700

> From: Hoang Le <hoang.h.le@dektech.com.au>
> 
> Checking and returning 'true' boolean is useless as it will be
> returning at end of function
> 
> Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au>
> Acked-by: Ying Xue <ying.xue@windriver.com>
> Acked-by: Jon Maloy <jmaloy@redhat.com>

Applied.

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

* Re: [net-next 2/2] tipc: add NULL pointer check to prevent kernel oops
  2020-03-13  3:18 ` [net-next 2/2] tipc: add NULL pointer check to prevent kernel oops hoang.h.le
@ 2020-03-15  7:07   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-03-15  7:07 UTC (permalink / raw)
  To: hoang.h.le; +Cc: ying.xue, netdev, jmaloy, maloy

From: hoang.h.le@dektech.com.au
Date: Fri, 13 Mar 2020 10:18:03 +0700

> From: Hoang Le <hoang.h.le@dektech.com.au>
> 
> Calling:
> tipc_node_link_down()->
>    - tipc_node_write_unlock()->tipc_mon_peer_down()
>    - tipc_mon_peer_down()
>   just after disabling bearer could be caused kernel oops.
> 
> Fix this by adding a sanity check to make sure valid memory
> access.
> 
> Acked-by: Jon Maloy <jmaloy@redhat.com>
> Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au>

Applied.

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

end of thread, other threads:[~2020-03-15  7:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13  3:18 [net-next 1/2] tipc: simplify trivial boolean return hoang.h.le
2020-03-13  3:18 ` [net-next 2/2] tipc: add NULL pointer check to prevent kernel oops hoang.h.le
2020-03-15  7:07   ` David Miller
2020-03-15  7:07 ` [net-next 1/2] tipc: simplify trivial boolean return 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).