* [PATCH] usercopy: Add parentheses around assignment in test_copy_struct_from_user
@ 2019-10-03 17:11 Nathan Chancellor
[not found] ` <CAHrFyr4GFJHQLHOi_OuDVkhuKxfnf_VkTWk6MJ2Mn1EtWhpqjg@mail.gmail.com>
2019-10-03 19:13 ` Christian Brauner
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2019-10-03 17:11 UTC (permalink / raw)
To: Christian Brauner, Aleksa Sarai
Cc: Kees Cook, linux-kernel, clang-built-linux, Nathan Chancellor
Clang warns:
lib/test_user_copy.c:96:10: warning: using the result of an assignment
as a condition without parentheses [-Wparentheses]
if (ret |= test(umem_src == NULL, "kmalloc failed"))
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/test_user_copy.c:96:10: note: place parentheses around the
assignment to silence this warning
if (ret |= test(umem_src == NULL, "kmalloc failed"))
^
( )
lib/test_user_copy.c:96:10: note: use '!=' to turn this compound
assignment into an inequality comparison
if (ret |= test(umem_src == NULL, "kmalloc failed"))
^~
!=
Add the parentheses as it suggests because this is intentional.
Fixes: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper")
Link: https://github.com/ClangBuiltLinux/linux/issues/731
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
lib/test_user_copy.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/test_user_copy.c b/lib/test_user_copy.c
index 950ee88cd6ac..e365ace06538 100644
--- a/lib/test_user_copy.c
+++ b/lib/test_user_copy.c
@@ -93,11 +93,11 @@ static int test_copy_struct_from_user(char *kmem, char __user *umem,
size_t ksize, usize;
umem_src = kmalloc(size, GFP_KERNEL);
- if (ret |= test(umem_src == NULL, "kmalloc failed"))
+ if ((ret |= test(umem_src == NULL, "kmalloc failed")))
goto out_free;
expected = kmalloc(size, GFP_KERNEL);
- if (ret |= test(expected == NULL, "kmalloc failed"))
+ if ((ret |= test(expected == NULL, "kmalloc failed")))
goto out_free;
/* Fill umem with a fixed byte pattern. */
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usercopy: Add parentheses around assignment in test_copy_struct_from_user
[not found] ` <CAHrFyr4GFJHQLHOi_OuDVkhuKxfnf_VkTWk6MJ2Mn1EtWhpqjg@mail.gmail.com>
@ 2019-10-03 17:33 ` Aleksa Sarai
0 siblings, 0 replies; 3+ messages in thread
From: Aleksa Sarai @ 2019-10-03 17:33 UTC (permalink / raw)
To: Christian Brauner
Cc: Nathan Chancellor, Kees Cook, linux-kernel, clang-built-linux
[-- Attachment #1: Type: text/plain, Size: 1500 bytes --]
On 2019-10-03, Christian Brauner <christian@brauner.io> wrote:
> On Thu, Oct 3, 2019, 19:11 Nathan Chancellor <natechancellor@gmail.com>
> wrote:
>
> > Clang warns:
> >
> > lib/test_user_copy.c:96:10: warning: using the result of an assignment
> > as a condition without parentheses [-Wparentheses]
> > if (ret |= test(umem_src == NULL, "kmalloc failed"))
> > ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > lib/test_user_copy.c:96:10: note: place parentheses around the
> > assignment to silence this warning
> > if (ret |= test(umem_src == NULL, "kmalloc failed"))
> > ^
> > ( )
> > lib/test_user_copy.c:96:10: note: use '!=' to turn this compound
> > assignment into an inequality comparison
> > if (ret |= test(umem_src == NULL, "kmalloc failed"))
> > ^~
> > !=
> >
> > Add the parentheses as it suggests because this is intentional.
> >
> > Fixes: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/731
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> >
>
> I'll take this. Aleksa, can I get your ack too, please?
>
> Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Acked-by: Aleksa Sarai <cyphar@cyphar.com>
--
Aleksa Sarai
Senior Software Engineer (Containers)
SUSE Linux GmbH
<https://www.cyphar.com/>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usercopy: Add parentheses around assignment in test_copy_struct_from_user
2019-10-03 17:11 [PATCH] usercopy: Add parentheses around assignment in test_copy_struct_from_user Nathan Chancellor
[not found] ` <CAHrFyr4GFJHQLHOi_OuDVkhuKxfnf_VkTWk6MJ2Mn1EtWhpqjg@mail.gmail.com>
@ 2019-10-03 19:13 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2019-10-03 19:13 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Aleksa Sarai, Kees Cook, linux-kernel, clang-built-linux
On Thu, Oct 03, 2019 at 10:11:21AM -0700, Nathan Chancellor wrote:
> Clang warns:
>
> lib/test_user_copy.c:96:10: warning: using the result of an assignment
> as a condition without parentheses [-Wparentheses]
> if (ret |= test(umem_src == NULL, "kmalloc failed"))
> ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> lib/test_user_copy.c:96:10: note: place parentheses around the
> assignment to silence this warning
> if (ret |= test(umem_src == NULL, "kmalloc failed"))
> ^
> ( )
> lib/test_user_copy.c:96:10: note: use '!=' to turn this compound
> assignment into an inequality comparison
> if (ret |= test(umem_src == NULL, "kmalloc failed"))
> ^~
> !=
>
> Add the parentheses as it suggests because this is intentional.
>
> Fixes: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper")
> Link: https://github.com/ClangBuiltLinux/linux/issues/731
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Applied to:
https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/log/?h=copy_struct_from_user
Thanks!
Christian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-03 19:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-03 17:11 [PATCH] usercopy: Add parentheses around assignment in test_copy_struct_from_user Nathan Chancellor
[not found] ` <CAHrFyr4GFJHQLHOi_OuDVkhuKxfnf_VkTWk6MJ2Mn1EtWhpqjg@mail.gmail.com>
2019-10-03 17:33 ` Aleksa Sarai
2019-10-03 19:13 ` Christian Brauner
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).