linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: guoren@kernel.org
To: guoren@kernel.org, arnd@arndb.de
Cc: linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org,
	linux-arch@vger.kernel.org, Guo Ren <guoren@linux.alibaba.com>
Subject: [PATCH] asm-generic: uaccess.h: Fixup GENERIC_STRNCPY_FROM_USER & STRNLEN_USER
Date: Wed, 21 Apr 2021 09:04:53 +0000	[thread overview]
Message-ID: <1618995893-92100-1-git-send-email-guoren@kernel.org> (raw)

From: Guo Ren <guoren@linux.alibaba.com>

When arch include asm-generic/uaccess.h and enable GENERIC
STRNCPY_FROM_USER / STRNLEN_USER. Then, compile error.

Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Cc: Arnd Bergmann <arnd@arndb.de>
---
 include/asm-generic/uaccess.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index 4973328..c02080d 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -243,6 +243,9 @@ static inline int __get_user_fn(size_t size, const void __user *ptr, void *x)
 
 extern int __get_user_bad(void) __attribute__((noreturn));
 
+#ifdef CONFIG_GENERIC_STRNCPY_FROM_USER
+long strncpy_from_user(char *dst, const char __user *src, long count);
+#else
 /*
  * Copy a null terminated string from userspace.
  */
@@ -265,7 +268,11 @@ strncpy_from_user(char *dst, const char __user *src, long count)
 		return -EFAULT;
 	return __strncpy_from_user(dst, src, count);
 }
+#endif /* CONFIG_GENERIC_STRNCPY_FROM_USER */
 
+#ifdef CONFIG_GENERIC_STRNLEN_USER
+long strnlen_user(const char __user *src, long n);
+#else
 /*
  * Return the size of a string (including the ending 0)
  *
@@ -286,6 +293,7 @@ static inline long strnlen_user(const char __user *src, long n)
 		return 0;
 	return __strnlen_user(src, n);
 }
+#endif /* CONFIG_GENERIC_STRNLEN_USER */
 
 /*
  * Zero Userspace
-- 
2.7.4


                 reply	other threads:[~2021-04-21  9:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1618995893-92100-1-git-send-email-guoren@kernel.org \
    --to=guoren@kernel.org \
    --cc=arnd@arndb.de \
    --cc=guoren@linux.alibaba.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-csky@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).