arm64: ptrace: user_regset_copyin_ignore() always returns 0
Subsystems (2)
PATCH 1/1 arm64: ptrace: user_regset_copyin_ignore() always returns 0
user_regset_copyin_ignore() always return 0, so checking its result seems pointless -- don't do this...
Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.
---
This patch is against the 'for-next/core' branch of the ARM64 repo...
arch/arm64/kernel/ptrace.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
arch/arm64/kernel/ptrace.c +4 -12
@@ -514,9 +514,7 @@ static int hw_break_set(struct task_stru/* Resource info and pad */ offset = offsetof(struct user_hwdebug_state , dbg_regs); - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf,0 , offset); -if (ret) -return ret; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf,0 , offset);/* (address, ctrl) registers */ limit = regset->n * regset->size;
@@ -543,11 +541,8 @@ static int hw_break_set(struct task_strureturn ret; offset +=PTRACE_HBP_CTRL_SZ ; - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, - offset, - offset +PTRACE_HBP_PAD_SZ ); -if (ret) -return ret; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, + offset, offset +PTRACE_HBP_PAD_SZ ); offset +=PTRACE_HBP_PAD_SZ ; idx++; }
@@ -939,10 +934,7 @@ static int sve_set_common(struct task_st start = end; end =SVE_PT_SVE_FPSR_OFFSET (vq); - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, - start, end); -if (ret) - goto out; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, start, end);/* * Copy fpsr, and fpcr which must follow contiguously in
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 1 line · Sergey Shtylyov
user_regset_copyin_ignore()always return 0, so checking its result seems
Oops, should've been "returns"...
Quoted 6 lines
pointless -- don't do this...
Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.
Signed-off-by Sergey Shtylyov <[email protected]>
[...]
MBR, Sergey
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Will Deacon
maintainerQuoted 44 lines · Sergey Shtylyov
user_regset_copyin_ignore()always return 0, so checking its result seems pointless -- don't do this...Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.
Signed-off-by Sergey Shtylyov <[email protected]>---
This patch is against the 'for-next/core' branch of the ARM64 repo...arch/arm64/kernel/ptrace.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)Index:
linux/arch/arm64/kernel/ptrace.c
===================================================================arch/arm64/kernel/ptrace.c +3
-8@@ -514,9 +514,7 @@ static int hw_break_set(struct task_stru/* Resource info and pad */ offset = offsetof(struct user_hwdebug_state , dbg_regs); - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf,0 , offset); -if (ret) -return ret; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf,0 , offset);/* (address, ctrl) registers */ limit = regset->n * regset->size;@@ -543,11 +541,8 @@ static int hw_break_set(struct task_strureturn ret; offset +=PTRACE_HBP_CTRL_SZ ; - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, - offset, - offset +PTRACE_HBP_PAD_SZ ); -if (ret) -return ret; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, + offset, offset +PTRACE_HBP_PAD_SZ ); offset +=PTRACE_HBP_PAD_SZ ; idx++; }
arch/arm64/kernel/ptrace.c static int sve_set_common(struct task_st · line 937
Quoted 8 lines
arch/arm64/kernel/ptrace.c +1
-4@@ -939,10 +934,7 @@ static int sve_set_common(struct task_st start = end; end =SVE_PT_SVE_FPSR_OFFSET (vq); - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, - start, end); -if (ret) - goto out; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, start, end);
I think it would be better to have user_regset_copyin_ignore() return void so that we don't run the risk of missing an error code if it starts returning one in future.
Will
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On 9/22/22 2:59 PM, Will Deacon wrote:
[...]
Quoted 45 lines
Quoted 45 lines
user_regset_copyin_ignore()always return 0, so checking its result seems pointless -- don't do this...Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.
Signed-off-by Sergey Shtylyov <[email protected]>---
This patch is against the 'for-next/core' branch of the ARM64 repo...arch/arm64/kernel/ptrace.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)Index:
linux/arch/arm64/kernel/ptrace.c
===================================================================arch/arm64/kernel/ptrace.c +3
-8@@ -514,9 +514,7 @@ static int hw_break_set(struct task_stru/* Resource info and pad */ offset = offsetof(struct user_hwdebug_state , dbg_regs); - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf,0 , offset); -if (ret) -return ret; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf,0 , offset);/* (address, ctrl) registers */ limit = regset->n * regset->size;@@ -543,11 +541,8 @@ static int hw_break_set(struct task_strureturn ret; offset +=PTRACE_HBP_CTRL_SZ ; - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, - offset, - offset +PTRACE_HBP_PAD_SZ ); -if (ret) -return ret; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, + offset, offset +PTRACE_HBP_PAD_SZ ); offset +=PTRACE_HBP_PAD_SZ ; idx++; }@@ -939,10 +934,7 @@ static int sve_set_common(struct task_st
Quoted 11 lines
arch/arm64/kernel/ptrace.c static int sve_set_common(struct task_st · line 937
Quoted 7 lines
arch/arm64/kernel/ptrace.c +1
-4start = end; end =SVE_PT_SVE_FPSR_OFFSET (vq); - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, - start, end); -if (ret) - goto out; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, start, end);I think it would be better to have
user_regset_copyin_ignore()return void so that we don't run the risk of missing an error code if it starts returning one in future.
That's the plan! But I need to convert the users 1st, right?
Quoted 1 line
Will
MBR, Sergey
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Catalin Marinas
maintainerQuoted 59 lines · Sergey Shtylyov
On 9/22/22 2:59 PM, Will Deacon wrote:
[...]Quoted 45 lines
Quoted 45 lines
user_regset_copyin_ignore()always return 0, so checking its result seems pointless -- don't do this...Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.
Signed-off-by Sergey Shtylyov <[email protected]>---
This patch is against the 'for-next/core' branch of the ARM64 repo...arch/arm64/kernel/ptrace.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)Index:
linux/arch/arm64/kernel/ptrace.c
===================================================================arch/arm64/kernel/ptrace.c +3
-8@@ -514,9 +514,7 @@ static int hw_break_set(struct task_stru/* Resource info and pad */ offset = offsetof(struct user_hwdebug_state , dbg_regs); - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf,0 , offset); -if (ret) -return ret; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf,0 , offset);/* (address, ctrl) registers */ limit = regset->n * regset->size;@@ -543,11 +541,8 @@ static int hw_break_set(struct task_strureturn ret; offset +=PTRACE_HBP_CTRL_SZ ; - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, - offset, - offset +PTRACE_HBP_PAD_SZ ); -if (ret) -return ret; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, + offset, offset +PTRACE_HBP_PAD_SZ ); offset +=PTRACE_HBP_PAD_SZ ; idx++; }@@ -939,10 +934,7 @@ static int sve_set_common(struct task_stQuoted 11 lines
arch/arm64/kernel/ptrace.c static int sve_set_common(struct task_st · line 937
Quoted 7 lines
arch/arm64/kernel/ptrace.c +1
-4start = end; end =SVE_PT_SVE_FPSR_OFFSET (vq); - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, - start, end); -if (ret) - goto out; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, start, end);I think it would be better to have
user_regset_copyin_ignore()return void so that we don't run the risk of missing an error code if it starts returning one in future.
Quoted 1 line
That's the plan! But I need to convert the users 1st, right?
Right, though normally we'd like to see the full series that does the arch clean-up followed by the user_regset_copyin_ignore() return changed to void. If for some reason the last patch is rejected by the maintainer because there are plans to actually return some non-zero value, we'd have to revert the above.
Signature · 6 lines
Catalin _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hello!
On 9/26/22 5:01 PM, Catalin Marinas wrote:
[...]
Quoted 57 lines
Quoted 57 lines
Quoted 56 lines
Quoted 44 lines
user_regset_copyin_ignore()always return 0, so checking its result seems pointless -- don't do this...Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.
Signed-off-by Sergey Shtylyov <[email protected]>---
This patch is against the 'for-next/core' branch of the ARM64 repo...arch/arm64/kernel/ptrace.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)Index:
linux/arch/arm64/kernel/ptrace.c
===================================================================arch/arm64/kernel/ptrace.c +3
-8@@ -514,9 +514,7 @@ static int hw_break_set(struct task_stru/* Resource info and pad */ offset = offsetof(struct user_hwdebug_state , dbg_regs); - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf,0 , offset); -if (ret) -return ret; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf,0 , offset);/* (address, ctrl) registers */ limit = regset->n * regset->size;@@ -543,11 +541,8 @@ static int hw_break_set(struct task_strureturn ret; offset +=PTRACE_HBP_CTRL_SZ ; - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, - offset, - offset +PTRACE_HBP_PAD_SZ ); -if (ret) -return ret; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, + offset, offset +PTRACE_HBP_PAD_SZ ); offset +=PTRACE_HBP_PAD_SZ ; idx++; }arch/arm64/kernel/ptrace.c static int sve_set_common(struct task_st · line 937
Quoted 8 lines
arch/arm64/kernel/ptrace.c +1
-4@@ -939,10 +934,7 @@ static int sve_set_common(struct task_st start = end; end =SVE_PT_SVE_FPSR_OFFSET (vq); - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, - start, end); -if (ret) - goto out; +user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, start, end);I think it would be better to have
user_regset_copyin_ignore()return void so that we don't run the risk of missing an error code if it starts returning one in future.
Quoted 7 lines
Quoted 1 line
That's the plan! But I need to convert the users 1st, right?
Right, though normally we'd like to see the full series that does the arch clean-up followed by the
user_regset_copyin_ignore()return changed to void. If for some reason the last patch is rejected by the maintainer because there are plans to actually return some non-zero value, we'd have to revert the above.
Hm... I usually try to avoid a cross-tree patch series but here I should
be able to use the linux-next repo as I series' base. Is that OK?
MBR, Sergey
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Catalin Marinas
maintainerQuoted 3 lines · Sergey Shtylyov
Quoted 2 lines · Catalin Marinas
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
user_regset_copyin_ignore()always return 0, so checking its result seems pointless -- don't do this...
[...]
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
I think it would be better to have
user_regset_copyin_ignore()return void so that we don't run the risk of missing an error code if it starts returning one in future.That's the plan! But I need to convert the users 1st, right?
Quoted 8 lines
Quoted 5 lines
Right, though normally we'd like to see the full series that does the arch clean-up followed by the
user_regset_copyin_ignore()return changed to void. If for some reason the last patch is rejected by the maintainer because there are plans to actually return some non-zero value, we'd have to revert the above.Hm... I usually try to avoid a cross-tree patch series but here I should
be able to use the linux-next repo as I series' base. Is that OK?
It depends on how you plan to merge it, though basing the series off linux-next is not ideal. It's fine to merge individual patches in one release though specific trees and the final patch in another but when you posted this single patch we didn't have the context. So ideally I'd like to see an ack on the patch converting user_regset_copyin_ignore() to void. It wasn't obvious there's such patch.
You can also have a cross-tree series and convince one of the maintainer to pick it up (usually cc'ing akpm does the trick ;)).
Signature · 6 lines
Catalin _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel