Subject: Re: mmotm 2020-06-25-20-36 uploaded (objtool warning)

From: Peter Zijlstra <[email-masked]>
Date: Tue, 30 Jun 2020 11:59:20 +0200

On Fri, Jun 26, 2020 at 04:35:08PM -0700, Randy Dunlap wrote:
> arch/x86/kernel/sys_ia32.o: warning: objtool: cp_stat64()+0x57: call to new_encode_dev() with UACCESS enabled

That's c120f3b81ede ("x86: switch cp_stat64() to unsafe_put_user()").

Where __put_user() made sure evaluate 'x' before doing
__uaccess_begin(), the new code has no such choice.

The simplest fix is probably something like this.

---
 include/linux/kdev_t.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/kdev_t.h b/include/linux/kdev_t.h
index 85b5151911cf..a840ffef7c19 100644
--- a/include/linux/kdev_t.h
+++ b/include/linux/kdev_t.h
@@ -36,7 +36,7 @@ static inline dev_t old_decode_dev(u16 val)
 	return MKDEV((val >> 8) & 255, val & 255);
 }
 
-static inline u32 new_encode_dev(dev_t dev)
+static __always_inline u32 new_encode_dev(dev_t dev)
 {
 	unsigned major = MAJOR(dev);
 	unsigned minor = MINOR(dev);
@@ -50,7 +50,7 @@ static inline dev_t new_decode_dev(u32 dev)
 	return MKDEV(major, minor);
 }
 
-static inline u64 huge_encode_dev(dev_t dev)
+static __always_inline u64 huge_encode_dev(dev_t dev)
 {
 	return new_encode_dev(dev);
 }