All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luis Henriques <lhenriques@suse.de>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Xiubo Li <xiubli@redhat.com>, Ilya Dryomov <idryomov@gmail.com>,
	Jeff Layton <jlayton@kernel.org>,
	ceph-devel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] ceph: fix type promotion bug on 32bit systems
Date: Mon, 09 Oct 2023 14:39:38 +0100	[thread overview]
Message-ID: <87sf6jrk2t.fsf@suse.de> (raw)
In-Reply-To: <5e0418d3-a31b-4231-80bf-99adca6bcbe5@moroto.mountain> (Dan Carpenter's message of "Sat, 7 Oct 2023 11:52:39 +0300")

Dan Carpenter <dan.carpenter@linaro.org> writes:

> In this code "ret" is type long and "src_objlen" is unsigned int.  The
> problem is that on 32bit systems, when we do the comparison signed longs
> are type promoted to unsigned int.  So negative error codes from
> do_splice_direct() are treated as success instead of failure.
>
> Fixes: 1b0c3b9f91f0 ("ceph: re-org copy_file_range and fix some error paths")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> 32bit is so weird and ancient.  It's strange to think that unsigned int
> has more positive bits than signed long.

Yikes! Thanks for catching this, Dan.  Really tricky.  I guess you used
some static analysis tool (smatch?) to highlight this issue for you,
right?

Anyway, feel free to add my

Reviewed-by: Luis Henriques <lhenriques@suse.de>

Cheers,
-- 
Luís


>
> fs/ceph/file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index b1da02f5dbe3..b5f8038065d7 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -2969,7 +2969,7 @@ static ssize_t __ceph_copy_file_range(struct file *src_file, loff_t src_off,
>  		ret = do_splice_direct(src_file, &src_off, dst_file,
>  				       &dst_off, src_objlen, flags);
>  		/* Abort on short copies or on error */
> -		if (ret < src_objlen) {
> +		if (ret < (long)src_objlen) {
>  			dout("Failed partial copy (%zd)\n", ret);
>  			goto out;
>  		}
> -- 
>
> 2.39.2
>

  parent reply	other threads:[~2023-10-09 13:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-07  8:52 [PATCH] ceph: fix type promotion bug on 32bit systems Dan Carpenter
2023-10-08  0:21 ` Xiubo Li
2023-10-10  6:54   ` Dan Carpenter
2023-10-09 13:39 ` Luis Henriques [this message]
2023-10-10  6:27   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sf6jrk2t.fsf@suse.de \
    --to=lhenriques@suse.de \
    --cc=ceph-devel@vger.kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=idryomov@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=xiubli@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.