On Fri, Apr 8, 2022 at 5:23 AM Goldwyn Rodrigues rgoldwyn@suse.de wrote:
On 16:37 08/04, Xiaomeng Tong wrote:
The bug is here: if (!rdev)
The list iterator value 'rdev' will *always* be set and non-NULL by rdev_for_each(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element found. Otherwise it will bypass the NULL check and lead to invalid memory access passing the check.
To fix the bug, use a new variable 'iter' as the list iterator, while using the original variable 'rdev' as a dedicated pointer to point to the found element.
Cc: stable@vger.kernel.org Fixes: 2aa82191ac36 ("md-cluster: Perform a lazy update") Acked-by: Guoqing Jiang guoqing.jiang@linux.dev Signed-off-by: Xiaomeng Tong xiam0nd.tong@gmail.com
Also safeguards from reading sb from a faulty device if all devices are faulty.
Acked-by: Goldwyn Rodrigues rgoldwyn@suse.com
Applied to md-next. Thanks!