* [PATCH] firmware: arm_ffa: avoid string-fortify warningn in export_uuid()
@ 2024-09-09 11:09 Arnd Bergmann
0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2024-09-09 11:09 UTC (permalink / raw)
To: Sudeep Holla
Cc: Arnd Bergmann, Cristian Marussi, Jens Wiklander, linux-arm-kernel,
linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Copying to a 16 byte structure into an 8-byte struct member
causes a compile-time warning:
In file included from drivers/firmware/arm_ffa/driver.c:25:
In function 'fortify_memcpy_chk',
inlined from 'export_uuid' at include/linux/uuid.h:88:2,
inlined from 'ffa_msg_send_direct_req2' at drivers/firmware/arm_ffa/driver.c:488:2:
include/linux/fortify-string.h:571:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
571 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Use a union for the conversion instead and make sure the byte order
is fixed in the process.
Fixes: aaef3bc98129 ("firmware: arm_ffa: Add support for FFA_MSG_SEND_DIRECT_{REQ,RESP}2")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Not sure how endianess is handled in the ABI, adding the conversion
seemed sensible here to allow big-endian kernels on a little-endian
firmware, but it's possible that ff-a is already required to do
the byte swapping in this case.
---
drivers/firmware/arm_ffa/driver.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 4d231bc375e0..8dd81db9b071 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -481,11 +481,16 @@ static int ffa_msg_send_direct_req2(u16 src_id, u16 dst_id, const uuid_t *uuid,
struct ffa_send_direct_data2 *data)
{
u32 src_dst_ids = PACK_TARGET_INFO(src_id, dst_id);
+ union {
+ uuid_t uuid;
+ __le64 regs[2];
+ } uuid_regs = { .uuid = *uuid };
ffa_value_t ret, args = {
- .a0 = FFA_MSG_SEND_DIRECT_REQ2, .a1 = src_dst_ids,
+ .a0 = FFA_MSG_SEND_DIRECT_REQ2,
+ .a1 = src_dst_ids,
+ .a2 = le64_to_cpu(uuid_regs.regs[0]),
+ .a3 = le64_to_cpu(uuid_regs.regs[1]),
};
-
- export_uuid((u8 *)&args.a2, uuid);
memcpy((void *)&args + offsetof(ffa_value_t, a4), data, sizeof(*data));
invoke_ffa_fn(args, &ret);
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] firmware: arm_ffa: avoid string-fortify warningn in export_uuid()
@ 2024-09-09 11:09 Arnd Bergmann
2024-09-11 14:14 ` Sudeep Holla
2024-10-15 15:27 ` Sudeep Holla
0 siblings, 2 replies; 6+ messages in thread
From: Arnd Bergmann @ 2024-09-09 11:09 UTC (permalink / raw)
To: Sudeep Holla
Cc: Arnd Bergmann, Cristian Marussi, Jens Wiklander, linux-arm-kernel,
linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Copying to a 16 byte structure into an 8-byte struct member
causes a compile-time warning:
In file included from drivers/firmware/arm_ffa/driver.c:25:
In function 'fortify_memcpy_chk',
inlined from 'export_uuid' at include/linux/uuid.h:88:2,
inlined from 'ffa_msg_send_direct_req2' at drivers/firmware/arm_ffa/driver.c:488:2:
include/linux/fortify-string.h:571:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
571 | __write_overflow_field(p_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Use a union for the conversion instead and make sure the byte order
is fixed in the process.
Fixes: aaef3bc98129 ("firmware: arm_ffa: Add support for FFA_MSG_SEND_DIRECT_{REQ,RESP}2")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Not sure how endianess is handled in the ABI, adding the conversion
seemed sensible here to allow big-endian kernels on a little-endian
firmware, but it's possible that ff-a is already required to do
the byte swapping in this case.
---
drivers/firmware/arm_ffa/driver.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 4d231bc375e0..8dd81db9b071 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -481,11 +481,16 @@ static int ffa_msg_send_direct_req2(u16 src_id, u16 dst_id, const uuid_t *uuid,
struct ffa_send_direct_data2 *data)
{
u32 src_dst_ids = PACK_TARGET_INFO(src_id, dst_id);
+ union {
+ uuid_t uuid;
+ __le64 regs[2];
+ } uuid_regs = { .uuid = *uuid };
ffa_value_t ret, args = {
- .a0 = FFA_MSG_SEND_DIRECT_REQ2, .a1 = src_dst_ids,
+ .a0 = FFA_MSG_SEND_DIRECT_REQ2,
+ .a1 = src_dst_ids,
+ .a2 = le64_to_cpu(uuid_regs.regs[0]),
+ .a3 = le64_to_cpu(uuid_regs.regs[1]),
};
-
- export_uuid((u8 *)&args.a2, uuid);
memcpy((void *)&args + offsetof(ffa_value_t, a4), data, sizeof(*data));
invoke_ffa_fn(args, &ret);
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] firmware: arm_ffa: avoid string-fortify warningn in export_uuid()
2024-09-09 11:09 [PATCH] firmware: arm_ffa: avoid string-fortify warningn in export_uuid() Arnd Bergmann
@ 2024-09-11 14:14 ` Sudeep Holla
2024-09-11 14:44 ` Arnd Bergmann
2024-10-15 15:27 ` Sudeep Holla
1 sibling, 1 reply; 6+ messages in thread
From: Sudeep Holla @ 2024-09-11 14:14 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Arnd Bergmann, Cristian Marussi, Jens Wiklander, linux-arm-kernel,
linux-kernel
On Mon, Sep 09, 2024 at 11:09:24AM +0000, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Copying to a 16 byte structure into an 8-byte struct member
> causes a compile-time warning:
>
> In file included from drivers/firmware/arm_ffa/driver.c:25:
> In function 'fortify_memcpy_chk',
> inlined from 'export_uuid' at include/linux/uuid.h:88:2,
> inlined from 'ffa_msg_send_direct_req2' at drivers/firmware/arm_ffa/driver.c:488:2:
> include/linux/fortify-string.h:571:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
> 571 | __write_overflow_field(p_size_field, size);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Use a union for the conversion instead and make sure the byte order
> is fixed in the process.
>
Thanks for spotting and fixing the issue. I tested enabling
CONFIG_FORTIFY_SOURCE but couldn't hit this with gcc 13 and clang 20
Also do you want this sent as fix on top of my FF-A PR now or after -rc1 ?
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] firmware: arm_ffa: avoid string-fortify warningn in export_uuid()
2024-09-11 14:14 ` Sudeep Holla
@ 2024-09-11 14:44 ` Arnd Bergmann
2024-09-11 15:37 ` Sudeep Holla
0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2024-09-11 14:44 UTC (permalink / raw)
To: Sudeep Holla, Arnd Bergmann
Cc: Cristian Marussi, Jens Wiklander, linux-arm-kernel, linux-kernel
On Wed, Sep 11, 2024, at 14:14, Sudeep Holla wrote:
> On Mon, Sep 09, 2024 at 11:09:24AM +0000, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> Copying to a 16 byte structure into an 8-byte struct member
>> causes a compile-time warning:
>>
>> In file included from drivers/firmware/arm_ffa/driver.c:25:
>> In function 'fortify_memcpy_chk',
>> inlined from 'export_uuid' at include/linux/uuid.h:88:2,
>> inlined from 'ffa_msg_send_direct_req2' at drivers/firmware/arm_ffa/driver.c:488:2:
>> include/linux/fortify-string.h:571:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
>> 571 | __write_overflow_field(p_size_field, size);
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Use a union for the conversion instead and make sure the byte order
>> is fixed in the process.
>>
>
> Thanks for spotting and fixing the issue. I tested enabling
> CONFIG_FORTIFY_SOURCE but couldn't hit this with gcc 13 and clang 20
Unfortunately I also don't have a reproducer at the moment,
but I know it was from a randconfig build with gcc-14.2. I tried
another few hundred randconfigs now with my patch reverted but it
didn't come back. I assume it only shows up in rare combinations
of some options,
Do you have any additional information on the endianess question?
Is this arm_ffa firmware code supposed to work with big-endian
kernels?
> Also do you want this sent as fix on top of my FF-A PR now or after -rc1 ?
Earlier would be better I think. I usually have one set of
bugfixes before rc1 even if it doesn't make it into the
first set of branches.
Arnd
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] firmware: arm_ffa: avoid string-fortify warningn in export_uuid()
2024-09-11 14:44 ` Arnd Bergmann
@ 2024-09-11 15:37 ` Sudeep Holla
0 siblings, 0 replies; 6+ messages in thread
From: Sudeep Holla @ 2024-09-11 15:37 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Arnd Bergmann, Cristian Marussi, Jens Wiklander, linux-arm-kernel,
linux-kernel
On Wed, Sep 11, 2024 at 02:44:25PM +0000, Arnd Bergmann wrote:
> On Wed, Sep 11, 2024, at 14:14, Sudeep Holla wrote:
> > On Mon, Sep 09, 2024 at 11:09:24AM +0000, Arnd Bergmann wrote:
> >> From: Arnd Bergmann <arnd@arndb.de>
> >>
> >> Copying to a 16 byte structure into an 8-byte struct member
> >> causes a compile-time warning:
> >>
> >> In file included from drivers/firmware/arm_ffa/driver.c:25:
> >> In function 'fortify_memcpy_chk',
> >> inlined from 'export_uuid' at include/linux/uuid.h:88:2,
> >> inlined from 'ffa_msg_send_direct_req2' at drivers/firmware/arm_ffa/driver.c:488:2:
> >> include/linux/fortify-string.h:571:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
> >> 571 | __write_overflow_field(p_size_field, size);
> >> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >>
> >> Use a union for the conversion instead and make sure the byte order
> >> is fixed in the process.
> >>
> >
> > Thanks for spotting and fixing the issue. I tested enabling
> > CONFIG_FORTIFY_SOURCE but couldn't hit this with gcc 13 and clang 20
>
> Unfortunately I also don't have a reproducer at the moment,
> but I know it was from a randconfig build with gcc-14.2. I tried
> another few hundred randconfigs now with my patch reverted but it
> didn't come back. I assume it only shows up in rare combinations
> of some options,
>
Oh OK.
> Do you have any additional information on the endianess question?
> Is this arm_ffa firmware code supposed to work with big-endian
> kernels?
>
I am trying to check if that is a requirement. Also the specification
doesn't have any specific mention about it. Since it executes on the same
AP cores as Linux in different EL, I assume the entire stack must be
running same endian-ness. I will check internally. Unlike SCMI, I haven't
tested FF-A with big-endian kernel so far.
> > Also do you want this sent as fix on top of my FF-A PR now or after -rc1 ?
>
> Earlier would be better I think. I usually have one set of
> bugfixes before rc1 even if it doesn't make it into the
> first set of branches.
>
I will try to send earlier unless this endian-ness triggers more questions.
I will update here anyways.
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] firmware: arm_ffa: avoid string-fortify warningn in export_uuid()
2024-09-09 11:09 [PATCH] firmware: arm_ffa: avoid string-fortify warningn in export_uuid() Arnd Bergmann
2024-09-11 14:14 ` Sudeep Holla
@ 2024-10-15 15:27 ` Sudeep Holla
1 sibling, 0 replies; 6+ messages in thread
From: Sudeep Holla @ 2024-10-15 15:27 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Sudeep Holla, Arnd Bergmann, Cristian Marussi, Jens Wiklander,
linux-arm-kernel, linux-kernel
On Mon, 09 Sep 2024 11:09:24 +0000, Arnd Bergmann wrote:
> Copying to a 16 byte structure into an 8-byte struct member
> causes a compile-time warning:
>
> In file included from drivers/firmware/arm_ffa/driver.c:25:
> In function 'fortify_memcpy_chk',
> inlined from 'export_uuid' at include/linux/uuid.h:88:2,
> inlined from 'ffa_msg_send_direct_req2' at drivers/firmware/arm_ffa/driver.c:488:2:
> include/linux/fortify-string.h:571:25: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
> 571 | __write_overflow_field(p_size_field, size);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> [...]
Sorry for the delay, was trying to see if I can test BE kernel and see if
it needs more fixing. The spec does require all memory region to be LE.
I will do that later, for now I am pulling this as fix for v6.12
Applied to sudeep.holla/linux (for-next/ffa/fixes), thanks!
[1/1] firmware: arm_ffa: avoid string-fortify warningn in export_uuid()
https://git.kernel.org/sudeep.holla/c/629253b2f6d7
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-15 15:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-09 11:09 [PATCH] firmware: arm_ffa: avoid string-fortify warningn in export_uuid() Arnd Bergmann
2024-09-11 14:14 ` Sudeep Holla
2024-09-11 14:44 ` Arnd Bergmann
2024-09-11 15:37 ` Sudeep Holla
2024-10-15 15:27 ` Sudeep Holla
-- strict thread matches above, loose matches on Subject: below --
2024-09-09 11:09 Arnd Bergmann
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).