* [PATCH] accessing invalid memory in "dm zoned: properly handle backing device failure"
@ 2019-08-26 6:41 Mikulas Patocka
2019-08-26 6:45 ` Damien Le Moal
0 siblings, 1 reply; 3+ messages in thread
From: Mikulas Patocka @ 2019-08-26 6:41 UTC (permalink / raw)
To: Dmitry Fomichev, Damien Le Moal, Mike Snitzer; +Cc: dm-devel
The patch 75d66ffb48efb30f2dd42f041ba8b39c5b2bd115 ("dm zoned: properly
handle backing device failure") triggers a coverity warning:
*** CID 1452808: Memory - illegal accesses (USE_AFTER_FREE)
/drivers/md/dm-zoned-target.c: 137 in dmz_submit_bio()
131 clone->bi_private = bioctx;
132
133 bio_advance(bio, clone->bi_iter.bi_size);
134
135 refcount_inc(&bioctx->ref);
136 generic_make_request(clone);
>>> CID 1452808: Memory - illegal accesses (USE_AFTER_FREE)
>>> Dereferencing freed pointer "clone".
137 if (clone->bi_status == BLK_STS_IOERR)
138 return -EIO;
139
140 if (bio_op(bio) == REQ_OP_WRITE && dmz_is_seq(zone))
141 zone->wp_block += nr_blocks;
142
The "clone" bio may be processed and freed before the check
"clone->bi_status == BLK_STS_IOERR" - so this check can access invalid
memory.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
---
drivers/md/dm-zoned-target.c | 2 --
1 file changed, 2 deletions(-)
Index: linux-2.6/drivers/md/dm-zoned-target.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-zoned-target.c 2019-08-26 08:30:30.000000000 +0200
+++ linux-2.6/drivers/md/dm-zoned-target.c 2019-08-26 08:36:23.000000000 +0200
@@ -134,8 +134,6 @@ static int dmz_submit_bio(struct dmz_tar
refcount_inc(&bioctx->ref);
generic_make_request(clone);
- if (clone->bi_status == BLK_STS_IOERR)
- return -EIO;
if (bio_op(bio) == REQ_OP_WRITE && dmz_is_seq(zone))
zone->wp_block += nr_blocks;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] accessing invalid memory in "dm zoned: properly handle backing device failure"
2019-08-26 6:41 [PATCH] accessing invalid memory in "dm zoned: properly handle backing device failure" Mikulas Patocka
@ 2019-08-26 6:45 ` Damien Le Moal
2019-08-26 10:14 ` Mikulas Patocka
0 siblings, 1 reply; 3+ messages in thread
From: Damien Le Moal @ 2019-08-26 6:45 UTC (permalink / raw)
To: Mikulas Patocka, Dmitry Fomichev, Mike Snitzer; +Cc: dm-devel
On 2019/08/26 15:41, Mikulas Patocka wrote:
> The patch 75d66ffb48efb30f2dd42f041ba8b39c5b2bd115 ("dm zoned: properly
> handle backing device failure") triggers a coverity warning:
>
> *** CID 1452808: Memory - illegal accesses (USE_AFTER_FREE)
> /drivers/md/dm-zoned-target.c: 137 in dmz_submit_bio()
> 131 clone->bi_private = bioctx;
> 132
> 133 bio_advance(bio, clone->bi_iter.bi_size);
> 134
> 135 refcount_inc(&bioctx->ref);
> 136 generic_make_request(clone);
>>>> CID 1452808: Memory - illegal accesses (USE_AFTER_FREE)
>>>> Dereferencing freed pointer "clone".
> 137 if (clone->bi_status == BLK_STS_IOERR)
> 138 return -EIO;
> 139
> 140 if (bio_op(bio) == REQ_OP_WRITE && dmz_is_seq(zone))
> 141 zone->wp_block += nr_blocks;
> 142
>
> The "clone" bio may be processed and freed before the check
> "clone->bi_status == BLK_STS_IOERR" - so this check can access invalid
> memory.
>
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> Cc: stable@vger.kernel.org
>
> ---
> drivers/md/dm-zoned-target.c | 2 --
> 1 file changed, 2 deletions(-)
>
> Index: linux-2.6/drivers/md/dm-zoned-target.c
> ===================================================================
> --- linux-2.6.orig/drivers/md/dm-zoned-target.c 2019-08-26 08:30:30.000000000 +0200
> +++ linux-2.6/drivers/md/dm-zoned-target.c 2019-08-26 08:36:23.000000000 +0200
> @@ -134,8 +134,6 @@ static int dmz_submit_bio(struct dmz_tar
>
> refcount_inc(&bioctx->ref);
> generic_make_request(clone);
> - if (clone->bi_status == BLK_STS_IOERR)
> - return -EIO;
>
> if (bio_op(bio) == REQ_OP_WRITE && dmz_is_seq(zone))
> zone->wp_block += nr_blocks;
>
Argh... Indeed. Thanks Mikulas.
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] accessing invalid memory in "dm zoned: properly handle backing device failure"
2019-08-26 6:45 ` Damien Le Moal
@ 2019-08-26 10:14 ` Mikulas Patocka
0 siblings, 0 replies; 3+ messages in thread
From: Mikulas Patocka @ 2019-08-26 10:14 UTC (permalink / raw)
To: Damien Le Moal; +Cc: Dmitry Fomichev, dm-devel, Mike Snitzer
On Mon, 26 Aug 2019, Damien Le Moal wrote:
> On 2019/08/26 15:41, Mikulas Patocka wrote:
> > The patch 75d66ffb48efb30f2dd42f041ba8b39c5b2bd115 ("dm zoned: properly
> > handle backing device failure") triggers a coverity warning:
> >
> > *** CID 1452808: Memory - illegal accesses (USE_AFTER_FREE)
> > /drivers/md/dm-zoned-target.c: 137 in dmz_submit_bio()
> > 131 clone->bi_private = bioctx;
> > 132
> > 133 bio_advance(bio, clone->bi_iter.bi_size);
> > 134
> > 135 refcount_inc(&bioctx->ref);
> > 136 generic_make_request(clone);
> >>>> CID 1452808: Memory - illegal accesses (USE_AFTER_FREE)
> >>>> Dereferencing freed pointer "clone".
> > 137 if (clone->bi_status == BLK_STS_IOERR)
> > 138 return -EIO;
> > 139
> > 140 if (bio_op(bio) == REQ_OP_WRITE && dmz_is_seq(zone))
> > 141 zone->wp_block += nr_blocks;
> > 142
> >
> > The "clone" bio may be processed and freed before the check
> > "clone->bi_status == BLK_STS_IOERR" - so this check can access invalid
> > memory.
> >
> > Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> > Cc: stable@vger.kernel.org
We should also append this line:
Fixes: 75d66ffb48ef ("dm zoned: properly handle backing device failure")
Mikulas
> > ---
> > drivers/md/dm-zoned-target.c | 2 --
> > 1 file changed, 2 deletions(-)
> >
> > Index: linux-2.6/drivers/md/dm-zoned-target.c
> > ===================================================================
> > --- linux-2.6.orig/drivers/md/dm-zoned-target.c 2019-08-26 08:30:30.000000000 +0200
> > +++ linux-2.6/drivers/md/dm-zoned-target.c 2019-08-26 08:36:23.000000000 +0200
> > @@ -134,8 +134,6 @@ static int dmz_submit_bio(struct dmz_tar
> >
> > refcount_inc(&bioctx->ref);
> > generic_make_request(clone);
> > - if (clone->bi_status == BLK_STS_IOERR)
> > - return -EIO;
> >
> > if (bio_op(bio) == REQ_OP_WRITE && dmz_is_seq(zone))
> > zone->wp_block += nr_blocks;
> >
>
> Argh... Indeed. Thanks Mikulas.
>
> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
>
> --
> Damien Le Moal
> Western Digital Research
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-26 10:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-26 6:41 [PATCH] accessing invalid memory in "dm zoned: properly handle backing device failure" Mikulas Patocka
2019-08-26 6:45 ` Damien Le Moal
2019-08-26 10:14 ` Mikulas Patocka
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.