1: 9cdcbbf138f7 ! 1: 5f24e748661f wifi: rtw89: debug: return the error when a read handler fails @@ Metadata ## Commit message ## wifi: rtw89: debug: return the error when a read handler fails  - I hit this while testing an RTL8922AU patch. Reading read_reg in debugfs - before choosing a register set off a kernel BUG that killed the reader. - It does the same every time on an RTL8852BU: + Return the error when a read handler fails, instead of passing it to the + copy to userspace as a length:  rtw89_8852bu 2-1:1.0: invalid read reg len 0 usercopy: Kernel memory exposure attempt detected from SLUB object 'kmalloc-8k' (offset 56, size 262144)! kernel BUG at mm/usercopy.c:102!  - After that the driver cannot be unloaded, and on my test box network - configuration hung until a power cycle. Without hardened usercopy the - reads return kernel memory instead, and cat kept reading until I - stopped it. - - The read path passes the handler's error to the copy as a length, and - saves it for reads at a later offset. Return the error before the copy. - - RTL8852BU over USB before after - read_reg, nothing chosen - 6.18.52 BUG -EINVAL - 7.2.6 BUG -EINVAL - 6.18.52, hardened usercopy off 256 KB -EINVAL - mac_mem_dump at offset 1, - after a failed read - 6.18.52 BUG -ENOENT - 7.2.6 BUG -ENOENT - 6.18.52, hardened usercopy off 256 KB -ENOENT - - RTL8922AU over USB before after - read_reg, nothing chosen - 7.2.6 BUG -EINVAL - mac_mem_dump at offset 1, - after a failed read - 7.2.6 BUG -ENOENT - Fixes: 831cceed3baf ("wifi: rtw89: debugfs: implement file_ops::read/write to replace seq_file") Cc: stable@vger.kernel.org Signed-off-by: Devin Wittmayer