mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: "idryomov@gmail.com" <idryomov@gmail.com>,
	"liujing@cmss.chinamobile.com" <liujing@cmss.chinamobile.com>
Cc: Xiubo Li <xiubli@redhat.com>,
	"ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re:  [PATCH] ceph: Fix the wrong format specifier
Date: Fri, 19 Sep 2025 18:38:54 +0000	[thread overview]
Message-ID: <2542244617e984f3cbb3f64b3383065cf55bbe59.camel@ibm.com> (raw)
In-Reply-To: <20250919032713.6534-1-liujing@cmss.chinamobile.com>

On Fri, 2025-09-19 at 11:27 +0800, liujing wrote:
> in the ceph_common.c file, to strictly comply with the requirements
> of the %x format specifier and avoid type mismatch and overflow
> issues, d should be defined as an unsigned int type.
> 
> Signed-off-by: liujing <liujing@cmss.chinamobile.com>
> ---
>  net/ceph/ceph_common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
> index 4c6441536d55..d3c19a63cadd 100644
> --- a/net/ceph/ceph_common.c
> +++ b/net/ceph/ceph_common.c
> @@ -195,7 +195,7 @@ int ceph_parse_fsid(const char *str, struct ceph_fsid *fsid)
>  	int i = 0;
>  	char tmp[3];
>  	int err = -EINVAL;
> -	int d;
> +	unsigned int d;
>  
>  	dout("%s '%s'\n", __func__, str);
>  	tmp[2] = 0;

The main action happens here [1]:

tmp[0] = str[0];
tmp[1] = str[1];
if (sscanf(tmp, "%x", &d) < 1)
	break;
fsid->fsid[i] = d & 0xff;

So, tmp is two symbols array with terminating '\0' symbol.
Finally, we make conversion of two digits (or two bytes) string
into the number. The maximum possible number could be 0xFFFF (65535).
Frankly speaking, I don't see how we can have the overflow issue here.
Could you please explain more clearly your point?

Thanks,
Slava.

[1] 
https://elixir.bootlin.com/linux/v6.17-rc6/source/net/ceph/ceph_common.c#L211

      reply	other threads:[~2025-09-19 18:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-19  3:27 liujing
2025-09-19 18:38 ` Viacheslav Dubeyko [this message]

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=2542244617e984f3cbb3f64b3383065cf55bbe59.camel@ibm.com \
    --to=slava.dubeyko@ibm.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liujing@cmss.chinamobile.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®