public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: nana <zhongling0719@126.com>
To: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>,
	 "idryomov@gmail.com" <idryomov@gmail.com>,
	"zenghongling@kylinos.cn" <zenghongling@kylinos.cn>,
	 "slava@dubeyko.com" <slava@dubeyko.com>,
	Alex Markuze <amarkuze@redhat.com>,
	 "brauner@kernel.org" <brauner@kernel.org>
Cc: "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 potential ERR_PTR dereference in ceph_submit_write()
Date: Mon, 20 Apr 2026 14:28:40 +0800	[thread overview]
Message-ID: <69E5C798.8050705@126.com> (raw)
In-Reply-To: <494716d7aa3fe860d89e19866fa3b59755183de8.camel@ibm.com>

  Hi  Slava
       You're correct: the fix doesn't make sense.The 
BUG_ON(IS_ERR(req))  ensures that req is a valid pointer, There is no 
code path that can skip the allocation code.

Thank you for your review.

在 2026年04月18日 01:48, Viacheslav Dubeyko 写道:
> On Fri, 2026-04-17 at 16:06 +0800, Hongling Zeng wrote:
>> Fix smatch warning:
>>   fs/ceph/addr.c:1489 ceph_submit_write() error: 'req' dereferencing possible ERR_PTR()
>>
>> Add a check to ensure req is not an ERR_PTR before calling
>> ceph_osdc_put_request().
>>
>> Fixes: 1551ec61dc55 ("ceph: improve error handling in writeback")
>> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
>> ---
>>   fs/ceph/addr.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
>> index fa4f25f99409..6091818674be 100644
>> --- a/fs/ceph/addr.c
>> +++ b/fs/ceph/addr.c
>> @@ -1468,7 +1468,8 @@ int ceph_submit_write(struct address_space *mapping,
>>   			unlock_page(page);
>>   		}
>>   
>> -		ceph_osdc_put_request(req);
>> +		if (!IS_ERR(req))
>> +			ceph_osdc_put_request(req);
>>   		return -EIO;
>>   	}
>>   
> I don't think that this fix makes sense. We create and check the request here
> [1]:
>
> 	req = ceph_osdc_new_request(&fsc->client->osdc,
> 				    &ci->i_layout, vino,
> 				    offset, &len, 0, ceph_wbc->num_ops,
> 				    CEPH_OSD_OP_WRITE, CEPH_OSD_FLAG_WRITE,
> 				    ceph_wbc->snapc, ceph_wbc->truncate_seq,
> 				    ceph_wbc->truncate_size, false);
> 	if (IS_ERR(req)) {
> 		req = ceph_osdc_new_request(&fsc->client->osdc,
> 					    &ci->i_layout, vino,
> 					    offset, &len, 0,
> 					    min(ceph_wbc->num_ops,
> 						CEPH_OSD_SLAB_OPS),
> 					    CEPH_OSD_OP_WRITE,
> 					    CEPH_OSD_FLAG_WRITE,
> 					    ceph_wbc->snapc,
> 					    ceph_wbc->truncate_seq,
> 					    ceph_wbc->truncate_size,
> 					    true);
> 		BUG_ON(IS_ERR(req));
> 	}
>
> So, it should be the valid request pointer when we called
> ceph_osdc_put_request(). Am I missing something?
>
> Thanks,
> Slava.
>
> [1] https://elixir.bootlin.com/linux/v7.0/source/fs/ceph/addr.c#L1421


      reply	other threads:[~2026-04-20  6:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-17  8:06 [PATCH] ceph: fix potential ERR_PTR dereference in ceph_submit_write() Hongling Zeng
2026-04-17 17:48 ` Viacheslav Dubeyko
2026-04-20  6:28   ` nana [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=69E5C798.8050705@126.com \
    --to=zhongling0719@126.com \
    --cc=Slava.Dubeyko@ibm.com \
    --cc=amarkuze@redhat.com \
    --cc=brauner@kernel.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=slava@dubeyko.com \
    --cc=zenghongling@kylinos.cn \
    /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