All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/uaccess: Use 'unsigned long' to placate UBSAN warnings, again
@ 2020-12-23  5:04 Josh Poimboeuf
  2020-12-23  7:18 ` Randy Dunlap
  2021-01-04 15:13 ` Peter Zijlstra
  0 siblings, 2 replies; 15+ messages in thread
From: Josh Poimboeuf @ 2020-12-23  5:04 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-kernel, Peter Zijlstra, Randy Dunlap

GCC 7 has a known bug where UBSAN ignores '-fwrapv' and generates false
signed-overflow-UB warnings.  The type mismatch between 'i' and
'nr_segs' in copy_compat_iovec_from_user() is causing such a warning,
which also happens to violate uaccess rules:

  lib/iov_iter.o: warning: objtool: iovec_from_user()+0x22d: call to __ubsan_handle_add_overflow() with UACCESS enabled

Fix it by making the variable types match.

This is similar to a previous commit:

  29da93fea3ea ("mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions")

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 lib/iov_iter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 1635111c5bd2..2e6a42f5d1df 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1656,7 +1656,8 @@ static int copy_compat_iovec_from_user(struct iovec *iov,
 {
 	const struct compat_iovec __user *uiov =
 		(const struct compat_iovec __user *)uvec;
-	int ret = -EFAULT, i;
+	int ret = -EFAULT;
+	unsigned long i;
 
 	if (!user_access_begin(uvec, nr_segs * sizeof(*uvec)))
 		return -EFAULT;
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-02-10  1:58 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-23  5:04 [PATCH] mm/uaccess: Use 'unsigned long' to placate UBSAN warnings, again Josh Poimboeuf
2020-12-23  7:18 ` Randy Dunlap
2021-01-07 10:06   ` David Laight
2021-01-04 15:13 ` Peter Zijlstra
2021-01-06 23:37   ` Kees Cook
2021-01-07  0:06     ` Randy Dunlap
2021-01-07 21:07       ` Kees Cook
2021-01-13 23:27         ` Josh Poimboeuf
2021-01-07 10:51     ` Dmitry Vyukov
2021-01-14 10:59   ` [PATCH] ubsan: Require GCC-8+ or Clang to use UBSAN Peter Zijlstra
2021-01-14 11:09     ` Andrey Ryabinin
2021-01-18 17:53       ` Josh Poimboeuf
2021-02-09 18:24         ` Josh Poimboeuf
2021-02-09 23:17           ` Andrey Rybainin
2021-02-10  0:21             ` Kees Cook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.