Hi,
This is a small update to Vincenzo's series enabling TUN/TAP support.
v1..v2: - Brought back tun_chr_compat_ioctl(), as we need to keep the handling of struct compat_ifreq being of a different size. The behaviour is otherwise unchanged from v1 (arg is always converted to a user pointer via compat_ptr(), just like when using compat_ptr_ioctl). - Adjusted the commit message in patch 1 accordingly, changed commit title as I suggested in v1.
Review branch:
https://git.morello-project.org/kbrodsky-arm/linux/-/commits/morello/tun_v2
Thanks, Kevin
Vincenzo Frascino (2): net: tun: Fix ioctl handler argument type arm64: morello: Enable TUN in defconfig
.../morello_transitional_pcuabi_defconfig | 1 + drivers/net/tun.c | 22 ++++--------------- 2 files changed, 5 insertions(+), 18 deletions(-)
From: Vincenzo Frascino vincenzo.frascino@arm.com
With the introduction of capabilities, the PCuABI expects a capability when dealing with the user pointers.
When the TUN driver is enabled in a PCuABI compatible kernel, the compiler reports the error below:
drivers/net/tun.c:3502:20: error: incompatible function pointer types initializing 'long (*)(struct file *, unsigned int, user_uintptr_t)' (aka 'long (*)(struct file *, unsigned int, unsigned __intcap)') with an expression of type 'long (struct file *, unsigned int, unsigned long)' [-Werror,-Wincompatible-function-pointer-types] .unlocked_ioctl = tun_chr_ioctl, ^~~~~~~~~~~~~ 1 error generated.
Address the issue using the proper type to represent user pointers (user_uintptr_t). Also make sure to always create a valid user pointer in tun_chr_compat_ioctl() by using compat_ptr(); this was only done for a small and very incomplete list of requests that expect a pointer.
Tested-by: David Horton david.horton@cyberhive.com Signed-off-by: Vincenzo Frascino vincenzo.frascino@arm.com Co-developed-by: Kevin Brodsky kevin.brodsky@arm.com Signed-off-by: Kevin Brodsky kevin.brodsky@arm.com --- drivers/net/tun.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 24001112c323..63242f93704c 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -3042,7 +3042,7 @@ static unsigned char tun_get_addr_len(unsigned short type) }
static long __tun_chr_ioctl(struct file *file, unsigned int cmd, - unsigned long arg, int ifreq_len) + user_uintptr_t arg, int ifreq_len) { struct tun_file *tfile = file->private_data; struct net *net = sock_net(&tfile->sk); @@ -3373,7 +3373,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, }
static long tun_chr_ioctl(struct file *file, - unsigned int cmd, unsigned long arg) + unsigned int cmd, user_uintptr_t arg) { return __tun_chr_ioctl(file, cmd, arg, sizeof (struct ifreq)); } @@ -3382,28 +3382,14 @@ static long tun_chr_ioctl(struct file *file, static long tun_chr_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - switch (cmd) { - case TUNSETIFF: - case TUNGETIFF: - case TUNSETTXFILTER: - case TUNGETSNDBUF: - case TUNSETSNDBUF: - case SIOCGIFHWADDR: - case SIOCSIFHWADDR: - arg = (unsigned long)compat_ptr(arg); - break; - default: - arg = (compat_ulong_t)arg; - break; - } - /* * compat_ifreq is shorter than ifreq, so we must not access beyond * the end of that structure. All fields that are used in this * driver are compatible though, we don't need to convert the * contents. */ - return __tun_chr_ioctl(file, cmd, arg, sizeof(struct compat_ifreq)); + return __tun_chr_ioctl(file, cmd, (user_uintptr_t)compat_ptr(arg), + sizeof(struct compat_ifreq)); } #endif /* CONFIG_COMPAT */
From: Vincenzo Frascino vincenzo.frascino@arm.com
Enable the required option to have the "Universal TUN/TAP device driver support" working on a Morello SoC in the default defconfig for Morello Transitional PCuABI (morello_transitional_pcuabi_defconfig): - CONFIG_TUN=y
Tested-by: David Horton david.horton@cyberhive.com Signed-off-by: Vincenzo Frascino vincenzo.frascino@arm.com --- arch/arm64/configs/morello_transitional_pcuabi_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm64/configs/morello_transitional_pcuabi_defconfig b/arch/arm64/configs/morello_transitional_pcuabi_defconfig index 988f22f094f1..856806652bac 100644 --- a/arch/arm64/configs/morello_transitional_pcuabi_defconfig +++ b/arch/arm64/configs/morello_transitional_pcuabi_defconfig @@ -95,6 +95,7 @@ CONFIG_SATA_AHCI=y CONFIG_MD=y CONFIG_BLK_DEV_DM=y CONFIG_NETDEVICES=y +CONFIG_TUN=y CONFIG_VETH=y CONFIG_VIRTIO_NET=y CONFIG_R8169=y
Hi Kevin,
On 3/29/23 08:53, Kevin Brodsky wrote:
Hi,
This is a small update to Vincenzo's series enabling TUN/TAP support.
v1..v2:
- Brought back tun_chr_compat_ioctl(), as we need to keep the handling of struct compat_ifreq being of a different size. The behaviour is otherwise unchanged from v1 (arg is always converted to a user pointer via compat_ptr(), just like when using compat_ptr_ioctl).
- Adjusted the commit message in patch 1 accordingly, changed commit title as I suggested in v1.
Review branch:
https://git.morello-project.org/kbrodsky-arm/linux/-/commits/morello/tun_v2
Thanks, Kevin
Thank you for the update, the patches look fine to be merged.
Vincenzo Frascino (2): net: tun: Fix ioctl handler argument type arm64: morello: Enable TUN in defconfig
.../morello_transitional_pcuabi_defconfig | 1 + drivers/net/tun.c | 22 ++++--------------- 2 files changed, 5 insertions(+), 18 deletions(-)
On 29/03/2023 10:23, Vincenzo Frascino wrote:
Hi Kevin,
On 3/29/23 08:53, Kevin Brodsky wrote:
Hi,
This is a small update to Vincenzo's series enabling TUN/TAP support.
v1..v2:
- Brought back tun_chr_compat_ioctl(), as we need to keep the handling of struct compat_ifreq being of a different size. The behaviour is otherwise unchanged from v1 (arg is always converted to a user pointer via compat_ptr(), just like when using compat_ptr_ioctl).
- Adjusted the commit message in patch 1 accordingly, changed commit title as I suggested in v1.
Review branch:
https://git.morello-project.org/kbrodsky-arm/linux/-/commits/morello/tun_v2
Thanks, Kevin
Thank you for the update, the patches look fine to be merged.
Thanks for having a look, the series is now in next.
Kevin
Vincenzo Frascino (2): net: tun: Fix ioctl handler argument type arm64: morello: Enable TUN in defconfig
.../morello_transitional_pcuabi_defconfig | 1 + drivers/net/tun.c | 22 ++++--------------- 2 files changed, 5 insertions(+), 18 deletions(-)
linux-morello@op-lists.linaro.org