client: do not allow zero‑length reads#65656
Conversation
6232c76 to
b31d6a8
Compare
| { | ||
| ceph_assert(ceph_mutex_is_locked_by_me(client_lock)); | ||
|
|
||
| // zero bytes read is not supported by osd |
There was a problem hiding this comment.
Hmm, I'm thinking more about this approach. If we put this up this high, we'll miss the check for f->mode & CEPH_FILE_MODE_RD) == 0.
There was a problem hiding this comment.
I can move that check above before declaring all those variables
There was a problem hiding this comment.
In this current form, we still exit if size == 0, but f->mode doesn't have CEPH_FILE_MODE_RD. It should fail in that case regardless of size. We should probably still do this.
There was a problem hiding this comment.
can you take a look now? I've moved the ldout statement to top, first check the file handle mode and then the size.
| // is duplicated and modified and exists in | ||
| // C_Read_Sync_NonBlocking::finish(). | ||
|
|
||
| // trim read based on file size? |
There was a problem hiding this comment.
I'm trying to keep things consistent. Right now case 1 (_read_async) and case 3 (_read_sync) both check again if the size/len is 0 within the functions. They both are only called from _read(). Do we want to remove those checks, or add a check to C_Read_Sync_NonBlocking to complete immediately in retry() if len == 0? That way we can potentially avoid bugs later on.
There was a problem hiding this comment.
Right now case 1 (_read_async) and case 3 (_read_sync) both check again if the size/len is 0 within the functions. They both are only called from _read()
I did thought about this initially but then wondered - what if in future these member functions are called independently from some new API? I felt that considering they are helper functions to carry out async/sync read; i kept those functions intact. WDYT?
There was a problem hiding this comment.
add a check to C_Read_Sync_NonBlocking to complete immediately in retry() if len == 0? That way we can potentially avoid bugs later on.
Yeah, doable. It's called from case 2 right now and fixing the retry() could help prevent future bugs.
There was a problem hiding this comment.
Also what about C_Read_Async_Finisher::finish? In Client::do_readahead - pair<uint64_t, uint64_t> readahead_extent = f->readahead.update(off, len, in->size); returns an extent and the extent.second would be readahead_length and then is passed in
int r2 = objectcacher->file_read(&in->oset, &in->layout, in->snapid,
readahead_extent.first, readahead_extent.second,
NULL, 0, onfinish2);
this could again crash
There was a problem hiding this comment.
some new API? I felt that considering they are helper functions to carry out async/sync read; i kept those functions intact. WDYT?
Yeah we can keep those, if _read_sync and _read_async both bail if the size is zero that will keep it from failing on unchecked new code paths.
There was a problem hiding this comment.
Also what about C_Read_Async_Finisher::finish?
Unless I'm missing something, that has a check, that skips do_readahead if size is 0.
Lines 11825 to 11826 in 9d82c94
There was a problem hiding this comment.
Also what about C_Read_Async_Finisher::finish?
Unless I'm missing something, that has a check, that skips do_readahead if size is 0.
Lines 11825 to 11826 in 9d82c94
oh glad it is, wonder how i missed it but thanks for pointing out!
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
@dparmar18 please rebase |
7cb3d4a to
4b82629
Compare
@vshankar this is ready |
anoopcs9
left a comment
There was a problem hiding this comment.
Please fix the commit message subject and PR title: client: do not allow zero‑length reads or client: disallow zero length reads
Please fix the typo in the commit message subject: src/test: test zero-length async-fsync read using ll_preadv_pwritev -> s/async/sync.
fd60702 to
d3ca82b
Compare
from the https://tracker.ceph.com/issues/73037 description, i think it should be async |
Requested changes have been made in the updated version.
chrisphoffman
left a comment
There was a problem hiding this comment.
all my comments were addressed. lgtm
| ldout(cct, 10) << " nothing to flush" << dendl; | ||
| return; | ||
| } | ||
| if (size == 0) { |
There was a problem hiding this comment.
nit: a new line before here
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
@vshankar request for a teuthology run |
|
@vshankar ping |
I don't have access to the new lab yet. Working it out... |
Fixes: https://tracker.ceph.com/issues/73037 Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
…_readv_writev Fixes: https://tracker.ceph.com/issues/73037 Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
fixing this in Client::_read which is called by both async and sync code paths. Fixes: https://tracker.ceph.com/issues/73037 Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.