Subject: CVE-2024-26692: smb: Fix regression in writes when non-standard maximum write size negotiated

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

smb: Fix regression in writes when non-standard maximum write size negotiated

The conversion to netfs in the 6.3 kernel caused a regression when
maximum write size is set by the server to an unexpected value which is
not a multiple of 4096 (similarly if the user overrides the maximum
write size by setting mount parm "wsize", but sets it to a value that
is not a multiple of 4096).  When negotiated write size is not a
multiple of 4096 the netfs code can skip the end of the final
page when doing large sequential writes, causing data corruption.

This section of code is being rewritten/removed due to a large
netfs change, but until that point (ie for the 6.3 kernel until now)
we can not support non-standard maximum write sizes.

Add a warning if a user specifies a wsize on mount that is not
a multiple of 4096 (and round down), also add a change where we
round down the maximum write size if the server negotiates a value
that is not a multiple of 4096 (we also have to check to make sure that
we do not round it down to zero).

The Linux kernel CVE team has assigned CVE-2024-26692 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 6.3 with commit d08089f649a0 and fixed in 6.6.18 with commit 4145ccff546e
	Issue introduced in 6.3 with commit d08089f649a0 and fixed in 6.7.6 with commit 63c35afd50e2
	Issue introduced in 6.3 with commit d08089f649a0 and fixed in 6.8 with commit 4860abb91f3d

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2024-26692
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	fs/smb/client/connect.c
	fs/smb/client/fs_context.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/4145ccff546ea868428b3e0fe6818c6261b574a9
	https://git.kernel.org/stable/c/63c35afd50e28b49c5b75542045a8c42b696dab9
	https://git.kernel.org/stable/c/4860abb91f3d7fbaf8147d54782149bb1fc45892