From: Mitchell Tasman <tasman@leaflabs.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: devel@driverdev.osuosl.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Marcelo Diop-Gonzalez <marcgonzalez@google.com>,
linux-kernel@vger.kernel.org,
bcm-kernel-feedback-list@broadcom.com,
linux-rpi-kernel@lists.infradead.org,
Nishka Dasgupta <nishkadg.linux@gmail.com>,
Jamal Shareef <jamal.k.shareef@gmail.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] staging: vchiq_arm: cast with __force as needed
Date: Mon, 25 May 2020 15:50:46 -0400 [thread overview]
Message-ID: <4dcf963f-ce9a-fa2b-09c9-c8657f407167@leaflabs.com> (raw)
In-Reply-To: <20200522110623.GL30374@kadam>
On 5/22/20 7:06 AM, Dan Carpenter wrote:
> On Mon, May 18, 2020 at 08:45:31PM -0400, Mitchell Tasman wrote:
>> 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.
>>
>> Signed-off-by: Mitchell Tasman <tasman@leaflabs.com>
>> ---
>> .../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(-)
>>
>> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
>> index c18c6ca0b6c0..38a13e4618a8 100644
>> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
>> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
>> @@ -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.
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.
>
> regards,
> dan carpenter
>
Regards,
Mitch
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
prev parent reply other threads:[~2020-05-25 19:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-19 0:45 [PATCH] staging: vchiq_arm: cast with __force as needed Mitchell Tasman
2020-05-22 11:06 ` Dan Carpenter
2020-05-25 19:50 ` Mitchell Tasman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4dcf963f-ce9a-fa2b-09c9-c8657f407167@leaflabs.com \
--to=tasman@leaflabs.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jamal.k.shareef@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=marcgonzalez@google.com \
--cc=nishkadg.linux@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).