lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <eb6026ac-1616-b6e4-5708-48610eb52213@nvidia.com>
Date:   Wed, 18 May 2022 20:35:38 +0000
From:   Chaitanya Kulkarni <chaitanyak@...dia.com>
To:     Vasily Averin <vvs@...nvz.org>
CC:     "kernel@...nvz.org" <kernel@...nvz.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Jens Axboe <axboe@...nel.dk>,
        Christoph Hellwig <hch@...radead.org>,
        "linux-block@...r.kernel.org" <linux-block@...r.kernel.org>
Subject: Re: [PATCH v2] blk-mq: fix incorrect blk_status_t casts

On 5/18/22 05:45, Vasily Averin wrote:
> Fixes sparse warnings:
> block/blk-mq.c:1163:36: sparse:
>   warning: cast from restricted blk_status_t
> block/blk-mq.c:1251:17: sparse:
>   warning: cast to restricted blk_status_t
> 
> blk_status_t type is bitwaise and requires __force for any casts.
> 
> Signed-off-by: Vasily Averin <vvs@...nvz.org>
> ---
> v2: introduced request_blk_status_en/decode helpers
> 	thanks Christoph Hellwig for the hint
> ---
>   block/blk-mq.c | 15 +++++++++++++--
>   1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 84d749511f55..8f067b021af3 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -1151,6 +1151,16 @@ void blk_mq_start_request(struct request *rq)
>   }
>   EXPORT_SYMBOL(blk_mq_start_request);
>   
> +static void *request_blk_status_encode(blk_status_t status)
> +{
> +	return (void *)(__force uintptr_t)status;
> +}
> +
> +static blk_status_t request_blk_status_decode(void *ptr)
> +{
> +	return (__force blk_status_t)(uintptr_t)ptr;
> +}
> +

why not use blk_sts_encode() and blk_sts_decode() since both the
functions neither accept request parameter nor return request in any
form ?

-ck

>   /**
>    * blk_end_sync_rq - executes a completion event on a request
>    * @rq: request to complete
> @@ -1160,7 +1170,7 @@ static void blk_end_sync_rq(struct request *rq, blk_status_t error)
>   {
>   	struct completion *waiting = rq->end_io_data;
>   
> -	rq->end_io_data = (void *)(uintptr_t)error;
> +	rq->end_io_data = request_blk_status_encode(error);
>   
>   	/*
>   	 * complete last, if this is a stack request the process (and thus
> @@ -1228,6 +1238,7 @@ static void blk_rq_poll_completion(struct request *rq, struct completion *wait)
>    *    for execution and wait for completion.
>    * Return: The blk_status_t result provided to blk_mq_end_request().
>    */
> +

white line ?

>   blk_status_t blk_execute_rq(struct request *rq, bool at_head)
>   {
>   	DECLARE_COMPLETION_ONSTACK(wait);
> @@ -1248,7 +1259,7 @@ blk_status_t blk_execute_rq(struct request *rq, bool at_head)
>   	else
>   		wait_for_completion_io(&wait);
>   
> -	return (blk_status_t)(uintptr_t)rq->end_io_data;
> +	return request_blk_status_decode(rq->end_io_data);
>   }
>   EXPORT_SYMBOL(blk_execute_rq);
>   

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ