2021-02-23 00:02:02

by Sami Tolvanen

[permalink] [raw]
Subject: Re: [PATCH] remoteproc: core: Remove casting to rproc_handle_resource_t

Hi,

On Sun, Feb 21, 2021 at 11:18 PM Jindong Yue <[email protected]> wrote:
>
> There are four different callback functions that are used for the
> rproc_handle_resource_t callback that all have different second
> parameter types.
>
> rproc_handle_vdev -> struct fw_rsc_vdev
> rproc_handle_trace -> struct fw_rsc_trace
> rproc_handle_devmem -> struct fw_rsc_devmem
> rproc_handle_carveout -> struct fw_rsc_carveout
>
> These callbacks are cast to rproc_handle_resource_t so that there is no
> error about incompatible pointer types. Unfortunately, this is a control
> flow integrity violation, which verifies that the callback function's
> types match the prototypes exactly before jumping.

Thank you for sending the patch! It might be worth noting that Clang's
Control-Flow Integrity checking is currently used only in Android
kernels, so while the type mismatches are real and should be fixed,
they don't result in runtime errors without this feature.

> To fix this, change the second parameter of all functions to void * and
> use a local variable with the correct type so that everything works
> properly. With this, we can remove casting to rproc_handle_resource_t
> for these functions.
>
> Signed-off-by: Jindong Yue <[email protected]>
> Reviewed-by: Peng Fan <[email protected]>

This looks correct to me. Please feel free to add:

Reviewed-by: Sami Tolvanen <[email protected]>

Sami


2021-02-23 16:46:54

by Mathieu Poirier

[permalink] [raw]
Subject: Re: [PATCH] remoteproc: core: Remove casting to rproc_handle_resource_t

On Mon, 22 Feb 2021 at 15:48, Sami Tolvanen <[email protected]> wrote:
>
> Hi,
>
> On Sun, Feb 21, 2021 at 11:18 PM Jindong Yue <[email protected]> wrote:
> >
> > There are four different callback functions that are used for the
> > rproc_handle_resource_t callback that all have different second
> > parameter types.
> >
> > rproc_handle_vdev -> struct fw_rsc_vdev
> > rproc_handle_trace -> struct fw_rsc_trace
> > rproc_handle_devmem -> struct fw_rsc_devmem
> > rproc_handle_carveout -> struct fw_rsc_carveout
> >
> > These callbacks are cast to rproc_handle_resource_t so that there is no
> > error about incompatible pointer types. Unfortunately, this is a control
> > flow integrity violation, which verifies that the callback function's
> > types match the prototypes exactly before jumping.
>
> Thank you for sending the patch! It might be worth noting that Clang's
> Control-Flow Integrity checking is currently used only in Android
> kernels, so while the type mismatches are real and should be fixed,
> they don't result in runtime errors without this feature.
>
> > To fix this, change the second parameter of all functions to void * and
> > use a local variable with the correct type so that everything works
> > properly. With this, we can remove casting to rproc_handle_resource_t
> > for these functions.
> >
> > Signed-off-by: Jindong Yue <[email protected]>
> > Reviewed-by: Peng Fan <[email protected]>
>
> This looks correct to me. Please feel free to add:
>
> Reviewed-by: Sami Tolvanen <[email protected]>

Where is the original patch? I can't find it on the linux-remoteproc
and linux-kernel mailing lists.

>
> Sami

2021-02-23 20:28:25

by Sami Tolvanen

[permalink] [raw]
Subject: Re: [PATCH] remoteproc: core: Remove casting to rproc_handle_resource_t

On Tue, Feb 23, 2021 at 8:41 AM Mathieu Poirier
<[email protected]> wrote:
>
> On Mon, 22 Feb 2021 at 15:48, Sami Tolvanen <[email protected]> wrote:
> >
> > Hi,
> >
> > On Sun, Feb 21, 2021 at 11:18 PM Jindong Yue <[email protected]> wrote:
> > >
> > > There are four different callback functions that are used for the
> > > rproc_handle_resource_t callback that all have different second
> > > parameter types.
> > >
> > > rproc_handle_vdev -> struct fw_rsc_vdev
> > > rproc_handle_trace -> struct fw_rsc_trace
> > > rproc_handle_devmem -> struct fw_rsc_devmem
> > > rproc_handle_carveout -> struct fw_rsc_carveout
> > >
> > > These callbacks are cast to rproc_handle_resource_t so that there is no
> > > error about incompatible pointer types. Unfortunately, this is a control
> > > flow integrity violation, which verifies that the callback function's
> > > types match the prototypes exactly before jumping.
> >
> > Thank you for sending the patch! It might be worth noting that Clang's
> > Control-Flow Integrity checking is currently used only in Android
> > kernels, so while the type mismatches are real and should be fixed,
> > they don't result in runtime errors without this feature.
> >
> > > To fix this, change the second parameter of all functions to void * and
> > > use a local variable with the correct type so that everything works
> > > properly. With this, we can remove casting to rproc_handle_resource_t
> > > for these functions.
> > >
> > > Signed-off-by: Jindong Yue <[email protected]>
> > > Reviewed-by: Peng Fan <[email protected]>
> >
> > This looks correct to me. Please feel free to add:
> >
> > Reviewed-by: Sami Tolvanen <[email protected]>
>
> Where is the original patch? I can't find it on the linux-remoteproc
> and linux-kernel mailing lists.

Looks like it was sent to linux-remoteproc, but I also don't see it in
lore.kernel.org. Not sure what happened there. Jindong, perhaps it's
worth resending and including linux-kernel too?

Sami

2021-02-23 20:33:46

by Mathieu Poirier

[permalink] [raw]
Subject: Re: [PATCH] remoteproc: core: Remove casting to rproc_handle_resource_t

On Tue, 23 Feb 2021 at 09:49, Sami Tolvanen <[email protected]> wrote:
>
> On Tue, Feb 23, 2021 at 8:41 AM Mathieu Poirier
> <[email protected]> wrote:
> >
> > On Mon, 22 Feb 2021 at 15:48, Sami Tolvanen <[email protected]> wrote:
> > >
> > > Hi,
> > >
> > > On Sun, Feb 21, 2021 at 11:18 PM Jindong Yue <[email protected]> wrote:
> > > >
> > > > There are four different callback functions that are used for the
> > > > rproc_handle_resource_t callback that all have different second
> > > > parameter types.
> > > >
> > > > rproc_handle_vdev -> struct fw_rsc_vdev
> > > > rproc_handle_trace -> struct fw_rsc_trace
> > > > rproc_handle_devmem -> struct fw_rsc_devmem
> > > > rproc_handle_carveout -> struct fw_rsc_carveout
> > > >
> > > > These callbacks are cast to rproc_handle_resource_t so that there is no
> > > > error about incompatible pointer types. Unfortunately, this is a control
> > > > flow integrity violation, which verifies that the callback function's
> > > > types match the prototypes exactly before jumping.
> > >
> > > Thank you for sending the patch! It might be worth noting that Clang's
> > > Control-Flow Integrity checking is currently used only in Android
> > > kernels, so while the type mismatches are real and should be fixed,
> > > they don't result in runtime errors without this feature.
> > >
> > > > To fix this, change the second parameter of all functions to void * and
> > > > use a local variable with the correct type so that everything works
> > > > properly. With this, we can remove casting to rproc_handle_resource_t
> > > > for these functions.
> > > >
> > > > Signed-off-by: Jindong Yue <[email protected]>
> > > > Reviewed-by: Peng Fan <[email protected]>
> > >
> > > This looks correct to me. Please feel free to add:
> > >
> > > Reviewed-by: Sami Tolvanen <[email protected]>
> >
> > Where is the original patch? I can't find it on the linux-remoteproc
> > and linux-kernel mailing lists.
>
> Looks like it was sent to linux-remoteproc, but I also don't see it in
> lore.kernel.org. Not sure what happened there. Jindong, perhaps it's
> worth resending and including linux-kernel too?

Something definitely happened because I can't find anything from
Jindong on the linux-remoteproc list... A resend it indeed in order.

>
> Sami