LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] xen-blkfront: fix kernel panic with negotiate_mq error path
@ 2018-10-29 18:31 Manjunath Patil
  2018-10-30  7:04 ` Juergen Gross
  2018-10-30 10:39 ` Roger Pau Monné
  0 siblings, 2 replies; 5+ messages in thread
From: Manjunath Patil @ 2018-10-29 18:31 UTC (permalink / raw)
  To: boris.ostrovsky, jgross, konrad.wilk, roger.pau
  Cc: axboe, xen-devel, linux-block, linux-kernel

info->nr_rings isn't adjusted in case of ENOMEM error from
negotiate_mq(). This leads to kernel panic in error path.

Typical call stack involving panic -
 #8 page_fault at ffffffff8175936f
    [exception RIP: blkif_free_ring+33]
    RIP: ffffffffa0149491  RSP: ffff8804f7673c08  RFLAGS: 00010292
 ...
 #9 blkif_free at ffffffffa0149aaa [xen_blkfront]
 #10 talk_to_blkback at ffffffffa014c8cd [xen_blkfront]
 #11 blkback_changed at ffffffffa014ea8b [xen_blkfront]
 #12 xenbus_otherend_changed at ffffffff81424670
 #13 backend_changed at ffffffff81426dc3
 #14 xenwatch_thread at ffffffff81422f29
 #15 kthread at ffffffff810abe6a
 #16 ret_from_fork at ffffffff81754078

Though either of my changes avoid the panic, I included both the
changes. This issue got introduced with "7ed8ce1 xen-blkfront: move
negotiate_mq to cover all cases of new VBDs"

Signed-off-by: Manjunath Patil <manjunath.b.patil@oracle.com>
---
 drivers/block/xen-blkfront.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 429d201..dc8fe25 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -1350,8 +1350,10 @@ static void blkif_free(struct blkfront_info *info, int suspend)
 	if (info->rq)
 		blk_mq_stop_hw_queues(info->rq);
 
-	for (i = 0; i < info->nr_rings; i++)
-		blkif_free_ring(&info->rinfo[i]);
+	if (info->rinfo) {
+		for (i = 0; i < info->nr_rings; i++)
+			blkif_free_ring(&info->rinfo[i]);
+	}
 
 	kfree(info->rinfo);
 	info->rinfo = NULL;
@@ -1919,6 +1921,7 @@ static int negotiate_mq(struct blkfront_info *info)
 			      GFP_KERNEL);
 	if (!info->rinfo) {
 		xenbus_dev_fatal(info->xbdev, -ENOMEM, "allocating ring_info structure");
+		info->nr_rings = 0;
 		return -ENOMEM;
 	}
 
-- 
1.7.1


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

* Re: [PATCH] xen-blkfront: fix kernel panic with negotiate_mq error path
  2018-10-29 18:31 [PATCH] xen-blkfront: fix kernel panic with negotiate_mq error path Manjunath Patil
@ 2018-10-30  7:04 ` Juergen Gross
  2018-10-30 16:27   ` [Xen-devel] " Manjunath Patil
  2018-10-30 10:39 ` Roger Pau Monné
  1 sibling, 1 reply; 5+ messages in thread
From: Juergen Gross @ 2018-10-30  7:04 UTC (permalink / raw)
  To: Manjunath Patil, boris.ostrovsky, konrad.wilk, roger.pau
  Cc: axboe, xen-devel, linux-block, linux-kernel

On 29/10/2018 19:31, Manjunath Patil wrote:
> info->nr_rings isn't adjusted in case of ENOMEM error from
> negotiate_mq(). This leads to kernel panic in error path.
> 
> Typical call stack involving panic -
>  #8 page_fault at ffffffff8175936f
>     [exception RIP: blkif_free_ring+33]
>     RIP: ffffffffa0149491  RSP: ffff8804f7673c08  RFLAGS: 00010292
>  ...
>  #9 blkif_free at ffffffffa0149aaa [xen_blkfront]
>  #10 talk_to_blkback at ffffffffa014c8cd [xen_blkfront]
>  #11 blkback_changed at ffffffffa014ea8b [xen_blkfront]
>  #12 xenbus_otherend_changed at ffffffff81424670
>  #13 backend_changed at ffffffff81426dc3
>  #14 xenwatch_thread at ffffffff81422f29
>  #15 kthread at ffffffff810abe6a
>  #16 ret_from_fork at ffffffff81754078
> 
> Though either of my changes avoid the panic, I included both the
> changes. This issue got introduced with "7ed8ce1 xen-blkfront: move
> negotiate_mq to cover all cases of new VBDs"

Please us the correct format for specifying another commit.

> Signed-off-by: Manjunath Patil <manjunath.b.patil@oracle.com>

Can you please add a "Fixes:" tag and "Cc: stable@vger.kernel.org" ?

> ---
>  drivers/block/xen-blkfront.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> index 429d201..dc8fe25 100644
> --- a/drivers/block/xen-blkfront.c
> +++ b/drivers/block/xen-blkfront.c
> @@ -1350,8 +1350,10 @@ static void blkif_free(struct blkfront_info *info, int suspend)
>  	if (info->rq)
>  		blk_mq_stop_hw_queues(info->rq);
>  
> -	for (i = 0; i < info->nr_rings; i++)
> -		blkif_free_ring(&info->rinfo[i]);
> +	if (info->rinfo) {
> +		for (i = 0; i < info->nr_rings; i++)
> +			blkif_free_ring(&info->rinfo[i]);
> +	}

I'd drop this change.

>  
>  	kfree(info->rinfo);
>  	info->rinfo = NULL;
> @@ -1919,6 +1921,7 @@ static int negotiate_mq(struct blkfront_info *info)
>  			      GFP_KERNEL);
>  	if (!info->rinfo) {
>  		xenbus_dev_fatal(info->xbdev, -ENOMEM, "allocating ring_info structure");
> +		info->nr_rings = 0;
>  		return -ENOMEM;
>  	}


Juergen


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

* Re: [PATCH] xen-blkfront: fix kernel panic with negotiate_mq error path
  2018-10-29 18:31 [PATCH] xen-blkfront: fix kernel panic with negotiate_mq error path Manjunath Patil
  2018-10-30  7:04 ` Juergen Gross
@ 2018-10-30 10:39 ` Roger Pau Monné
  2018-10-30 16:29   ` [Xen-devel] " Manjunath Patil
  1 sibling, 1 reply; 5+ messages in thread
From: Roger Pau Monné @ 2018-10-30 10:39 UTC (permalink / raw)
  To: Manjunath Patil
  Cc: boris.ostrovsky, jgross, konrad.wilk, axboe, xen-devel,
	linux-block, linux-kernel

On Mon, Oct 29, 2018 at 11:31:56AM -0700, Manjunath Patil wrote:
> info->nr_rings isn't adjusted in case of ENOMEM error from
> negotiate_mq(). This leads to kernel panic in error path.
> 
> Typical call stack involving panic -
>  #8 page_fault at ffffffff8175936f
>     [exception RIP: blkif_free_ring+33]
>     RIP: ffffffffa0149491  RSP: ffff8804f7673c08  RFLAGS: 00010292
>  ...
>  #9 blkif_free at ffffffffa0149aaa [xen_blkfront]
>  #10 talk_to_blkback at ffffffffa014c8cd [xen_blkfront]
>  #11 blkback_changed at ffffffffa014ea8b [xen_blkfront]
>  #12 xenbus_otherend_changed at ffffffff81424670
>  #13 backend_changed at ffffffff81426dc3
>  #14 xenwatch_thread at ffffffff81422f29
>  #15 kthread at ffffffff810abe6a
>  #16 ret_from_fork at ffffffff81754078
> 
> Though either of my changes avoid the panic, I included both the
> changes. This issue got introduced with "7ed8ce1 xen-blkfront: move
> negotiate_mq to cover all cases of new VBDs"
> 
> Signed-off-by: Manjunath Patil <manjunath.b.patil@oracle.com>
> ---
>  drivers/block/xen-blkfront.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> index 429d201..dc8fe25 100644
> --- a/drivers/block/xen-blkfront.c
> +++ b/drivers/block/xen-blkfront.c
> @@ -1350,8 +1350,10 @@ static void blkif_free(struct blkfront_info *info, int suspend)
>  	if (info->rq)
>  		blk_mq_stop_hw_queues(info->rq);
>  
> -	for (i = 0; i < info->nr_rings; i++)
> -		blkif_free_ring(&info->rinfo[i]);
> +	if (info->rinfo) {
> +		for (i = 0; i < info->nr_rings; i++)
> +			blkif_free_ring(&info->rinfo[i]);
> +	}

I don't see the point in the if case here, you already fixed it by
setting the nr_rings value which I think it's the correct way of
fixing it.

Thanks, Roger.

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

* Re: [Xen-devel] [PATCH] xen-blkfront: fix kernel panic with negotiate_mq error path
  2018-10-30  7:04 ` Juergen Gross
@ 2018-10-30 16:27   ` Manjunath Patil
  0 siblings, 0 replies; 5+ messages in thread
From: Manjunath Patil @ 2018-10-30 16:27 UTC (permalink / raw)
  To: Juergen Gross, boris.ostrovsky, konrad.wilk, roger.pau
  Cc: axboe, xen-devel, linux-block, linux-kernel

Thank you Juergen for your comments.

I will soon send v2 patch.

-Thanks,
Manjunath
On 10/30/2018 12:04 AM, Juergen Gross wrote:
> On 29/10/2018 19:31, Manjunath Patil wrote:
>> info->nr_rings isn't adjusted in case of ENOMEM error from
>> negotiate_mq(). This leads to kernel panic in error path.
>>
>> Typical call stack involving panic -
>>   #8 page_fault at ffffffff8175936f
>>      [exception RIP: blkif_free_ring+33]
>>      RIP: ffffffffa0149491  RSP: ffff8804f7673c08  RFLAGS: 00010292
>>   ...
>>   #9 blkif_free at ffffffffa0149aaa [xen_blkfront]
>>   #10 talk_to_blkback at ffffffffa014c8cd [xen_blkfront]
>>   #11 blkback_changed at ffffffffa014ea8b [xen_blkfront]
>>   #12 xenbus_otherend_changed at ffffffff81424670
>>   #13 backend_changed at ffffffff81426dc3
>>   #14 xenwatch_thread at ffffffff81422f29
>>   #15 kthread at ffffffff810abe6a
>>   #16 ret_from_fork at ffffffff81754078
>>
>> Though either of my changes avoid the panic, I included both the
>> changes. This issue got introduced with "7ed8ce1 xen-blkfront: move
>> negotiate_mq to cover all cases of new VBDs"
> Please us the correct format for specifying another commit.
>
>> Signed-off-by: Manjunath Patil <manjunath.b.patil@oracle.com>
> Can you please add a "Fixes:" tag and "Cc: stable@vger.kernel.org" ?
>
>> ---
>>   drivers/block/xen-blkfront.c |    7 +++++--
>>   1 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
>> index 429d201..dc8fe25 100644
>> --- a/drivers/block/xen-blkfront.c
>> +++ b/drivers/block/xen-blkfront.c
>> @@ -1350,8 +1350,10 @@ static void blkif_free(struct blkfront_info *info, int suspend)
>>   	if (info->rq)
>>   		blk_mq_stop_hw_queues(info->rq);
>>   
>> -	for (i = 0; i < info->nr_rings; i++)
>> -		blkif_free_ring(&info->rinfo[i]);
>> +	if (info->rinfo) {
>> +		for (i = 0; i < info->nr_rings; i++)
>> +			blkif_free_ring(&info->rinfo[i]);
>> +	}
> I'd drop this change.
>
>>   
>>   	kfree(info->rinfo);
>>   	info->rinfo = NULL;
>> @@ -1919,6 +1921,7 @@ static int negotiate_mq(struct blkfront_info *info)
>>   			      GFP_KERNEL);
>>   	if (!info->rinfo) {
>>   		xenbus_dev_fatal(info->xbdev, -ENOMEM, "allocating ring_info structure");
>> +		info->nr_rings = 0;
>>   		return -ENOMEM;
>>   	}
>
> Juergen
>


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

* Re: [Xen-devel] [PATCH] xen-blkfront: fix kernel panic with negotiate_mq error path
  2018-10-30 10:39 ` Roger Pau Monné
@ 2018-10-30 16:29   ` Manjunath Patil
  0 siblings, 0 replies; 5+ messages in thread
From: Manjunath Patil @ 2018-10-30 16:29 UTC (permalink / raw)
  To: Roger Pau Monné
  Cc: boris.ostrovsky, jgross, konrad.wilk, axboe, xen-devel,
	linux-block, linux-kernel

On 10/30/2018 3:39 AM, Roger Pau Monné wrote:

> On Mon, Oct 29, 2018 at 11:31:56AM -0700, Manjunath Patil wrote:
>> info->nr_rings isn't adjusted in case of ENOMEM error from
>> negotiate_mq(). This leads to kernel panic in error path.
>>
>> Typical call stack involving panic -
>>   #8 page_fault at ffffffff8175936f
>>      [exception RIP: blkif_free_ring+33]
>>      RIP: ffffffffa0149491  RSP: ffff8804f7673c08  RFLAGS: 00010292
>>   ...
>>   #9 blkif_free at ffffffffa0149aaa [xen_blkfront]
>>   #10 talk_to_blkback at ffffffffa014c8cd [xen_blkfront]
>>   #11 blkback_changed at ffffffffa014ea8b [xen_blkfront]
>>   #12 xenbus_otherend_changed at ffffffff81424670
>>   #13 backend_changed at ffffffff81426dc3
>>   #14 xenwatch_thread at ffffffff81422f29
>>   #15 kthread at ffffffff810abe6a
>>   #16 ret_from_fork at ffffffff81754078
>>
>> Though either of my changes avoid the panic, I included both the
>> changes. This issue got introduced with "7ed8ce1 xen-blkfront: move
>> negotiate_mq to cover all cases of new VBDs"
>>
>> Signed-off-by: Manjunath Patil <manjunath.b.patil@oracle.com>
>> ---
>>   drivers/block/xen-blkfront.c |    7 +++++--
>>   1 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
>> index 429d201..dc8fe25 100644
>> --- a/drivers/block/xen-blkfront.c
>> +++ b/drivers/block/xen-blkfront.c
>> @@ -1350,8 +1350,10 @@ static void blkif_free(struct blkfront_info *info, int suspend)
>>   	if (info->rq)
>>   		blk_mq_stop_hw_queues(info->rq);
>>   
>> -	for (i = 0; i < info->nr_rings; i++)
>> -		blkif_free_ring(&info->rinfo[i]);
>> +	if (info->rinfo) {
>> +		for (i = 0; i < info->nr_rings; i++)
>> +			blkif_free_ring(&info->rinfo[i]);
>> +	}
> I don't see the point in the if case here, you already fixed it by
> setting the nr_rings value which I think it's the correct way of
> fixing it.
>
> Thanks, Roger.
Thank you Roger for your comments.
I will exclude this change and send for review again.

-Thanks,
Manjunath

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

end of thread, other threads:[~2018-10-30 16:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-29 18:31 [PATCH] xen-blkfront: fix kernel panic with negotiate_mq error path Manjunath Patil
2018-10-30  7:04 ` Juergen Gross
2018-10-30 16:27   ` [Xen-devel] " Manjunath Patil
2018-10-30 10:39 ` Roger Pau Monné
2018-10-30 16:29   ` [Xen-devel] " Manjunath Patil

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).