Addresses an issue of multiple invalid loops in the rpmsgfs_mkpath function
Summary
This commit addresses an issue of multiple invalid loops in the rpmsgfs_mkpath function under specific cross-system mount scenarios.
Problem Description: The mount command in the NuttX shell is as follows:
mount -t rpmsgfs -o cpu=server,fs=/root/demo/fold /nuttx_fold
Running “ls nuttx_fold“ correctly lists the contents of the /root/demo/fold directory on the Linux side. However, if NuttX is compromised by a hacker, the hacker could modify the input parameters of the ls command. Without directory access restrictions implemented on the Linux side, this would allow the hacker to arbitrarily access any directory on the Linux system.
When directory access restrictions are implemented on the Linux side—such as modifying the rpmsgfs driver on the Linux side to return "permission deny" upon detecting unauthorized access—the rpmsgfs_client_stat function in rpmsgfs_mkpath (on the NuttX side) fails to handle this error and continues waiting in the while loop.
Impact
Only modifies the error handling branch in rpmsgfs_mkpath, with no impact on other functions of the rpmsgfs module.
Testing
In the Linux shell, create the directory /root/demo/fold, and restrict NuttX from accessing the fold directory itself by configuring the rpmsg_fs driver.
In Nuttx shell:
mount -t rpmsgfs -o cpu=server,fs=/root/demo/fold /nuttx_fold
ls /nuttx_fold
Nuttx shell output:
proxy> mount -t rpmsgfs -o cpu=server,fs=/root/demo/fold nuttx_fold
proxy> ls
proxy> ls nuttx_fold
nsh: ls: stat failed: 13
Signed-off-by: Lijing [email protected]
Note: I re-formatted your PR description so that it displays with wrapped lines on GitHub. Otherwise it was very difficult to read because text required scrolling to the right quite far.
@sszllxos nice finding. Could you please tell me which link interface are you using to connect Linux and NuttX?
@xiaoxiang781216 did you submit the RPMsg SPI driver to Linux mainline?
@xiaoxiang781216 did you submit the RPMsg SPI driver to Linux mainline?
not yet.
@acassis RPMsg SPI driver