All of lore.kernel.org
 help / color / mirror / Atom feed
* Backports 4.14, 4.9, 4.4: dm: fix potential for q->make_request_fn NULL pointer
@ 2020-02-13  9:52 Stefan Bader
  2020-02-13  9:52 ` [PATCH 4.14.y] " Stefan Bader
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Stefan Bader @ 2020-02-13  9:52 UTC (permalink / raw)
  To: stable, snitzer

Following are the backports into the 3 stable trees mentioned. Unfortunately
context required ajustments for each tree. Mike, I would appreciate if you
could glance over those to double check. Thanks.

-Stefan


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

* [PATCH 4.14.y] dm: fix potential for q->make_request_fn NULL pointer
  2020-02-13  9:52 Backports 4.14, 4.9, 4.4: dm: fix potential for q->make_request_fn NULL pointer Stefan Bader
@ 2020-02-13  9:52 ` Stefan Bader
  2020-02-13  9:52 ` [PATCH 4.9.y] " Stefan Bader
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Stefan Bader @ 2020-02-13  9:52 UTC (permalink / raw)
  To: stable, snitzer

From: Mike Snitzer <snitzer@redhat.com>

[ Upstream commit 47ace7e012b9f7ad71d43ac9063d335ea3d6820b ]
Move blk_queue_make_request() to dm.c:alloc_dev() so that
q->make_request_fn is never NULL during the lifetime of a DM device
(even one that is created without a DM table).

Otherwise generic_make_request() will crash simply by doing:
  dmsetup create -n test
  mount /dev/dm-N /mnt

While at it, move ->congested_data initialization out of
dm.c:alloc_dev() and into the bio-based specific init method.

Reported-by: Stefan Bader <stefan.bader@canonical.com>
BugLink: https://bugs.launchpad.net/bugs/1860231
Fixes: ff36ab34583a ("dm: remove request-based logic from make_request_fn wrapper")
Depends-on: c12c9a3c3860c ("dm: various cleanups to md->queue initialization code")
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
[smb: adjusted for context and dm_init_md_queue() exitsting in older
      kernels]
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 drivers/md/dm.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index a56008b2e7c2..02ba6849f89d 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1647,7 +1647,6 @@ void dm_init_md_queue(struct mapped_device *md)
 	 * - must do so here (in alloc_dev callchain) before queue is used
 	 */
 	md->queue->queuedata = md;
-	md->queue->backing_dev_info->congested_data = md;
 }
 
 void dm_init_normal_md_queue(struct mapped_device *md)
@@ -1658,6 +1657,7 @@ void dm_init_normal_md_queue(struct mapped_device *md)
 	/*
 	 * Initialize aspects of queue that aren't relevant for blk-mq
 	 */
+	md->queue->backing_dev_info->congested_data = md;
 	md->queue->backing_dev_info->congested_fn = dm_any_congested;
 }
 
@@ -1750,6 +1750,12 @@ static struct mapped_device *alloc_dev(int minor)
 		goto bad;
 
 	dm_init_md_queue(md);
+	/*
+	 * default to bio-based required ->make_request_fn until DM
+	 * table is loaded and md->type established. If request-based
+	 * table is loaded: blk-mq will override accordingly.
+	 */
+	blk_queue_make_request(md->queue, dm_make_request);
 
 	md->disk = alloc_disk_node(1, numa_node_id);
 	if (!md->disk)
@@ -2055,7 +2061,6 @@ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t)
 	case DM_TYPE_BIO_BASED:
 	case DM_TYPE_DAX_BIO_BASED:
 		dm_init_normal_md_queue(md);
-		blk_queue_make_request(md->queue, dm_make_request);
 		/*
 		 * DM handles splitting bios as needed.  Free the bio_split bioset
 		 * since it won't be used (saves 1 process per bio-based DM device).
-- 
2.17.1


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

* [PATCH 4.9.y] dm: fix potential for q->make_request_fn NULL pointer
  2020-02-13  9:52 Backports 4.14, 4.9, 4.4: dm: fix potential for q->make_request_fn NULL pointer Stefan Bader
  2020-02-13  9:52 ` [PATCH 4.14.y] " Stefan Bader
@ 2020-02-13  9:52 ` Stefan Bader
  2020-02-13  9:52 ` [PATCH 4.4.y] " Stefan Bader
  2020-02-13 14:58 ` Backports 4.14, 4.9, 4.4: " Greg KH
  3 siblings, 0 replies; 7+ messages in thread
From: Stefan Bader @ 2020-02-13  9:52 UTC (permalink / raw)
  To: stable, snitzer

From: Mike Snitzer <snitzer@redhat.com>

[ Upstream commit 47ace7e012b9f7ad71d43ac9063d335ea3d6820b ]
Move blk_queue_make_request() to dm.c:alloc_dev() so that
q->make_request_fn is never NULL during the lifetime of a DM device
(even one that is created without a DM table).

Otherwise generic_make_request() will crash simply by doing:
  dmsetup create -n test
  mount /dev/dm-N /mnt

While at it, move ->congested_data initialization out of
dm.c:alloc_dev() and into the bio-based specific init method.

Reported-by: Stefan Bader <stefan.bader@canonical.com>
BugLink: https://bugs.launchpad.net/bugs/1860231
Fixes: ff36ab34583a ("dm: remove request-based logic from make_request_fn wrapper")
Depends-on: c12c9a3c3860c ("dm: various cleanups to md->queue initialization code")
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
[smb: adjusted for context and dm_init_md_queue() exitsting in older
      kernels, and congested_data embedded in backing_dev_info]
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 drivers/md/dm.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 36e6221fabab..dd154027adc9 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1457,7 +1457,6 @@ void dm_init_md_queue(struct mapped_device *md)
 	 * - must do so here (in alloc_dev callchain) before queue is used
 	 */
 	md->queue->queuedata = md;
-	md->queue->backing_dev_info.congested_data = md;
 }
 
 void dm_init_normal_md_queue(struct mapped_device *md)
@@ -1468,6 +1467,7 @@ void dm_init_normal_md_queue(struct mapped_device *md)
 	/*
 	 * Initialize aspects of queue that aren't relevant for blk-mq
 	 */
+	md->queue->backing_dev_info.congested_data = md;
 	md->queue->backing_dev_info.congested_fn = dm_any_congested;
 	blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY);
 }
@@ -1555,6 +1555,12 @@ static struct mapped_device *alloc_dev(int minor)
 		goto bad;
 
 	dm_init_md_queue(md);
+	/*
+	 * default to bio-based required ->make_request_fn until DM
+	 * table is loaded and md->type established. If request-based
+	 * table is loaded: blk-mq will override accordingly.
+	 */
+	blk_queue_make_request(md->queue, dm_make_request);
 
 	md->disk = alloc_disk_node(1, numa_node_id);
 	if (!md->disk)
@@ -1853,7 +1859,6 @@ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t)
 	case DM_TYPE_BIO_BASED:
 	case DM_TYPE_DAX_BIO_BASED:
 		dm_init_normal_md_queue(md);
-		blk_queue_make_request(md->queue, dm_make_request);
 		/*
 		 * DM handles splitting bios as needed.  Free the bio_split bioset
 		 * since it won't be used (saves 1 process per bio-based DM device).
-- 
2.17.1


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

* [PATCH 4.4.y] dm: fix potential for q->make_request_fn NULL pointer
  2020-02-13  9:52 Backports 4.14, 4.9, 4.4: dm: fix potential for q->make_request_fn NULL pointer Stefan Bader
  2020-02-13  9:52 ` [PATCH 4.14.y] " Stefan Bader
  2020-02-13  9:52 ` [PATCH 4.9.y] " Stefan Bader
@ 2020-02-13  9:52 ` Stefan Bader
  2020-02-13 14:58 ` Backports 4.14, 4.9, 4.4: " Greg KH
  3 siblings, 0 replies; 7+ messages in thread
From: Stefan Bader @ 2020-02-13  9:52 UTC (permalink / raw)
  To: stable, snitzer

From: Mike Snitzer <snitzer@redhat.com>

[ Upstream commit 47ace7e012b9f7ad71d43ac9063d335ea3d6820b ]
Move blk_queue_make_request() to dm.c:alloc_dev() so that
q->make_request_fn is never NULL during the lifetime of a DM device
(even one that is created without a DM table).

Otherwise generic_make_request() will crash simply by doing:
  dmsetup create -n test
  mount /dev/dm-N /mnt

While at it, move ->congested_data initialization out of
dm.c:alloc_dev() and into the bio-based specific init method.

Reported-by: Stefan Bader <stefan.bader@canonical.com>
BugLink: https://bugs.launchpad.net/bugs/1860231
Fixes: ff36ab34583a ("dm: remove request-based logic from make_request_fn wrapper")
Depends-on: c12c9a3c3860c ("dm: various cleanups to md->queue initialization code")
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
[smb: adjusted for context and dm_init_md_queue() exitsting in older
      kernels, and congested_data embedded in backing_dev_info, and
      dm_init_normal_md_queue() was called dm_init_old_md_queue()]
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 drivers/md/dm.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index c752c55f0bb2..c4d4cd38a58f 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2293,7 +2293,6 @@ static void dm_init_md_queue(struct mapped_device *md)
 	 * - must do so here (in alloc_dev callchain) before queue is used
 	 */
 	md->queue->queuedata = md;
-	md->queue->backing_dev_info.congested_data = md;
 }
 
 static void dm_init_old_md_queue(struct mapped_device *md)
@@ -2304,6 +2303,7 @@ static void dm_init_old_md_queue(struct mapped_device *md)
 	/*
 	 * Initialize aspects of queue that aren't relevant for blk-mq
 	 */
+	md->queue->backing_dev_info.congested_data = md;
 	md->queue->backing_dev_info.congested_fn = dm_any_congested;
 	blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY);
 }
@@ -2386,6 +2386,12 @@ static struct mapped_device *alloc_dev(int minor)
 		goto bad;
 
 	dm_init_md_queue(md);
+	/*
+	 * default to bio-based required ->make_request_fn until DM
+	 * table is loaded and md->type established. If request-based
+	 * table is loaded: blk-mq will override accordingly.
+	 */
+	blk_queue_make_request(md->queue, dm_make_request);
 
 	md->disk = alloc_disk(1);
 	if (!md->disk)
@@ -2849,7 +2855,6 @@ int dm_setup_md_queue(struct mapped_device *md)
 		break;
 	case DM_TYPE_BIO_BASED:
 		dm_init_old_md_queue(md);
-		blk_queue_make_request(md->queue, dm_make_request);
 		/*
 		 * DM handles splitting bios as needed.  Free the bio_split bioset
 		 * since it won't be used (saves 1 process per bio-based DM device).
-- 
2.17.1


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

* Re: Backports 4.14, 4.9, 4.4: dm: fix potential for q->make_request_fn NULL pointer
  2020-02-13  9:52 Backports 4.14, 4.9, 4.4: dm: fix potential for q->make_request_fn NULL pointer Stefan Bader
                   ` (2 preceding siblings ...)
  2020-02-13  9:52 ` [PATCH 4.4.y] " Stefan Bader
@ 2020-02-13 14:58 ` Greg KH
  3 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2020-02-13 14:58 UTC (permalink / raw)
  To: Stefan Bader; +Cc: stable, snitzer

On Thu, Feb 13, 2020 at 10:52:06AM +0100, Stefan Bader wrote:
> Following are the backports into the 3 stable trees mentioned. Unfortunately
> context required ajustments for each tree. Mike, I would appreciate if you
> could glance over those to double check. Thanks.

All now queued up, thanks.

greg k-h

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

* Re: Backports 4.14, 4.9, 4.4: dm: fix potential for q->make_request_fn NULL pointer
  2020-02-13  9:49 Stefan Bader
@ 2020-02-13  9:53 ` Stefan Bader
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Bader @ 2020-02-13  9:53 UTC (permalink / raw)
  To: stable, snitzer


[-- Attachment #1.1: Type: text/plain, Size: 396 bytes --]

On 13.02.20 10:49, Stefan Bader wrote:
> Following are the backports into the 3 stable trees mentioned. Unfortunately
> context required ajustments for each tree. Mike, I would appreciate if you
> could glance over those to double check. Thanks.
> 
> -Stefan
> 
Something went wrong sending this the first time and ate the 4.4.y backport. I
am re-sending the whole batch.

-Stefan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Backports 4.14, 4.9, 4.4: dm: fix potential for q->make_request_fn NULL pointer
@ 2020-02-13  9:49 Stefan Bader
  2020-02-13  9:53 ` Stefan Bader
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Bader @ 2020-02-13  9:49 UTC (permalink / raw)
  To: stable, snitzer

Following are the backports into the 3 stable trees mentioned. Unfortunately
context required ajustments for each tree. Mike, I would appreciate if you
could glance over those to double check. Thanks.

-Stefan


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

end of thread, other threads:[~2020-02-13 14:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-13  9:52 Backports 4.14, 4.9, 4.4: dm: fix potential for q->make_request_fn NULL pointer Stefan Bader
2020-02-13  9:52 ` [PATCH 4.14.y] " Stefan Bader
2020-02-13  9:52 ` [PATCH 4.9.y] " Stefan Bader
2020-02-13  9:52 ` [PATCH 4.4.y] " Stefan Bader
2020-02-13 14:58 ` Backports 4.14, 4.9, 4.4: " Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2020-02-13  9:49 Stefan Bader
2020-02-13  9:53 ` Stefan Bader

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.