Skip to contentSkip to conversation

remoteproc: core: Remove casting to rproc_handle_resource_t

PATCH Sami Tolvanen 2 participants 4 messages Feb 22, 2021 – Feb 23, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Sami Tolvanen

author Reviewed-by
#1 lore raw

Hi,

Quoted 10 lines · Jindong Yue

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

Quoted 4 lines

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.

Quoted 7 lines

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.

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

Sami

#2 lore raw
Quoted 29 lines · Sami Tolvanen

Hi,

Quoted 10 lines · Jindong Yue

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

Quoted 4 lines

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.

Quoted 5 lines

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.

Quoted 6 lines
Quoted 2 lines

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

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

Quoted 2 lines

Sami

#3 lore raw
Quoted 34 lines · Mathieu Poirier
Quoted 32 lines · Sami Tolvanen

Hi,

Quoted 10 lines · Jindong Yue

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

Quoted 4 lines

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.

Quoted 7 lines

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.

Quoted 6 lines
Quoted 3 lines

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

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

#4 lore raw
Quoted 39 lines · Sami Tolvanen
Quoted 36 lines · Mathieu Poirier
Quoted 34 lines · Sami Tolvanen

Hi,

Quoted 10 lines · Jindong Yue

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

Quoted 4 lines

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.

Quoted 7 lines

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.

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

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

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.

Quoted 2 lines

Sami