Skip to content

Commit

Permalink
LoongArch: Fix MAX_REG_OFFSET calculation
Browse files Browse the repository at this point in the history
commit 90436d2 upstream.

Fix MAX_REG_OFFSET calculation, make it point to the last register
in 'struct pt_regs' and not to the marker itself, which could allow
regs_get_register() to return an invalid offset.

Cc: stable@vger.kernel.org
Fixes: 803b0fc ("LoongArch: Add process management")
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Huacai Chen authored and Greg Kroah-Hartman committed May 22, 2025
1 parent 02a11d8 commit 0567e79
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/loongarch/include/asm/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static inline void instruction_pointer_set(struct pt_regs *regs, unsigned long v

/* Query offset/name of register from its name/offset */
extern int regs_query_register_offset(const char *name);
#define MAX_REG_OFFSET (offsetof(struct pt_regs, __last))
#define MAX_REG_OFFSET (offsetof(struct pt_regs, __last) - sizeof(unsigned long))

/**
* regs_get_register() - get register value from its offset
Expand Down

0 comments on commit 0567e79

Please sign in to comment.