Re: [PATCH] ksmbd: fix incorrect handling of iterate_dir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2022년 8월 23일 (화) 오전 11:45, Namjae Jeon <linkinjeon@xxxxxxxxxx>님이 작성:
>
> >> >> >> > diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
> >> >> >> > index 53c91ab02be2..6716c4e3c16d 100644
> >> >> >> > --- a/fs/ksmbd/smb2pdu.c
> >> >> >> > +++ b/fs/ksmbd/smb2pdu.c
> >> >> >> > @@ -3970,11 +3970,9 @@ int smb2_query_dir(struct ksmbd_work
> >> >> >> > *work)
> >> >> >> >        */
> >> >> >> >       if (!d_info.out_buf_len && !d_info.num_entry)
> >> >> >> >               goto no_buf_len;
> >> >> >> > -     if (rc == 0)
> >> >> >> > -             restart_ctx(&dir_fp->readdir_data.ctx);
> >> >> >> > -     if (rc == -ENOSPC)
> >> >> >> > +     if (rc > 0 || rc == -ENOSPC)
> >> >> >> Do you know why -ENOSPC error is ignored ?
> >> >> >>
> >> >> >
> >> >> > I don't know why and can't find the commit history
> >> >> > for this.
> >> >> After checking if -ENOSPC error is returned, there is no need to leave
> >> >> it if it is not needed.
> >> >
> >> > In most cases, -ENOSPC is not returned. Because the value
> >> > is set to the return value from filesystems' iterate or iterate_share,
> >> > and most file systems don't allocate disk space for this operation.
> >> >
> >> > But we cannot guarantee this. So how about changing handling
> >> > iterate_dir
> >> > like gendents system call. Even if an error code is returned by
> >> > iterate_dir,
> >> > it treats as normal if several child files are iterated and the buffer
> >> > is filled with
> >> > information about those.
> >> Among the errors of the smb2 query directory in the specification,
> >> there is a file corruption error response
> >> type(STATUS_FILE_CORRUPT_ERROR).
> >> Can you check when smb server return that error response for smb2
> >> query directory?
> >>
> >
> > According to MS-REREF, it means "The file or directory is corrupt and
> > unreadable.
> > Run the chkdsk utility". And there is no function to return the error in
> > Samba.
> Is samba not able to know corruption errors using getdents syscall as you said?

If iterate_dir returns an error and there are files iterated, getdents
syscall will succeed.
But if a client requests SMB2_QUERY_DIR again due to STATUS_NO_MORE_FILES
absence of the last response, iterate_dir returns an error again and
there are no
files iterated, getdents syscall will fail. Samba can send a response
with an error.

> There is no reason to follow it. I think that ksmbd is able to return
> this error.

Can we determine we should return a response with STATUS_FILE_CORRUPT_ERROR
if iterate_dir returns -EIO?

-- 
Thanks,
Hyunchul




[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux