RDMA/rxe: Fix possible NULL pointer dereference
Subsystems (2)
PATCH 1/1 RDMA/rxe: Fix possible NULL pointer dereference
skb_clone() is called without checking if the returned pointer is NULL before it is dereferenced. Fix by adding an additional error check.
Addresses-Coverity-ID: 1497804: Null pointer dereferences (NULL_RETURNS)
--- drivers/infiniband/sw/rxe/rxe_recv.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/infiniband/sw/rxe/rxe_recv.c +9 -2
@@ -266,10 +266,13 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)/* for all but the last qp create a new clone of the * skb and pass to the qp. */ -if (mce->qp_list.next != &mcg->qp_list) +if (mce->qp_list.next != &mcg->qp_list) { per_qp_skb =skb_clone (skb,GFP_ATOMIC ); -else +if (!per_qp_skb) + goto err2; + }else { per_qp_skb = skb; + } per_qp_pkt =SKB_TO_PKT (per_qp_skb); per_qp_pkt->qp = qp;
@@ -283,6 +286,10 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)return ; +err2: +spin_unlock_bh (&mcg->mcg_lock); +rxe_drop_ref (mcg);/* drop ref from rxe_pool_get_key. */ + err1:kfree_skb (skb); }
Signature · 1 line
2.28.0
A message that is not in the archive (sent off-list or not yet received): DM6PR12MB3516EC1E0F28EB8F9B970F24D5050@DM6PR12MB3516.namprd12.prod.outlook.com
Zhu Yanjun
maintainerQuoted 9 lines · Yanjun Zhu
-----Original Message-----
From: Alex Dewar <[email protected]>
Sent: Tuesday, October 13, 2020 12:53 AM
Cc: Alex Dewar <[email protected]>; Yanjun Zhu <[email protected]>; Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>; Bob Pearson <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] RDMA/rxe: Fix possible NULL pointer dereference
Quoted 5 lines
skb_clone()is called without checking if the returned pointer is NULL before it is dereferenced. Fix by adding an additional error check.Fixes e7ec96fc7932 ("RDMA/rxe: Fix skb lifetime in rxe_rcv_mcast_pkt()")Addresses-Coverity-ID: 1497804: Null pointer dereferences (
NULL_RETURNS)Signed-off-by Alex Dewar <[email protected]>
Thanks a lot.
Zhu Yanjun
Quoted 38 lines
--- drivers/infiniband/sw/rxe/rxe_recv.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/infiniband/sw/rxe/rxe_recv.c +9
-3@@ -266,10 +266,13 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)/* for all but the last qp create a new clone of the * skb and pass to the qp. */ -if (mce->qp_list.next != &mcg->qp_list) +if (mce->qp_list.next != &mcg->qp_list) { per_qp_skb =skb_clone (skb,GFP_ATOMIC ); -else +if (!per_qp_skb) + goto err2; + }else { per_qp_skb = skb; + } per_qp_pkt =SKB_TO_PKT (per_qp_skb); per_qp_pkt->qp = qp;@@ -283,6 +286,10 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)return ; +err2: +spin_unlock_bh (&mcg->mcg_lock); +rxe_drop_ref (mcg);/* drop ref from rxe_pool_get_key. */ + err1:kfree_skb (skb); } --2.28.0
Jason Gunthorpe
maintainerQuoted 9 lines · Alex Dewar
skb_clone()is called without checking if the returned pointer is NULL before it is dereferenced. Fix by adding an additional error check.Fixes e7ec96fc7932 ("RDMA/rxe: Fix skb lifetime in rxe_rcv_mcast_pkt()")Addresses-Coverity-ID: 1497804: Null pointer dereferences (
NULL_RETURNS)Signed-off-by Alex Dewar <[email protected]>--- drivers/infiniband/sw/rxe/rxe_recv.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
I took Bob's version of this since it is a little bit simpler
Thanks,
Jason