From: "Arnd Bergmann" <arnd@arndb.de>
To: "Stefan Wahren" <wahrenst@gmx.net>,
"Umang Jain" <umang.jain@ideasonboard.com>,
linux-staging@lists.linux.dev
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Ray Jui" <rjui@broadcom.com>,
"Scott Branden" <sbranden@broadcom.com>,
"Dan Carpenter" <dan.carpenter@linaro.org>,
"Kieran Bingham" <kieran.bingham@ideasonboard.com>,
"laurent.pinchart" <laurent.pinchart@ideasonboard.com>,
"Yang Li" <yang.lee@linux.alibaba.com>,
"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: vchiq: Avoid mixing bulk_userdata kernel and userspace pointer
Date: Tue, 30 Jul 2024 23:28:40 +0200 [thread overview]
Message-ID: <3d3b7368-93b2-4c0d-845e-4099c2de9dc1@app.fastmail.com> (raw)
In-Reply-To: <e0692316-f8c5-4ddc-ab39-ba70cbfbdf28@gmx.net>
On Tue, Jul 30, 2024, at 20:05, Stefan Wahren wrote:
> Hi Umang,
>
> Am 30.07.24 um 19:08 schrieb Umang Jain:
>> In vchiq_dev.c, there are two places where the __user bulk_userdata
>> pointer to set to a kernel-space pointer which then gives relevant
>> Sparse warnings as below:
>>
>> vchiq_dev.c:328:26: warning: incorrect type in assignment (different address spaces)
>> vchiq_dev.c:328:26: expected void *[assigned] userdata
>> vchiq_dev.c:328:26: got void [noderef] __user *userdata
>> vchiq_dev.c:543:47: warning: incorrect type in assignment (different address spaces)
>> vchiq_dev.c:543:47: expected void [noderef] __user *[addressable] [assigned] bulk_userdata
>> vchiq_dev.c:543:47: got void *bulk_userdata
>>
>> This is solved by adding additional functional argument to track the
>> userspace bulk_userdata separately and passing it accordingly to
>> completion handlers.
> IMO this patch fixes the issue for spare, but don't address the
> confusing member naming for humans. It's not clear that "userdata" is a
> kernel pointer and "uuserdata" is a pointer to userspace. It would be
> nice to avoid the word "user" for kernel pointer in this case.
Right, also you need to provide a much better explanation about
how the code is meant to work, and what this opaque pointer
is meant to do.
Ideally this should be cleaned up in a way that completely
avoids passing both user and kernel data at the same time.
A small step would be to separate out the "struct bulk_waiter
*bulk_waiter" argument and make that typesafe.
You can also wrap vchiq_bulk_transfer() in order to have
four separate functions based on the different 'mode'
values and have them only take the arguments they actually
need.
Arnd
prev parent reply other threads:[~2024-07-30 21:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 17:08 [PATCH] staging: vchiq: Avoid mixing bulk_userdata kernel and userspace pointer Umang Jain
2024-07-30 18:05 ` Stefan Wahren
2024-07-30 21:28 ` Arnd Bergmann [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=3d3b7368-93b2-4c0d-845e-4099c2de9dc1@app.fastmail.com \
--to=arnd@arndb.de \
--cc=dan.carpenter@linaro.org \
--cc=florian.fainelli@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=kieran.bingham@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-staging@lists.linux.dev \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
--cc=umang.jain@ideasonboard.com \
--cc=wahrenst@gmx.net \
--cc=wsa+renesas@sang-engineering.com \
--cc=yang.lee@linux.alibaba.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