Skip to content

Commit bba5478

Browse files
charlie-rivosAlexandre Ghiti
authored andcommitted
riscv: tracing: Fix __write_overflow_field in ftrace_partial_regs()
The size of &regs->a0 is unknown, causing the error: ../include/linux/fortify-string.h:571:25: warning: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wattribute-warning] Fix this by wrapping the required registers in pt_regs with struct_group() and reference the group when doing the offending memcpy(). Signed-off-by: Charlie Jenkins <[email protected]> Reviewed-by: Alexandre Ghiti <[email protected]> Tested-by: Alexandre Ghiti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Ghiti <[email protected]>
1 parent 7277069 commit bba5478

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

arch/riscv/include/asm/ftrace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ ftrace_partial_regs(const struct ftrace_regs *fregs, struct pt_regs *regs)
207207
{
208208
struct __arch_ftrace_regs *afregs = arch_ftrace_regs(fregs);
209209

210-
memcpy(&regs->a0, afregs->args, sizeof(afregs->args));
210+
memcpy(&regs->a_regs, afregs->args, sizeof(afregs->args));
211211
regs->epc = afregs->epc;
212212
regs->ra = afregs->ra;
213213
regs->sp = afregs->sp;

arch/riscv/include/asm/ptrace.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ struct pt_regs {
2323
unsigned long t2;
2424
unsigned long s0;
2525
unsigned long s1;
26-
unsigned long a0;
27-
unsigned long a1;
28-
unsigned long a2;
29-
unsigned long a3;
30-
unsigned long a4;
31-
unsigned long a5;
32-
unsigned long a6;
33-
unsigned long a7;
26+
struct_group(a_regs,
27+
unsigned long a0;
28+
unsigned long a1;
29+
unsigned long a2;
30+
unsigned long a3;
31+
unsigned long a4;
32+
unsigned long a5;
33+
unsigned long a6;
34+
unsigned long a7;
35+
);
3436
unsigned long s2;
3537
unsigned long s3;
3638
unsigned long s4;

0 commit comments

Comments
 (0)