A trio of vchiq bulk transfer fixes
Subsystems (2)
v2 cover A trio of vchiq bulk transfer fixes
The recent batch of vchiq improvements broke bulk transfers in two ways:
1. The userdata associated with a transfer was lost in the case that a non-blocking mode was used.
2. The 64-bit ioctl compatibility shim for a bulk transfer used the wrong ioctl command.
This patch set fixes both of those bugs, and adds a security-related note to the TODO file.
Changes in v2:
- Expand the commit message on patch 1 to clarify the impact of the bug, and add Tested-by.
- Add commit 3 with an additional TODO item.
- Change the name of the patch set to be numerically accurate.
Phil Elwell (3):
staging: vchiq: Fix bulk userdata handling
staging: vchiq: Fix bulk transfers on 64-bit builds
staging: vc04_services: Add a note to the TODO
drivers/staging/vc04_services/interface/TODO | 4 ++++ .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 1/3 staging: vchiq: Fix bulk userdata handling
The addition of the local 'userdata' pointer to vchiq_irq_queue_bulk_tx_rx omitted the case where neither BLOCKING nor WAITING modes are used, in which case the value provided by the caller is not returned to them as expected, but instead it is replaced with a NULL. This lack of a suitable context may cause the application to crash or otherwise malfunction.
--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +3 -1
@@ -958,7 +958,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,struct vchiq_service *service;struct bulk_waiter_node *waiter =NULL ;bool found = false; -void *userdata =NULL ; +void *userdata;int status =0 ;int ret;
@@ -997,6 +997,8 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,"found bulk_waiter %pK for pid %d" , waiter, current->pid); userdata = &waiter->bulk_waiter; + }else { + userdata = args->userdata; }/*
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 2/3 staging: vchiq: Fix bulk transfers on 64-bit builds
In reply to Phil ElwellThe recent change to the bulk transfer compat function missed the fact the relevant ioctl command is VCHIQ_IOC_QUEUE_BULK_TRANSMIT32, not VCHIQ_IOC_QUEUE_BULK_TRANSMIT, as any attempt to send a bulk block to the VPU would have shown.
--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +1 -1
@@ -1717,7 +1717,7 @@ vchiq_compat_ioctl_queue_bulk(struct file *file, {struct vchiq_queue_bulk_transfer32 args32;struct vchiq_queue_bulk_transfer args; -enum vchiq_bulk_dir dir = (cmd ==VCHIQ_IOC_QUEUE_BULK_TRANSMIT ) ? +enum vchiq_bulk_dir dir = (cmd ==VCHIQ_IOC_QUEUE_BULK_TRANSMIT32 ) ?VCHIQ_BULK_TRANSMIT :VCHIQ_BULK_RECEIVE ;if (copy_from_user (&args32, argp,sizeof (args32)))
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 3/3 staging: vc04_services: Add a note to the TODO
In reply to Phil ElwellRecord in the TODO file that the address of "&waiter->bulk_waiter" should never be returned to userspace.
--- drivers/staging/vc04_services/interface/TODO | 4 ++++ 1 file changed, 4 insertions(+)
drivers/staging/vc04_services/interface/TODO +4 -0
@@ -91,3 +91,7 @@ The first thing one generally sees in a probe function is a memory allocation for all the device specific data. This structure is then passed all over the driver. This is good practice since it makes the driver work regardless of the number of devices probed. + +14) Clean up Sparse warnings from __user annotations. See +vchiq_irq_queue_bulk_tx_rx(). Ensure that the address of "&waiter->bulk_waiter" +is never disclosed to userspace.
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thanks!
regards,
dan carpenter
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 2/3] staging: vchiq: Fix bulk transfers on 64-bit builds
In reply to Phil ElwellQuoted 9 lines · Phil Elwell
The recent change to the bulk transfer compat function missed the fact the relevant ioctl command is
VCHIQ_IOC_QUEUE_BULK_TRANSMIT32, notVCHIQ_IOC_QUEUE_BULK_TRANSMIT, as any attempt to send a bulk block to the VPU would have shown.Fixes a4367cd2b231 ("staging: vchiq: convert compat bulk transfer")Signed-off-by Phil Elwell <[email protected]>
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 17 lines · Phil Elwell
The recent batch of vchiq improvements broke bulk transfers in two ways:
1. The userdata associated with a transfer was lost in the case that a non-blocking mode was used.
2. The 64-bit ioctl compatibility shim for a bulk transfer used the wrong ioctl command.
This patch set fixes both of those bugs, and adds a security-related note to the TODO file.
Changes in v2:
- Expand the commit message on patch 1 to clarify the impact of the bug, and add Tested-by.
- Add commit 3 with an additional TODO item.
- Change the name of the patch set to be numerically accurate.
Quoted 9 lines
Phil Elwell (3):
staging: vchiq: Fix bulk userdata handling
staging: vchiq: Fix bulk transfers on 64-bit builds
staging:vc04_services: Add a note to the TODOdrivers/staging/vc04_services/interface/TODO | 4 ++++
.../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 ++++--2 files changed, 8 insertions(+), 2 deletions(-)
Regards,
Nicolas
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel