Re: [PATCH v3] smb: client: don't use read data that failed signature verification

From: Paulo Alcantara

Date: Thu Nov 19 2026 - 13:47:19 EST


Suyuan Wang via B4 Relay <devnull+shyckless.gmail.com@xxxxxxxxxx>
writes:

> From: Suyuan Wang <stevewong@xxxxxxxxxxx>
>
> When smb2_readv_callback() finds a bad signature, it sets the error in
> rdata->result but leaves rdata->got_bytes alone. Further down, a short
> read that reaches the remote EOF clears the error again:
>
> size_t trans = rdata->subreq.transferred + rdata->got_bytes;
> if (trans < rdata->subreq.len &&
> rdata->subreq.start + trans >= netfs_read_remote_i_size(inode)) {
> rdata->result = 0;
>
> and got_bytes is then added to subreq.transferred. So the last part of a
> file, or all of a small one, is returned even though its signature is
> wrong.
>
> Clearing got_bytes is not enough on its own. If the read starts at or
> past the cached remote size, for example because the file has grown on
> the server since the size was last fetched, the check above still
> matches and the error turns into EOF, or into a zero-filled tail when
> NETFS_SREQ_CLEAR_TAIL is set.
>
> Clear got_bytes when the signature check fails, as the retry path in the
> same function already does, and only treat a short read as hitting the
> remote EOF when the read itself succeeded. That is what commit
> 1da29f2c39b6 ("netfs, cifs: Fix handling of short DIO read") describes:
> "clear the error if a short read occurred without error and the read-to
> file position is now at the remote inode size".
> ...

Applied with the redudant 'rdata->result = 0' removed.