* [PATCH] virtio_blk: Fix signedness bug in virtblk_prep_rq()
@ 2022-10-21 20:41 Rafael Mendonca
2022-10-24 13:33 ` Stefano Garzarella
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Rafael Mendonca @ 2022-10-21 20:41 UTC (permalink / raw)
To: Michael S. Tsirkin, Jason Wang, Paolo Bonzini, Stefan Hajnoczi,
Jens Axboe, Chaitanya Kulkarni, Suwan Kim
Cc: Rafael Mendonca, virtualization, linux-block, linux-kernel
The virtblk_map_data() function returns negative error codes, however, the
'nents' field of vbr->sg_table is an unsigned int, which causes the error
handling not to work correctly.
Fixes: 0e9911fa768f ("virtio-blk: support mq_ops->queue_rqs()")
Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
---
drivers/block/virtio_blk.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 19da5defd734..291f705e61a8 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -321,16 +321,18 @@ static blk_status_t virtblk_prep_rq(struct blk_mq_hw_ctx *hctx,
struct virtblk_req *vbr)
{
blk_status_t status;
+ int num;
status = virtblk_setup_cmd(vblk->vdev, req, vbr);
if (unlikely(status))
return status;
- vbr->sg_table.nents = virtblk_map_data(hctx, req, vbr);
- if (unlikely(vbr->sg_table.nents < 0)) {
+ num = virtblk_map_data(hctx, req, vbr);
+ if (unlikely(num < 0)) {
virtblk_cleanup_cmd(req);
return BLK_STS_RESOURCE;
}
+ vbr->sg_table.nents = num;
blk_mq_start_request(req);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio_blk: Fix signedness bug in virtblk_prep_rq()
2022-10-21 20:41 [PATCH] virtio_blk: Fix signedness bug in virtblk_prep_rq() Rafael Mendonca
@ 2022-10-24 13:33 ` Stefano Garzarella
2022-10-24 14:46 ` Suwan Kim
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Stefano Garzarella @ 2022-10-24 13:33 UTC (permalink / raw)
To: Rafael Mendonca
Cc: Michael S. Tsirkin, Jason Wang, Paolo Bonzini, Stefan Hajnoczi,
Jens Axboe, Chaitanya Kulkarni, Suwan Kim, virtualization,
linux-block, linux-kernel
On Fri, Oct 21, 2022 at 05:41:26PM -0300, Rafael Mendonca wrote:
>The virtblk_map_data() function returns negative error codes, however, the
>'nents' field of vbr->sg_table is an unsigned int, which causes the error
>handling not to work correctly.
>
>Fixes: 0e9911fa768f ("virtio-blk: support mq_ops->queue_rqs()")
>Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
>---
> drivers/block/virtio_blk.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Good catch!
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
>
>diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
>index 19da5defd734..291f705e61a8 100644
>--- a/drivers/block/virtio_blk.c
>+++ b/drivers/block/virtio_blk.c
>@@ -321,16 +321,18 @@ static blk_status_t virtblk_prep_rq(struct blk_mq_hw_ctx *hctx,
> struct virtblk_req *vbr)
> {
> blk_status_t status;
>+ int num;
>
> status = virtblk_setup_cmd(vblk->vdev, req, vbr);
> if (unlikely(status))
> return status;
>
>- vbr->sg_table.nents = virtblk_map_data(hctx, req, vbr);
>- if (unlikely(vbr->sg_table.nents < 0)) {
>+ num = virtblk_map_data(hctx, req, vbr);
>+ if (unlikely(num < 0)) {
> virtblk_cleanup_cmd(req);
> return BLK_STS_RESOURCE;
> }
>+ vbr->sg_table.nents = num;
>
> blk_mq_start_request(req);
>
>--
>2.34.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio_blk: Fix signedness bug in virtblk_prep_rq()
2022-10-21 20:41 [PATCH] virtio_blk: Fix signedness bug in virtblk_prep_rq() Rafael Mendonca
2022-10-24 13:33 ` Stefano Garzarella
@ 2022-10-24 14:46 ` Suwan Kim
2022-10-24 15:44 ` Stefan Hajnoczi
2022-11-07 7:44 ` Jason Wang
3 siblings, 0 replies; 5+ messages in thread
From: Suwan Kim @ 2022-10-24 14:46 UTC (permalink / raw)
To: Rafael Mendonca
Cc: Michael S. Tsirkin, Jason Wang, Paolo Bonzini, Stefan Hajnoczi,
Jens Axboe, Chaitanya Kulkarni, virtualization, linux-block,
linux-kernel
On Sat, Oct 22, 2022 at 5:42 AM Rafael Mendonca <rafaelmendsr@gmail.com> wrote:
>
> The virtblk_map_data() function returns negative error codes, however, the
> 'nents' field of vbr->sg_table is an unsigned int, which causes the error
> handling not to work correctly.
>
> Fixes: 0e9911fa768f ("virtio-blk: support mq_ops->queue_rqs()")
> Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
> ---
> drivers/block/virtio_blk.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 19da5defd734..291f705e61a8 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -321,16 +321,18 @@ static blk_status_t virtblk_prep_rq(struct blk_mq_hw_ctx *hctx,
> struct virtblk_req *vbr)
> {
> blk_status_t status;
> + int num;
>
> status = virtblk_setup_cmd(vblk->vdev, req, vbr);
> if (unlikely(status))
> return status;
>
> - vbr->sg_table.nents = virtblk_map_data(hctx, req, vbr);
> - if (unlikely(vbr->sg_table.nents < 0)) {
> + num = virtblk_map_data(hctx, req, vbr);
> + if (unlikely(num < 0)) {
> virtblk_cleanup_cmd(req);
> return BLK_STS_RESOURCE;
> }
> + vbr->sg_table.nents = num;
>
> blk_mq_start_request(req);
>
> --
> 2.34.1
>
Looks good to me!
Reviewed-by: Suwan Kim <suwan.kim027@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio_blk: Fix signedness bug in virtblk_prep_rq()
2022-10-21 20:41 [PATCH] virtio_blk: Fix signedness bug in virtblk_prep_rq() Rafael Mendonca
2022-10-24 13:33 ` Stefano Garzarella
2022-10-24 14:46 ` Suwan Kim
@ 2022-10-24 15:44 ` Stefan Hajnoczi
2022-11-07 7:44 ` Jason Wang
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2022-10-24 15:44 UTC (permalink / raw)
To: Rafael Mendonca
Cc: Michael S. Tsirkin, Jason Wang, Paolo Bonzini, Jens Axboe,
Chaitanya Kulkarni, Suwan Kim, virtualization, linux-block,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 541 bytes --]
On Fri, Oct 21, 2022 at 05:41:26PM -0300, Rafael Mendonca wrote:
> The virtblk_map_data() function returns negative error codes, however, the
> 'nents' field of vbr->sg_table is an unsigned int, which causes the error
> handling not to work correctly.
>
> Fixes: 0e9911fa768f ("virtio-blk: support mq_ops->queue_rqs()")
> Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
> ---
> drivers/block/virtio_blk.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio_blk: Fix signedness bug in virtblk_prep_rq()
2022-10-21 20:41 [PATCH] virtio_blk: Fix signedness bug in virtblk_prep_rq() Rafael Mendonca
` (2 preceding siblings ...)
2022-10-24 15:44 ` Stefan Hajnoczi
@ 2022-11-07 7:44 ` Jason Wang
3 siblings, 0 replies; 5+ messages in thread
From: Jason Wang @ 2022-11-07 7:44 UTC (permalink / raw)
To: Rafael Mendonca
Cc: Michael S. Tsirkin, Paolo Bonzini, Stefan Hajnoczi, Jens Axboe,
Chaitanya Kulkarni, Suwan Kim, virtualization, linux-block,
linux-kernel
On Sat, Oct 22, 2022 at 4:42 AM Rafael Mendonca <rafaelmendsr@gmail.com> wrote:
>
> The virtblk_map_data() function returns negative error codes, however, the
> 'nents' field of vbr->sg_table is an unsigned int, which causes the error
> handling not to work correctly.
>
> Fixes: 0e9911fa768f ("virtio-blk: support mq_ops->queue_rqs()")
> Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Do we need to cc the stable?
Thanks
> ---
> drivers/block/virtio_blk.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 19da5defd734..291f705e61a8 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -321,16 +321,18 @@ static blk_status_t virtblk_prep_rq(struct blk_mq_hw_ctx *hctx,
> struct virtblk_req *vbr)
> {
> blk_status_t status;
> + int num;
>
> status = virtblk_setup_cmd(vblk->vdev, req, vbr);
> if (unlikely(status))
> return status;
>
> - vbr->sg_table.nents = virtblk_map_data(hctx, req, vbr);
> - if (unlikely(vbr->sg_table.nents < 0)) {
> + num = virtblk_map_data(hctx, req, vbr);
> + if (unlikely(num < 0)) {
> virtblk_cleanup_cmd(req);
> return BLK_STS_RESOURCE;
> }
> + vbr->sg_table.nents = num;
>
> blk_mq_start_request(req);
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-11-07 7:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21 20:41 [PATCH] virtio_blk: Fix signedness bug in virtblk_prep_rq() Rafael Mendonca
2022-10-24 13:33 ` Stefano Garzarella
2022-10-24 14:46 ` Suwan Kim
2022-10-24 15:44 ` Stefan Hajnoczi
2022-11-07 7:44 ` Jason Wang
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).