From patchwork Sat May 15 10:17:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12259583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA8ACC433B4 for ; Sat, 15 May 2021 10:19:30 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29EAB613F0 for ; Sat, 15 May 2021 10:19:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29EAB613F0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DEGxVSgyvBiDo3MCKbxW4KB/EkBSSger8AHhbvepGA4=; b=hivZcMNDZri0OIazW/mEmouoX R8mnqqHzdDXSP2jY29dqPAVrIRqfB6q/F21uxyDOQRZKs6h9s7/5KpNEH9Ppw2gypSlOMXzmk/fdh lMyaQt9lu5FO7ahQlKG8unbPM2OCD7GepOmwNwShs0KaF6obo9j2GxUva8b4Me01M84VWEeYTOmZf Z+oK8uAKPMRq8A1iv1OQBfJuKdsuPQPCYssE2NayazMURzMsvqopsO3UTnIUWEV4j3rwkeUPhseNc TBH1WKJbHgMSPuIeEOHKNVcrYMvi/9Mc4+NsDAMbB2MYV5OpkNYKAz3c4Xp87VKDTB9Kgnln52nZO cnLrDZ+Rw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lhrO7-00A8aW-AE; Sat, 15 May 2021 10:19:15 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhrNz-00A8Z7-Sq; Sat, 15 May 2021 10:19:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=tNtVzum3+jmItql2AdkblZN0kg2xjCy6+6H3Mnz/RAM=; b=lk5lvsl9mHMFn9x9aTHh3tCO1X F5AL27UFp/QM2bQ2ac5jiIXBH53e1z1mPsVlbVEIv3y6dEpeWbqcAtL34mKt/OspsgMrib/8c0+oc LV0dNmzqxbx/5LOU6m8apAg41hYarDy2Q0m9jvjk1MffQSdGwBWN5+l8ArLK31I1WNQQQLCITayRa 4xMOI46cPLl/OhSiLsRhMxYs3uVSxgSpwh9WM/JO0Z4EDnHKkovYezMk0CTJff+oKBYClxN1fKBXg 10wtkU7S7b+dJCqM/wWBBxvBerFTz6WSLHp0iUivKjdcAUF0pAlVuMl80Bb39cH+Lkbe7jGrLBwp+ pry2LP3g==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhrNx-00CU4M-16; Sat, 15 May 2021 10:19:06 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id A3FBB613F0; Sat, 15 May 2021 10:19:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621073944; bh=aUw+r/nEodOPwyLxBnACR72ulITbwIstVbqXf4RRoJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=trkutkxcnJRIqjCJl5fzX4m8g+f9dXj47YeJhNDXPgpHCzkseDwPWb4P6QWz2Zf61 VLamr3iGUC60re+vvVRHTAg+uM9Ie2xB+Bm0H8Lg3Esi4aTo8aJM3Wzp9t4MiRhHNw Fc5OThFM3IF4zHUDXaQpgUQ+miGB7Lei29RIcnefK8DWmtBQeXMIo2am1p5XNrZYTU AHyPlsByAa628d6vEuM39gUkY/wzzvOYe+Qz1fDD6OeIjvY/CD+mkfI/1/+yWWuKGc gFZ4NXJdj8hq0OPPyBlMy/QHez47fvv1ZFgWJGj6bnAIWL6PngLfVl/Bq34EGh3ZA4 tzsH4QVKpEqkw== From: Arnd Bergmann To: linux-arch@vger.kernel.org Cc: Arnd Bergmann , Christoph Hellwig , Al Viro , Vineet Gupta , Yoshinori Sato , Brian Cain , Geert Uytterhoeven , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jeff Dike , Richard Weinberger , Anton Ivanov , Sid Manning , Andrew Morton , Mike Rapoport , linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-um@lists.infradead.org Subject: [PATCH 1/6] [v2] asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user Date: Sat, 15 May 2021 12:17:58 +0200 Message-Id: <20210515101803.924427-2-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210515101803.924427-1-arnd@kernel.org> References: <20210515101803.924427-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210515_031905_120736_5179497D X-CRM114-Status: GOOD ( 18.47 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann This is a preparation for changing over architectures to the generic implementation one at a time. As there are no callers of either __strncpy_from_user() or __strnlen_user(), fold these into the strncpy_from_user() strnlen_user() functions to make each implementation independent of the others. Many of these implementations have known bugs, but the intention here is to not change behavior at all and stay compatible with those bugs for the moment. Signed-off-by: Arnd Bergmann --- arch/arc/include/asm/uaccess.h | 14 ++++++++++---- arch/hexagon/include/asm/uaccess.h | 22 +++++++++++++--------- arch/um/include/asm/uaccess.h | 8 ++++---- arch/um/kernel/skas/uaccess.c | 5 ++++- include/asm-generic/uaccess.h | 28 +++++++++++----------------- 5 files changed, 42 insertions(+), 35 deletions(-) diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h index ea40ec7f6cae..3476348f361e 100644 --- a/arch/arc/include/asm/uaccess.h +++ b/arch/arc/include/asm/uaccess.h @@ -661,6 +661,9 @@ __arc_strncpy_from_user(char *dst, const char __user *src, long count) long res = 0; char val; + if (!access_ok(src, 1)) + return -EFAULT; + if (count == 0) return 0; @@ -693,6 +696,9 @@ static inline long __arc_strnlen_user(const char __user *s, long n) long res, tmp1, cnt; char val; + if (!access_ok(s, 1)) + return 0; + __asm__ __volatile__( " mov %2, %1 \n" "1: ldb.ab %3, [%0, 1] \n" @@ -724,8 +730,8 @@ static inline long __arc_strnlen_user(const char __user *s, long n) #define INLINE_COPY_FROM_USER #define __clear_user(d, n) __arc_clear_user(d, n) -#define __strncpy_from_user(d, s, n) __arc_strncpy_from_user(d, s, n) -#define __strnlen_user(s, n) __arc_strnlen_user(s, n) +#define strncpy_from_user(d, s, n) __arc_strncpy_from_user(d, s, n) +#define strnlen_user(s, n) __arc_strnlen_user(s, n) #else extern unsigned long arc_clear_user_noinline(void __user *to, unsigned long n); @@ -734,8 +740,8 @@ extern long arc_strncpy_from_user_noinline (char *dst, const char __user *src, extern long arc_strnlen_user_noinline(const char __user *src, long n); #define __clear_user(d, n) arc_clear_user_noinline(d, n) -#define __strncpy_from_user(d, s, n) arc_strncpy_from_user_noinline(d, s, n) -#define __strnlen_user(s, n) arc_strnlen_user_noinline(s, n) +#define strncpy_from_user(d, s, n) arc_strncpy_from_user_noinline(d, s, n) +#define strnlen_user(s, n) arc_strnlen_user_noinline(s, n) #endif diff --git a/arch/hexagon/include/asm/uaccess.h b/arch/hexagon/include/asm/uaccess.h index c1019a736ff1..59aa3a50744f 100644 --- a/arch/hexagon/include/asm/uaccess.h +++ b/arch/hexagon/include/asm/uaccess.h @@ -57,23 +57,27 @@ unsigned long raw_copy_to_user(void __user *to, const void *from, __kernel_size_t __clear_user_hexagon(void __user *dest, unsigned long count); #define __clear_user(a, s) __clear_user_hexagon((a), (s)) -#define __strncpy_from_user(dst, src, n) hexagon_strncpy_from_user(dst, src, n) +extern long __strnlen_user(const char __user *src, long n); -/* get around the ifndef in asm-generic/uaccess.h */ -#define __strnlen_user __strnlen_user +static inline strnlen_user(const char __user *src, long n) +{ + if (!access_ok(src, 1)) + return 0; -extern long __strnlen_user(const char __user *src, long n); + return __strnlen_user(src, n); +} +/* get around the ifndef in asm-generic/uaccess.h */ +#define strnlen_user strnlen_user -static inline long hexagon_strncpy_from_user(char *dst, const char __user *src, - long n); +static inline long strncpy_from_user(char *dst, const char __user *src, long n); +#define strncpy_from_user strncpy_from_user #include /* Todo: an actual accelerated version of this. */ -static inline long hexagon_strncpy_from_user(char *dst, const char __user *src, - long n) +static inline long strncpy_from_user(char *dst, const char __user *src, long n) { - long res = __strnlen_user(src, n); + long res = strnlen_user(src, n); if (unlikely(!res)) return -EFAULT; diff --git a/arch/um/include/asm/uaccess.h b/arch/um/include/asm/uaccess.h index fe66d659acad..3bf209f683f8 100644 --- a/arch/um/include/asm/uaccess.h +++ b/arch/um/include/asm/uaccess.h @@ -23,16 +23,16 @@ extern unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n); extern unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n); -extern long __strncpy_from_user(char *dst, const char __user *src, long count); -extern long __strnlen_user(const void __user *str, long len); +extern long strncpy_from_user(char *dst, const char __user *src, long count); +extern long strnlen_user(const void __user *str, long len); extern unsigned long __clear_user(void __user *mem, unsigned long len); static inline int __access_ok(unsigned long addr, unsigned long size); /* Teach asm-generic/uaccess.h that we have C functions for these. */ #define __access_ok __access_ok #define __clear_user __clear_user -#define __strnlen_user __strnlen_user -#define __strncpy_from_user __strncpy_from_user +#define strnlen_user strnlen_user +#define strncpy_from_user strncpy_from_user #define INLINE_COPY_FROM_USER #define INLINE_COPY_TO_USER diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c index 2dec915abe6f..205679cc4bb7 100644 --- a/arch/um/kernel/skas/uaccess.c +++ b/arch/um/kernel/skas/uaccess.c @@ -188,11 +188,14 @@ static int strncpy_chunk_from_user(unsigned long from, int len, void *arg) return 0; } -long __strncpy_from_user(char *dst, const char __user *src, long count) +long strncpy_from_user(char *dst, const char __user *src, long count) { long n; char *ptr = dst; + if (!access_ok(src, 1)) + return -EFAULT; + if (uaccess_kernel()) { strncpy(dst, (__force void *) src, count); return strnlen(dst, count); diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index 4973328f3c6e..c03889cc904c 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h @@ -246,11 +246,15 @@ extern int __get_user_bad(void) __attribute__((noreturn)); /* * Copy a null terminated string from userspace. */ -#ifndef __strncpy_from_user +#ifndef strncpy_from_user static inline long -__strncpy_from_user(char *dst, const char __user *src, long count) +strncpy_from_user(char *dst, const char __user *src, long count) { char *tmp; + + if (!access_ok(src, 1)) + return -EFAULT; + strncpy(dst, (const char __force *)src, count); for (tmp = dst; *tmp && count > 0; tmp++, count--) ; @@ -258,24 +262,12 @@ __strncpy_from_user(char *dst, const char __user *src, long count) } #endif -static inline long -strncpy_from_user(char *dst, const char __user *src, long count) -{ - if (!access_ok(src, 1)) - return -EFAULT; - return __strncpy_from_user(dst, src, count); -} - +#ifndef strnlen_user /* * Return the size of a string (including the ending 0) * * Return 0 on exception, a value greater than N if too long - */ -#ifndef __strnlen_user -#define __strnlen_user(s, n) (strnlen((s), (n)) + 1) -#endif - -/* + * * Unlike strnlen, strnlen_user includes the nul terminator in * its returned count. Callers should check for a returned value * greater than N as an indication the string is too long. @@ -284,8 +276,10 @@ static inline long strnlen_user(const char __user *src, long n) { if (!access_ok(src, 1)) return 0; - return __strnlen_user(src, n); + + return strnlen(src, n) + 1; } +#endif /* * Zero Userspace From patchwork Sat May 15 10:17:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12259587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78A19C43470 for ; Sat, 15 May 2021 10:19:32 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3C3C613F0 for ; Sat, 15 May 2021 10:19:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3C3C613F0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sGUfaFmwx7SvpSIDVL58T4Kydc+0Lw8u75/34WE+VQE=; b=AO2maToCW98+onBbhNQbADety 3T/LFKdUCLS5uixEzF8uspRi2EYWSeW8R1NmbWJy2zOcdceHD70HDeHcMNs19j1kJUC/VX+61utA6 ONT+ShZ6U6zW7EwoWGtnYhm7O7JpMnwdPULHrW0pZUjpE46wJhiAufLcKcNKnZ6nUgK2HQ8uW/Z8K K/vJzXDwTBU+YOw3NLyYLHRoERWChG7SNotbyra4LLJ4VHSsf5xRAdAUA3yHO4lMtasxS4d7izacP 9L+B/jPRBef88iAS3VbX77qLS76KZBMGHRDMJ/xrmn/a+bo8y8g0lkUPkThFi7pSM7keRSbZHtTPi rh+VsQDMA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lhrOB-00A8cD-1A; Sat, 15 May 2021 10:19:19 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhrO3-00A8ZY-Vt; Sat, 15 May 2021 10:19:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=iRPS09GKtyHN36s6c6tnCvwonnTmhlRhulJXnYJYC2s=; b=h7OckPo5keHsV6lpPqqWgLBrkK MkdV+2dlTkoB9GOCW+BCZGi4PaXYxZVT58Ea/OzRUfZdkj9XMxv7xmgY4HuMl5JHPBqgzMAp3Gp+V ZWNsNAsZ6jZgo81I4TQGo4tIRMpjx7HmTW16fh8xv4epFYJ8ANRz3/672NPj5qN8qv/5aMVvo3huI q5RGb+AN5rGEWQjJ/E0CBOAiLl8alIJMX721HrBi0jjO/klERbG6ihUXwnNmLyn5Wg1nIbwwIYEUV Gq+DwSh3cerLxnp7r4jrXpAROK1YESg0mOqE4NzTQYl3w07QHbxITAJW5LGIlwxhLmqpDhEGqb5wj Ob1WW1vg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhrO1-00CU4c-G2; Sat, 15 May 2021 10:19:10 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 222DB613F2; Sat, 15 May 2021 10:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621073949; bh=ZuoXd0B2SrZ7Z7bKOj6098xfQUeD3LlhjJk6ioEZ4Xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OaXxzQOLVw4qXYynCG0CbJTLPAAS4Cb6ml36FdzlD2oZFwMEoeLCGboIwHsdJ5exf Ga2adeohFo6jmgrDUQjP94/gg0dswfFTbe+zdsfcWzgNBT43wk4Rxgkfpfu1PQ0+Z7 ZxuSwUyFzpHZs+JqnThCfpAyalEYKBpG0bbzQmP4PXw6PFNb5+nQV6gUU6v/7++9gN Hzg5TNwsEo/ElbE+CUdy7zXGXcUoVWfppN9fShcogVKUpONLfuipIrULhaQbwVAGSP c+UkqkoXdQGbJ9zE+9HHem2AcbupgnH8nxd1PtiVRb0sqYrQm9KC8BHrRsfyNFx2uH C6SoseNotBhMg== From: Arnd Bergmann To: linux-arch@vger.kernel.org Cc: Arnd Bergmann , Christoph Hellwig , Al Viro , Vineet Gupta , Yoshinori Sato , Brian Cain , Geert Uytterhoeven , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jeff Dike , Richard Weinberger , Anton Ivanov , Sid Manning , Andrew Morton , Mike Rapoport , linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-um@lists.infradead.org Subject: [PATCH 2/6] [v2] h8300: remove stale strncpy_from_user Date: Sat, 15 May 2021 12:17:59 +0200 Message-Id: <20210515101803.924427-3-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210515101803.924427-1-arnd@kernel.org> References: <20210515101803.924427-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210515_031909_593674_35CCB514 X-CRM114-Status: GOOD ( 11.36 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann This function is never called because h8300 uses the asm-generic inline function version. Signed-off-by: Arnd Bergmann --- arch/h8300/kernel/h8300_ksyms.c | 2 -- arch/h8300/lib/Makefile | 2 +- arch/h8300/lib/strncpy.S | 35 --------------------------------- 3 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 arch/h8300/lib/strncpy.S diff --git a/arch/h8300/kernel/h8300_ksyms.c b/arch/h8300/kernel/h8300_ksyms.c index 1c6f902e82a5..853d6e886477 100644 --- a/arch/h8300/kernel/h8300_ksyms.c +++ b/arch/h8300/kernel/h8300_ksyms.c @@ -19,7 +19,6 @@ asmlinkage long __mulsi3(long, long); asmlinkage long __udivsi3(long, long); asmlinkage void *memcpy(void *, const void *, size_t); asmlinkage void *memset(void *, int, size_t); -asmlinkage long strncpy_from_user(void *to, void *from, size_t n); /* gcc lib functions */ EXPORT_SYMBOL(__ucmpdi2); @@ -34,4 +33,3 @@ EXPORT_SYMBOL(__mulsi3); EXPORT_SYMBOL(__udivsi3); EXPORT_SYMBOL(memcpy); EXPORT_SYMBOL(memset); -EXPORT_SYMBOL(strncpy_from_user); diff --git a/arch/h8300/lib/Makefile b/arch/h8300/lib/Makefile index 685fa837c1f7..5911c1fa856d 100644 --- a/arch/h8300/lib/Makefile +++ b/arch/h8300/lib/Makefile @@ -3,7 +3,7 @@ # Makefile for H8/300-specific library files.. # -lib-y = memcpy.o memset.o abs.o strncpy.o \ +lib-y = memcpy.o memset.o abs.o \ mulsi3.o udivsi3.o muldi3.o moddivsi3.o \ ashldi3.o lshrdi3.o ashrdi3.o ucmpdi2.o \ delay.o diff --git a/arch/h8300/lib/strncpy.S b/arch/h8300/lib/strncpy.S deleted file mode 100644 index 8b65d7c4727b..000000000000 --- a/arch/h8300/lib/strncpy.S +++ /dev/null @@ -1,35 +0,0 @@ -;;; SPDX-License-Identifier: GPL-2.0 -;;; strncpy.S - -#include - - .text -.global strncpy_from_user - -;;; long strncpy_from_user(void *to, void *from, size_t n) -strncpy_from_user: - mov.l er2,er2 - bne 1f - sub.l er0,er0 - rts -1: - mov.l er4,@-sp - sub.l er3,er3 -2: - mov.b @er1+,r4l - mov.b r4l,@er0 - adds #1,er0 - beq 3f - inc.l #1,er3 - dec.l #1,er2 - bne 2b -3: - dec.l #1,er2 -4: - mov.b r4l,@er0 - adds #1,er0 - dec.l #1,er2 - bne 4b - mov.l er3,er0 - mov.l @sp+,er4 - rts From patchwork Sat May 15 10:18:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12259589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D71CC433B4 for ; Sat, 15 May 2021 10:19:35 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0F9CB613F0 for ; Sat, 15 May 2021 10:19:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F9CB613F0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GsnUhHTiI2U+ihYqqR0ELLQStbGU5V2DcG2ulH0TUP4=; b=Bq6K722jPGbQJKRzocQz6XcUA 4UOqHyNRN0aQ23hwkUb4g3nwZN88iYidFxLCCSYpDK9TqvBrA0HtOvsuQFnp5pv35JNg+OCND/XNz 0JfiAM+87Lvk5CjlXBYvNe81p6otikPPhQ57YgbJ8EMltBc0ovRx/vgOHVHMwxb5Glkfn9f2mJP1W C1b+52OL356ETVYB5JcGReAos64qKoCMbsfOYNH15X9zeX+x9uvjhOM4VHtxgGQDBfQ+ZjKkSD4bH NXVWABuj3QI4b2EtRE0mFvOuFHzFXxruggT7zmFYB/FwEcmf/O8k9e+Ivd52iUNzF6l1mXNye142g hZR5Y+SXA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lhrOI-00A8eT-0x; Sat, 15 May 2021 10:19:26 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhrO8-00A8ak-NN; Sat, 15 May 2021 10:19:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=SzKaI6dXc74+BRW8SKXs0CQeJ0fbvs60xmG21l/oZOE=; b=TUqPQWMhzKbPJwPSDgva7HOlSx roZWstrCHkkYR+fhHcta/Mn9Imru08NTpvoARkBG5iSRiB/ejooxXBOBgO2zSs//7e6S4kqs3VHbs 5SM/5C9bAFCj0TjO0UzPyPs3F70CAG22/wl0XWz1Mv9VAhCUJUsM2MnJPeWO7/aroKBJb53oSnKUp f8hVoKN0c+YaBzL3JdHuGDGfTieG1IMPnNT/pSx5XdDGXMHwDgL/5EkUx6xtczaaE8u8xESDBu3MX seTXBHjnw8NnLHue1SUTje8AzS7P2QPLxfwHio6H/VSIVja8Rrk1IlqURjhrHeJWYdMH2Z6dH7sbs T+bzKQXg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhrO5-00CU57-Ud; Sat, 15 May 2021 10:19:15 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 91842613F7; Sat, 15 May 2021 10:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621073953; bh=kI7iPmlJRPV9cT24htrm0onuzJ0NEoNiBghzMsHijxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XfM/0trNZKCIK7Oa1enMTPiSVt8geLkcYU8otQOB9OeV/EdYV8/BVKtML4mcS7vCO r/SkhN/MThpOxdGCYI0s9BEv3QHUmpi9sl8uGaS4zRqre+k8FBybLBQMr21jw1aZxk qmEpWFxRY5cpCO8vFEPeL7idKCVz4MxheBnAB0o7Vm8kfMcGCggwxGwpUyCN1U1jtn 6WNMJUo/V/aQlwYibT7yGorRNWV7qFEFrNoXajIPaaPp2jxC5roUUYE0fUSFx+I3bu wuJsMlYmtOursEBvcgKO0DT8u+TwMaalVsQucbwm5B9zckFSvQCyMiluZkg/oPDE9n LU3061hEHSCtw== From: Arnd Bergmann To: linux-arch@vger.kernel.org Cc: Arnd Bergmann , Christoph Hellwig , Al Viro , Vineet Gupta , Yoshinori Sato , Brian Cain , Geert Uytterhoeven , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jeff Dike , Richard Weinberger , Anton Ivanov , Sid Manning , Andrew Morton , Mike Rapoport , linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-um@lists.infradead.org Subject: [PATCH 3/6] [v2] hexagon: use generic strncpy/strnlen from_user Date: Sat, 15 May 2021 12:18:00 +0200 Message-Id: <20210515101803.924427-4-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210515101803.924427-1-arnd@kernel.org> References: <20210515101803.924427-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210515_031914_052760_C271B4F1 X-CRM114-Status: GOOD ( 17.51 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann Most per-architecture versions of these functions are broken in some form, and they are almost certainly slower than the generic code as well. Remove the ones for hexagon and instead use the generic version. This custom version reads the data twice for strncpy() by doing an extra strnlen(), and it apparently lacks a check for user_addr_max(). Signed-off-by: Arnd Bergmann --- arch/hexagon/Kconfig | 2 + arch/hexagon/include/asm/uaccess.h | 33 +------- arch/hexagon/kernel/hexagon_ksyms.c | 1 - arch/hexagon/mm/Makefile | 2 +- arch/hexagon/mm/strnlen_user.S | 126 ---------------------------- 5 files changed, 5 insertions(+), 159 deletions(-) delete mode 100644 arch/hexagon/mm/strnlen_user.S diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index f18ec6f49c15..d094186188df 100644 --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig @@ -19,6 +19,8 @@ config HEXAGON # GENERIC_ALLOCATOR is used by dma_alloc_coherent() select GENERIC_ALLOCATOR select GENERIC_IRQ_SHOW + select GENERIC_STRNCPY_FROM_USER + select GENERIC_STRNLEN_USER select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK select NEED_SG_DMA_LENGTH diff --git a/arch/hexagon/include/asm/uaccess.h b/arch/hexagon/include/asm/uaccess.h index 59aa3a50744f..d950df12d8c5 100644 --- a/arch/hexagon/include/asm/uaccess.h +++ b/arch/hexagon/include/asm/uaccess.h @@ -57,42 +57,13 @@ unsigned long raw_copy_to_user(void __user *to, const void *from, __kernel_size_t __clear_user_hexagon(void __user *dest, unsigned long count); #define __clear_user(a, s) __clear_user_hexagon((a), (s)) -extern long __strnlen_user(const char __user *src, long n); - -static inline strnlen_user(const char __user *src, long n) -{ - if (!access_ok(src, 1)) - return 0; - - return __strnlen_user(src, n); -} -/* get around the ifndef in asm-generic/uaccess.h */ +extern long strnlen_user(const char __user *src, long n); #define strnlen_user strnlen_user -static inline long strncpy_from_user(char *dst, const char __user *src, long n); +extern long strncpy_from_user(char *dst, const char __user *src, long n) #define strncpy_from_user strncpy_from_user #include -/* Todo: an actual accelerated version of this. */ -static inline long strncpy_from_user(char *dst, const char __user *src, long n) -{ - long res = strnlen_user(src, n); - - if (unlikely(!res)) - return -EFAULT; - - if (res > n) { - long left = raw_copy_from_user(dst, src, n); - if (unlikely(left)) - memset(dst + (n - left), 0, left); - return n; - } else { - long left = raw_copy_from_user(dst, src, res); - if (unlikely(left)) - memset(dst + (res - left), 0, left); - return res-1; - } -} #endif diff --git a/arch/hexagon/kernel/hexagon_ksyms.c b/arch/hexagon/kernel/hexagon_ksyms.c index 35545a7386a0..ec56ce2d92a2 100644 --- a/arch/hexagon/kernel/hexagon_ksyms.c +++ b/arch/hexagon/kernel/hexagon_ksyms.c @@ -15,7 +15,6 @@ EXPORT_SYMBOL(__clear_user_hexagon); EXPORT_SYMBOL(raw_copy_from_user); EXPORT_SYMBOL(raw_copy_to_user); EXPORT_SYMBOL(iounmap); -EXPORT_SYMBOL(__strnlen_user); EXPORT_SYMBOL(__vmgetie); EXPORT_SYMBOL(__vmsetie); EXPORT_SYMBOL(__vmyield); diff --git a/arch/hexagon/mm/Makefile b/arch/hexagon/mm/Makefile index 893838499591..49911a906fd0 100644 --- a/arch/hexagon/mm/Makefile +++ b/arch/hexagon/mm/Makefile @@ -4,4 +4,4 @@ # obj-y := init.o ioremap.o uaccess.o vm_fault.o cache.o -obj-y += copy_to_user.o copy_from_user.o strnlen_user.o vm_tlb.o +obj-y += copy_to_user.o copy_from_user.o vm_tlb.o diff --git a/arch/hexagon/mm/strnlen_user.S b/arch/hexagon/mm/strnlen_user.S deleted file mode 100644 index 4b5574a7cc9c..000000000000 --- a/arch/hexagon/mm/strnlen_user.S +++ /dev/null @@ -1,126 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * User string length functions for kernel - * - * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. - */ - -#define isrc r0 -#define max r1 /* Do not change! */ - -#define end r2 -#define tmp1 r3 - -#define obo r6 /* off-by-one */ -#define start r7 -#define mod8 r8 -#define dbuf r15:14 -#define dcmp r13:12 - -/* - * The vector mask version of this turned out *really* badly. - * The hardware loop version also turned out *really* badly. - * Seems straight pointer arithmetic basically wins here. - */ - -#define fname __strnlen_user - - .text - .global fname - .type fname, @function - .p2align 5 /* why? */ -fname: - { - mod8 = and(isrc,#7); - end = add(isrc,max); - start = isrc; - } - { - P0 = cmp.eq(mod8,#0); - mod8 = and(end,#7); - dcmp = #0; - if (P0.new) jump:t dw_loop; /* fire up the oven */ - } - -alignment_loop: -fail_1: { - tmp1 = memb(start++#1); - } - { - P0 = cmp.eq(tmp1,#0); - if (P0.new) jump:nt exit_found; - P1 = cmp.gtu(end,start); - mod8 = and(start,#7); - } - { - if (!P1) jump exit_error; /* hit the end */ - P0 = cmp.eq(mod8,#0); - } - { - if (!P0) jump alignment_loop; - } - - - -dw_loop: -fail_2: { - dbuf = memd(start); - obo = add(start,#1); - } - { - P0 = vcmpb.eq(dbuf,dcmp); - } - { - tmp1 = P0; - P0 = cmp.gtu(end,start); - } - { - tmp1 = ct0(tmp1); - mod8 = and(end,#7); - if (!P0) jump end_check; - } - { - P0 = cmp.eq(tmp1,#32); - if (!P0.new) jump:nt exit_found; - if (!P0.new) start = add(obo,tmp1); - } - { - start = add(start,#8); - jump dw_loop; - } /* might be nice to combine these jumps... */ - - -end_check: - { - P0 = cmp.gt(tmp1,mod8); - if (P0.new) jump:nt exit_error; /* neverfound! */ - start = add(obo,tmp1); - } - -exit_found: - { - R0 = sub(start,isrc); - jumpr R31; - } - -exit_error: - { - R0 = add(max,#1); - jumpr R31; - } - - /* Uh, what does the "fixup" return here? */ - .falign -fix_1: - { - R0 = #0; - jumpr R31; - } - - .size fname,.-fname - - -.section __ex_table,"a" -.long fail_1,fix_1 -.long fail_2,fix_1 -.previous From patchwork Sat May 15 10:18:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12259591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEFE3C433B4 for ; Sat, 15 May 2021 10:19:47 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 639F4613F0 for ; Sat, 15 May 2021 10:19:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 639F4613F0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+ZTnrtv2xvdwi91A3pbmrpOaIfScV6wlu//Y5Skjs7w=; b=IGH/NNeF9VVy6IVZtU+NCOGS7 MqsXAmfBVncMLG9mrAmz9Meq3Id7+kkBT6YNN/eaESkNey26cuxAU9n6b43RGqKNxzPXJEf0E9q1G OGRstXDUJJSP0+6sWPdwCq17tbEYS9VnACdTUtQXoxlTuPjXp7Wb03u5WEtN4MHZQqag3P5JeXo8L Y2p1HXzr09oDh0R1TxiA25rn8eGVpcP2X+7nS+PA9LQ+lFTSjk1YKqannvPzE91GQepGmWIJfVkY7 m5w9rrTUfXQ9q+8SLArjuXLurDK2P7TnVNYI47pQbkOvD0cqJEX+y8XRhmqN9rGtSQt7OXnyMl/e/ Jpr7w4uQg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lhrOL-00A8gT-TK; Sat, 15 May 2021 10:19:30 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhrOD-00A8cO-47; Sat, 15 May 2021 10:19:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=NaqXJV908V1jIAVejU+NdX55MLC7FA58Fe0o+EeCqG4=; b=wU1JLmm9mUirjVwBwAwpxvJZFm IFkiBwBTuzZDHbvrNtERcmMRFyFM/3q+coQnjklMDuLOczJ7PAxaIjIyA68MPwhTey+hgGdTITSnZ /66pSSNIHhdlLKK1C+/E3lARU9Rn58BObZUnT6D5ON/YyUdkVAnCQa0qLvMcjcorp7FuseduM8iDP u8fw5DtqWXtGuDNcHtmEpz9DeuJ2TPBjvdKfPSOHIHLz14GS0x0wOUljMN8S2eU/01XJbRdUoCyBq OF3PXEXwOL0m/fJ1EtKHw2DQRWYPBDb+kJikvPAb/OjgT8yvH3vB8OBu8R5irLDIb8ETkrkCRQcrU sbSbrxWQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhrOA-00CU5X-FI; Sat, 15 May 2021 10:19:19 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0B335613ED; Sat, 15 May 2021 10:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621073958; bh=5EiV6+uSoRXpKB9TPWxNu5WmBqsPjct5G2z66NyP0fw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bjky3cSuDqZIES1KbepcV5Oby6RvxvISRH0AGI4mDxg/BM6uDnjAapszFc+ptgQNt J0tcmi3xigYXX6LJOuynlQSBPrO9WxPj+DHGujJh2g321TLT2yXZIWKChiUclVzNT4 e58Rf8vzaJI19p63w017oebZKBmnLE1JxFJ1EqoB+mcwLFkW7KFxUSpVniv3oWMjB/ AbImTti61Fc9PLzwUugONY6MJ21I7VRetVRK7MGExtcfjVaYKiPP3HYU+Cv6SlyudR o0/Wn48mXsLWAkQpjkkDV0eSXkAeuZeYrNAIMxNEqrbMd6pJyq6LaoRglM9p2zd//o ggJFHQ3qZVlvw== From: Arnd Bergmann To: linux-arch@vger.kernel.org Cc: Arnd Bergmann , Christoph Hellwig , Al Viro , Vineet Gupta , Yoshinori Sato , Brian Cain , Geert Uytterhoeven , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jeff Dike , Richard Weinberger , Anton Ivanov , Sid Manning , Andrew Morton , Mike Rapoport , linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-um@lists.infradead.org Subject: [PATCH 4/6] [v2] arc: use generic strncpy/strnlen from_user Date: Sat, 15 May 2021 12:18:01 +0200 Message-Id: <20210515101803.924427-5-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210515101803.924427-1-arnd@kernel.org> References: <20210515101803.924427-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210515_031918_576644_7FE31180 X-CRM114-Status: GOOD ( 11.49 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann Most per-architecture versions of these functions are broken in some form, and they are almost certainly slower than the generic code as well. This version is fairly slow because it always does byte accesses even for aligned data, and its checks for user_addr_max() differ from the generic code. Remove the ones for arc and instead use the generic version. Signed-off-by: Arnd Bergmann --- arch/arc/Kconfig | 2 + arch/arc/include/asm/uaccess.h | 83 ++-------------------------------- arch/arc/mm/extable.c | 12 ----- 3 files changed, 7 insertions(+), 90 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 2d98501c0897..a38f403a8811 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -27,6 +27,8 @@ config ARC select GENERIC_PENDING_IRQ if SMP select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD + select GENERIC_STRNCPY_FROM_USER + select GENERIC_STRNLEN_USER select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARC_MMU_V4 diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h index 3476348f361e..754a23f26736 100644 --- a/arch/arc/include/asm/uaccess.h +++ b/arch/arc/include/asm/uaccess.h @@ -655,96 +655,23 @@ static inline unsigned long __arc_clear_user(void __user *to, unsigned long n) return res; } -static inline long -__arc_strncpy_from_user(char *dst, const char __user *src, long count) -{ - long res = 0; - char val; - - if (!access_ok(src, 1)) - return -EFAULT; - - if (count == 0) - return 0; - - __asm__ __volatile__( - " mov lp_count, %5 \n" - " lp 3f \n" - "1: ldb.ab %3, [%2, 1] \n" - " breq.d %3, 0, 3f \n" - " stb.ab %3, [%1, 1] \n" - " add %0, %0, 1 # Num of NON NULL bytes copied \n" - "3: \n" - " .section .fixup, \"ax\" \n" - " .align 4 \n" - "4: mov %0, %4 # sets @res as -EFAULT \n" - " j 3b \n" - " .previous \n" - " .section __ex_table, \"a\" \n" - " .align 4 \n" - " .word 1b, 4b \n" - " .previous \n" - : "+r"(res), "+r"(dst), "+r"(src), "=r"(val) - : "g"(-EFAULT), "r"(count) - : "lp_count", "memory"); - - return res; -} - -static inline long __arc_strnlen_user(const char __user *s, long n) -{ - long res, tmp1, cnt; - char val; - - if (!access_ok(s, 1)) - return 0; - - __asm__ __volatile__( - " mov %2, %1 \n" - "1: ldb.ab %3, [%0, 1] \n" - " breq.d %3, 0, 2f \n" - " sub.f %2, %2, 1 \n" - " bnz 1b \n" - " sub %2, %2, 1 \n" - "2: sub %0, %1, %2 \n" - "3: ;nop \n" - " .section .fixup, \"ax\" \n" - " .align 4 \n" - "4: mov %0, 0 \n" - " j 3b \n" - " .previous \n" - " .section __ex_table, \"a\" \n" - " .align 4 \n" - " .word 1b, 4b \n" - " .previous \n" - : "=r"(res), "=r"(tmp1), "=r"(cnt), "=r"(val) - : "0"(s), "1"(n) - : "memory"); - - return res; -} - #ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE #define INLINE_COPY_TO_USER #define INLINE_COPY_FROM_USER #define __clear_user(d, n) __arc_clear_user(d, n) -#define strncpy_from_user(d, s, n) __arc_strncpy_from_user(d, s, n) -#define strnlen_user(s, n) __arc_strnlen_user(s, n) #else extern unsigned long arc_clear_user_noinline(void __user *to, unsigned long n); -extern long arc_strncpy_from_user_noinline (char *dst, const char __user *src, - long count); -extern long arc_strnlen_user_noinline(const char __user *src, long n); - #define __clear_user(d, n) arc_clear_user_noinline(d, n) -#define strncpy_from_user(d, s, n) arc_strncpy_from_user_noinline(d, s, n) -#define strnlen_user(s, n) arc_strnlen_user_noinline(s, n) - #endif +extern long strncpy_from_user(char *dst, const char __user *src, long count); +#define strncpy_from_user(d, s, n) strncpy_from_user(d, s, n) +extern long strnlen_user(const char __user *src, long n); +#define strnlen_user(s, n) strnlen_user(s, n) + #include #include diff --git a/arch/arc/mm/extable.c b/arch/arc/mm/extable.c index b06b09ddf924..4e14c4244ea2 100644 --- a/arch/arc/mm/extable.c +++ b/arch/arc/mm/extable.c @@ -32,16 +32,4 @@ unsigned long arc_clear_user_noinline(void __user *to, } EXPORT_SYMBOL(arc_clear_user_noinline); -long arc_strncpy_from_user_noinline(char *dst, const char __user *src, - long count) -{ - return __arc_strncpy_from_user(dst, src, count); -} -EXPORT_SYMBOL(arc_strncpy_from_user_noinline); - -long arc_strnlen_user_noinline(const char __user *src, long n) -{ - return __arc_strnlen_user(src, n); -} -EXPORT_SYMBOL(arc_strnlen_user_noinline); #endif From patchwork Sat May 15 10:18:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12259593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49E29C433B4 for ; Sat, 15 May 2021 10:19:52 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BCABA613F0 for ; Sat, 15 May 2021 10:19:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BCABA613F0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=C+6wKKG2D7/4oWoMGqXCAv5s9VsY0k1K2vu5ITVngnM=; b=e5d7wDnjNIqU49svvlR/ZMUeg 66A56MOHqHZ69my3yZfQM3pyfLdX7Tc9BUiGI1Iq5Mh+xJsYZg8lI9ZykVJiabKAN984PLSLo+Xxk 8kaH5pAe40AMM9UxxVJGyRIAtiX7JSqgqqgSwi0c19FZP696IQRQFAPmaGqLOBEhonDO5VUcI214y uJBWsVIxPrZjIdAu7eF7ztgTuRu+IquO2eDgbo/4+P6FxNXcItm2DYUGkuymORMHZGFwnMpkznm+v BUw6irBf9mNr6lO8dMlwactumByYR6qoAtp6yIVjxXanH5Dn1mb1MiPv6VhJ39zZZpXP1lWxZjxQA WvBEAcy9g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lhrOS-00A8jK-4R; Sat, 15 May 2021 10:19:36 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhrOI-00A8eX-N3; Sat, 15 May 2021 10:19:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=FU4k2uMM9mwcp1WgQUinaWftWLJ6tL6ok/JHUHLhO1U=; b=ZLDjbvvIuiCTTZC+Dj4koBkiW2 ltVtaujtQ/TRzakEJqLkUnPrWASutLWy6J4TtLGtvX9XAr3KBkfqNCieVcHG8xYnYtmZutN9FUDTA o+xOTGCjop13Jng79xBYmnwwCeNVIwy60lNTZVwuC4dsXnwEM6Mj5kEnd+2BukAGFejxC3SkwcsDr d77y13CIgN8JPYD4EtdlDaOiA1txVDayAYcZzhuNioPqu8c9bSvGRN436cUbxtgEyAlNUl1Qc4TEP eG+dIry7hsx+1/zihELAWi5o7cLzWTZS+bHrA8AowwoRd+qDVK9uQ4Rp5PPt0laqLnjDZC3LN1rFH uBihVknQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhrOE-00CU5u-RZ; Sat, 15 May 2021 10:19:25 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 78078613F1; Sat, 15 May 2021 10:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621073962; bh=OHYyLARVOpPFIbAcC7K6UIcn3rkRJrz96uQAgiEquDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qcRi/50ljOQgAZf8i+VFhWF6uabdLpEfT7FHBTtxYuSMtemuV9LrEtTDSACDtVyfw salCHZmpn79xzNXb8B78wch24f//jkb6g+Fki5uCNdP8zNnv9UtDzG7e22EknaCACh mrPOxaZq4mdM1UsevzFRyixsupIwTAYWl49hqhEg3ck/tFFeNs7qINE0LN5ZtJSLfX H47TnEMDXTRGI4KAr0xEHobI2Wx0rYPpPUDbXbSo9MF06IlZHzfOPDMp3r4qLLEKvN GNVZauk3D4wviEHeU3e+G301vOcgnCYQ7ZvM9PTwWoO0iy7NC/13CbD7OJqRdxhixA j4vbx08vZ6TPA== From: Arnd Bergmann To: linux-arch@vger.kernel.org Cc: Arnd Bergmann , Christoph Hellwig , Al Viro , Vineet Gupta , Yoshinori Sato , Brian Cain , Geert Uytterhoeven , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jeff Dike , Richard Weinberger , Anton Ivanov , Sid Manning , Andrew Morton , Mike Rapoport , linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-um@lists.infradead.org Subject: [PATCH 5/6] [v2] asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user Date: Sat, 15 May 2021 12:18:02 +0200 Message-Id: <20210515101803.924427-6-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210515101803.924427-1-arnd@kernel.org> References: <20210515101803.924427-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210515_031922_956360_01DE1088 X-CRM114-Status: GOOD ( 13.00 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann Consolidate the asm-generic implementation with the library version that is used everywhere else. These are the three versions for NOMMU kernels, which can in principle fall back to strncpy()/strnlen() as the version in asm-generic does, but this version is particularly inefficient when it scans the string one byte at a time twice. The generic version also lacks a check for user_addr_max(), but this is probably ok on NOMMU targets. Signed-off-by: Arnd Bergmann --- arch/h8300/Kconfig | 2 ++ arch/m68k/Kconfig | 4 +-- arch/riscv/Kconfig | 4 +-- include/asm-generic/uaccess.h | 46 ++++++----------------------------- 4 files changed, 14 insertions(+), 42 deletions(-) diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index 3e3e0f16f7e0..53dfd2d47e0e 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig @@ -11,6 +11,8 @@ config H8300 select GENERIC_IRQ_SHOW select FRAME_POINTER select GENERIC_CPU_DEVICES + select GENERIC_STRNCPY_FROM_USER + select GENERIC_STRNLEN_USER select MODULES_USE_ELF_RELA select COMMON_CLK select ARCH_WANT_FRAME_POINTERS diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index ed6b8050e3ed..5f1aafa7b2e2 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -17,8 +17,8 @@ config M68K select GENERIC_CPU_DEVICES select GENERIC_IOMAP select GENERIC_IRQ_SHOW - select GENERIC_STRNCPY_FROM_USER if MMU - select GENERIC_STRNLEN_USER if MMU + select GENERIC_STRNCPY_FROM_USER + select GENERIC_STRNLEN_USER select HAVE_AOUT if MMU select HAVE_ASM_MODVERSIONS select HAVE_DEBUG_BUGVERBOSE diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index a8ad8eb76120..ada7a2918c05 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -55,8 +55,8 @@ config RISCV select GENERIC_PTDUMP if MMU select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD - select GENERIC_STRNCPY_FROM_USER if MMU - select GENERIC_STRNLEN_USER if MMU + select GENERIC_STRNCPY_FROM_USER + select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL if MMU && 64BIT select HANDLE_DOMAIN_IRQ select HAVE_ARCH_AUDITSYSCALL diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index c03889cc904c..83a48f430951 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h @@ -119,6 +119,11 @@ static inline void set_fs(mm_segment_t fs) #ifndef uaccess_kernel #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg) #endif + +#ifndef user_addr_max +#define user_addr_max() (uaccess_kernel() ? ~0UL : TASK_SIZE) +#endif + #endif /* CONFIG_SET_FS */ #define access_ok(addr, size) __access_ok((unsigned long)(addr),(size)) @@ -243,44 +248,6 @@ static inline int __get_user_fn(size_t size, const void __user *ptr, void *x) extern int __get_user_bad(void) __attribute__((noreturn)); -/* - * Copy a null terminated string from userspace. - */ -#ifndef strncpy_from_user -static inline long -strncpy_from_user(char *dst, const char __user *src, long count) -{ - char *tmp; - - if (!access_ok(src, 1)) - return -EFAULT; - - strncpy(dst, (const char __force *)src, count); - for (tmp = dst; *tmp && count > 0; tmp++, count--) - ; - return (tmp - dst); -} -#endif - -#ifndef strnlen_user -/* - * Return the size of a string (including the ending 0) - * - * Return 0 on exception, a value greater than N if too long - * - * Unlike strnlen, strnlen_user includes the nul terminator in - * its returned count. Callers should check for a returned value - * greater than N as an indication the string is too long. - */ -static inline long strnlen_user(const char __user *src, long n) -{ - if (!access_ok(src, 1)) - return 0; - - return strnlen(src, n) + 1; -} -#endif - /* * Zero Userspace */ @@ -305,4 +272,7 @@ clear_user(void __user *to, unsigned long n) #include +extern long strncpy_from_user(char *dst, const char __user *src, long count); +extern long strnlen_user(const char __user *src, long n); + #endif /* __ASM_GENERIC_UACCESS_H */ From patchwork Sat May 15 10:18:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12259595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45373C43460 for ; Sat, 15 May 2021 10:19:53 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BC28B613F0 for ; Sat, 15 May 2021 10:19:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC28B613F0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DgVytqFjBuVcwQKGFL4Kyasoz451RwvwlrvkCBSqVBs=; b=kgckZxfcAqazHGB9BBA/kyMfB VpL/6yuF86w9Zfcks0zpn2W5OaJ3fzVBYhZoS3Nao+2idXieTy7v9FUanrKVii9R4Kb+DglQQjU56 1b9ytKZYNLqDIdlQYa+QyCfojUfL2yQdaKJby3/q1aAQjcnQpoP8kkT4P8VqhmafFFDRjh0feb3ZM wdvz4K1cQUkUX9AEvDxFBodOMYE+x6j90KJi7OkLnUHv6oFU2Zj5ZlT5sm0dyAKUPWSO7r6qB43fr YuMld+/uJiDLiTXmdo1oS7K4ynlpSO/xv++fhb4mFG2Fd1MstOK+Iyc8wFeCTMOZ7iwkm5DLta5zh WfzhRys0w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lhrOW-00A8lw-Rm; Sat, 15 May 2021 10:19:40 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhrOL-00A8g3-U2; Sat, 15 May 2021 10:19:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=9Fw1IFvYq/KjZTRKKWVzQNRcjazScUqC2uvuOnLwQW0=; b=Y+uvjse+1MvjzSJhMngSlDQ4KV kWrh2ud6kQ7RCMGXTCRDj6porqRUfY3+v0uf0csvvqMOEBDEpQ/gJT1cSolZMPj7wOrTK9ktKejbE PuxXHEj+Q/w2ZAH+gPLp/UMm0zeyDaXzYL1UjadCHfJBAmAAwNTDZYOr27Sq12KsE0ELXyHIfOcox pr0/xC/mZ1hLZ9Qo8O+4EpQK4ohZ0U+OdlccRLI2tHCBaNQ77FmIj7TuPUTc/O3MNYhRSQ0rPr6Lt 2ZZDrjRqGleoDY5F8X62SMgVE2xWwsfrkKNv0nJdgv7NjUo6YjT1My3bDYKzS2gS+8XG7yhach++3 hyKfDKWw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhrOJ-00CU6B-A3; Sat, 15 May 2021 10:19:28 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id E949460C40; Sat, 15 May 2021 10:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621073967; bh=Lb/DGS9E/FUSMtSHAOCH5rcc8a7ucnqACx5B/SB9r64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lp+IzcRjKvLR7R++grQxnLp5gtXP/qgN/cg/jcb91yHCafo9eiUfkQxObCDBCGovC TFKLGUohWA3fQwZPvPi3so4qDwe/nQwdVB/Zpg89Ei6NLVc98yHvm8h8zpxNkOXOzJ HqlnbG+AOzcfs7TiPxwHgCjBWg/sp1i9Mx+5NkeL/2X5g4YE7j9kLgiy41okPcWaDK GZ3hLjqev+EZ0yJmEGmLgCdC9w79agdGf9FvOnZDObtON4etwgfiPcWKWiAgelyks0 Gtn4EtMiZohOg//Wb49qpe1Brp+XFagahm8puDaxQjJ1NEBFDVrRK656cJmTzk6wAb 0ws3B/3Ao+LfA== From: Arnd Bergmann To: linux-arch@vger.kernel.org Cc: Arnd Bergmann , Christoph Hellwig , Al Viro , Vineet Gupta , Yoshinori Sato , Brian Cain , Geert Uytterhoeven , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jeff Dike , Richard Weinberger , Anton Ivanov , Sid Manning , Andrew Morton , Mike Rapoport , linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-riscv@lists.infradead.org, linux-um@lists.infradead.org Subject: [PATCH 6/6] [v2] asm-generic: remove extra strn{cpy_from, len}_user declarations Date: Sat, 15 May 2021 12:18:03 +0200 Message-Id: <20210515101803.924427-7-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210515101803.924427-1-arnd@kernel.org> References: <20210515101803.924427-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210515_031927_392424_A939B3DB X-CRM114-Status: UNSURE ( 9.79 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann As these are now in asm-generic, it's no longer necessary to declare them in the architecture. Signed-off-by: Arnd Bergmann --- arch/arc/include/asm/uaccess.h | 5 ----- arch/hexagon/include/asm/uaccess.h | 6 ------ arch/um/include/asm/uaccess.h | 5 +---- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h index 754a23f26736..783bfdb3bfa3 100644 --- a/arch/arc/include/asm/uaccess.h +++ b/arch/arc/include/asm/uaccess.h @@ -667,11 +667,6 @@ extern unsigned long arc_clear_user_noinline(void __user *to, #define __clear_user(d, n) arc_clear_user_noinline(d, n) #endif -extern long strncpy_from_user(char *dst, const char __user *src, long count); -#define strncpy_from_user(d, s, n) strncpy_from_user(d, s, n) -extern long strnlen_user(const char __user *src, long n); -#define strnlen_user(s, n) strnlen_user(s, n) - #include #include diff --git a/arch/hexagon/include/asm/uaccess.h b/arch/hexagon/include/asm/uaccess.h index d950df12d8c5..ef5bfef8d490 100644 --- a/arch/hexagon/include/asm/uaccess.h +++ b/arch/hexagon/include/asm/uaccess.h @@ -57,12 +57,6 @@ unsigned long raw_copy_to_user(void __user *to, const void *from, __kernel_size_t __clear_user_hexagon(void __user *dest, unsigned long count); #define __clear_user(a, s) __clear_user_hexagon((a), (s)) -extern long strnlen_user(const char __user *src, long n); -#define strnlen_user strnlen_user - -extern long strncpy_from_user(char *dst, const char __user *src, long n) -#define strncpy_from_user strncpy_from_user - #include diff --git a/arch/um/include/asm/uaccess.h b/arch/um/include/asm/uaccess.h index 3bf209f683f8..191ef36dd543 100644 --- a/arch/um/include/asm/uaccess.h +++ b/arch/um/include/asm/uaccess.h @@ -23,16 +23,13 @@ extern unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n); extern unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n); -extern long strncpy_from_user(char *dst, const char __user *src, long count); -extern long strnlen_user(const void __user *str, long len); extern unsigned long __clear_user(void __user *mem, unsigned long len); static inline int __access_ok(unsigned long addr, unsigned long size); /* Teach asm-generic/uaccess.h that we have C functions for these. */ #define __access_ok __access_ok #define __clear_user __clear_user -#define strnlen_user strnlen_user -#define strncpy_from_user strncpy_from_user + #define INLINE_COPY_FROM_USER #define INLINE_COPY_TO_USER