* [PATCH] scsi: target: cxgbit: check skb dequeue result
@ 2023-04-06 15:04 Denis Plotnikov
2023-04-07 19:16 ` Bodo Stroesser
2023-04-10 11:45 ` Varun Prakash
0 siblings, 2 replies; 5+ messages in thread
From: Denis Plotnikov @ 2023-04-06 15:04 UTC (permalink / raw)
To: linux-scsi
Cc: linux-kernel, den-plotnikov, target-devel, varun, nab,
martin.petersen
On a couple of abort packet paths skb dequeuing may end up with
returning NULL, which, in turn, may end up with further null
pointer dereference.
Fix it by checking the return value of skb dequeuing.
Found by Linux Verification Center(linuxtesting.org) with SVACE.
Fixes: 9730ffcb8957 (cxgbit: add files for cxgbit.ko)
Signed-off-by: Denis Plotnikov <den-plotnikov@yandex-team.ru>
---
drivers/target/iscsi/cxgbit/cxgbit_cm.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
index 518ded214e74..d43fd761c20a 100644
--- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c
+++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
@@ -669,6 +669,9 @@ static int cxgbit_send_abort_req(struct cxgbit_sock *csk)
cxgbit_send_tx_flowc_wr(csk);
skb = __skb_dequeue(&csk->skbq);
+ if (!skb)
+ return 0;
+
cxgb_mk_abort_req(skb, len, csk->tid, csk->txq_idx,
csk->com.cdev, cxgbit_abort_arp_failure);
@@ -1769,9 +1772,10 @@ static void cxgbit_abort_req_rss(struct cxgbit_sock *csk, struct sk_buff *skb)
cxgbit_send_tx_flowc_wr(csk);
rpl_skb = __skb_dequeue(&csk->skbq);
-
- cxgb_mk_abort_rpl(rpl_skb, len, csk->tid, csk->txq_idx);
- cxgbit_ofld_send(csk->com.cdev, rpl_skb);
+ if (!rpl_skb) {
+ cxgb_mk_abort_rpl(rpl_skb, len, csk->tid, csk->txq_idx);
+ cxgbit_ofld_send(csk->com.cdev, rpl_skb);
+ }
if (wakeup_thread) {
cxgbit_queue_rx_skb(csk, skb);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi: target: cxgbit: check skb dequeue result
2023-04-06 15:04 [PATCH] scsi: target: cxgbit: check skb dequeue result Denis Plotnikov
@ 2023-04-07 19:16 ` Bodo Stroesser
2023-04-10 7:35 ` Denis Plotnikov
2023-04-10 11:45 ` Varun Prakash
1 sibling, 1 reply; 5+ messages in thread
From: Bodo Stroesser @ 2023-04-07 19:16 UTC (permalink / raw)
To: Denis Plotnikov, linux-scsi
Cc: linux-kernel, target-devel, varun, nab, martin.petersen
On 06.04.23 17:04, Denis Plotnikov wrote:
> On a couple of abort packet paths skb dequeuing may end up with
> returning NULL, which, in turn, may end up with further null
> pointer dereference.
>
> Fix it by checking the return value of skb dequeuing.
>
> Found by Linux Verification Center(linuxtesting.org) with SVACE.
>
> Fixes: 9730ffcb8957 (cxgbit: add files for cxgbit.ko)
> Signed-off-by: Denis Plotnikov <den-plotnikov@yandex-team.ru>
> ---
> drivers/target/iscsi/cxgbit/cxgbit_cm.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
> index 518ded214e74..d43fd761c20a 100644
> --- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c
> +++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
> @@ -669,6 +669,9 @@ static int cxgbit_send_abort_req(struct cxgbit_sock *csk)
> cxgbit_send_tx_flowc_wr(csk);
>
> skb = __skb_dequeue(&csk->skbq);
> + if (!skb)
> + return 0;
> +
> cxgb_mk_abort_req(skb, len, csk->tid, csk->txq_idx,
> csk->com.cdev, cxgbit_abort_arp_failure);
>
> @@ -1769,9 +1772,10 @@ static void cxgbit_abort_req_rss(struct cxgbit_sock *csk, struct sk_buff *skb)
> cxgbit_send_tx_flowc_wr(csk);
>
> rpl_skb = __skb_dequeue(&csk->skbq);
> -
> - cxgb_mk_abort_rpl(rpl_skb, len, csk->tid, csk->txq_idx);
> - cxgbit_ofld_send(csk->com.cdev, rpl_skb);
> + if (!rpl_skb) {
Honestly I have no clue about cxgbit, but to avoid null pointer
dereference, shouldn't it be "if (rpl_skb) {"?
Bodo
> + cxgb_mk_abort_rpl(rpl_skb, len, csk->tid, csk->txq_idx);
> + cxgbit_ofld_send(csk->com.cdev, rpl_skb);
> + }
>
> if (wakeup_thread) {
> cxgbit_queue_rx_skb(csk, skb);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi: target: cxgbit: check skb dequeue result
2023-04-07 19:16 ` Bodo Stroesser
@ 2023-04-10 7:35 ` Denis Plotnikov
0 siblings, 0 replies; 5+ messages in thread
From: Denis Plotnikov @ 2023-04-10 7:35 UTC (permalink / raw)
To: Bodo Stroesser, linux-scsi
Cc: linux-kernel, target-devel, varun, nab, martin.petersen
On 07.04.2023 22:16, Bodo Stroesser wrote:
> On 06.04.23 17:04, Denis Plotnikov wrote:
>> On a couple of abort packet paths skb dequeuing may end up with
>> returning NULL, which, in turn, may end up with further null
>> pointer dereference.
>>
>> Fix it by checking the return value of skb dequeuing.
>>
>> Found by Linux Verification Center(linuxtesting.org) with SVACE.
>>
>> Fixes: 9730ffcb8957 (cxgbit: add files for cxgbit.ko)
>> Signed-off-by: Denis Plotnikov <den-plotnikov@yandex-team.ru>
>> ---
>> drivers/target/iscsi/cxgbit/cxgbit_cm.c | 10 +++++++---
>> 1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/target/iscsi/cxgbit/cxgbit_cm.c
>> b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
>> index 518ded214e74..d43fd761c20a 100644
>> --- a/drivers/target/iscsi/cxgbit/cxgbit_cm.c
>> +++ b/drivers/target/iscsi/cxgbit/cxgbit_cm.c
>> @@ -669,6 +669,9 @@ static int cxgbit_send_abort_req(struct
>> cxgbit_sock *csk)
>> cxgbit_send_tx_flowc_wr(csk);
>> skb = __skb_dequeue(&csk->skbq);
>> + if (!skb)
>> + return 0;
>> +
>> cxgb_mk_abort_req(skb, len, csk->tid, csk->txq_idx,
>> csk->com.cdev, cxgbit_abort_arp_failure);
>> @@ -1769,9 +1772,10 @@ static void cxgbit_abort_req_rss(struct
>> cxgbit_sock *csk, struct sk_buff *skb)
>> cxgbit_send_tx_flowc_wr(csk);
>> rpl_skb = __skb_dequeue(&csk->skbq);
>> -
>> - cxgb_mk_abort_rpl(rpl_skb, len, csk->tid, csk->txq_idx);
>> - cxgbit_ofld_send(csk->com.cdev, rpl_skb);
>> + if (!rpl_skb) {
>
> Honestly I have no clue about cxgbit, but to avoid null pointer
> dereference, shouldn't it be "if (rpl_skb) {"?
Yes it should. Thanks for finding that. I'll resend the patch.
Frankly, I have no clue about cxgbit as well, so may be there is a
better way to cope with the null pointer issue here.
Denis
>
> Bodo
>
>
>> + cxgb_mk_abort_rpl(rpl_skb, len, csk->tid, csk->txq_idx);
>> + cxgbit_ofld_send(csk->com.cdev, rpl_skb);
>> + }
>> if (wakeup_thread) {
>> cxgbit_queue_rx_skb(csk, skb);
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] scsi: target: cxgbit: check skb dequeue result
2023-04-06 15:04 [PATCH] scsi: target: cxgbit: check skb dequeue result Denis Plotnikov
2023-04-07 19:16 ` Bodo Stroesser
@ 2023-04-10 11:45 ` Varun Prakash
2023-04-10 13:04 ` Denis Plotnikov
1 sibling, 1 reply; 5+ messages in thread
From: Varun Prakash @ 2023-04-10 11:45 UTC (permalink / raw)
To: Denis Plotnikov, linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, target-devel@vger.kernel.org,
nab@linux-iscsi.org, martin.petersen@oracle.com
>On a couple of abort packet paths skb dequeuing may end up with
>returning NULL, which, in turn, may end up with further null
>pointer dereference.
>
>Fix it by checking the return value of skb dequeuing.
skbs in csk->skbq are preallocated for critical events in cxgbit_alloc_csk_skb(),
so there is no need to check for NULL.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi: target: cxgbit: check skb dequeue result
2023-04-10 11:45 ` Varun Prakash
@ 2023-04-10 13:04 ` Denis Plotnikov
0 siblings, 0 replies; 5+ messages in thread
From: Denis Plotnikov @ 2023-04-10 13:04 UTC (permalink / raw)
To: Varun Prakash, linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, target-devel@vger.kernel.org,
nab@linux-iscsi.org, martin.petersen@oracle.com
On 10.04.2023 14:45, Varun Prakash wrote:
>> On a couple of abort packet paths skb dequeuing may end up with
>> returning NULL, which, in turn, may end up with further null
>> pointer dereference.
>>
>> Fix it by checking the return value of skb dequeuing.
> skbs in csk->skbq are preallocated for critical events in cxgbit_alloc_csk_skb(),
> so there is no need to check for NULL.
Ok, thanks for the reply
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-04-10 13:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06 15:04 [PATCH] scsi: target: cxgbit: check skb dequeue result Denis Plotnikov
2023-04-07 19:16 ` Bodo Stroesser
2023-04-10 7:35 ` Denis Plotnikov
2023-04-10 11:45 ` Varun Prakash
2023-04-10 13:04 ` Denis Plotnikov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox