From: Andrey Konovalov <andreyknvl@google.com>
To: kbuild test robot <lkp@intel.com>, Christoph Hellwig <hch@infradead.org>
Cc: kbuild-all@01.org, Roman Gushchin <guro@fb.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Khalid Aziz <khalid.aziz@oracle.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [rgushchin:fix_vmstats 199/221] lib/strncpy_from_user.c:112:42: warning: passing argument 1 of 'untagged_addr' makes integer from pointer without a cast
Date: Tue, 13 Aug 2019 18:01:07 +0200 [thread overview]
Message-ID: <CAAeHK+yx4a-P0sDrXTUxMvO2H0CJZUFPffBrg_cU7oJOZyC7ew@mail.gmail.com> (raw)
In-Reply-To: <201908132234.dxi9IQrs%lkp@intel.com>
On Tue, Aug 13, 2019 at 4:01 PM kbuild test robot <lkp@intel.com> wrote:
>
> tree: https://github.com/rgushchin/linux.git fix_vmstats
> head: 4ec858b5201ae067607e82706b36588631c1b990
> commit: f198eb8345ed9cef77b65d1c0edffba3fa3f6d2a [199/221] lib: untag user pointers in strn*_user
> config: sparc64-allmodconfig (attached as .config)
> compiler: sparc64-linux-gcc (GCC) 7.4.0
> reproduce:
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> git checkout f198eb8345ed9cef77b65d1c0edffba3fa3f6d2a
> # save the attached .config to linux build tree
> GCC_VERSION=7.4.0 make.cross ARCH=sparc64
>
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> lib/strncpy_from_user.c: In function 'strncpy_from_user':
> >> lib/strncpy_from_user.c:112:42: warning: passing argument 1 of 'untagged_addr' makes integer from pointer without a cast [-Wint-conversion]
> src_addr = (unsigned long)untagged_addr(src);
> ^~~
> In file included from arch/sparc/include/asm/pgtable.h:5:0,
> from include/linux/mm.h:99,
> from lib/strncpy_from_user.c:9:
> arch/sparc/include/asm/pgtable_64.h:1081:29: note: expected 'long unsigned int' but argument is of type 'const char *'
> static inline unsigned long untagged_addr(unsigned long start)
> ^~~~~~~~~~~~~
> --
> lib/strnlen_user.c: In function 'strnlen_user':
> >> lib/strnlen_user.c:113:42: warning: passing argument 1 of 'untagged_addr' makes integer from pointer without a cast [-Wint-conversion]
> src_addr = (unsigned long)untagged_addr(str);
> ^~~
> In file included from arch/sparc/include/asm/pgtable.h:5:0,
> from include/linux/mm.h:99,
> from lib/strnlen_user.c:5:
> arch/sparc/include/asm/pgtable_64.h:1081:29: note: expected 'long unsigned int' but argument is of type 'const char *'
> static inline unsigned long untagged_addr(unsigned long start)
> ^~~~~~~~~~~~~
This is caused by the difference in untagged_addr() definitions for
sparc and arm64. untagged_addr() for arm64 uses __typeof__ to avoid
casting in places where it is used. Perhaps we should do something
similar for sparc:
diff --git a/arch/sparc/include/asm/pgtable_64.h
b/arch/sparc/include/asm/pgtable_64.h
index 1599de730532..2c4cd82066cb 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -1078,7 +1078,7 @@ static inline int io_remap_pfn_range(struct
vm_area_struct *vma,
}
#define io_remap_pfn_range io_remap_pfn_range
-static inline unsigned long untagged_addr(unsigned long start)
+static inline unsigned long __untagged_addr(unsigned long start)
{
if (adi_capable()) {
long addr = start;
@@ -1098,7 +1098,8 @@ static inline unsigned long
untagged_addr(unsigned long start)
return start;
}
-#define untagged_addr untagged_addr
+#define untagged_addr(addr) \
+ ((__typeof__(addr))(__untagged_addr((unsigned long)(addr)))
static inline bool pte_access_permitted(pte_t pte, bool write)
{
Christoph, WDYT?
>
> vim +/untagged_addr +112 lib/strncpy_from_user.c
>
> 85
> 86 /**
> 87 * strncpy_from_user: - Copy a NUL terminated string from userspace.
> 88 * @dst: Destination address, in kernel space. This buffer must be at
> 89 * least @count bytes long.
> 90 * @src: Source address, in user space.
> 91 * @count: Maximum number of bytes to copy, including the trailing NUL.
> 92 *
> 93 * Copies a NUL-terminated string from userspace to kernel space.
> 94 *
> 95 * On success, returns the length of the string (not including the trailing
> 96 * NUL).
> 97 *
> 98 * If access to userspace fails, returns -EFAULT (some data may have been
> 99 * copied).
> 100 *
> 101 * If @count is smaller than the length of the string, copies @count bytes
> 102 * and returns @count.
> 103 */
> 104 long strncpy_from_user(char *dst, const char __user *src, long count)
> 105 {
> 106 unsigned long max_addr, src_addr;
> 107
> 108 if (unlikely(count <= 0))
> 109 return 0;
> 110
> 111 max_addr = user_addr_max();
> > 112 src_addr = (unsigned long)untagged_addr(src);
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
prev parent reply other threads:[~2019-08-13 16:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-13 14:00 [rgushchin:fix_vmstats 199/221] lib/strncpy_from_user.c:112:42: warning: passing argument 1 of 'untagged_addr' makes integer from pointer without a cast kbuild test robot
2019-08-13 16:01 ` Andrey Konovalov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAeHK+yx4a-P0sDrXTUxMvO2H0CJZUFPffBrg_cU7oJOZyC7ew@mail.gmail.com \
--to=andreyknvl@google.com \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=hch@infradead.org \
--cc=kbuild-all@01.org \
--cc=khalid.aziz@oracle.com \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=vincenzo.frascino@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).