This series of patches enables nfs rootfs support on the Morello board.
Patch 01 is fixing the inital kernel build error associated with a wrong function pointer type within the sunrpc modules due to the unlocked_ioctl fp, the error occurs upon enabling nfs within the defconfig.
Patch 02 deals with the fallout caused by changes inferred by patches 01. See details in the description of the patch.
Patch 03 is enabling nfs rootfs by default in the kernel.
It was confirmed that the kernel can boot with a nfs rootfs.
V2 changes: - patch only the modules that are actually being used - change description and fix nits - address the incorrect proc_compat_ioctl
Pawel Zalewski (3): net: sunrpc: fix unlocked_ioctl handler signature include: linux: fix proc_ioctl arm64: morello: enable nfs rootfs by default
arch/arm64/configs/morello_transitional_pcuabi_defconfig | 2 ++ drivers/pci/proc.c | 4 ++-- include/linux/proc_fs.h | 2 +- net/sunrpc/cache.c | 6 +++--- net/sunrpc/rpc_pipe.c | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-)
The function pointer file_operations.unlocked_ioctl requires the use of user_uintptr_t type as argument to pass CHERI capabilities so change the argument type from unsigned long to user_uintptr_t.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk --- net/sunrpc/cache.c | 4 ++-- net/sunrpc/rpc_pipe.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index f075a9fb5ccc..c4aaef5430f1 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -991,7 +991,7 @@ static __poll_t cache_poll(struct file *filp, poll_table *wait, }
static int cache_ioctl(struct inode *ino, struct file *filp, - unsigned int cmd, unsigned long arg, + unsigned int cmd, user_uintptr_t arg, struct cache_detail *cd) { int len = 0; @@ -1791,7 +1791,7 @@ static __poll_t cache_poll_pipefs(struct file *filp, poll_table *wait) }
static long cache_ioctl_pipefs(struct file *filp, - unsigned int cmd, unsigned long arg) + unsigned int cmd, user_uintptr_t arg) { struct inode *inode = file_inode(filp); struct cache_detail *cd = RPC_I(inode)->private; diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 0b6034fab9ab..1259e1e863f1 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -354,7 +354,7 @@ rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait) }
static long -rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +rpc_pipe_ioctl(struct file *filp, unsigned int cmd, user_uintptr_t arg) { struct inode *inode = file_inode(filp); struct rpc_pipe *pipe;
The module net:sunrpc:cache.c will effectively use the same callback cache_ioctl for pointers passed from file_operations.unlocked_ioctl and proc_ops.proc_ioctl and it expects pointers as the argument. Thus to be able to pass CHERI capabilities, the .proc_ioctl fp's arg input should also be of user_uintptr_t type.
The proc_compat_ioctl handler in the pci/proc.c module is replaced with compat_noptr_ioctl as the arg is not being passed as a pointer into the proc_bus_pci_ioctl handler.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk --- drivers/pci/proc.c | 4 ++-- include/linux/proc_fs.h | 2 +- net/sunrpc/cache.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index f967709082d6..dfd7a3d3a89e 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -192,7 +192,7 @@ struct pci_filp_private { #endif /* HAVE_PCI_MMAP */
static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) + user_uintptr_t arg) { struct pci_dev *dev = pde_data(file_inode(file)); #ifdef HAVE_PCI_MMAP @@ -322,7 +322,7 @@ static const struct proc_ops proc_bus_pci_ops = { .proc_write = proc_bus_pci_write, .proc_ioctl = proc_bus_pci_ioctl, #ifdef CONFIG_COMPAT - .proc_compat_ioctl = proc_bus_pci_ioctl, + .proc_compat_ioctl = compat_noptr_ioctl, #endif #ifdef HAVE_PCI_MMAP .proc_open = proc_bus_pci_open, diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 81d6e4ec2294..11d6c3620175 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -36,7 +36,7 @@ struct proc_ops { loff_t (*proc_lseek)(struct file *, loff_t, int); int (*proc_release)(struct inode *, struct file *); __poll_t (*proc_poll)(struct file *, struct poll_table_struct *); - long (*proc_ioctl)(struct file *, unsigned int, unsigned long); + long (*proc_ioctl)(struct file *, unsigned int, user_uintptr_t); #ifdef CONFIG_COMPAT long (*proc_compat_ioctl)(struct file *, unsigned int, unsigned long); #endif diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index c4aaef5430f1..b682aa223bd6 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -1573,7 +1573,7 @@ static __poll_t cache_poll_procfs(struct file *filp, poll_table *wait) }
static long cache_ioctl_procfs(struct file *filp, - unsigned int cmd, unsigned long arg) + unsigned int cmd, user_uintptr_t arg) { struct inode *inode = file_inode(filp); struct cache_detail *cd = pde_data(inode);
In the commit title: considering the patch impacts various files, I think the most appropriate tag is "proc:". It would also be good to have a title more similar to patch 1 (just "fix proc_ioctl" is very vague).
On 17/05/2023 15:40, Pawel Zalewski wrote:
The module net:sunrpc:cache.c will effectively use the same callback cache_ioctl for pointers passed from file_operations.unlocked_ioctl and proc_ops.proc_ioctl and it expects pointers as the argument. Thus to be able to pass CHERI capabilities, the .proc_ioctl fp's arg input should also be of user_uintptr_t type.
The proc_compat_ioctl handler in the pci/proc.c module is replaced with compat_noptr_ioctl as the arg is not being passed as a pointer into the proc_bus_pci_ioctl handler.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk
drivers/pci/proc.c | 4 ++-- include/linux/proc_fs.h | 2 +- net/sunrpc/cache.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index f967709082d6..dfd7a3d3a89e 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -192,7 +192,7 @@ struct pci_filp_private { #endif /* HAVE_PCI_MMAP */ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
user_uintptr_t arg)
There's still one tab that has gone missing here.
Apart from these two nits, the series looks good to me.
Kevin
There's still one tab that has gone missing here.
I blame Eclipse.
In the commit title: considering the patch impacts various files, I
think the most appropriate tag is "proc:"
Thanks, you are correct, I have overlooked this, will change in V3.
Pawel
It is very useful to be able to boot from a remote rootfs, especially during the development and due to the nature of the Morello project development will be the most often encountered use case.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk --- arch/arm64/configs/morello_transitional_pcuabi_defconfig | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/arch/arm64/configs/morello_transitional_pcuabi_defconfig b/arch/arm64/configs/morello_transitional_pcuabi_defconfig index 856806652bac..40b74494980c 100644 --- a/arch/arm64/configs/morello_transitional_pcuabi_defconfig +++ b/arch/arm64/configs/morello_transitional_pcuabi_defconfig @@ -146,6 +146,8 @@ CONFIG_PROC_KCORE=y CONFIG_TMPFS=y CONFIG_HUGETLBFS=y # CONFIG_EFIVAR_FS is not set +CONFIG_NFS_FS=y +CONFIG_ROOT_NFS=y CONFIG_9P_FS=y CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_ISO8859_1=y
linux-morello@op-lists.linaro.org