staging: vchiq_arm: cast with __force as needed
Subsystems (2)
PATCH 1/1 staging: vchiq_arm: cast with __force as needed
In several cases where a pointer marked as __user is (intentionally) assigned or passed to a non-marked target, cast to the target pointer type with a __force directive to quiet warnings from sparse.
--- .../vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 7 ++++--- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +4 -3
@@ -371,14 +371,15 @@ create_pagelist(char __user *buf, size_t count, unsigned short type) pagelistinfo->scatterlist = scatterlist; pagelistinfo->scatterlist_mapped =0 ; -if (is_vmalloc_addr (buf)) { +if (is_vmalloc_addr ((void __force *)buf)) {unsigned long length = count;unsigned int off = offset;for (actual_pages =0 ; actual_pages < num_pages; actual_pages++) { -struct page *pg =vmalloc_to_page (buf + (actual_pages * -PAGE_SIZE )); +struct page *pg = +vmalloc_to_page ((void __force *)(buf + + (actual_pages *PAGE_SIZE )));size_t bytes =PAGE_SIZE - off;if (!pg) {
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +3 -1
@@ -1209,7 +1209,9 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)/* The completion must point to the ** msgbuf. */ - completion->header = msgbuf; + completion->header = + (struct vchiq_header __force *) + msgbuf; } if ((completion->reason ==
Signature · 1 line
2.17.1
Quoted 16 lines · Mitchell Tasman
In several cases where a pointer marked as
__useris (intentionally) assigned or passed to a non-marked target, cast to the target pointer type with a__forcedirective to quiet warnings from sparse.Signed-off-by Mitchell Tasman <[email protected]>--- .../vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 7 ++++--- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +0
-0
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c create_pagelist(char __user *buf, size_t count, unsigned short type) · line 374
Quoted 5 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +1
-1@@ -371,14 +371,15 @@ create_pagelist(char __user *buf, size_t count, unsigned short type) pagelistinfo->scatterlist = scatterlist; pagelistinfo->scatterlist_mapped =0 ; -if (is_vmalloc_addr (buf)) { +if (is_vmalloc_addr ((void __force *)buf)) {
Am I reading this correctly???
This is actually a user controlled pointer that comes from the vchiq_ioctl() when we do VCHIQ_IOC_QUEUE_BULK_TRANSMIT/RECEIVE. So we take random pointer from user space and if it happens to point to kernel space then we trust it and presumably start BULK_TRANSMITing data to it???
LOL.... This doesn't seem safe at all.
regards,
dan carpenter
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 25 lines · Dan Carpenter
Quoted 16 lines · Mitchell Tasman
In several cases where a pointer marked as
__useris (intentionally) assigned or passed to a non-marked target, cast to the target pointer type with a__forcedirective to quiet warnings from sparse.Signed-off-by Mitchell Tasman <[email protected]>--- .../vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 7 ++++--- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +0
-0drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c create_pagelist(char __user *buf, size_t count, unsigned short type) · line 374
Quoted 5 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +1
-1@@ -371,14 +371,15 @@ create_pagelist(char __user *buf, size_t count, unsigned short type) pagelistinfo->scatterlist = scatterlist; pagelistinfo->scatterlist_mapped =0 ; -if (is_vmalloc_addr (buf)) { +if (is_vmalloc_addr ((void __force *)buf)) {Am I reading this correctly???
Quoted 7 lines
This is actually a user controlled pointer that comes from the
vchiq_ioctl()when we do VCHIQ_IOC_QUEUE_BULK_TRANSMIT/RECEIVE. So we take random pointer from user space and if it happens to point to kernel space then we trust it and presumably startBULK_TRANSMITingdata to it???LOL.... This doesn't seem safe at all.
Is additional validation of buf and its extent necessary and sufficient, e.g. perhaps access_ok(buf, count * PAGE_SIZE) somewhere along the call chain? Or does vhciq_arm need to take a different approach in the area that Dan Carpenter flagged?
Thank you.
Quoted 4 lines
regards,
dan carpenter
Regards,
Mitch