Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wuninitialized in arch/mips/include/asm/syscall.h #604

Closed
nathanchance opened this issue Jul 17, 2019 · 3 comments
Closed

-Wuninitialized in arch/mips/include/asm/syscall.h #604

nathanchance opened this issue Jul 17, 2019 · 3 comments
Assignees
Labels
-Wuninitialized [ARCH] mips This bug impacts ARCH=mips [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.4 This bug was fixed in Linux 5.4

Comments

@nathanchance
Copy link
Member

In file included from arch/mips/kernel/ptrace.c:45:
arch/mips/include/asm/syscall.h:130:3: warning: variable 'ret' is uninitialized when used here [-Wuninitialized]
                ret |= mips_get_syscall_arg(args++, task, regs, i++);
                ^~~
arch/mips/include/asm/syscall.h:123:9: note: initialize the variable 'ret' to silence this warning
        int ret;
               ^
                = 0
1 warning generated.

Tentative patch (going to send as a series):

From dbe84f9fe5a2e82ba23b143e1a2cf5be895c8fe2 Mon Sep 17 00:00:00 2001
From: Nathan Chancellor <natechancellor@gmail.com>
Date: Wed, 17 Jul 2019 11:42:56 -0700
Subject: [PATCH] MIPS/ptrace: Update mips_get_syscall_arg's return type

clang warns:

In file included from arch/mips/kernel/ptrace.c:45:
arch/mips/include/asm/syscall.h:130:3: warning: variable 'ret' is
uninitialized when used here [-Wuninitialized]
                ret |= mips_get_syscall_arg(args++, task, regs, i++);
                ^~~
arch/mips/include/asm/syscall.h:123:9: note: initialize the variable
'ret' to silence this warning
        int ret;
               ^
                = 0
1 warning generated.

It's not wrong; however, it's not an issue in practice because ret is
only assigned to, not read from. ret could just be initialized to zero
but looking into it further, ret has been unused since it was first
added in 2012 so just get rid of it and update mips_get_syscall_arg's
return type since none of the return values are ever checked. If it is
ever needed again, this commit can be reverted and ret can be properly
initialized.

Fixes: c0ff3c53d4f9 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")
Link: https://github.com/ClangBuiltLinux/linux/issues/604
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 arch/mips/include/asm/syscall.h | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h
index 83bb439597d8..06f01390b7f2 100644
--- a/arch/mips/include/asm/syscall.h
+++ b/arch/mips/include/asm/syscall.h
@@ -54,7 +54,7 @@ static inline void mips_syscall_update_nr(struct task_struct *task,
 		task_thread_info(task)->syscall = regs->regs[2];
 }
 
-static inline unsigned long mips_get_syscall_arg(unsigned long *arg,
+static inline void mips_get_syscall_arg(unsigned long *arg,
 	struct task_struct *task, struct pt_regs *regs, unsigned int n)
 {
 	unsigned long usp __maybe_unused = regs->regs[29];
@@ -63,23 +63,25 @@ static inline unsigned long mips_get_syscall_arg(unsigned long *arg,
 	case 0: case 1: case 2: case 3:
 		*arg = regs->regs[4 + n];
 
-		return 0;
+		return;
 
 #ifdef CONFIG_32BIT
 	case 4: case 5: case 6: case 7:
-		return get_user(*arg, (int *)usp + n);
+		get_user(*arg, (int *)usp + n);
+		return;
 #endif
 
 #ifdef CONFIG_64BIT
 	case 4: case 5: case 6: case 7:
 #ifdef CONFIG_MIPS32_O32
 		if (test_tsk_thread_flag(task, TIF_32BIT_REGS))
-			return get_user(*arg, (int *)usp + n);
+			get_user(*arg, (int *)usp + n);
+			return
 		else
 #endif
 			*arg = regs->regs[4 + n];
 
-		return 0;
+		return;
 #endif
 
 	default:
@@ -126,21 +128,13 @@ static inline void syscall_get_arguments(struct task_struct *task,
 {
 	unsigned int i = 0;
 	unsigned int n = 6;
-	int ret;
 
 	/* O32 ABI syscall() */
 	if (mips_syscall_is_indirect(task, regs))
 		i++;
 
 	while (n--)
-		ret |= mips_get_syscall_arg(args++, task, regs, i++);
-
-	/*
-	 * No way to communicate an error because this is a void function.
-	 */
-#if 0
-	return ret;
-#endif
+		mips_get_syscall_arg(args++, task, regs, i++);
 }
 
 extern const unsigned long sys_call_table[];
-- 
2.22.0
@nathanchance nathanchance added [BUG] linux A bug that should be fixed in the mainline kernel. [PATCH] Exists There is a patch that fixes this issue -Wuninitialized [ARCH] mips This bug impacts ARCH=mips labels Jul 17, 2019
@nathanchance nathanchance self-assigned this Jul 17, 2019
nathanchance added a commit that referenced this issue Jul 18, 2019
clang warns:

In file included from arch/mips/kernel/ptrace.c:45:
arch/mips/include/asm/syscall.h:130:3: warning: variable 'ret' is
uninitialized when used here [-Wuninitialized]
                ret |= mips_get_syscall_arg(args++, task, regs, i++);
                ^~~
arch/mips/include/asm/syscall.h:123:9: note: initialize the variable
'ret' to silence this warning
        int ret;
               ^
                = 0
1 warning generated.

It's not wrong; however, it's not an issue in practice because ret is
only assigned to, not read from. ret could just be initialized to zero
but looking into it further, ret has been unused since it was first
added in 2012 so just get rid of it and update mips_get_syscall_arg's
return type since none of the return values are ever checked. If it is
ever needed again, this commit can be reverted and ret can be properly
initialized.

Fixes: c0ff3c5 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")
Link: #604
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
nathanchance added a commit that referenced this issue Jul 19, 2019
clang warns:

In file included from arch/mips/kernel/ptrace.c:45:
arch/mips/include/asm/syscall.h:130:3: warning: variable 'ret' is
uninitialized when used here [-Wuninitialized]
                ret |= mips_get_syscall_arg(args++, task, regs, i++);
                ^~~
arch/mips/include/asm/syscall.h:123:9: note: initialize the variable
'ret' to silence this warning
        int ret;
               ^
                = 0
1 warning generated.

It's not wrong; however, it's not an issue in practice because ret is
only assigned to, not read from. ret could just be initialized to zero
but looking into it further, ret has been unused since it was first
added in 2012 so just get rid of it and update mips_get_syscall_arg's
return type since none of the return values are ever checked. If it is
ever needed again, this commit can be reverted and ret can be properly
initialized.

Fixes: c0ff3c5 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")
Link: #604
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
nathanchance added a commit that referenced this issue Jul 25, 2019
clang warns:

In file included from arch/mips/kernel/ptrace.c:45:
arch/mips/include/asm/syscall.h:130:3: warning: variable 'ret' is
uninitialized when used here [-Wuninitialized]
                ret |= mips_get_syscall_arg(args++, task, regs, i++);
                ^~~
arch/mips/include/asm/syscall.h:123:9: note: initialize the variable
'ret' to silence this warning
        int ret;
               ^
                = 0
1 warning generated.

It's not wrong; however, it's not an issue in practice because ret is
only assigned to, not read from. ret could just be initialized to zero
but looking into it further, ret has been unused since it was first
added in 2012 so just get rid of it and update mips_get_syscall_arg's
return type since none of the return values are ever checked. If it is
ever needed again, this commit can be reverted and ret can be properly
initialized.

Fixes: c0ff3c5 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")
Link: #604
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
nathanchance added a commit that referenced this issue Jul 27, 2019
clang warns:

In file included from arch/mips/kernel/ptrace.c:45:
arch/mips/include/asm/syscall.h:130:3: warning: variable 'ret' is
uninitialized when used here [-Wuninitialized]
                ret |= mips_get_syscall_arg(args++, task, regs, i++);
                ^~~
arch/mips/include/asm/syscall.h:123:9: note: initialize the variable
'ret' to silence this warning
        int ret;
               ^
                = 0
1 warning generated.

It's not wrong; however, it's not an issue in practice because ret is
only assigned to, not read from. ret could just be initialized to zero
but looking into it further, ret has been unused since it was first
added in 2012 so just get rid of it and update mips_get_syscall_arg's
return type since none of the return values are ever checked. If it is
ever needed again, this commit can be reverted and ret can be properly
initialized.

Fixes: c0ff3c5 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")
Link: #604
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
nathanchance added a commit that referenced this issue Aug 3, 2019
clang warns:

In file included from arch/mips/kernel/ptrace.c:45:
arch/mips/include/asm/syscall.h:130:3: warning: variable 'ret' is
uninitialized when used here [-Wuninitialized]
                ret |= mips_get_syscall_arg(args++, task, regs, i++);
                ^~~
arch/mips/include/asm/syscall.h:123:9: note: initialize the variable
'ret' to silence this warning
        int ret;
               ^
                = 0
1 warning generated.

It's not wrong; however, it's not an issue in practice because ret is
only assigned to, not read from. ret could just be initialized to zero
but looking into it further, ret has been unused since it was first
added in 2012 so just get rid of it and update mips_get_syscall_arg's
return type since none of the return values are ever checked. If it is
ever needed again, this commit can be reverted and ret can be properly
initialized.

Fixes: c0ff3c5 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")
Link: #604
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
@nathanchance
Copy link
Member Author

@nathanchance nathanchance added [PATCH] Submitted A patch has been submitted for review and removed [PATCH] Exists There is a patch that fixes this issue labels Aug 12, 2019
nathanchance added a commit that referenced this issue Aug 12, 2019
clang warns:

arch/mips/include/asm/syscall.h:136:3: error: variable 'ret' is
uninitialized when used here [-Werror,-Wuninitialized]
                ret |= mips_get_syscall_arg(args++, task, regs, i++);
                ^~~
arch/mips/include/asm/syscall.h:129:9: note: initialize the variable
'ret' to silence this warning
        int ret;
               ^
                = 0
1 error generated.

It's not wrong; however, it's not an issue in practice because ret is
only assigned to, not read from. ret could just be initialized to zero
but looking into it further, ret has been unused since it was first
added in 2012 so just get rid of it and update mips_get_syscall_arg's
return type since none of the return values are ever checked. If it is
ever needed again, this commit can be reverted and ret can be properly
initialized.

Fixes: c0ff3c5 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")
Link: #604
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
@nathanchance
Copy link
Member Author

@nathanchance nathanchance added [PATCH] Accepted A submitted patch has been accepted upstream and removed [PATCH] Submitted A patch has been submitted for review labels Aug 12, 2019
nathanchance added a commit that referenced this issue Aug 12, 2019
clang warns:

arch/mips/include/asm/syscall.h:136:3: error: variable 'ret' is
uninitialized when used here [-Werror,-Wuninitialized]
                ret |= mips_get_syscall_arg(args++, task, regs, i++);
                ^~~
arch/mips/include/asm/syscall.h:129:9: note: initialize the variable
'ret' to silence this warning
        int ret;
               ^
                = 0
1 error generated.

It's not wrong; however, it's not an issue in practice because ret is
only assigned to, not read from. ret could just be initialized to zero
but looking into it further, ret has been unused since it was first
added in 2012 so just get rid of it and update mips_get_syscall_arg's
return type since none of the return values are ever checked. If it is
ever needed again, this commit can be reverted and ret can be properly
initialized.

Fixes: c0ff3c5 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")
Link: #604
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: James Hogan <jhogan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: linux-mips@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: clang-built-linux@googlegroups.com
@nathanchance
Copy link
Member Author

Merged into mainline: https://git.kernel.org/linus/077ff3be06e8de2657075dd2738b9a21f8ebd890

@nathanchance nathanchance added [FIXED][LINUX] 5.4 This bug was fixed in Linux 5.4 and removed [PATCH] Accepted A submitted patch has been accepted upstream labels Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Wuninitialized [ARCH] mips This bug impacts ARCH=mips [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.4 This bug was fixed in Linux 5.4
Projects
None yet
Development

No branches or pull requests

1 participant