* [PATCH] block: fix offset/size check in bio_trim()
@ 2022-04-14 8:44 Ming Lei
2022-04-14 16:16 ` Jens Axboe
2022-04-15 5:26 ` Chaitanya Kulkarni
0 siblings, 2 replies; 5+ messages in thread
From: Ming Lei @ 2022-04-14 8:44 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Christoph Hellwig, Ming Lei, Chaitanya Kulkarni
Unit of bio->bi_iter.bi_size is bytes, but unit of offset/size
is sector.
Fix the above issue in checking offset/size in bio_trim().
Fixes: e83502ca5f1e ("block: fix argument type of bio_trim()")
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
V2:
- use bio_sectors() as suggested by Christoph
block/bio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/bio.c b/block/bio.c
index cdd7b2915c53..4259125e16ab 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1598,7 +1598,7 @@ EXPORT_SYMBOL(bio_split);
void bio_trim(struct bio *bio, sector_t offset, sector_t size)
{
if (WARN_ON_ONCE(offset > BIO_MAX_SECTORS || size > BIO_MAX_SECTORS ||
- offset + size > bio->bi_iter.bi_size))
+ offset + size > bio_sectors(bio)))
return;
size <<= 9;
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] block: fix offset/size check in bio_trim()
2022-04-14 8:44 [PATCH] block: fix offset/size check in bio_trim() Ming Lei
@ 2022-04-14 16:16 ` Jens Axboe
2022-04-15 5:26 ` Chaitanya Kulkarni
1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2022-04-14 16:16 UTC (permalink / raw)
To: ming.lei; +Cc: chaitanya.kulkarni, Christoph Hellwig, linux-block
On Thu, 14 Apr 2022 16:44:43 +0800, Ming Lei wrote:
> Unit of bio->bi_iter.bi_size is bytes, but unit of offset/size
> is sector.
>
> Fix the above issue in checking offset/size in bio_trim().
>
>
Applied, thanks!
[1/1] block: fix offset/size check in bio_trim()
commit: 8535c0185d14ea41f0efd6a357961b05daf6687e
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: fix offset/size check in bio_trim()
2022-04-14 8:44 [PATCH] block: fix offset/size check in bio_trim() Ming Lei
2022-04-14 16:16 ` Jens Axboe
@ 2022-04-15 5:26 ` Chaitanya Kulkarni
1 sibling, 0 replies; 5+ messages in thread
From: Chaitanya Kulkarni @ 2022-04-15 5:26 UTC (permalink / raw)
To: Ming Lei, Jens Axboe; +Cc: linux-block, Christoph Hellwig, Chaitanya Kulkarni
On 4/14/22 01:44, Ming Lei wrote:
> Unit of bio->bi_iter.bi_size is bytes, but unit of offset/size
> is sector.
>
> Fix the above issue in checking offset/size in bio_trim().
>
> Fixes: e83502ca5f1e ("block: fix argument type of bio_trim()")
> Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
Thanks a lot for this fix.
-ck
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: fix offset/size check in bio_trim()
2022-04-12 14:58 Ming Lei
@ 2022-04-13 16:47 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2022-04-13 16:47 UTC (permalink / raw)
To: Ming Lei; +Cc: Jens Axboe, linux-block, Chaitanya Kulkarni
On Tue, Apr 12, 2022 at 10:58:14PM +0800, Ming Lei wrote:
> Unit of bio->bi_iter.bi_size is bytes, but unit of offset/size
> is sector.
>
> Fix the above issue in checking offset/size in bio_trim().
Just use bio_sectors() instead.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] block: fix offset/size check in bio_trim()
@ 2022-04-12 14:58 Ming Lei
2022-04-13 16:47 ` Christoph Hellwig
0 siblings, 1 reply; 5+ messages in thread
From: Ming Lei @ 2022-04-12 14:58 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Ming Lei, Chaitanya Kulkarni
Unit of bio->bi_iter.bi_size is bytes, but unit of offset/size
is sector.
Fix the above issue in checking offset/size in bio_trim().
Fixes: e83502ca5f1e ("block: fix argument type of bio_trim()")
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/bio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/bio.c b/block/bio.c
index cdd7b2915c53..7c5dcc352db6 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1598,7 +1598,7 @@ EXPORT_SYMBOL(bio_split);
void bio_trim(struct bio *bio, sector_t offset, sector_t size)
{
if (WARN_ON_ONCE(offset > BIO_MAX_SECTORS || size > BIO_MAX_SECTORS ||
- offset + size > bio->bi_iter.bi_size))
+ offset + size > bio->bi_iter.bi_size >> 9))
return;
size <<= 9;
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-15 5:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14 8:44 [PATCH] block: fix offset/size check in bio_trim() Ming Lei
2022-04-14 16:16 ` Jens Axboe
2022-04-15 5:26 ` Chaitanya Kulkarni
-- strict thread matches above, loose matches on Subject: below --
2022-04-12 14:58 Ming Lei
2022-04-13 16:47 ` Christoph Hellwig
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.