All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/6] asm-generic: strncpy_from_user/strnlen_user cleanup
@ 2021-07-22 12:48 ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

I had run into some regressions for the previous version of this
series, the new version is based on v5.14-rc2 instead.

These two functions appear to be unnecessarily different between
architectures, and the asm-generic version is a bit questionable,
even for NOMMU architectures.

Clean this up to just use the generic library version for anything
that uses the generic version today. I've expanded on the patch
descriptions a little, as suggested by Christoph Hellwig, but I
suspect a more detailed review would uncover additional problems
with the custom versions that are getting removed.

I ended up adding patches for csky and microblaze as they had the
same implementation that I removed elsewhere, these are now gone
as well.

If I hear no objections from architecture maintainers or new
build regressions, I'll queue these up in the asm-generic tree
for 5.15.

       Arnd

Link: https://lore.kernel.org/linux-arch/20210515101803.924427-1-arnd@kernel.org/

Arnd Bergmann (9):
  asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
  h8300: remove stale strncpy_from_user
  hexagon: use generic strncpy/strnlen from_user
  arc: use generic strncpy/strnlen from_user
  csky: use generic strncpy/strnlen from_user
  microblaze: use generic strncpy/strnlen from_user
  asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
  asm-generic: remove extra strn{cpy_from,len}_user declarations
  asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols

 arch/alpha/Kconfig                        |   2 -
 arch/arc/include/asm/uaccess.h            |  72 -------------
 arch/arc/mm/extable.c                     |  12 ---
 arch/arm/Kconfig                          |   2 -
 arch/arm64/Kconfig                        |   2 -
 arch/csky/include/asm/uaccess.h           |   6 --
 arch/csky/lib/usercopy.c                  | 102 ------------------
 arch/h8300/kernel/h8300_ksyms.c           |   2 -
 arch/h8300/lib/Makefile                   |   2 +-
 arch/h8300/lib/strncpy.S                  |  35 ------
 arch/hexagon/include/asm/uaccess.h        |  31 ------
 arch/hexagon/kernel/hexagon_ksyms.c       |   1 -
 arch/hexagon/mm/Makefile                  |   2 +-
 arch/hexagon/mm/strnlen_user.S            | 126 ----------------------
 arch/ia64/Kconfig                         |   2 +
 arch/m68k/Kconfig                         |   2 -
 arch/microblaze/include/asm/uaccess.h     |  19 +---
 arch/microblaze/kernel/microblaze_ksyms.c |   3 -
 arch/microblaze/lib/uaccess_old.S         |  90 ----------------
 arch/mips/Kconfig                         |   2 +
 arch/nds32/Kconfig                        |   2 -
 arch/nios2/Kconfig                        |   2 -
 arch/openrisc/Kconfig                     |   2 -
 arch/parisc/Kconfig                       |   2 +-
 arch/powerpc/Kconfig                      |   2 -
 arch/riscv/Kconfig                        |   2 -
 arch/s390/Kconfig                         |   2 +
 arch/sh/Kconfig                           |   2 -
 arch/sparc/Kconfig                        |   2 -
 arch/um/Kconfig                           |   2 +
 arch/um/include/asm/uaccess.h             |   5 +-
 arch/um/kernel/skas/uaccess.c             |  14 ++-
 arch/x86/Kconfig                          |   2 -
 arch/xtensa/Kconfig                       |   3 +-
 arch/xtensa/include/asm/uaccess.h         |   3 +-
 include/asm-generic/uaccess.h             |  52 ++-------
 lib/Kconfig                               |  10 +-
 37 files changed, 43 insertions(+), 581 deletions(-)
 delete mode 100644 arch/h8300/lib/strncpy.S
 delete mode 100644 arch/hexagon/mm/strnlen_user.S

-- 
2.29.2

Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> 
Cc: Al Viro <viro@zeniv.linux.org.uk> 
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> 
Cc: Brian Cain <bcain@codeaurora.org> 
Cc: Chris Zankel <chris@zankel.net> 
Cc: Christian Borntraeger <borntraeger@de.ibm.com> 
Cc: Christoph Hellwig <hch@lst.de>
Cc: Guo Ren <guoren@kernel.org> 
Cc: Heiko Carstens <hca@linux.ibm.com> 
Cc: Helge Deller <deller@gmx.de> 
Cc: Jeff Dike <jdike@addtoit.com> 
Cc: Linus Walleij <linus.walleij@linaro.org> 
Cc: Max Filippov <jcmvbkbc@gmail.com> 
Cc: Michal Simek <monstr@monstr.eu> 
Cc: Richard Weinberger <richard@nod.at> 
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> 
Cc: Vasily Gorbik <gor@linux.ibm.com> 
Cc: Vineet Gupta <vgupta@synopsys.com> 
Cc: Yoshinori Sato <ysato@users.sourceforge.jp> 
Cc: linux-arch@vger.kernel.org 
Cc: linux-csky@vger.kernel.org 
Cc: linux-hexagon@vger.kernel.org 
Cc: linux-ia64@vger.kernel.org 
Cc: linux-kernel@vger.kernel.org 
Cc: linux-mips@vger.kernel.org 
Cc: linux-parisc@vger.kernel.org 
Cc: linux-s390@vger.kernel.org 
Cc: linux-snps-arc@lists.infradead.org 
Cc: linux-um@lists.infradead.org 
Cc: linux-xtensa@linux-xtensa.org 
Cc: uclinux-h8-devel@lists.sourceforge.jp 

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

* [PATCH v3 0/6] asm-generic: strncpy_from_user/strnlen_user cleanup
@ 2021-07-22 12:48 ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

I had run into some regressions for the previous version of this
series, the new version is based on v5.14-rc2 instead.

These two functions appear to be unnecessarily different between
architectures, and the asm-generic version is a bit questionable,
even for NOMMU architectures.

Clean this up to just use the generic library version for anything
that uses the generic version today. I've expanded on the patch
descriptions a little, as suggested by Christoph Hellwig, but I
suspect a more detailed review would uncover additional problems
with the custom versions that are getting removed.

I ended up adding patches for csky and microblaze as they had the
same implementation that I removed elsewhere, these are now gone
as well.

If I hear no objections from architecture maintainers or new
build regressions, I'll queue these up in the asm-generic tree
for 5.15.

       Arnd

Link: https://lore.kernel.org/linux-arch/20210515101803.924427-1-arnd@kernel.org/

Arnd Bergmann (9):
  asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
  h8300: remove stale strncpy_from_user
  hexagon: use generic strncpy/strnlen from_user
  arc: use generic strncpy/strnlen from_user
  csky: use generic strncpy/strnlen from_user
  microblaze: use generic strncpy/strnlen from_user
  asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
  asm-generic: remove extra strn{cpy_from,len}_user declarations
  asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols

 arch/alpha/Kconfig                        |   2 -
 arch/arc/include/asm/uaccess.h            |  72 -------------
 arch/arc/mm/extable.c                     |  12 ---
 arch/arm/Kconfig                          |   2 -
 arch/arm64/Kconfig                        |   2 -
 arch/csky/include/asm/uaccess.h           |   6 --
 arch/csky/lib/usercopy.c                  | 102 ------------------
 arch/h8300/kernel/h8300_ksyms.c           |   2 -
 arch/h8300/lib/Makefile                   |   2 +-
 arch/h8300/lib/strncpy.S                  |  35 ------
 arch/hexagon/include/asm/uaccess.h        |  31 ------
 arch/hexagon/kernel/hexagon_ksyms.c       |   1 -
 arch/hexagon/mm/Makefile                  |   2 +-
 arch/hexagon/mm/strnlen_user.S            | 126 ----------------------
 arch/ia64/Kconfig                         |   2 +
 arch/m68k/Kconfig                         |   2 -
 arch/microblaze/include/asm/uaccess.h     |  19 +---
 arch/microblaze/kernel/microblaze_ksyms.c |   3 -
 arch/microblaze/lib/uaccess_old.S         |  90 ----------------
 arch/mips/Kconfig                         |   2 +
 arch/nds32/Kconfig                        |   2 -
 arch/nios2/Kconfig                        |   2 -
 arch/openrisc/Kconfig                     |   2 -
 arch/parisc/Kconfig                       |   2 +-
 arch/powerpc/Kconfig                      |   2 -
 arch/riscv/Kconfig                        |   2 -
 arch/s390/Kconfig                         |   2 +
 arch/sh/Kconfig                           |   2 -
 arch/sparc/Kconfig                        |   2 -
 arch/um/Kconfig                           |   2 +
 arch/um/include/asm/uaccess.h             |   5 +-
 arch/um/kernel/skas/uaccess.c             |  14 ++-
 arch/x86/Kconfig                          |   2 -
 arch/xtensa/Kconfig                       |   3 +-
 arch/xtensa/include/asm/uaccess.h         |   3 +-
 include/asm-generic/uaccess.h             |  52 ++-------
 lib/Kconfig                               |  10 +-
 37 files changed, 43 insertions(+), 581 deletions(-)
 delete mode 100644 arch/h8300/lib/strncpy.S
 delete mode 100644 arch/hexagon/mm/strnlen_user.S

-- 
2.29.2

Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> 
Cc: Al Viro <viro@zeniv.linux.org.uk> 
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> 
Cc: Brian Cain <bcain@codeaurora.org> 
Cc: Chris Zankel <chris@zankel.net> 
Cc: Christian Borntraeger <borntraeger@de.ibm.com> 
Cc: Christoph Hellwig <hch@lst.de>
Cc: Guo Ren <guoren@kernel.org> 
Cc: Heiko Carstens <hca@linux.ibm.com> 
Cc: Helge Deller <deller@gmx.de> 
Cc: Jeff Dike <jdike@addtoit.com> 
Cc: Linus Walleij <linus.walleij@linaro.org> 
Cc: Max Filippov <jcmvbkbc@gmail.com> 
Cc: Michal Simek <monstr@monstr.eu> 
Cc: Richard Weinberger <richard@nod.at> 
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> 
Cc: Vasily Gorbik <gor@linux.ibm.com> 
Cc: Vineet Gupta <vgupta@synopsys.com> 
Cc: Yoshinori Sato <ysato@users.sourceforge.jp> 
Cc: linux-arch@vger.kernel.org 
Cc: linux-csky@vger.kernel.org 
Cc: linux-hexagon@vger.kernel.org 
Cc: linux-ia64@vger.kernel.org 
Cc: linux-kernel@vger.kernel.org 
Cc: linux-mips@vger.kernel.org 
Cc: linux-parisc@vger.kernel.org 
Cc: linux-s390@vger.kernel.org 
Cc: linux-snps-arc@lists.infradead.org 
Cc: linux-um@lists.infradead.org 
Cc: linux-xtensa@linux-xtensa.org 
Cc: uclinux-h8-devel@lists.sourceforge.jp 

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* [PATCH v3 0/6] asm-generic: strncpy_from_user/strnlen_user cleanup
@ 2021-07-22 12:48 ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

I had run into some regressions for the previous version of this
series, the new version is based on v5.14-rc2 instead.

These two functions appear to be unnecessarily different between
architectures, and the asm-generic version is a bit questionable,
even for NOMMU architectures.

Clean this up to just use the generic library version for anything
that uses the generic version today. I've expanded on the patch
descriptions a little, as suggested by Christoph Hellwig, but I
suspect a more detailed review would uncover additional problems
with the custom versions that are getting removed.

I ended up adding patches for csky and microblaze as they had the
same implementation that I removed elsewhere, these are now gone
as well.

If I hear no objections from architecture maintainers or new
build regressions, I'll queue these up in the asm-generic tree
for 5.15.

       Arnd

Link: https://lore.kernel.org/linux-arch/20210515101803.924427-1-arnd@kernel.org/

Arnd Bergmann (9):
  asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
  h8300: remove stale strncpy_from_user
  hexagon: use generic strncpy/strnlen from_user
  arc: use generic strncpy/strnlen from_user
  csky: use generic strncpy/strnlen from_user
  microblaze: use generic strncpy/strnlen from_user
  asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
  asm-generic: remove extra strn{cpy_from,len}_user declarations
  asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols

 arch/alpha/Kconfig                        |   2 -
 arch/arc/include/asm/uaccess.h            |  72 -------------
 arch/arc/mm/extable.c                     |  12 ---
 arch/arm/Kconfig                          |   2 -
 arch/arm64/Kconfig                        |   2 -
 arch/csky/include/asm/uaccess.h           |   6 --
 arch/csky/lib/usercopy.c                  | 102 ------------------
 arch/h8300/kernel/h8300_ksyms.c           |   2 -
 arch/h8300/lib/Makefile                   |   2 +-
 arch/h8300/lib/strncpy.S                  |  35 ------
 arch/hexagon/include/asm/uaccess.h        |  31 ------
 arch/hexagon/kernel/hexagon_ksyms.c       |   1 -
 arch/hexagon/mm/Makefile                  |   2 +-
 arch/hexagon/mm/strnlen_user.S            | 126 ----------------------
 arch/ia64/Kconfig                         |   2 +
 arch/m68k/Kconfig                         |   2 -
 arch/microblaze/include/asm/uaccess.h     |  19 +---
 arch/microblaze/kernel/microblaze_ksyms.c |   3 -
 arch/microblaze/lib/uaccess_old.S         |  90 ----------------
 arch/mips/Kconfig                         |   2 +
 arch/nds32/Kconfig                        |   2 -
 arch/nios2/Kconfig                        |   2 -
 arch/openrisc/Kconfig                     |   2 -
 arch/parisc/Kconfig                       |   2 +-
 arch/powerpc/Kconfig                      |   2 -
 arch/riscv/Kconfig                        |   2 -
 arch/s390/Kconfig                         |   2 +
 arch/sh/Kconfig                           |   2 -
 arch/sparc/Kconfig                        |   2 -
 arch/um/Kconfig                           |   2 +
 arch/um/include/asm/uaccess.h             |   5 +-
 arch/um/kernel/skas/uaccess.c             |  14 ++-
 arch/x86/Kconfig                          |   2 -
 arch/xtensa/Kconfig                       |   3 +-
 arch/xtensa/include/asm/uaccess.h         |   3 +-
 include/asm-generic/uaccess.h             |  52 ++-------
 lib/Kconfig                               |  10 +-
 37 files changed, 43 insertions(+), 581 deletions(-)
 delete mode 100644 arch/h8300/lib/strncpy.S
 delete mode 100644 arch/hexagon/mm/strnlen_user.S

-- 
2.29.2

Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> 
Cc: Al Viro <viro@zeniv.linux.org.uk> 
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> 
Cc: Brian Cain <bcain@codeaurora.org> 
Cc: Chris Zankel <chris@zankel.net> 
Cc: Christian Borntraeger <borntraeger@de.ibm.com> 
Cc: Christoph Hellwig <hch@lst.de>
Cc: Guo Ren <guoren@kernel.org> 
Cc: Heiko Carstens <hca@linux.ibm.com> 
Cc: Helge Deller <deller@gmx.de> 
Cc: Jeff Dike <jdike@addtoit.com> 
Cc: Linus Walleij <linus.walleij@linaro.org> 
Cc: Max Filippov <jcmvbkbc@gmail.com> 
Cc: Michal Simek <monstr@monstr.eu> 
Cc: Richard Weinberger <richard@nod.at> 
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> 
Cc: Vasily Gorbik <gor@linux.ibm.com> 
Cc: Vineet Gupta <vgupta@synopsys.com> 
Cc: Yoshinori Sato <ysato@users.sourceforge.jp> 
Cc: linux-arch@vger.kernel.org 
Cc: linux-csky@vger.kernel.org 
Cc: linux-hexagon@vger.kernel.org 
Cc: linux-ia64@vger.kernel.org 
Cc: linux-kernel@vger.kernel.org 
Cc: linux-mips@vger.kernel.org 
Cc: linux-parisc@vger.kernel.org 
Cc: linux-s390@vger.kernel.org 
Cc: linux-snps-arc@lists.infradead.org 
Cc: linux-um@lists.infradead.org 
Cc: linux-xtensa@linux-xtensa.org 
Cc: uclinux-h8-devel@lists.sourceforge.jp 

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

* [PATCH v3 0/6] asm-generic: strncpy_from_user/strnlen_user cleanup
@ 2021-07-22 12:48 ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato

From: Arnd Bergmann <arnd@arndb.de>

I had run into some regressions for the previous version of this
series, the new version is based on v5.14-rc2 instead.

These two functions appear to be unnecessarily different between
architectures, and the asm-generic version is a bit questionable,
even for NOMMU architectures.

Clean this up to just use the generic library version for anything
that uses the generic version today. I've expanded on the patch
descriptions a little, as suggested by Christoph Hellwig, but I
suspect a more detailed review would uncover additional problems
with the custom versions that are getting removed.

I ended up adding patches for csky and microblaze as they had the
same implementation that I removed elsewhere, these are now gone
as well.

If I hear no objections from architecture maintainers or new
build regressions, I'll queue these up in the asm-generic tree
for 5.15.

       Arnd

Link: https://lore.kernel.org/linux-arch/20210515101803.924427-1-arnd@kernel.org/

Arnd Bergmann (9):
  asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
  h8300: remove stale strncpy_from_user
  hexagon: use generic strncpy/strnlen from_user
  arc: use generic strncpy/strnlen from_user
  csky: use generic strncpy/strnlen from_user
  microblaze: use generic strncpy/strnlen from_user
  asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
  asm-generic: remove extra strn{cpy_from,len}_user declarations
  asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols

 arch/alpha/Kconfig                        |   2 -
 arch/arc/include/asm/uaccess.h            |  72 -------------
 arch/arc/mm/extable.c                     |  12 ---
 arch/arm/Kconfig                          |   2 -
 arch/arm64/Kconfig                        |   2 -
 arch/csky/include/asm/uaccess.h           |   6 --
 arch/csky/lib/usercopy.c                  | 102 ------------------
 arch/h8300/kernel/h8300_ksyms.c           |   2 -
 arch/h8300/lib/Makefile                   |   2 +-
 arch/h8300/lib/strncpy.S                  |  35 ------
 arch/hexagon/include/asm/uaccess.h        |  31 ------
 arch/hexagon/kernel/hexagon_ksyms.c       |   1 -
 arch/hexagon/mm/Makefile                  |   2 +-
 arch/hexagon/mm/strnlen_user.S            | 126 ----------------------
 arch/ia64/Kconfig                         |   2 +
 arch/m68k/Kconfig                         |   2 -
 arch/microblaze/include/asm/uaccess.h     |  19 +---
 arch/microblaze/kernel/microblaze_ksyms.c |   3 -
 arch/microblaze/lib/uaccess_old.S         |  90 ----------------
 arch/mips/Kconfig                         |   2 +
 arch/nds32/Kconfig                        |   2 -
 arch/nios2/Kconfig                        |   2 -
 arch/openrisc/Kconfig                     |   2 -
 arch/parisc/Kconfig                       |   2 +-
 arch/powerpc/Kconfig                      |   2 -
 arch/riscv/Kconfig                        |   2 -
 arch/s390/Kconfig                         |   2 +
 arch/sh/Kconfig                           |   2 -
 arch/sparc/Kconfig                        |   2 -
 arch/um/Kconfig                           |   2 +
 arch/um/include/asm/uaccess.h             |   5 +-
 arch/um/kernel/skas/uaccess.c             |  14 ++-
 arch/x86/Kconfig                          |   2 -
 arch/xtensa/Kconfig                       |   3 +-
 arch/xtensa/include/asm/uaccess.h         |   3 +-
 include/asm-generic/uaccess.h             |  52 ++-------
 lib/Kconfig                               |  10 +-
 37 files changed, 43 insertions(+), 581 deletions(-)
 delete mode 100644 arch/h8300/lib/strncpy.S
 delete mode 100644 arch/hexagon/mm/strnlen_user.S

-- 
2.29.2

Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> 
Cc: Al Viro <viro@zeniv.linux.org.uk> 
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com> 
Cc: Brian Cain <bcain@codeaurora.org> 
Cc: Chris Zankel <chris@zankel.net> 
Cc: Christian Borntraeger <borntraeger@de.ibm.com> 
Cc: Christoph Hellwig <hch@lst.de>
Cc: Guo Ren <guoren@kernel.org> 
Cc: Heiko Carstens <hca@linux.ibm.com> 
Cc: Helge Deller <deller@gmx.de> 
Cc: Jeff Dike <jdike@addtoit.com> 
Cc: Linus Walleij <linus.walleij@linaro.org> 
Cc: Max Filippov <jcmvbkbc@gmail.com> 
Cc: Michal Simek <monstr@monstr.eu> 
Cc: Richard Weinberger <richard@nod.at> 
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> 
Cc: Vasily Gorbik <gor@linux.ibm.com> 
Cc: Vineet Gupta <vgupta@synopsys.com> 
Cc: Yoshinori Sato <ysato@users.sourceforge.jp> 
Cc: linux-arch@vger.kernel.org 
Cc: linux-csky@vger.kernel.org 
Cc: linux-hexagon@vger.kernel.org 
Cc: linux-ia64@vger.kernel.org 
Cc: linux-kernel@vger.kernel.org 
Cc: linux-mips@vger.kernel.org 
Cc: linux-parisc@vger.kernel.org 
Cc: linux-s390@vger.kernel.org 
Cc: linux-snps-arc@lists.infradead.org 
Cc: linux-um@lists.infradead.org 
Cc: linux-xtensa@linux-xtensa.org 
Cc: uclinux-h8-devel@lists.sourceforge.jp 

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

* [PATCH v3 1/9] asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
  2021-07-22 12:48 ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 12:48   ` Arnd Bergmann
  -1 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

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() and 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 <arnd@arndb.de>
---
 arch/arc/include/asm/uaccess.h     | 14 ++++++++++----
 arch/csky/include/asm/uaccess.h    |  8 ++++----
 arch/csky/lib/usercopy.c           | 14 ++++++++++----
 arch/hexagon/include/asm/uaccess.h | 22 +++++++++++++---------
 arch/um/include/asm/uaccess.h      |  8 ++++----
 arch/um/kernel/skas/uaccess.c      | 14 ++++++++++----
 include/asm-generic/uaccess.h      | 28 +++++++++++-----------------
 7 files changed, 62 insertions(+), 46 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/csky/include/asm/uaccess.h b/arch/csky/include/asm/uaccess.h
index ac83823fc437..e17c02a6709f 100644
--- a/arch/csky/include/asm/uaccess.h
+++ b/arch/csky/include/asm/uaccess.h
@@ -209,11 +209,11 @@ unsigned long raw_copy_to_user(void *to, const void *from, unsigned long n);
 unsigned long __clear_user(void __user *to, unsigned long n);
 #define __clear_user __clear_user
 
-long __strncpy_from_user(char *dst, const char *src, long count);
-#define __strncpy_from_user __strncpy_from_user
+long strncpy_from_user(char *dst, const char *src, long count);
+#define strncpy_from_user strncpy_from_user
 
-long __strnlen_user(const char *s, long n);
-#define __strnlen_user __strnlen_user
+long strnlen_user(const char *s, long n);
+#define strnlen_user strnlen_user
 
 #include <asm/segment.h>
 #include <asm-generic/uaccess.h>
diff --git a/arch/csky/lib/usercopy.c b/arch/csky/lib/usercopy.c
index c5d394a0ae78..938b750d2fb1 100644
--- a/arch/csky/lib/usercopy.c
+++ b/arch/csky/lib/usercopy.c
@@ -163,11 +163,14 @@ EXPORT_SYMBOL(raw_copy_to_user);
  * If @count is smaller than the length of the string, copies @count bytes
  * and returns @count.
  */
-long __strncpy_from_user(char *dst, const char *src, long count)
+long strncpy_from_user(char *dst, const char *src, long count)
 {
 	long res, faultres;
 	int tmp;
 
+	if (!access_ok(src, 1))
+		return -EFAULT;
+
 	__asm__ __volatile__(
 	"       cmpnei  %3, 0           \n"
 	"       bf      4f              \n"
@@ -198,7 +201,7 @@ long __strncpy_from_user(char *dst, const char *src, long count)
 
 	return res;
 }
-EXPORT_SYMBOL(__strncpy_from_user);
+EXPORT_SYMBOL(strncpy_from_user);
 
 /*
  * strnlen_user: - Get the size of a string in user space.
@@ -211,10 +214,13 @@ EXPORT_SYMBOL(__strncpy_from_user);
  * On exception, returns 0.
  * If the string is too long, returns a value greater than @n.
  */
-long __strnlen_user(const char *s, long n)
+long strnlen_user(const char *s, long n)
 {
 	unsigned long res, tmp;
 
+	if (!access_ok(src, 1))
+		return -EFAULT;
+
 	__asm__ __volatile__(
 	"       cmpnei  %1, 0           \n"
 	"       bf      3f              \n"
@@ -242,7 +248,7 @@ long __strnlen_user(const char *s, long n)
 
 	return res;
 }
-EXPORT_SYMBOL(__strnlen_user);
+EXPORT_SYMBOL(strnlen_user);
 
 /*
  * __clear_user: - Zero a block of memory in user space, with less checking.
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 <asm-generic/uaccess.h>
 
 /*  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 6c76df96e858..fc2c7e961e72 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -189,11 +189,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);
@@ -205,7 +208,7 @@ long __strncpy_from_user(char *dst, const char __user *src, long count)
 		return -EFAULT;
 	return strnlen(dst, count);
 }
-EXPORT_SYMBOL(__strncpy_from_user);
+EXPORT_SYMBOL(strncpy_from_user);
 
 static int clear_chunk(unsigned long addr, int len, void *unused)
 {
@@ -236,10 +239,13 @@ static int strnlen_chunk(unsigned long str, int len, void *arg)
 	return 0;
 }
 
-long __strnlen_user(const void __user *str, long len)
+long strnlen_user(const void __user *str, long len)
 {
 	int count = 0, n;
 
+	if (!access_ok(src, 1))
+		return -EFAULT;
+
 	if (uaccess_kernel())
 		return strnlen((__force char*)str, len) + 1;
 
@@ -248,7 +254,7 @@ long __strnlen_user(const void __user *str, long len)
 		return count + 1;
 	return 0;
 }
-EXPORT_SYMBOL(__strnlen_user);
+EXPORT_SYMBOL(strnlen_user);
 
 /**
  * arch_futex_atomic_op_inuser() - Atomic arithmetic operation with constant
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index a0b2f270dddc..2f8a5d3bbd57 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
-- 
2.29.2


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

* [PATCH v3 1/9] asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

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() and 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 <arnd@arndb.de>
---
 arch/arc/include/asm/uaccess.h     | 14 ++++++++++----
 arch/csky/include/asm/uaccess.h    |  8 ++++----
 arch/csky/lib/usercopy.c           | 14 ++++++++++----
 arch/hexagon/include/asm/uaccess.h | 22 +++++++++++++---------
 arch/um/include/asm/uaccess.h      |  8 ++++----
 arch/um/kernel/skas/uaccess.c      | 14 ++++++++++----
 include/asm-generic/uaccess.h      | 28 +++++++++++-----------------
 7 files changed, 62 insertions(+), 46 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/csky/include/asm/uaccess.h b/arch/csky/include/asm/uaccess.h
index ac83823fc437..e17c02a6709f 100644
--- a/arch/csky/include/asm/uaccess.h
+++ b/arch/csky/include/asm/uaccess.h
@@ -209,11 +209,11 @@ unsigned long raw_copy_to_user(void *to, const void *from, unsigned long n);
 unsigned long __clear_user(void __user *to, unsigned long n);
 #define __clear_user __clear_user
 
-long __strncpy_from_user(char *dst, const char *src, long count);
-#define __strncpy_from_user __strncpy_from_user
+long strncpy_from_user(char *dst, const char *src, long count);
+#define strncpy_from_user strncpy_from_user
 
-long __strnlen_user(const char *s, long n);
-#define __strnlen_user __strnlen_user
+long strnlen_user(const char *s, long n);
+#define strnlen_user strnlen_user
 
 #include <asm/segment.h>
 #include <asm-generic/uaccess.h>
diff --git a/arch/csky/lib/usercopy.c b/arch/csky/lib/usercopy.c
index c5d394a0ae78..938b750d2fb1 100644
--- a/arch/csky/lib/usercopy.c
+++ b/arch/csky/lib/usercopy.c
@@ -163,11 +163,14 @@ EXPORT_SYMBOL(raw_copy_to_user);
  * If @count is smaller than the length of the string, copies @count bytes
  * and returns @count.
  */
-long __strncpy_from_user(char *dst, const char *src, long count)
+long strncpy_from_user(char *dst, const char *src, long count)
 {
 	long res, faultres;
 	int tmp;
 
+	if (!access_ok(src, 1))
+		return -EFAULT;
+
 	__asm__ __volatile__(
 	"       cmpnei  %3, 0           \n"
 	"       bf      4f              \n"
@@ -198,7 +201,7 @@ long __strncpy_from_user(char *dst, const char *src, long count)
 
 	return res;
 }
-EXPORT_SYMBOL(__strncpy_from_user);
+EXPORT_SYMBOL(strncpy_from_user);
 
 /*
  * strnlen_user: - Get the size of a string in user space.
@@ -211,10 +214,13 @@ EXPORT_SYMBOL(__strncpy_from_user);
  * On exception, returns 0.
  * If the string is too long, returns a value greater than @n.
  */
-long __strnlen_user(const char *s, long n)
+long strnlen_user(const char *s, long n)
 {
 	unsigned long res, tmp;
 
+	if (!access_ok(src, 1))
+		return -EFAULT;
+
 	__asm__ __volatile__(
 	"       cmpnei  %1, 0           \n"
 	"       bf      3f              \n"
@@ -242,7 +248,7 @@ long __strnlen_user(const char *s, long n)
 
 	return res;
 }
-EXPORT_SYMBOL(__strnlen_user);
+EXPORT_SYMBOL(strnlen_user);
 
 /*
  * __clear_user: - Zero a block of memory in user space, with less checking.
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 <asm-generic/uaccess.h>
 
 /*  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 6c76df96e858..fc2c7e961e72 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -189,11 +189,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);
@@ -205,7 +208,7 @@ long __strncpy_from_user(char *dst, const char __user *src, long count)
 		return -EFAULT;
 	return strnlen(dst, count);
 }
-EXPORT_SYMBOL(__strncpy_from_user);
+EXPORT_SYMBOL(strncpy_from_user);
 
 static int clear_chunk(unsigned long addr, int len, void *unused)
 {
@@ -236,10 +239,13 @@ static int strnlen_chunk(unsigned long str, int len, void *arg)
 	return 0;
 }
 
-long __strnlen_user(const void __user *str, long len)
+long strnlen_user(const void __user *str, long len)
 {
 	int count = 0, n;
 
+	if (!access_ok(src, 1))
+		return -EFAULT;
+
 	if (uaccess_kernel())
 		return strnlen((__force char*)str, len) + 1;
 
@@ -248,7 +254,7 @@ long __strnlen_user(const void __user *str, long len)
 		return count + 1;
 	return 0;
 }
-EXPORT_SYMBOL(__strnlen_user);
+EXPORT_SYMBOL(strnlen_user);
 
 /**
  * arch_futex_atomic_op_inuser() - Atomic arithmetic operation with constant
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index a0b2f270dddc..2f8a5d3bbd57 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
-- 
2.29.2


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* [PATCH v3 1/9] asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

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() and 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 <arnd@arndb.de>
---
 arch/arc/include/asm/uaccess.h     | 14 ++++++++++----
 arch/csky/include/asm/uaccess.h    |  8 ++++----
 arch/csky/lib/usercopy.c           | 14 ++++++++++----
 arch/hexagon/include/asm/uaccess.h | 22 +++++++++++++---------
 arch/um/include/asm/uaccess.h      |  8 ++++----
 arch/um/kernel/skas/uaccess.c      | 14 ++++++++++----
 include/asm-generic/uaccess.h      | 28 +++++++++++-----------------
 7 files changed, 62 insertions(+), 46 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/csky/include/asm/uaccess.h b/arch/csky/include/asm/uaccess.h
index ac83823fc437..e17c02a6709f 100644
--- a/arch/csky/include/asm/uaccess.h
+++ b/arch/csky/include/asm/uaccess.h
@@ -209,11 +209,11 @@ unsigned long raw_copy_to_user(void *to, const void *from, unsigned long n);
 unsigned long __clear_user(void __user *to, unsigned long n);
 #define __clear_user __clear_user
 
-long __strncpy_from_user(char *dst, const char *src, long count);
-#define __strncpy_from_user __strncpy_from_user
+long strncpy_from_user(char *dst, const char *src, long count);
+#define strncpy_from_user strncpy_from_user
 
-long __strnlen_user(const char *s, long n);
-#define __strnlen_user __strnlen_user
+long strnlen_user(const char *s, long n);
+#define strnlen_user strnlen_user
 
 #include <asm/segment.h>
 #include <asm-generic/uaccess.h>
diff --git a/arch/csky/lib/usercopy.c b/arch/csky/lib/usercopy.c
index c5d394a0ae78..938b750d2fb1 100644
--- a/arch/csky/lib/usercopy.c
+++ b/arch/csky/lib/usercopy.c
@@ -163,11 +163,14 @@ EXPORT_SYMBOL(raw_copy_to_user);
  * If @count is smaller than the length of the string, copies @count bytes
  * and returns @count.
  */
-long __strncpy_from_user(char *dst, const char *src, long count)
+long strncpy_from_user(char *dst, const char *src, long count)
 {
 	long res, faultres;
 	int tmp;
 
+	if (!access_ok(src, 1))
+		return -EFAULT;
+
 	__asm__ __volatile__(
 	"       cmpnei  %3, 0           \n"
 	"       bf      4f              \n"
@@ -198,7 +201,7 @@ long __strncpy_from_user(char *dst, const char *src, long count)
 
 	return res;
 }
-EXPORT_SYMBOL(__strncpy_from_user);
+EXPORT_SYMBOL(strncpy_from_user);
 
 /*
  * strnlen_user: - Get the size of a string in user space.
@@ -211,10 +214,13 @@ EXPORT_SYMBOL(__strncpy_from_user);
  * On exception, returns 0.
  * If the string is too long, returns a value greater than @n.
  */
-long __strnlen_user(const char *s, long n)
+long strnlen_user(const char *s, long n)
 {
 	unsigned long res, tmp;
 
+	if (!access_ok(src, 1))
+		return -EFAULT;
+
 	__asm__ __volatile__(
 	"       cmpnei  %1, 0           \n"
 	"       bf      3f              \n"
@@ -242,7 +248,7 @@ long __strnlen_user(const char *s, long n)
 
 	return res;
 }
-EXPORT_SYMBOL(__strnlen_user);
+EXPORT_SYMBOL(strnlen_user);
 
 /*
  * __clear_user: - Zero a block of memory in user space, with less checking.
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 <asm-generic/uaccess.h>
 
 /*  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 6c76df96e858..fc2c7e961e72 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -189,11 +189,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);
@@ -205,7 +208,7 @@ long __strncpy_from_user(char *dst, const char __user *src, long count)
 		return -EFAULT;
 	return strnlen(dst, count);
 }
-EXPORT_SYMBOL(__strncpy_from_user);
+EXPORT_SYMBOL(strncpy_from_user);
 
 static int clear_chunk(unsigned long addr, int len, void *unused)
 {
@@ -236,10 +239,13 @@ static int strnlen_chunk(unsigned long str, int len, void *arg)
 	return 0;
 }
 
-long __strnlen_user(const void __user *str, long len)
+long strnlen_user(const void __user *str, long len)
 {
 	int count = 0, n;
 
+	if (!access_ok(src, 1))
+		return -EFAULT;
+
 	if (uaccess_kernel())
 		return strnlen((__force char*)str, len) + 1;
 
@@ -248,7 +254,7 @@ long __strnlen_user(const void __user *str, long len)
 		return count + 1;
 	return 0;
 }
-EXPORT_SYMBOL(__strnlen_user);
+EXPORT_SYMBOL(strnlen_user);
 
 /**
  * arch_futex_atomic_op_inuser() - Atomic arithmetic operation with constant
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index a0b2f270dddc..2f8a5d3bbd57 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
-- 
2.29.2

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

* [PATCH v3 1/9] asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato

From: Arnd Bergmann <arnd@arndb.de>

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() and 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 <arnd@arndb.de>
---
 arch/arc/include/asm/uaccess.h     | 14 ++++++++++----
 arch/csky/include/asm/uaccess.h    |  8 ++++----
 arch/csky/lib/usercopy.c           | 14 ++++++++++----
 arch/hexagon/include/asm/uaccess.h | 22 +++++++++++++---------
 arch/um/include/asm/uaccess.h      |  8 ++++----
 arch/um/kernel/skas/uaccess.c      | 14 ++++++++++----
 include/asm-generic/uaccess.h      | 28 +++++++++++-----------------
 7 files changed, 62 insertions(+), 46 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/csky/include/asm/uaccess.h b/arch/csky/include/asm/uaccess.h
index ac83823fc437..e17c02a6709f 100644
--- a/arch/csky/include/asm/uaccess.h
+++ b/arch/csky/include/asm/uaccess.h
@@ -209,11 +209,11 @@ unsigned long raw_copy_to_user(void *to, const void *from, unsigned long n);
 unsigned long __clear_user(void __user *to, unsigned long n);
 #define __clear_user __clear_user
 
-long __strncpy_from_user(char *dst, const char *src, long count);
-#define __strncpy_from_user __strncpy_from_user
+long strncpy_from_user(char *dst, const char *src, long count);
+#define strncpy_from_user strncpy_from_user
 
-long __strnlen_user(const char *s, long n);
-#define __strnlen_user __strnlen_user
+long strnlen_user(const char *s, long n);
+#define strnlen_user strnlen_user
 
 #include <asm/segment.h>
 #include <asm-generic/uaccess.h>
diff --git a/arch/csky/lib/usercopy.c b/arch/csky/lib/usercopy.c
index c5d394a0ae78..938b750d2fb1 100644
--- a/arch/csky/lib/usercopy.c
+++ b/arch/csky/lib/usercopy.c
@@ -163,11 +163,14 @@ EXPORT_SYMBOL(raw_copy_to_user);
  * If @count is smaller than the length of the string, copies @count bytes
  * and returns @count.
  */
-long __strncpy_from_user(char *dst, const char *src, long count)
+long strncpy_from_user(char *dst, const char *src, long count)
 {
 	long res, faultres;
 	int tmp;
 
+	if (!access_ok(src, 1))
+		return -EFAULT;
+
 	__asm__ __volatile__(
 	"       cmpnei  %3, 0           \n"
 	"       bf      4f              \n"
@@ -198,7 +201,7 @@ long __strncpy_from_user(char *dst, const char *src, long count)
 
 	return res;
 }
-EXPORT_SYMBOL(__strncpy_from_user);
+EXPORT_SYMBOL(strncpy_from_user);
 
 /*
  * strnlen_user: - Get the size of a string in user space.
@@ -211,10 +214,13 @@ EXPORT_SYMBOL(__strncpy_from_user);
  * On exception, returns 0.
  * If the string is too long, returns a value greater than @n.
  */
-long __strnlen_user(const char *s, long n)
+long strnlen_user(const char *s, long n)
 {
 	unsigned long res, tmp;
 
+	if (!access_ok(src, 1))
+		return -EFAULT;
+
 	__asm__ __volatile__(
 	"       cmpnei  %1, 0           \n"
 	"       bf      3f              \n"
@@ -242,7 +248,7 @@ long __strnlen_user(const char *s, long n)
 
 	return res;
 }
-EXPORT_SYMBOL(__strnlen_user);
+EXPORT_SYMBOL(strnlen_user);
 
 /*
  * __clear_user: - Zero a block of memory in user space, with less checking.
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 <asm-generic/uaccess.h>
 
 /*  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 6c76df96e858..fc2c7e961e72 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -189,11 +189,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);
@@ -205,7 +208,7 @@ long __strncpy_from_user(char *dst, const char __user *src, long count)
 		return -EFAULT;
 	return strnlen(dst, count);
 }
-EXPORT_SYMBOL(__strncpy_from_user);
+EXPORT_SYMBOL(strncpy_from_user);
 
 static int clear_chunk(unsigned long addr, int len, void *unused)
 {
@@ -236,10 +239,13 @@ static int strnlen_chunk(unsigned long str, int len, void *arg)
 	return 0;
 }
 
-long __strnlen_user(const void __user *str, long len)
+long strnlen_user(const void __user *str, long len)
 {
 	int count = 0, n;
 
+	if (!access_ok(src, 1))
+		return -EFAULT;
+
 	if (uaccess_kernel())
 		return strnlen((__force char*)str, len) + 1;
 
@@ -248,7 +254,7 @@ long __strnlen_user(const void __user *str, long len)
 		return count + 1;
 	return 0;
 }
-EXPORT_SYMBOL(__strnlen_user);
+EXPORT_SYMBOL(strnlen_user);
 
 /**
  * arch_futex_atomic_op_inuser() - Atomic arithmetic operation with constant
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index a0b2f270dddc..2f8a5d3bbd57 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
-- 
2.29.2


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

* [PATCH v3 2/9] h8300: remove stale strncpy_from_user
  2021-07-22 12:48 ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 12:48   ` Arnd Bergmann
  -1 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

This function is never called because h8300 uses the asm-generic
inline function version.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 <asm/linkage.h>
-
-	.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
-- 
2.29.2


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

* [PATCH v3 2/9] h8300: remove stale strncpy_from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

This function is never called because h8300 uses the asm-generic
inline function version.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 <asm/linkage.h>
-
-	.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
-- 
2.29.2


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* [PATCH v3 2/9] h8300: remove stale strncpy_from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

This function is never called because h8300 uses the asm-generic
inline function version.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 <asm/linkage.h>
-
-	.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
-- 
2.29.2

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

* [PATCH v3 2/9] h8300: remove stale strncpy_from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato

From: Arnd Bergmann <arnd@arndb.de>

This function is never called because h8300 uses the asm-generic
inline function version.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 <asm/linkage.h>
-
-	.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
-- 
2.29.2


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

* [PATCH v3 3/9] hexagon: use generic strncpy/strnlen from_user
  2021-07-22 12:48 ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 12:48   ` Arnd Bergmann
  -1 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Remove the hexagon implementation of strncpy/strnlen and instead use
the generic version.  The hexagon 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 <arnd@arndb.de>
---
 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 e5a852080730..3bf4845fed4b 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 <asm-generic/uaccess.h>
 
-/*  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
-- 
2.29.2


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

* [PATCH v3 3/9] hexagon: use generic strncpy/strnlen from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Remove the hexagon implementation of strncpy/strnlen and instead use
the generic version.  The hexagon 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 <arnd@arndb.de>
---
 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 e5a852080730..3bf4845fed4b 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 <asm-generic/uaccess.h>
 
-/*  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
-- 
2.29.2


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* [PATCH v3 3/9] hexagon: use generic strncpy/strnlen from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Remove the hexagon implementation of strncpy/strnlen and instead use
the generic version.  The hexagon 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 <arnd@arndb.de>
---
 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 e5a852080730..3bf4845fed4b 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 <asm-generic/uaccess.h>
 
-/*  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
-- 
2.29.2

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

* [PATCH v3 3/9] hexagon: use generic strncpy/strnlen from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato

From: Arnd Bergmann <arnd@arndb.de>

Remove the hexagon implementation of strncpy/strnlen and instead use
the generic version.  The hexagon 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 <arnd@arndb.de>
---
 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 e5a852080730..3bf4845fed4b 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 <asm-generic/uaccess.h>
 
-/*  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
-- 
2.29.2


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

* [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
  2021-07-22 12:48 ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 12:48   ` Arnd Bergmann
  -1 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Remove the arc implemenation of strncpy/strnlen and instead use the
generic versions.  The arc 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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 d8f51eb8963b..64e5f9366401 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 <asm/segment.h>
 #include <asm-generic/uaccess.h>
 
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
-- 
2.29.2


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

* [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Remove the arc implemenation of strncpy/strnlen and instead use the
generic versions.  The arc 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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 d8f51eb8963b..64e5f9366401 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 <asm/segment.h>
 #include <asm-generic/uaccess.h>
 
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
-- 
2.29.2


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Remove the arc implemenation of strncpy/strnlen and instead use the
generic versions.  The arc 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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 d8f51eb8963b..64e5f9366401 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 <asm/segment.h>
 #include <asm-generic/uaccess.h>
 
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
-- 
2.29.2

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

* [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato

From: Arnd Bergmann <arnd@arndb.de>

Remove the arc implemenation of strncpy/strnlen and instead use the
generic versions.  The arc 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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 d8f51eb8963b..64e5f9366401 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 <asm/segment.h>
 #include <asm-generic/uaccess.h>
 
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);

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

* [PATCH v3 5/9] csky: use generic strncpy/strnlen from_user
  2021-07-22 12:48 ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 12:48   ` Arnd Bergmann
  -1 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Remove the csky implemenation of strncpy/strnlen and instead use the
generic versions.  The csky version is fairly slow because it always does
byte accesses even for aligned data, and it lacks a checks for
user_addr_max().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/csky/Kconfig               |   2 +
 arch/csky/include/asm/uaccess.h |   6 --
 arch/csky/lib/usercopy.c        | 108 --------------------------------
 3 files changed, 2 insertions(+), 114 deletions(-)

diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 2716f6395ba7..5043e221ced4 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -35,6 +35,8 @@ config CSKY
 	select GENERIC_IRQ_MULTI_HANDLER
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_VDSO_32
 	select GENERIC_GETTIMEOFDAY
diff --git a/arch/csky/include/asm/uaccess.h b/arch/csky/include/asm/uaccess.h
index e17c02a6709f..c40f06ee8d3e 100644
--- a/arch/csky/include/asm/uaccess.h
+++ b/arch/csky/include/asm/uaccess.h
@@ -209,12 +209,6 @@ unsigned long raw_copy_to_user(void *to, const void *from, unsigned long n);
 unsigned long __clear_user(void __user *to, unsigned long n);
 #define __clear_user __clear_user
 
-long strncpy_from_user(char *dst, const char *src, long count);
-#define strncpy_from_user strncpy_from_user
-
-long strnlen_user(const char *s, long n);
-#define strnlen_user strnlen_user
-
 #include <asm/segment.h>
 #include <asm-generic/uaccess.h>
 
diff --git a/arch/csky/lib/usercopy.c b/arch/csky/lib/usercopy.c
index 938b750d2fb1..3c01c54421ca 100644
--- a/arch/csky/lib/usercopy.c
+++ b/arch/csky/lib/usercopy.c
@@ -142,114 +142,6 @@ unsigned long raw_copy_to_user(void *to, const void *from,
 }
 EXPORT_SYMBOL(raw_copy_to_user);
 
-/*
- * __strncpy_from_user: - Copy a NUL terminated string from userspace,
- * with less checking.
- * @dst:   Destination address, in kernel space.  This buffer must be at
- *         least @count bytes long.
- * @src:   Source address, in user space.
- * @count: Maximum number of bytes to copy, including the trailing NUL.
- *
- * Copies a NUL-terminated string from userspace to kernel space.
- * Caller must check the specified block with access_ok() before calling
- * this function.
- *
- * On success, returns the length of the string (not including the trailing
- * NUL).
- *
- * If access to userspace fails, returns -EFAULT (some data may have been
- * copied).
- *
- * If @count is smaller than the length of the string, copies @count bytes
- * and returns @count.
- */
-long strncpy_from_user(char *dst, const char *src, long count)
-{
-	long res, faultres;
-	int tmp;
-
-	if (!access_ok(src, 1))
-		return -EFAULT;
-
-	__asm__ __volatile__(
-	"       cmpnei  %3, 0           \n"
-	"       bf      4f              \n"
-	"1:     cmpnei  %1, 0          	\n"
-	"       bf      5f              \n"
-	"2:     ldb     %4, (%3, 0)     \n"
-	"       stb     %4, (%2, 0)     \n"
-	"       cmpnei  %4, 0           \n"
-	"       bf      3f              \n"
-	"       addi    %3,  1          \n"
-	"       addi    %2,  1          \n"
-	"       subi    %1,  1          \n"
-	"       br      1b              \n"
-	"3:     subu	%0, %1          \n"
-	"       br      5f              \n"
-	"4:     mov     %0, %5          \n"
-	"       br      5f              \n"
-	".section __ex_table, \"a\"     \n"
-	".align   2                     \n"
-	".long    2b, 4b                \n"
-	".previous                      \n"
-	"5:                             \n"
-	: "=r"(res), "=r"(count), "=r"(dst),
-	  "=r"(src), "=r"(tmp), "=r"(faultres)
-	: "5"(-EFAULT), "0"(count), "1"(count),
-	  "2"(dst), "3"(src)
-	: "memory");
-
-	return res;
-}
-EXPORT_SYMBOL(strncpy_from_user);
-
-/*
- * strnlen_user: - Get the size of a string in user space.
- * @str: The string to measure.
- * @n:   The maximum valid length
- *
- * Get the size of a NUL-terminated string in user space.
- *
- * Returns the size of the string INCLUDING the terminating NUL.
- * On exception, returns 0.
- * If the string is too long, returns a value greater than @n.
- */
-long strnlen_user(const char *s, long n)
-{
-	unsigned long res, tmp;
-
-	if (!access_ok(src, 1))
-		return -EFAULT;
-
-	__asm__ __volatile__(
-	"       cmpnei  %1, 0           \n"
-	"       bf      3f              \n"
-	"1:     cmpnei  %0, 0           \n"
-	"       bf      3f              \n"
-	"2:     ldb     %3, (%1, 0)     \n"
-	"       cmpnei  %3, 0           \n"
-	"       bf      3f              \n"
-	"       subi    %0,  1          \n"
-	"       addi    %1,  1          \n"
-	"       br      1b              \n"
-	"3:     subu    %2, %0          \n"
-	"       addi    %2,  1          \n"
-	"       br      5f              \n"
-	"4:     movi    %0, 0           \n"
-	"       br      5f              \n"
-	".section __ex_table, \"a\"     \n"
-	".align   2                     \n"
-	".long    2b, 4b                \n"
-	".previous                      \n"
-	"5:                             \n"
-	: "=r"(n), "=r"(s), "=r"(res), "=r"(tmp)
-	: "0"(n), "1"(s), "2"(n)
-	: "memory");
-
-	return res;
-}
-EXPORT_SYMBOL(strnlen_user);
-
 /*
  * __clear_user: - Zero a block of memory in user space, with less checking.
  * @to:   Destination address, in user space.
-- 
2.29.2


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

* [PATCH v3 5/9] csky: use generic strncpy/strnlen from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Remove the csky implemenation of strncpy/strnlen and instead use the
generic versions.  The csky version is fairly slow because it always does
byte accesses even for aligned data, and it lacks a checks for
user_addr_max().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/csky/Kconfig               |   2 +
 arch/csky/include/asm/uaccess.h |   6 --
 arch/csky/lib/usercopy.c        | 108 --------------------------------
 3 files changed, 2 insertions(+), 114 deletions(-)

diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 2716f6395ba7..5043e221ced4 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -35,6 +35,8 @@ config CSKY
 	select GENERIC_IRQ_MULTI_HANDLER
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_VDSO_32
 	select GENERIC_GETTIMEOFDAY
diff --git a/arch/csky/include/asm/uaccess.h b/arch/csky/include/asm/uaccess.h
index e17c02a6709f..c40f06ee8d3e 100644
--- a/arch/csky/include/asm/uaccess.h
+++ b/arch/csky/include/asm/uaccess.h
@@ -209,12 +209,6 @@ unsigned long raw_copy_to_user(void *to, const void *from, unsigned long n);
 unsigned long __clear_user(void __user *to, unsigned long n);
 #define __clear_user __clear_user
 
-long strncpy_from_user(char *dst, const char *src, long count);
-#define strncpy_from_user strncpy_from_user
-
-long strnlen_user(const char *s, long n);
-#define strnlen_user strnlen_user
-
 #include <asm/segment.h>
 #include <asm-generic/uaccess.h>
 
diff --git a/arch/csky/lib/usercopy.c b/arch/csky/lib/usercopy.c
index 938b750d2fb1..3c01c54421ca 100644
--- a/arch/csky/lib/usercopy.c
+++ b/arch/csky/lib/usercopy.c
@@ -142,114 +142,6 @@ unsigned long raw_copy_to_user(void *to, const void *from,
 }
 EXPORT_SYMBOL(raw_copy_to_user);
 
-/*
- * __strncpy_from_user: - Copy a NUL terminated string from userspace,
- * with less checking.
- * @dst:   Destination address, in kernel space.  This buffer must be at
- *         least @count bytes long.
- * @src:   Source address, in user space.
- * @count: Maximum number of bytes to copy, including the trailing NUL.
- *
- * Copies a NUL-terminated string from userspace to kernel space.
- * Caller must check the specified block with access_ok() before calling
- * this function.
- *
- * On success, returns the length of the string (not including the trailing
- * NUL).
- *
- * If access to userspace fails, returns -EFAULT (some data may have been
- * copied).
- *
- * If @count is smaller than the length of the string, copies @count bytes
- * and returns @count.
- */
-long strncpy_from_user(char *dst, const char *src, long count)
-{
-	long res, faultres;
-	int tmp;
-
-	if (!access_ok(src, 1))
-		return -EFAULT;
-
-	__asm__ __volatile__(
-	"       cmpnei  %3, 0           \n"
-	"       bf      4f              \n"
-	"1:     cmpnei  %1, 0          	\n"
-	"       bf      5f              \n"
-	"2:     ldb     %4, (%3, 0)     \n"
-	"       stb     %4, (%2, 0)     \n"
-	"       cmpnei  %4, 0           \n"
-	"       bf      3f              \n"
-	"       addi    %3,  1          \n"
-	"       addi    %2,  1          \n"
-	"       subi    %1,  1          \n"
-	"       br      1b              \n"
-	"3:     subu	%0, %1          \n"
-	"       br      5f              \n"
-	"4:     mov     %0, %5          \n"
-	"       br      5f              \n"
-	".section __ex_table, \"a\"     \n"
-	".align   2                     \n"
-	".long    2b, 4b                \n"
-	".previous                      \n"
-	"5:                             \n"
-	: "=r"(res), "=r"(count), "=r"(dst),
-	  "=r"(src), "=r"(tmp), "=r"(faultres)
-	: "5"(-EFAULT), "0"(count), "1"(count),
-	  "2"(dst), "3"(src)
-	: "memory");
-
-	return res;
-}
-EXPORT_SYMBOL(strncpy_from_user);
-
-/*
- * strnlen_user: - Get the size of a string in user space.
- * @str: The string to measure.
- * @n:   The maximum valid length
- *
- * Get the size of a NUL-terminated string in user space.
- *
- * Returns the size of the string INCLUDING the terminating NUL.
- * On exception, returns 0.
- * If the string is too long, returns a value greater than @n.
- */
-long strnlen_user(const char *s, long n)
-{
-	unsigned long res, tmp;
-
-	if (!access_ok(src, 1))
-		return -EFAULT;
-
-	__asm__ __volatile__(
-	"       cmpnei  %1, 0           \n"
-	"       bf      3f              \n"
-	"1:     cmpnei  %0, 0           \n"
-	"       bf      3f              \n"
-	"2:     ldb     %3, (%1, 0)     \n"
-	"       cmpnei  %3, 0           \n"
-	"       bf      3f              \n"
-	"       subi    %0,  1          \n"
-	"       addi    %1,  1          \n"
-	"       br      1b              \n"
-	"3:     subu    %2, %0          \n"
-	"       addi    %2,  1          \n"
-	"       br      5f              \n"
-	"4:     movi    %0, 0           \n"
-	"       br      5f              \n"
-	".section __ex_table, \"a\"     \n"
-	".align   2                     \n"
-	".long    2b, 4b                \n"
-	".previous                      \n"
-	"5:                             \n"
-	: "=r"(n), "=r"(s), "=r"(res), "=r"(tmp)
-	: "0"(n), "1"(s), "2"(n)
-	: "memory");
-
-	return res;
-}
-EXPORT_SYMBOL(strnlen_user);
-
 /*
  * __clear_user: - Zero a block of memory in user space, with less checking.
  * @to:   Destination address, in user space.
-- 
2.29.2


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* [PATCH v3 5/9] csky: use generic strncpy/strnlen from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Remove the csky implemenation of strncpy/strnlen and instead use the
generic versions.  The csky version is fairly slow because it always does
byte accesses even for aligned data, and it lacks a checks for
user_addr_max().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/csky/Kconfig               |   2 +
 arch/csky/include/asm/uaccess.h |   6 --
 arch/csky/lib/usercopy.c        | 108 --------------------------------
 3 files changed, 2 insertions(+), 114 deletions(-)

diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 2716f6395ba7..5043e221ced4 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -35,6 +35,8 @@ config CSKY
 	select GENERIC_IRQ_MULTI_HANDLER
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_VDSO_32
 	select GENERIC_GETTIMEOFDAY
diff --git a/arch/csky/include/asm/uaccess.h b/arch/csky/include/asm/uaccess.h
index e17c02a6709f..c40f06ee8d3e 100644
--- a/arch/csky/include/asm/uaccess.h
+++ b/arch/csky/include/asm/uaccess.h
@@ -209,12 +209,6 @@ unsigned long raw_copy_to_user(void *to, const void *from, unsigned long n);
 unsigned long __clear_user(void __user *to, unsigned long n);
 #define __clear_user __clear_user
 
-long strncpy_from_user(char *dst, const char *src, long count);
-#define strncpy_from_user strncpy_from_user
-
-long strnlen_user(const char *s, long n);
-#define strnlen_user strnlen_user
-
 #include <asm/segment.h>
 #include <asm-generic/uaccess.h>
 
diff --git a/arch/csky/lib/usercopy.c b/arch/csky/lib/usercopy.c
index 938b750d2fb1..3c01c54421ca 100644
--- a/arch/csky/lib/usercopy.c
+++ b/arch/csky/lib/usercopy.c
@@ -142,114 +142,6 @@ unsigned long raw_copy_to_user(void *to, const void *from,
 }
 EXPORT_SYMBOL(raw_copy_to_user);
 
-/*
- * __strncpy_from_user: - Copy a NUL terminated string from userspace,
- * with less checking.
- * @dst:   Destination address, in kernel space.  This buffer must be at
- *         least @count bytes long.
- * @src:   Source address, in user space.
- * @count: Maximum number of bytes to copy, including the trailing NUL.
- *
- * Copies a NUL-terminated string from userspace to kernel space.
- * Caller must check the specified block with access_ok() before calling
- * this function.
- *
- * On success, returns the length of the string (not including the trailing
- * NUL).
- *
- * If access to userspace fails, returns -EFAULT (some data may have been
- * copied).
- *
- * If @count is smaller than the length of the string, copies @count bytes
- * and returns @count.
- */
-long strncpy_from_user(char *dst, const char *src, long count)
-{
-	long res, faultres;
-	int tmp;
-
-	if (!access_ok(src, 1))
-		return -EFAULT;
-
-	__asm__ __volatile__(
-	"       cmpnei  %3, 0           \n"
-	"       bf      4f              \n"
-	"1:     cmpnei  %1, 0          	\n"
-	"       bf      5f              \n"
-	"2:     ldb     %4, (%3, 0)     \n"
-	"       stb     %4, (%2, 0)     \n"
-	"       cmpnei  %4, 0           \n"
-	"       bf      3f              \n"
-	"       addi    %3,  1          \n"
-	"       addi    %2,  1          \n"
-	"       subi    %1,  1          \n"
-	"       br      1b              \n"
-	"3:     subu	%0, %1          \n"
-	"       br      5f              \n"
-	"4:     mov     %0, %5          \n"
-	"       br      5f              \n"
-	".section __ex_table, \"a\"     \n"
-	".align   2                     \n"
-	".long    2b, 4b                \n"
-	".previous                      \n"
-	"5:                             \n"
-	: "=r"(res), "=r"(count), "=r"(dst),
-	  "=r"(src), "=r"(tmp), "=r"(faultres)
-	: "5"(-EFAULT), "0"(count), "1"(count),
-	  "2"(dst), "3"(src)
-	: "memory");
-
-	return res;
-}
-EXPORT_SYMBOL(strncpy_from_user);
-
-/*
- * strnlen_user: - Get the size of a string in user space.
- * @str: The string to measure.
- * @n:   The maximum valid length
- *
- * Get the size of a NUL-terminated string in user space.
- *
- * Returns the size of the string INCLUDING the terminating NUL.
- * On exception, returns 0.
- * If the string is too long, returns a value greater than @n.
- */
-long strnlen_user(const char *s, long n)
-{
-	unsigned long res, tmp;
-
-	if (!access_ok(src, 1))
-		return -EFAULT;
-
-	__asm__ __volatile__(
-	"       cmpnei  %1, 0           \n"
-	"       bf      3f              \n"
-	"1:     cmpnei  %0, 0           \n"
-	"       bf      3f              \n"
-	"2:     ldb     %3, (%1, 0)     \n"
-	"       cmpnei  %3, 0           \n"
-	"       bf      3f              \n"
-	"       subi    %0,  1          \n"
-	"       addi    %1,  1          \n"
-	"       br      1b              \n"
-	"3:     subu    %2, %0          \n"
-	"       addi    %2,  1          \n"
-	"       br      5f              \n"
-	"4:     movi    %0, 0           \n"
-	"       br      5f              \n"
-	".section __ex_table, \"a\"     \n"
-	".align   2                     \n"
-	".long    2b, 4b                \n"
-	".previous                      \n"
-	"5:                             \n"
-	: "=r"(n), "=r"(s), "=r"(res), "=r"(tmp)
-	: "0"(n), "1"(s), "2"(n)
-	: "memory");
-
-	return res;
-}
-EXPORT_SYMBOL(strnlen_user);
-
 /*
  * __clear_user: - Zero a block of memory in user space, with less checking.
  * @to:   Destination address, in user space.
-- 
2.29.2

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

* [PATCH v3 5/9] csky: use generic strncpy/strnlen from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato

From: Arnd Bergmann <arnd@arndb.de>

Remove the csky implemenation of strncpy/strnlen and instead use the
generic versions.  The csky version is fairly slow because it always does
byte accesses even for aligned data, and it lacks a checks for
user_addr_max().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/csky/Kconfig               |   2 +
 arch/csky/include/asm/uaccess.h |   6 --
 arch/csky/lib/usercopy.c        | 108 --------------------------------
 3 files changed, 2 insertions(+), 114 deletions(-)

diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 2716f6395ba7..5043e221ced4 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -35,6 +35,8 @@ config CSKY
 	select GENERIC_IRQ_MULTI_HANDLER
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_VDSO_32
 	select GENERIC_GETTIMEOFDAY
diff --git a/arch/csky/include/asm/uaccess.h b/arch/csky/include/asm/uaccess.h
index e17c02a6709f..c40f06ee8d3e 100644
--- a/arch/csky/include/asm/uaccess.h
+++ b/arch/csky/include/asm/uaccess.h
@@ -209,12 +209,6 @@ unsigned long raw_copy_to_user(void *to, const void *from, unsigned long n);
 unsigned long __clear_user(void __user *to, unsigned long n);
 #define __clear_user __clear_user
 
-long strncpy_from_user(char *dst, const char *src, long count);
-#define strncpy_from_user strncpy_from_user
-
-long strnlen_user(const char *s, long n);
-#define strnlen_user strnlen_user
-
 #include <asm/segment.h>
 #include <asm-generic/uaccess.h>
 
diff --git a/arch/csky/lib/usercopy.c b/arch/csky/lib/usercopy.c
index 938b750d2fb1..3c01c54421ca 100644
--- a/arch/csky/lib/usercopy.c
+++ b/arch/csky/lib/usercopy.c
@@ -142,114 +142,6 @@ unsigned long raw_copy_to_user(void *to, const void *from,
 }
 EXPORT_SYMBOL(raw_copy_to_user);
 
-/*
- * __strncpy_from_user: - Copy a NUL terminated string from userspace,
- * with less checking.
- * @dst:   Destination address, in kernel space.  This buffer must be at
- *         least @count bytes long.
- * @src:   Source address, in user space.
- * @count: Maximum number of bytes to copy, including the trailing NUL.
- *
- * Copies a NUL-terminated string from userspace to kernel space.
- * Caller must check the specified block with access_ok() before calling
- * this function.
- *
- * On success, returns the length of the string (not including the trailing
- * NUL).
- *
- * If access to userspace fails, returns -EFAULT (some data may have been
- * copied).
- *
- * If @count is smaller than the length of the string, copies @count bytes
- * and returns @count.
- */
-long strncpy_from_user(char *dst, const char *src, long count)
-{
-	long res, faultres;
-	int tmp;
-
-	if (!access_ok(src, 1))
-		return -EFAULT;
-
-	__asm__ __volatile__(
-	"       cmpnei  %3, 0           \n"
-	"       bf      4f              \n"
-	"1:     cmpnei  %1, 0          	\n"
-	"       bf      5f              \n"
-	"2:     ldb     %4, (%3, 0)     \n"
-	"       stb     %4, (%2, 0)     \n"
-	"       cmpnei  %4, 0           \n"
-	"       bf      3f              \n"
-	"       addi    %3,  1          \n"
-	"       addi    %2,  1          \n"
-	"       subi    %1,  1          \n"
-	"       br      1b              \n"
-	"3:     subu	%0, %1          \n"
-	"       br      5f              \n"
-	"4:     mov     %0, %5          \n"
-	"       br      5f              \n"
-	".section __ex_table, \"a\"     \n"
-	".align   2                     \n"
-	".long    2b, 4b                \n"
-	".previous                      \n"
-	"5:                             \n"
-	: "=r"(res), "=r"(count), "=r"(dst),
-	  "=r"(src), "=r"(tmp), "=r"(faultres)
-	: "5"(-EFAULT), "0"(count), "1"(count),
-	  "2"(dst), "3"(src)
-	: "memory");
-
-	return res;
-}
-EXPORT_SYMBOL(strncpy_from_user);
-
-/*
- * strnlen_user: - Get the size of a string in user space.
- * @str: The string to measure.
- * @n:   The maximum valid length
- *
- * Get the size of a NUL-terminated string in user space.
- *
- * Returns the size of the string INCLUDING the terminating NUL.
- * On exception, returns 0.
- * If the string is too long, returns a value greater than @n.
- */
-long strnlen_user(const char *s, long n)
-{
-	unsigned long res, tmp;
-
-	if (!access_ok(src, 1))
-		return -EFAULT;
-
-	__asm__ __volatile__(
-	"       cmpnei  %1, 0           \n"
-	"       bf      3f              \n"
-	"1:     cmpnei  %0, 0           \n"
-	"       bf      3f              \n"
-	"2:     ldb     %3, (%1, 0)     \n"
-	"       cmpnei  %3, 0           \n"
-	"       bf      3f              \n"
-	"       subi    %0,  1          \n"
-	"       addi    %1,  1          \n"
-	"       br      1b              \n"
-	"3:     subu    %2, %0          \n"
-	"       addi    %2,  1          \n"
-	"       br      5f              \n"
-	"4:     movi    %0, 0           \n"
-	"       br      5f              \n"
-	".section __ex_table, \"a\"     \n"
-	".align   2                     \n"
-	".long    2b, 4b                \n"
-	".previous                      \n"
-	"5:                             \n"
-	: "=r"(n), "=r"(s), "=r"(res), "=r"(tmp)
-	: "0"(n), "1"(s), "2"(n)
-	: "memory");
-
-	return res;
-}
-EXPORT_SYMBOL(strnlen_user);
-
 /*
  * __clear_user: - Zero a block of memory in user space, with less checking.
  * @to:   Destination address, in user space.
-- 
2.29.2


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

* [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
  2021-07-22 12:48 ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 12:48   ` Arnd Bergmann
  -1 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Remove the microblaze implemenation of strncpy/strnlen and instead use
the generic versions.  The microblaze version is fairly slow because it
always does byte accesses even for aligned data, and it lacks a checks
for user_addr_max().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/microblaze/Kconfig                   |  2 +
 arch/microblaze/include/asm/uaccess.h     | 19 +----
 arch/microblaze/kernel/microblaze_ksyms.c |  3 -
 arch/microblaze/lib/uaccess_old.S         | 90 -----------------------
 4 files changed, 4 insertions(+), 110 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 14a67a42fcae..10dfa7b4feff 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -21,6 +21,8 @@ config MICROBLAZE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index c44b59470e45..bbe39fe00461 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -296,28 +296,13 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
 /*
  * Copy a null terminated string from userspace.
  */
-extern int __strncpy_user(char *to, const char __user *from, int len);
-
-static inline long
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	if (!access_ok(src, 1))
-		return -EFAULT;
-	return __strncpy_user(dst, src, count);
-}
+extern long strncpy_from_user(char *dst, const char __user *src, long count);
 
 /*
  * Return the size of a string (including the ending 0)
  *
  * Return 0 on exception, a value greater than N if too long
  */
-extern int __strnlen_user(const char __user *sstr, int len);
-
-static inline long strnlen_user(const char __user *src, long n)
-{
-	if (!access_ok(src, 1))
-		return 0;
-	return __strnlen_user(src, n);
-}
+extern long strnlen_user(const char __user *sstr, int len);
 
 #endif /* _ASM_MICROBLAZE_UACCESS_H */
diff --git a/arch/microblaze/kernel/microblaze_ksyms.c b/arch/microblaze/kernel/microblaze_ksyms.c
index 303aaf13573b..14e0f2100c41 100644
--- a/arch/microblaze/kernel/microblaze_ksyms.c
+++ b/arch/microblaze/kernel/microblaze_ksyms.c
@@ -25,9 +25,6 @@ EXPORT_SYMBOL(_mcount);
 /*
  * Assembly functions that may be used (directly or indirectly) by modules
  */
-EXPORT_SYMBOL(__copy_tofrom_user);
-EXPORT_SYMBOL(__strncpy_user);
-
 #ifdef CONFIG_OPT_LIB_ASM
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
diff --git a/arch/microblaze/lib/uaccess_old.S b/arch/microblaze/lib/uaccess_old.S
index eca290090038..dd5f3bfbc2c5 100644
--- a/arch/microblaze/lib/uaccess_old.S
+++ b/arch/microblaze/lib/uaccess_old.S
@@ -12,96 +12,6 @@
 #include <linux/linkage.h>
 #include <asm/page.h>
 
-/*
- * int __strncpy_user(char *to, char *from, int len);
- *
- * Returns:
- *  -EFAULT  for an exception
- *  len      if we hit the buffer limit
- *  bytes copied
- */
-
-	.text
-.globl __strncpy_user;
-.type  __strncpy_user, @function
-.align 4;
-__strncpy_user:
-
-	/*
-	 * r5 - to
-	 * r6 - from
-	 * r7 - len
-	 * r3 - temp count
-	 * r4 - temp val
-	 */
-	beqid	r7,3f
-	addik	r3,r7,0		/* temp_count = len */
-1:
-	lbu	r4,r6,r0
-	beqid	r4,2f
-	sb	r4,r5,r0
-
-	addik	r5,r5,1
-	addik	r6,r6,1		/* delay slot */
-
-	addik	r3,r3,-1
-	bnei	r3,1b		/* break on len */
-2:
-	rsubk	r3,r3,r7	/* temp_count = len - temp_count */
-3:
-	rtsd	r15,8
-	nop
-	.size   __strncpy_user, . - __strncpy_user
-
-	.section	.fixup, "ax"
-	.align	2
-4:
-	brid	3b
-	addik	r3,r0, -EFAULT
-
-	.section	__ex_table, "a"
-	.word	1b,4b
-
-/*
- * int __strnlen_user(char __user *str, int maxlen);
- *
- * Returns:
- *  0 on error
- *  maxlen + 1  if no NUL byte found within maxlen bytes
- *  size of the string (including NUL byte)
- */
-
-	.text
-.globl __strnlen_user;
-.type  __strnlen_user, @function
-.align 4;
-__strnlen_user:
-	beqid	r6,3f
-	addik	r3,r6,0
-1:
-	lbu	r4,r5,r0
-	beqid	r4,2f		/* break on NUL */
-	addik	r3,r3,-1	/* delay slot */
-
-	bneid	r3,1b
-	addik	r5,r5,1		/* delay slot */
-
-	addik	r3,r3,-1	/* for break on len */
-2:
-	rsubk	r3,r3,r6
-3:
-	rtsd	r15,8
-	nop
-	.size   __strnlen_user, . - __strnlen_user
-
-	.section	.fixup,"ax"
-4:
-	brid	3b
-	addk	r3,r0,r0
-
-	.section	__ex_table,"a"
-	.word	1b,4b
-
 /* Loop unrolling for __copy_tofrom_user */
 #define COPY(offset)	\
 1:	lwi	r4 , r6, 0x0000 + offset;	\
-- 
2.29.2


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

* [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Remove the microblaze implemenation of strncpy/strnlen and instead use
the generic versions.  The microblaze version is fairly slow because it
always does byte accesses even for aligned data, and it lacks a checks
for user_addr_max().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/microblaze/Kconfig                   |  2 +
 arch/microblaze/include/asm/uaccess.h     | 19 +----
 arch/microblaze/kernel/microblaze_ksyms.c |  3 -
 arch/microblaze/lib/uaccess_old.S         | 90 -----------------------
 4 files changed, 4 insertions(+), 110 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 14a67a42fcae..10dfa7b4feff 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -21,6 +21,8 @@ config MICROBLAZE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index c44b59470e45..bbe39fe00461 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -296,28 +296,13 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
 /*
  * Copy a null terminated string from userspace.
  */
-extern int __strncpy_user(char *to, const char __user *from, int len);
-
-static inline long
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	if (!access_ok(src, 1))
-		return -EFAULT;
-	return __strncpy_user(dst, src, count);
-}
+extern long strncpy_from_user(char *dst, const char __user *src, long count);
 
 /*
  * Return the size of a string (including the ending 0)
  *
  * Return 0 on exception, a value greater than N if too long
  */
-extern int __strnlen_user(const char __user *sstr, int len);
-
-static inline long strnlen_user(const char __user *src, long n)
-{
-	if (!access_ok(src, 1))
-		return 0;
-	return __strnlen_user(src, n);
-}
+extern long strnlen_user(const char __user *sstr, int len);
 
 #endif /* _ASM_MICROBLAZE_UACCESS_H */
diff --git a/arch/microblaze/kernel/microblaze_ksyms.c b/arch/microblaze/kernel/microblaze_ksyms.c
index 303aaf13573b..14e0f2100c41 100644
--- a/arch/microblaze/kernel/microblaze_ksyms.c
+++ b/arch/microblaze/kernel/microblaze_ksyms.c
@@ -25,9 +25,6 @@ EXPORT_SYMBOL(_mcount);
 /*
  * Assembly functions that may be used (directly or indirectly) by modules
  */
-EXPORT_SYMBOL(__copy_tofrom_user);
-EXPORT_SYMBOL(__strncpy_user);
-
 #ifdef CONFIG_OPT_LIB_ASM
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
diff --git a/arch/microblaze/lib/uaccess_old.S b/arch/microblaze/lib/uaccess_old.S
index eca290090038..dd5f3bfbc2c5 100644
--- a/arch/microblaze/lib/uaccess_old.S
+++ b/arch/microblaze/lib/uaccess_old.S
@@ -12,96 +12,6 @@
 #include <linux/linkage.h>
 #include <asm/page.h>
 
-/*
- * int __strncpy_user(char *to, char *from, int len);
- *
- * Returns:
- *  -EFAULT  for an exception
- *  len      if we hit the buffer limit
- *  bytes copied
- */
-
-	.text
-.globl __strncpy_user;
-.type  __strncpy_user, @function
-.align 4;
-__strncpy_user:
-
-	/*
-	 * r5 - to
-	 * r6 - from
-	 * r7 - len
-	 * r3 - temp count
-	 * r4 - temp val
-	 */
-	beqid	r7,3f
-	addik	r3,r7,0		/* temp_count = len */
-1:
-	lbu	r4,r6,r0
-	beqid	r4,2f
-	sb	r4,r5,r0
-
-	addik	r5,r5,1
-	addik	r6,r6,1		/* delay slot */
-
-	addik	r3,r3,-1
-	bnei	r3,1b		/* break on len */
-2:
-	rsubk	r3,r3,r7	/* temp_count = len - temp_count */
-3:
-	rtsd	r15,8
-	nop
-	.size   __strncpy_user, . - __strncpy_user
-
-	.section	.fixup, "ax"
-	.align	2
-4:
-	brid	3b
-	addik	r3,r0, -EFAULT
-
-	.section	__ex_table, "a"
-	.word	1b,4b
-
-/*
- * int __strnlen_user(char __user *str, int maxlen);
- *
- * Returns:
- *  0 on error
- *  maxlen + 1  if no NUL byte found within maxlen bytes
- *  size of the string (including NUL byte)
- */
-
-	.text
-.globl __strnlen_user;
-.type  __strnlen_user, @function
-.align 4;
-__strnlen_user:
-	beqid	r6,3f
-	addik	r3,r6,0
-1:
-	lbu	r4,r5,r0
-	beqid	r4,2f		/* break on NUL */
-	addik	r3,r3,-1	/* delay slot */
-
-	bneid	r3,1b
-	addik	r5,r5,1		/* delay slot */
-
-	addik	r3,r3,-1	/* for break on len */
-2:
-	rsubk	r3,r3,r6
-3:
-	rtsd	r15,8
-	nop
-	.size   __strnlen_user, . - __strnlen_user
-
-	.section	.fixup,"ax"
-4:
-	brid	3b
-	addk	r3,r0,r0
-
-	.section	__ex_table,"a"
-	.word	1b,4b
-
 /* Loop unrolling for __copy_tofrom_user */
 #define COPY(offset)	\
 1:	lwi	r4 , r6, 0x0000 + offset;	\
-- 
2.29.2


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Remove the microblaze implemenation of strncpy/strnlen and instead use
the generic versions.  The microblaze version is fairly slow because it
always does byte accesses even for aligned data, and it lacks a checks
for user_addr_max().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/microblaze/Kconfig                   |  2 +
 arch/microblaze/include/asm/uaccess.h     | 19 +----
 arch/microblaze/kernel/microblaze_ksyms.c |  3 -
 arch/microblaze/lib/uaccess_old.S         | 90 -----------------------
 4 files changed, 4 insertions(+), 110 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 14a67a42fcae..10dfa7b4feff 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -21,6 +21,8 @@ config MICROBLAZE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index c44b59470e45..bbe39fe00461 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -296,28 +296,13 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
 /*
  * Copy a null terminated string from userspace.
  */
-extern int __strncpy_user(char *to, const char __user *from, int len);
-
-static inline long
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	if (!access_ok(src, 1))
-		return -EFAULT;
-	return __strncpy_user(dst, src, count);
-}
+extern long strncpy_from_user(char *dst, const char __user *src, long count);
 
 /*
  * Return the size of a string (including the ending 0)
  *
  * Return 0 on exception, a value greater than N if too long
  */
-extern int __strnlen_user(const char __user *sstr, int len);
-
-static inline long strnlen_user(const char __user *src, long n)
-{
-	if (!access_ok(src, 1))
-		return 0;
-	return __strnlen_user(src, n);
-}
+extern long strnlen_user(const char __user *sstr, int len);
 
 #endif /* _ASM_MICROBLAZE_UACCESS_H */
diff --git a/arch/microblaze/kernel/microblaze_ksyms.c b/arch/microblaze/kernel/microblaze_ksyms.c
index 303aaf13573b..14e0f2100c41 100644
--- a/arch/microblaze/kernel/microblaze_ksyms.c
+++ b/arch/microblaze/kernel/microblaze_ksyms.c
@@ -25,9 +25,6 @@ EXPORT_SYMBOL(_mcount);
 /*
  * Assembly functions that may be used (directly or indirectly) by modules
  */
-EXPORT_SYMBOL(__copy_tofrom_user);
-EXPORT_SYMBOL(__strncpy_user);
-
 #ifdef CONFIG_OPT_LIB_ASM
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
diff --git a/arch/microblaze/lib/uaccess_old.S b/arch/microblaze/lib/uaccess_old.S
index eca290090038..dd5f3bfbc2c5 100644
--- a/arch/microblaze/lib/uaccess_old.S
+++ b/arch/microblaze/lib/uaccess_old.S
@@ -12,96 +12,6 @@
 #include <linux/linkage.h>
 #include <asm/page.h>
 
-/*
- * int __strncpy_user(char *to, char *from, int len);
- *
- * Returns:
- *  -EFAULT  for an exception
- *  len      if we hit the buffer limit
- *  bytes copied
- */
-
-	.text
-.globl __strncpy_user;
-.type  __strncpy_user, @function
-.align 4;
-__strncpy_user:
-
-	/*
-	 * r5 - to
-	 * r6 - from
-	 * r7 - len
-	 * r3 - temp count
-	 * r4 - temp val
-	 */
-	beqid	r7,3f
-	addik	r3,r7,0		/* temp_count = len */
-1:
-	lbu	r4,r6,r0
-	beqid	r4,2f
-	sb	r4,r5,r0
-
-	addik	r5,r5,1
-	addik	r6,r6,1		/* delay slot */
-
-	addik	r3,r3,-1
-	bnei	r3,1b		/* break on len */
-2:
-	rsubk	r3,r3,r7	/* temp_count = len - temp_count */
-3:
-	rtsd	r15,8
-	nop
-	.size   __strncpy_user, . - __strncpy_user
-
-	.section	.fixup, "ax"
-	.align	2
-4:
-	brid	3b
-	addik	r3,r0, -EFAULT
-
-	.section	__ex_table, "a"
-	.word	1b,4b
-
-/*
- * int __strnlen_user(char __user *str, int maxlen);
- *
- * Returns:
- *  0 on error
- *  maxlen + 1  if no NUL byte found within maxlen bytes
- *  size of the string (including NUL byte)
- */
-
-	.text
-.globl __strnlen_user;
-.type  __strnlen_user, @function
-.align 4;
-__strnlen_user:
-	beqid	r6,3f
-	addik	r3,r6,0
-1:
-	lbu	r4,r5,r0
-	beqid	r4,2f		/* break on NUL */
-	addik	r3,r3,-1	/* delay slot */
-
-	bneid	r3,1b
-	addik	r5,r5,1		/* delay slot */
-
-	addik	r3,r3,-1	/* for break on len */
-2:
-	rsubk	r3,r3,r6
-3:
-	rtsd	r15,8
-	nop
-	.size   __strnlen_user, . - __strnlen_user
-
-	.section	.fixup,"ax"
-4:
-	brid	3b
-	addk	r3,r0,r0
-
-	.section	__ex_table,"a"
-	.word	1b,4b
-
 /* Loop unrolling for __copy_tofrom_user */
 #define COPY(offset)	\
 1:	lwi	r4 , r6, 0x0000 + offset;	\
-- 
2.29.2

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

* [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato

From: Arnd Bergmann <arnd@arndb.de>

Remove the microblaze implemenation of strncpy/strnlen and instead use
the generic versions.  The microblaze version is fairly slow because it
always does byte accesses even for aligned data, and it lacks a checks
for user_addr_max().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/microblaze/Kconfig                   |  2 +
 arch/microblaze/include/asm/uaccess.h     | 19 +----
 arch/microblaze/kernel/microblaze_ksyms.c |  3 -
 arch/microblaze/lib/uaccess_old.S         | 90 -----------------------
 4 files changed, 4 insertions(+), 110 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 14a67a42fcae..10dfa7b4feff 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -21,6 +21,8 @@ config MICROBLAZE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index c44b59470e45..bbe39fe00461 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -296,28 +296,13 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
 /*
  * Copy a null terminated string from userspace.
  */
-extern int __strncpy_user(char *to, const char __user *from, int len);
-
-static inline long
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	if (!access_ok(src, 1))
-		return -EFAULT;
-	return __strncpy_user(dst, src, count);
-}
+extern long strncpy_from_user(char *dst, const char __user *src, long count);
 
 /*
  * Return the size of a string (including the ending 0)
  *
  * Return 0 on exception, a value greater than N if too long
  */
-extern int __strnlen_user(const char __user *sstr, int len);
-
-static inline long strnlen_user(const char __user *src, long n)
-{
-	if (!access_ok(src, 1))
-		return 0;
-	return __strnlen_user(src, n);
-}
+extern long strnlen_user(const char __user *sstr, int len);
 
 #endif /* _ASM_MICROBLAZE_UACCESS_H */
diff --git a/arch/microblaze/kernel/microblaze_ksyms.c b/arch/microblaze/kernel/microblaze_ksyms.c
index 303aaf13573b..14e0f2100c41 100644
--- a/arch/microblaze/kernel/microblaze_ksyms.c
+++ b/arch/microblaze/kernel/microblaze_ksyms.c
@@ -25,9 +25,6 @@ EXPORT_SYMBOL(_mcount);
 /*
  * Assembly functions that may be used (directly or indirectly) by modules
  */
-EXPORT_SYMBOL(__copy_tofrom_user);
-EXPORT_SYMBOL(__strncpy_user);
-
 #ifdef CONFIG_OPT_LIB_ASM
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
diff --git a/arch/microblaze/lib/uaccess_old.S b/arch/microblaze/lib/uaccess_old.S
index eca290090038..dd5f3bfbc2c5 100644
--- a/arch/microblaze/lib/uaccess_old.S
+++ b/arch/microblaze/lib/uaccess_old.S
@@ -12,96 +12,6 @@
 #include <linux/linkage.h>
 #include <asm/page.h>
 
-/*
- * int __strncpy_user(char *to, char *from, int len);
- *
- * Returns:
- *  -EFAULT  for an exception
- *  len      if we hit the buffer limit
- *  bytes copied
- */
-
-	.text
-.globl __strncpy_user;
-.type  __strncpy_user, @function
-.align 4;
-__strncpy_user:
-
-	/*
-	 * r5 - to
-	 * r6 - from
-	 * r7 - len
-	 * r3 - temp count
-	 * r4 - temp val
-	 */
-	beqid	r7,3f
-	addik	r3,r7,0		/* temp_count = len */
-1:
-	lbu	r4,r6,r0
-	beqid	r4,2f
-	sb	r4,r5,r0
-
-	addik	r5,r5,1
-	addik	r6,r6,1		/* delay slot */
-
-	addik	r3,r3,-1
-	bnei	r3,1b		/* break on len */
-2:
-	rsubk	r3,r3,r7	/* temp_count = len - temp_count */
-3:
-	rtsd	r15,8
-	nop
-	.size   __strncpy_user, . - __strncpy_user
-
-	.section	.fixup, "ax"
-	.align	2
-4:
-	brid	3b
-	addik	r3,r0, -EFAULT
-
-	.section	__ex_table, "a"
-	.word	1b,4b
-
-/*
- * int __strnlen_user(char __user *str, int maxlen);
- *
- * Returns:
- *  0 on error
- *  maxlen + 1  if no NUL byte found within maxlen bytes
- *  size of the string (including NUL byte)
- */
-
-	.text
-.globl __strnlen_user;
-.type  __strnlen_user, @function
-.align 4;
-__strnlen_user:
-	beqid	r6,3f
-	addik	r3,r6,0
-1:
-	lbu	r4,r5,r0
-	beqid	r4,2f		/* break on NUL */
-	addik	r3,r3,-1	/* delay slot */
-
-	bneid	r3,1b
-	addik	r5,r5,1		/* delay slot */
-
-	addik	r3,r3,-1	/* for break on len */
-2:
-	rsubk	r3,r3,r6
-3:
-	rtsd	r15,8
-	nop
-	.size   __strnlen_user, . - __strnlen_user
-
-	.section	.fixup,"ax"
-4:
-	brid	3b
-	addk	r3,r0,r0
-
-	.section	__ex_table,"a"
-	.word	1b,4b
-
 /* Loop unrolling for __copy_tofrom_user */
 #define COPY(offset)	\
 1:	lwi	r4 , r6, 0x0000 + offset;	\
-- 
2.29.2


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

* [PATCH v3 7/9] asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
  2021-07-22 12:48 ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 12:48   ` Arnd Bergmann
  -1 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel,
	Geert Uytterhoeven

From: Arnd Bergmann <arnd@arndb.de>

The inline version is used on three NOMMU architectures and is
particularly inefficient when it scans the string one byte at a time
twice. It also lacks a check for user_addr_max(), but this is
probably ok on NOMMU targets.

Consolidate the asm-generic implementation with the library version
that is used everywhere else.  This version is generalized enough to
work efficiently on both MMU and NOMMU targets, and using the
same code everywhere reduces the potential for subtle bugs.

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 96989ad46f66..37a65bed6dfa 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -16,8 +16,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 8fcceb8eda07..47bbbcab91b2 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -56,8 +56,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 2f8a5d3bbd57..df60871ce2e8 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 <asm/extable.h>
 
+long strncpy_from_user(char *dst, const char __user *src, long count);
+long strnlen_user(const char __user *src, long n);
+
 #endif /* __ASM_GENERIC_UACCESS_H */
-- 
2.29.2


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

* [PATCH v3 7/9] asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel,
	Geert Uytterhoeven

From: Arnd Bergmann <arnd@arndb.de>

The inline version is used on three NOMMU architectures and is
particularly inefficient when it scans the string one byte at a time
twice. It also lacks a check for user_addr_max(), but this is
probably ok on NOMMU targets.

Consolidate the asm-generic implementation with the library version
that is used everywhere else.  This version is generalized enough to
work efficiently on both MMU and NOMMU targets, and using the
same code everywhere reduces the potential for subtle bugs.

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 96989ad46f66..37a65bed6dfa 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -16,8 +16,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 8fcceb8eda07..47bbbcab91b2 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -56,8 +56,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 2f8a5d3bbd57..df60871ce2e8 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 <asm/extable.h>
 
+long strncpy_from_user(char *dst, const char __user *src, long count);
+long strnlen_user(const char __user *src, long n);
+
 #endif /* __ASM_GENERIC_UACCESS_H */
-- 
2.29.2


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* [PATCH v3 7/9] asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel,
	Geert Uytterhoeven

From: Arnd Bergmann <arnd@arndb.de>

The inline version is used on three NOMMU architectures and is
particularly inefficient when it scans the string one byte at a time
twice. It also lacks a check for user_addr_max(), but this is
probably ok on NOMMU targets.

Consolidate the asm-generic implementation with the library version
that is used everywhere else.  This version is generalized enough to
work efficiently on both MMU and NOMMU targets, and using the
same code everywhere reduces the potential for subtle bugs.

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 96989ad46f66..37a65bed6dfa 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -16,8 +16,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 8fcceb8eda07..47bbbcab91b2 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -56,8 +56,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 2f8a5d3bbd57..df60871ce2e8 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 <asm/extable.h>
 
+long strncpy_from_user(char *dst, const char __user *src, long count);
+long strnlen_user(const char __user *src, long n);
+
 #endif /* __ASM_GENERIC_UACCESS_H */
-- 
2.29.2

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

* [PATCH v3 7/9] asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato

From: Arnd Bergmann <arnd@arndb.de>

The inline version is used on three NOMMU architectures and is
particularly inefficient when it scans the string one byte at a time
twice. It also lacks a check for user_addr_max(), but this is
probably ok on NOMMU targets.

Consolidate the asm-generic implementation with the library version
that is used everywhere else.  This version is generalized enough to
work efficiently on both MMU and NOMMU targets, and using the
same code everywhere reduces the potential for subtle bugs.

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 96989ad46f66..37a65bed6dfa 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -16,8 +16,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 8fcceb8eda07..47bbbcab91b2 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -56,8 +56,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 2f8a5d3bbd57..df60871ce2e8 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 <asm/extable.h>
 
+long strncpy_from_user(char *dst, const char __user *src, long count);
+long strnlen_user(const char __user *src, long n);
+
 #endif /* __ASM_GENERIC_UACCESS_H */
-- 
2.29.2


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

* [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from,len}_user declarations
  2021-07-22 12:48 ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 12:48   ` Arnd Bergmann
  -1 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

As these are now in asm-generic, it's no longer necessary to
declare them in the architecture.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 <asm/segment.h>
 #include <asm-generic/uaccess.h>
 
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 <asm-generic/uaccess.h>
 
 
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
 
-- 
2.29.2


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

* [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from, len}_user declarations
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

As these are now in asm-generic, it's no longer necessary to
declare them in the architecture.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 <asm/segment.h>
 #include <asm-generic/uaccess.h>
 
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 <asm-generic/uaccess.h>
 
 
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
 
-- 
2.29.2


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from,len}_user declarations
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

As these are now in asm-generic, it's no longer necessary to
declare them in the architecture.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 <asm/segment.h>
 #include <asm-generic/uaccess.h>
 
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 <asm-generic/uaccess.h>
 
 
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
 
-- 
2.29.2

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

* [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from,len}_user declarations
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato

From: Arnd Bergmann <arnd@arndb.de>

As these are now in asm-generic, it's no longer necessary to
declare them in the architecture.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 <asm/segment.h>
 #include <asm-generic/uaccess.h>
 
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 <asm-generic/uaccess.h>
 
 
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
 
-- 
2.29.2


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

* [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
  2021-07-22 12:48 ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 12:48   ` Arnd Bergmann
  -1 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Most architectures do not need a custom implementation, and in most
cases the generic implementation is preferred, so change the polariy
on these Kconfig symbols to require architectures to select them when
they provide their own version.

The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.

The remaining architectures at the moment are: ia64, mips, parisc,
s390, um and xtensa. We should probably convert these as well, but
I was not sure how far to take this series.

Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-mips@vger.kernel.org
Cc: linux-parisc@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linux-um@lists.infradead.org
Cc: linux-xtensa@linux-xtensa.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/alpha/Kconfig                |  2 --
 arch/arc/Kconfig                  |  2 --
 arch/arm/Kconfig                  |  2 --
 arch/arm64/Kconfig                |  2 --
 arch/csky/Kconfig                 |  2 --
 arch/h8300/Kconfig                |  2 --
 arch/hexagon/Kconfig              |  2 --
 arch/ia64/Kconfig                 |  2 ++
 arch/m68k/Kconfig                 |  2 --
 arch/microblaze/Kconfig           |  2 --
 arch/mips/Kconfig                 |  2 ++
 arch/nds32/Kconfig                |  2 --
 arch/nios2/Kconfig                |  2 --
 arch/openrisc/Kconfig             |  2 --
 arch/parisc/Kconfig               |  2 +-
 arch/powerpc/Kconfig              |  2 --
 arch/riscv/Kconfig                |  2 --
 arch/s390/Kconfig                 |  2 ++
 arch/sh/Kconfig                   |  2 --
 arch/sparc/Kconfig                |  2 --
 arch/um/Kconfig                   |  2 ++
 arch/x86/Kconfig                  |  2 --
 arch/xtensa/Kconfig               |  3 ++-
 arch/xtensa/include/asm/uaccess.h |  3 +--
 lib/Kconfig                       | 10 ++++++++--
 25 files changed, 20 insertions(+), 40 deletions(-)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 77d3280dc678..62935da8e69e 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -29,8 +29,6 @@ config ALPHA
 	select AUDIT_ARCH
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_MOD_ARCH_SPECIFIC
 	select MODULES_USE_ELF_RELA
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 64e5f9366401..d8f51eb8963b 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -27,8 +27,6 @@ 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/arm/Kconfig b/arch/arm/Kconfig
index 82f908fa5676..e8ebbb9ededf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -63,8 +63,6 @@ config ARM
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HANDLE_DOMAIN_IRQ
 	select HARDIRQS_SW_RESEND
 	select HAVE_ARCH_AUDITSYSCALL if AEABI && !OABI_COMPAT
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index b5b13a932561..e0c6c14a21d0 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -130,8 +130,6 @@ config ARM64
 	select GENERIC_PTDUMP
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_VDSO_TIME_NS
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 5043e221ced4..2716f6395ba7 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -35,8 +35,6 @@ config CSKY
 	select GENERIC_IRQ_MULTI_HANDLER
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_VDSO_32
 	select GENERIC_GETTIMEOFDAY
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 53dfd2d47e0e..3e3e0f16f7e0 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -11,8 +11,6 @@ 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/hexagon/Kconfig b/arch/hexagon/Kconfig
index 3bf4845fed4b..e5a852080730 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -19,8 +19,6 @@ 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/ia64/Kconfig b/arch/ia64/Kconfig
index cf425c2c63af..7aa5b94464c6 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -9,6 +9,8 @@ menu "Processor type and features"
 config IA64
 	bool
 	select ARCH_HAS_DMA_MARK_CLEAN
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_MIGHT_HAVE_PC_PARPORT
 	select ARCH_MIGHT_HAVE_PC_SERIO
 	select ACPI
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 37a65bed6dfa..7970d316dc9b 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -16,8 +16,6 @@ config M68K
 	select GENERIC_CPU_DEVICES
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_SHOW
-	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/microblaze/Kconfig b/arch/microblaze/Kconfig
index 10dfa7b4feff..14a67a42fcae 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -21,8 +21,6 @@ config MICROBLAZE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index cee6087cd686..22aa4d75fa34 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -12,6 +12,8 @@ config MIPS
 	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_GCOV_PROFILE_ALL
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_KEEP_MEMBLOCK
 	select ARCH_SUPPORTS_UPROBES
 	select ARCH_USE_BUILTIN_BSWAP
diff --git a/arch/nds32/Kconfig b/arch/nds32/Kconfig
index 62313902d75d..9c9f3877abf9 100644
--- a/arch/nds32/Kconfig
+++ b/arch/nds32/Kconfig
@@ -26,8 +26,6 @@ config NDS32
 	select GENERIC_LIB_LSHRDI3
 	select GENERIC_LIB_MULDI3
 	select GENERIC_LIB_UCMPDI2
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select HANDLE_DOMAIN_IRQ
 	select HAVE_ARCH_TRACEHOOK
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
index c24955c81c92..3efe5533ea1c 100644
--- a/arch/nios2/Kconfig
+++ b/arch/nios2/Kconfig
@@ -13,8 +13,6 @@ config NIOS2
 	select GENERIC_CPU_DEVICES
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_ARCH_KGDB
 	select IRQ_DOMAIN
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 591acc5990dc..50035a9816c8 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -25,8 +25,6 @@ config OPENRISC
 	select HAVE_UID16
 	select GENERIC_ATOMIC64
 	select GENERIC_CLOCKEVENTS_BROADCAST
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_SMP_IDLE_THREAD
 	select MODULES_USE_ELF_RELA
 	select HAVE_DEBUG_STACKOVERFLOW
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index bde9907bc5b2..727c823f866e 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -11,6 +11,7 @@ config PARISC
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_NO_SG_CHAIN
 	select ARCH_SUPPORTS_HUGETLBFS if PA20
 	select ARCH_SUPPORTS_MEMORY_FAILURE
@@ -34,7 +35,6 @@ config PARISC
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_CPU_DEVICES
-	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_LIB_DEVMEM_IS_ALLOWED
 	select SYSCTL_ARCH_UNALIGN_ALLOW
 	select SYSCTL_EXCEPTION_TRACE
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index d01e3401581d..d2df3d2db3eb 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -183,8 +183,6 @@ config PPC
 	select GENERIC_IRQ_SHOW_LEVEL
 	select GENERIC_PCI_IOMAP		if PCI
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_VDSO_TIME_NS
 	select HAVE_ARCH_AUDITSYSCALL
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 47bbbcab91b2..49d642df6ab9 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -56,8 +56,6 @@ config RISCV
 	select GENERIC_PTDUMP if MMU
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	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/arch/s390/Kconfig b/arch/s390/Kconfig
index a0e2130f0100..f4f39087cad0 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -75,6 +75,8 @@ config S390
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_HAS_SYSCALL_WRAPPER
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_VDSO_DATA
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 45a0549421cd..5d20509e5556 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -22,8 +22,6 @@ config SUPERH
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP if PCI
 	select GENERIC_SCHED_CLOCK
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_SMP_IDLE_THREAD
 	select GUP_GET_PTE_LOW_HIGH if X2TLB
 	select HAVE_ARCH_AUDITSYSCALL
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index c5fa7932b550..9f78822562eb 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -38,8 +38,6 @@ config SPARC
 	select HAVE_EBPF_JIT if SPARC64
 	select HAVE_DEBUG_BUGVERBOSE
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select MODULES_USE_ELF_RELA
 	select PCI_SYSCALL if PCI
 	select PCI_MSI_ARCH_FALLBACKS if PCI_MSI
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 0561b73cfd9a..77e66d3719f6 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -7,6 +7,8 @@ config UML
 	default y
 	select ARCH_EPHEMERAL_INODES
 	select ARCH_HAS_KCOV
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_NO_PREEMPT
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_SECCOMP_FILTER
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 49270655e827..5509c828bc93 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -144,8 +144,6 @@ config X86
 	select GENERIC_PENDING_IRQ		if SMP
 	select GENERIC_PTDUMP
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_VDSO_TIME_NS
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 2332b2156993..282fc195680e 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -7,6 +7,8 @@ config XTENSA
 	select ARCH_HAS_SYNC_DMA_FOR_CPU if MMU
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE if MMU
 	select ARCH_HAS_DMA_SET_UNCACHED if MMU
+	select ARCH_HAS_STRNCPY_FROM_USER if !KASAN
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_USE_MEMTEST
 	select ARCH_USE_QUEUED_RWLOCKS
 	select ARCH_USE_QUEUED_SPINLOCKS
@@ -20,7 +22,6 @@ config XTENSA
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
-	select GENERIC_STRNCPY_FROM_USER if KASAN
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
 	select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL
diff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/uaccess.h
index 5c9fb8005aa8..250ee68e9d82 100644
--- a/arch/xtensa/include/asm/uaccess.h
+++ b/arch/xtensa/include/asm/uaccess.h
@@ -290,8 +290,7 @@ clear_user(void __user *addr, unsigned long size)
 #define __clear_user  __xtensa_clear_user
 
 
-#ifndef CONFIG_GENERIC_STRNCPY_FROM_USER
-
+#ifdef CONFIG_HAS_STRNCPY_FROM_USER
 extern long __strncpy_user(char *dst, const char __user *src, long count);
 
 static inline long
diff --git a/lib/Kconfig b/lib/Kconfig
index d241fe476fda..0e66c9fa636b 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -50,12 +50,18 @@ config HAVE_ARCH_BITREVERSE
 	  This option enables the use of hardware bit-reversal instructions on
 	  architectures which support such operations.
 
-config GENERIC_STRNCPY_FROM_USER
+config ARCH_HAS_STRNCPY_FROM_USER
 	bool
 
-config GENERIC_STRNLEN_USER
+config ARCH_HAS_STRNLEN_USER
 	bool
 
+config GENERIC_STRNCPY_FROM_USER
+	def_bool !ARCH_HAS_STRNCPY_FROM_USER
+
+config GENERIC_STRNLEN_USER
+	def_bool !ARCH_HAS_STRNLEN_USER
+
 config GENERIC_NET_UTILS
 	bool
 
-- 
2.29.2


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

* [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Most architectures do not need a custom implementation, and in most
cases the generic implementation is preferred, so change the polariy
on these Kconfig symbols to require architectures to select them when
they provide their own version.

The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.

The remaining architectures at the moment are: ia64, mips, parisc,
s390, um and xtensa. We should probably convert these as well, but
I was not sure how far to take this series.

Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-mips@vger.kernel.org
Cc: linux-parisc@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linux-um@lists.infradead.org
Cc: linux-xtensa@linux-xtensa.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/alpha/Kconfig                |  2 --
 arch/arc/Kconfig                  |  2 --
 arch/arm/Kconfig                  |  2 --
 arch/arm64/Kconfig                |  2 --
 arch/csky/Kconfig                 |  2 --
 arch/h8300/Kconfig                |  2 --
 arch/hexagon/Kconfig              |  2 --
 arch/ia64/Kconfig                 |  2 ++
 arch/m68k/Kconfig                 |  2 --
 arch/microblaze/Kconfig           |  2 --
 arch/mips/Kconfig                 |  2 ++
 arch/nds32/Kconfig                |  2 --
 arch/nios2/Kconfig                |  2 --
 arch/openrisc/Kconfig             |  2 --
 arch/parisc/Kconfig               |  2 +-
 arch/powerpc/Kconfig              |  2 --
 arch/riscv/Kconfig                |  2 --
 arch/s390/Kconfig                 |  2 ++
 arch/sh/Kconfig                   |  2 --
 arch/sparc/Kconfig                |  2 --
 arch/um/Kconfig                   |  2 ++
 arch/x86/Kconfig                  |  2 --
 arch/xtensa/Kconfig               |  3 ++-
 arch/xtensa/include/asm/uaccess.h |  3 +--
 lib/Kconfig                       | 10 ++++++++--
 25 files changed, 20 insertions(+), 40 deletions(-)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 77d3280dc678..62935da8e69e 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -29,8 +29,6 @@ config ALPHA
 	select AUDIT_ARCH
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_MOD_ARCH_SPECIFIC
 	select MODULES_USE_ELF_RELA
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 64e5f9366401..d8f51eb8963b 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -27,8 +27,6 @@ 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/arm/Kconfig b/arch/arm/Kconfig
index 82f908fa5676..e8ebbb9ededf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -63,8 +63,6 @@ config ARM
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HANDLE_DOMAIN_IRQ
 	select HARDIRQS_SW_RESEND
 	select HAVE_ARCH_AUDITSYSCALL if AEABI && !OABI_COMPAT
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index b5b13a932561..e0c6c14a21d0 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -130,8 +130,6 @@ config ARM64
 	select GENERIC_PTDUMP
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_VDSO_TIME_NS
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 5043e221ced4..2716f6395ba7 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -35,8 +35,6 @@ config CSKY
 	select GENERIC_IRQ_MULTI_HANDLER
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_VDSO_32
 	select GENERIC_GETTIMEOFDAY
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 53dfd2d47e0e..3e3e0f16f7e0 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -11,8 +11,6 @@ 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/hexagon/Kconfig b/arch/hexagon/Kconfig
index 3bf4845fed4b..e5a852080730 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -19,8 +19,6 @@ 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/ia64/Kconfig b/arch/ia64/Kconfig
index cf425c2c63af..7aa5b94464c6 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -9,6 +9,8 @@ menu "Processor type and features"
 config IA64
 	bool
 	select ARCH_HAS_DMA_MARK_CLEAN
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_MIGHT_HAVE_PC_PARPORT
 	select ARCH_MIGHT_HAVE_PC_SERIO
 	select ACPI
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 37a65bed6dfa..7970d316dc9b 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -16,8 +16,6 @@ config M68K
 	select GENERIC_CPU_DEVICES
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_SHOW
-	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/microblaze/Kconfig b/arch/microblaze/Kconfig
index 10dfa7b4feff..14a67a42fcae 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -21,8 +21,6 @@ config MICROBLAZE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index cee6087cd686..22aa4d75fa34 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -12,6 +12,8 @@ config MIPS
 	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_GCOV_PROFILE_ALL
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_KEEP_MEMBLOCK
 	select ARCH_SUPPORTS_UPROBES
 	select ARCH_USE_BUILTIN_BSWAP
diff --git a/arch/nds32/Kconfig b/arch/nds32/Kconfig
index 62313902d75d..9c9f3877abf9 100644
--- a/arch/nds32/Kconfig
+++ b/arch/nds32/Kconfig
@@ -26,8 +26,6 @@ config NDS32
 	select GENERIC_LIB_LSHRDI3
 	select GENERIC_LIB_MULDI3
 	select GENERIC_LIB_UCMPDI2
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select HANDLE_DOMAIN_IRQ
 	select HAVE_ARCH_TRACEHOOK
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
index c24955c81c92..3efe5533ea1c 100644
--- a/arch/nios2/Kconfig
+++ b/arch/nios2/Kconfig
@@ -13,8 +13,6 @@ config NIOS2
 	select GENERIC_CPU_DEVICES
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_ARCH_KGDB
 	select IRQ_DOMAIN
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 591acc5990dc..50035a9816c8 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -25,8 +25,6 @@ config OPENRISC
 	select HAVE_UID16
 	select GENERIC_ATOMIC64
 	select GENERIC_CLOCKEVENTS_BROADCAST
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_SMP_IDLE_THREAD
 	select MODULES_USE_ELF_RELA
 	select HAVE_DEBUG_STACKOVERFLOW
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index bde9907bc5b2..727c823f866e 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -11,6 +11,7 @@ config PARISC
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_NO_SG_CHAIN
 	select ARCH_SUPPORTS_HUGETLBFS if PA20
 	select ARCH_SUPPORTS_MEMORY_FAILURE
@@ -34,7 +35,6 @@ config PARISC
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_CPU_DEVICES
-	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_LIB_DEVMEM_IS_ALLOWED
 	select SYSCTL_ARCH_UNALIGN_ALLOW
 	select SYSCTL_EXCEPTION_TRACE
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index d01e3401581d..d2df3d2db3eb 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -183,8 +183,6 @@ config PPC
 	select GENERIC_IRQ_SHOW_LEVEL
 	select GENERIC_PCI_IOMAP		if PCI
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_VDSO_TIME_NS
 	select HAVE_ARCH_AUDITSYSCALL
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 47bbbcab91b2..49d642df6ab9 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -56,8 +56,6 @@ config RISCV
 	select GENERIC_PTDUMP if MMU
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	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/arch/s390/Kconfig b/arch/s390/Kconfig
index a0e2130f0100..f4f39087cad0 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -75,6 +75,8 @@ config S390
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_HAS_SYSCALL_WRAPPER
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_VDSO_DATA
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 45a0549421cd..5d20509e5556 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -22,8 +22,6 @@ config SUPERH
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP if PCI
 	select GENERIC_SCHED_CLOCK
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_SMP_IDLE_THREAD
 	select GUP_GET_PTE_LOW_HIGH if X2TLB
 	select HAVE_ARCH_AUDITSYSCALL
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index c5fa7932b550..9f78822562eb 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -38,8 +38,6 @@ config SPARC
 	select HAVE_EBPF_JIT if SPARC64
 	select HAVE_DEBUG_BUGVERBOSE
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select MODULES_USE_ELF_RELA
 	select PCI_SYSCALL if PCI
 	select PCI_MSI_ARCH_FALLBACKS if PCI_MSI
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 0561b73cfd9a..77e66d3719f6 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -7,6 +7,8 @@ config UML
 	default y
 	select ARCH_EPHEMERAL_INODES
 	select ARCH_HAS_KCOV
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_NO_PREEMPT
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_SECCOMP_FILTER
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 49270655e827..5509c828bc93 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -144,8 +144,6 @@ config X86
 	select GENERIC_PENDING_IRQ		if SMP
 	select GENERIC_PTDUMP
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_VDSO_TIME_NS
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 2332b2156993..282fc195680e 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -7,6 +7,8 @@ config XTENSA
 	select ARCH_HAS_SYNC_DMA_FOR_CPU if MMU
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE if MMU
 	select ARCH_HAS_DMA_SET_UNCACHED if MMU
+	select ARCH_HAS_STRNCPY_FROM_USER if !KASAN
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_USE_MEMTEST
 	select ARCH_USE_QUEUED_RWLOCKS
 	select ARCH_USE_QUEUED_SPINLOCKS
@@ -20,7 +22,6 @@ config XTENSA
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
-	select GENERIC_STRNCPY_FROM_USER if KASAN
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
 	select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL
diff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/uaccess.h
index 5c9fb8005aa8..250ee68e9d82 100644
--- a/arch/xtensa/include/asm/uaccess.h
+++ b/arch/xtensa/include/asm/uaccess.h
@@ -290,8 +290,7 @@ clear_user(void __user *addr, unsigned long size)
 #define __clear_user  __xtensa_clear_user
 
 
-#ifndef CONFIG_GENERIC_STRNCPY_FROM_USER
-
+#ifdef CONFIG_HAS_STRNCPY_FROM_USER
 extern long __strncpy_user(char *dst, const char __user *src, long count);
 
 static inline long
diff --git a/lib/Kconfig b/lib/Kconfig
index d241fe476fda..0e66c9fa636b 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -50,12 +50,18 @@ config HAVE_ARCH_BITREVERSE
 	  This option enables the use of hardware bit-reversal instructions on
 	  architectures which support such operations.
 
-config GENERIC_STRNCPY_FROM_USER
+config ARCH_HAS_STRNCPY_FROM_USER
 	bool
 
-config GENERIC_STRNLEN_USER
+config ARCH_HAS_STRNLEN_USER
 	bool
 
+config GENERIC_STRNCPY_FROM_USER
+	def_bool !ARCH_HAS_STRNCPY_FROM_USER
+
+config GENERIC_STRNLEN_USER
+	def_bool !ARCH_HAS_STRNLEN_USER
+
 config GENERIC_NET_UTILS
 	bool
 
-- 
2.29.2


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

From: Arnd Bergmann <arnd@arndb.de>

Most architectures do not need a custom implementation, and in most
cases the generic implementation is preferred, so change the polariy
on these Kconfig symbols to require architectures to select them when
they provide their own version.

The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.

The remaining architectures at the moment are: ia64, mips, parisc,
s390, um and xtensa. We should probably convert these as well, but
I was not sure how far to take this series.

Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-mips@vger.kernel.org
Cc: linux-parisc@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linux-um@lists.infradead.org
Cc: linux-xtensa@linux-xtensa.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/alpha/Kconfig                |  2 --
 arch/arc/Kconfig                  |  2 --
 arch/arm/Kconfig                  |  2 --
 arch/arm64/Kconfig                |  2 --
 arch/csky/Kconfig                 |  2 --
 arch/h8300/Kconfig                |  2 --
 arch/hexagon/Kconfig              |  2 --
 arch/ia64/Kconfig                 |  2 ++
 arch/m68k/Kconfig                 |  2 --
 arch/microblaze/Kconfig           |  2 --
 arch/mips/Kconfig                 |  2 ++
 arch/nds32/Kconfig                |  2 --
 arch/nios2/Kconfig                |  2 --
 arch/openrisc/Kconfig             |  2 --
 arch/parisc/Kconfig               |  2 +-
 arch/powerpc/Kconfig              |  2 --
 arch/riscv/Kconfig                |  2 --
 arch/s390/Kconfig                 |  2 ++
 arch/sh/Kconfig                   |  2 --
 arch/sparc/Kconfig                |  2 --
 arch/um/Kconfig                   |  2 ++
 arch/x86/Kconfig                  |  2 --
 arch/xtensa/Kconfig               |  3 ++-
 arch/xtensa/include/asm/uaccess.h |  3 +--
 lib/Kconfig                       | 10 ++++++++--
 25 files changed, 20 insertions(+), 40 deletions(-)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 77d3280dc678..62935da8e69e 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -29,8 +29,6 @@ config ALPHA
 	select AUDIT_ARCH
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_MOD_ARCH_SPECIFIC
 	select MODULES_USE_ELF_RELA
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 64e5f9366401..d8f51eb8963b 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -27,8 +27,6 @@ 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/arm/Kconfig b/arch/arm/Kconfig
index 82f908fa5676..e8ebbb9ededf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -63,8 +63,6 @@ config ARM
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HANDLE_DOMAIN_IRQ
 	select HARDIRQS_SW_RESEND
 	select HAVE_ARCH_AUDITSYSCALL if AEABI && !OABI_COMPAT
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index b5b13a932561..e0c6c14a21d0 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -130,8 +130,6 @@ config ARM64
 	select GENERIC_PTDUMP
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_VDSO_TIME_NS
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 5043e221ced4..2716f6395ba7 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -35,8 +35,6 @@ config CSKY
 	select GENERIC_IRQ_MULTI_HANDLER
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_VDSO_32
 	select GENERIC_GETTIMEOFDAY
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 53dfd2d47e0e..3e3e0f16f7e0 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -11,8 +11,6 @@ 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/hexagon/Kconfig b/arch/hexagon/Kconfig
index 3bf4845fed4b..e5a852080730 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -19,8 +19,6 @@ 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/ia64/Kconfig b/arch/ia64/Kconfig
index cf425c2c63af..7aa5b94464c6 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -9,6 +9,8 @@ menu "Processor type and features"
 config IA64
 	bool
 	select ARCH_HAS_DMA_MARK_CLEAN
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_MIGHT_HAVE_PC_PARPORT
 	select ARCH_MIGHT_HAVE_PC_SERIO
 	select ACPI
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 37a65bed6dfa..7970d316dc9b 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -16,8 +16,6 @@ config M68K
 	select GENERIC_CPU_DEVICES
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_SHOW
-	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/microblaze/Kconfig b/arch/microblaze/Kconfig
index 10dfa7b4feff..14a67a42fcae 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -21,8 +21,6 @@ config MICROBLAZE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index cee6087cd686..22aa4d75fa34 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -12,6 +12,8 @@ config MIPS
 	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_GCOV_PROFILE_ALL
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_KEEP_MEMBLOCK
 	select ARCH_SUPPORTS_UPROBES
 	select ARCH_USE_BUILTIN_BSWAP
diff --git a/arch/nds32/Kconfig b/arch/nds32/Kconfig
index 62313902d75d..9c9f3877abf9 100644
--- a/arch/nds32/Kconfig
+++ b/arch/nds32/Kconfig
@@ -26,8 +26,6 @@ config NDS32
 	select GENERIC_LIB_LSHRDI3
 	select GENERIC_LIB_MULDI3
 	select GENERIC_LIB_UCMPDI2
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select HANDLE_DOMAIN_IRQ
 	select HAVE_ARCH_TRACEHOOK
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
index c24955c81c92..3efe5533ea1c 100644
--- a/arch/nios2/Kconfig
+++ b/arch/nios2/Kconfig
@@ -13,8 +13,6 @@ config NIOS2
 	select GENERIC_CPU_DEVICES
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_ARCH_KGDB
 	select IRQ_DOMAIN
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 591acc5990dc..50035a9816c8 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -25,8 +25,6 @@ config OPENRISC
 	select HAVE_UID16
 	select GENERIC_ATOMIC64
 	select GENERIC_CLOCKEVENTS_BROADCAST
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_SMP_IDLE_THREAD
 	select MODULES_USE_ELF_RELA
 	select HAVE_DEBUG_STACKOVERFLOW
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index bde9907bc5b2..727c823f866e 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -11,6 +11,7 @@ config PARISC
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_NO_SG_CHAIN
 	select ARCH_SUPPORTS_HUGETLBFS if PA20
 	select ARCH_SUPPORTS_MEMORY_FAILURE
@@ -34,7 +35,6 @@ config PARISC
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_CPU_DEVICES
-	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_LIB_DEVMEM_IS_ALLOWED
 	select SYSCTL_ARCH_UNALIGN_ALLOW
 	select SYSCTL_EXCEPTION_TRACE
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index d01e3401581d..d2df3d2db3eb 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -183,8 +183,6 @@ config PPC
 	select GENERIC_IRQ_SHOW_LEVEL
 	select GENERIC_PCI_IOMAP		if PCI
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_VDSO_TIME_NS
 	select HAVE_ARCH_AUDITSYSCALL
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 47bbbcab91b2..49d642df6ab9 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -56,8 +56,6 @@ config RISCV
 	select GENERIC_PTDUMP if MMU
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	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/arch/s390/Kconfig b/arch/s390/Kconfig
index a0e2130f0100..f4f39087cad0 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -75,6 +75,8 @@ config S390
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_HAS_SYSCALL_WRAPPER
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_VDSO_DATA
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 45a0549421cd..5d20509e5556 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -22,8 +22,6 @@ config SUPERH
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP if PCI
 	select GENERIC_SCHED_CLOCK
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_SMP_IDLE_THREAD
 	select GUP_GET_PTE_LOW_HIGH if X2TLB
 	select HAVE_ARCH_AUDITSYSCALL
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index c5fa7932b550..9f78822562eb 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -38,8 +38,6 @@ config SPARC
 	select HAVE_EBPF_JIT if SPARC64
 	select HAVE_DEBUG_BUGVERBOSE
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select MODULES_USE_ELF_RELA
 	select PCI_SYSCALL if PCI
 	select PCI_MSI_ARCH_FALLBACKS if PCI_MSI
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 0561b73cfd9a..77e66d3719f6 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -7,6 +7,8 @@ config UML
 	default y
 	select ARCH_EPHEMERAL_INODES
 	select ARCH_HAS_KCOV
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_NO_PREEMPT
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_SECCOMP_FILTER
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 49270655e827..5509c828bc93 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -144,8 +144,6 @@ config X86
 	select GENERIC_PENDING_IRQ		if SMP
 	select GENERIC_PTDUMP
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_VDSO_TIME_NS
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 2332b2156993..282fc195680e 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -7,6 +7,8 @@ config XTENSA
 	select ARCH_HAS_SYNC_DMA_FOR_CPU if MMU
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE if MMU
 	select ARCH_HAS_DMA_SET_UNCACHED if MMU
+	select ARCH_HAS_STRNCPY_FROM_USER if !KASAN
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_USE_MEMTEST
 	select ARCH_USE_QUEUED_RWLOCKS
 	select ARCH_USE_QUEUED_SPINLOCKS
@@ -20,7 +22,6 @@ config XTENSA
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
-	select GENERIC_STRNCPY_FROM_USER if KASAN
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
 	select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL
diff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/uaccess.h
index 5c9fb8005aa8..250ee68e9d82 100644
--- a/arch/xtensa/include/asm/uaccess.h
+++ b/arch/xtensa/include/asm/uaccess.h
@@ -290,8 +290,7 @@ clear_user(void __user *addr, unsigned long size)
 #define __clear_user  __xtensa_clear_user
 
 
-#ifndef CONFIG_GENERIC_STRNCPY_FROM_USER
-
+#ifdef CONFIG_HAS_STRNCPY_FROM_USER
 extern long __strncpy_user(char *dst, const char __user *src, long count);
 
 static inline long
diff --git a/lib/Kconfig b/lib/Kconfig
index d241fe476fda..0e66c9fa636b 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -50,12 +50,18 @@ config HAVE_ARCH_BITREVERSE
 	  This option enables the use of hardware bit-reversal instructions on
 	  architectures which support such operations.
 
-config GENERIC_STRNCPY_FROM_USER
+config ARCH_HAS_STRNCPY_FROM_USER
 	bool
 
-config GENERIC_STRNLEN_USER
+config ARCH_HAS_STRNLEN_USER
 	bool
 
+config GENERIC_STRNCPY_FROM_USER
+	def_bool !ARCH_HAS_STRNCPY_FROM_USER
+
+config GENERIC_STRNLEN_USER
+	def_bool !ARCH_HAS_STRNLEN_USER
+
 config GENERIC_NET_UTILS
 	bool
 
-- 
2.29.2

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

* [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
@ 2021-07-22 12:48   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 12:48 UTC (permalink / raw)
  To: linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato

From: Arnd Bergmann <arnd@arndb.de>

Most architectures do not need a custom implementation, and in most
cases the generic implementation is preferred, so change the polariy
on these Kconfig symbols to require architectures to select them when
they provide their own version.

The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.

The remaining architectures at the moment are: ia64, mips, parisc,
s390, um and xtensa. We should probably convert these as well, but
I was not sure how far to take this series.

Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-mips@vger.kernel.org
Cc: linux-parisc@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linux-um@lists.infradead.org
Cc: linux-xtensa@linux-xtensa.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/alpha/Kconfig                |  2 --
 arch/arc/Kconfig                  |  2 --
 arch/arm/Kconfig                  |  2 --
 arch/arm64/Kconfig                |  2 --
 arch/csky/Kconfig                 |  2 --
 arch/h8300/Kconfig                |  2 --
 arch/hexagon/Kconfig              |  2 --
 arch/ia64/Kconfig                 |  2 ++
 arch/m68k/Kconfig                 |  2 --
 arch/microblaze/Kconfig           |  2 --
 arch/mips/Kconfig                 |  2 ++
 arch/nds32/Kconfig                |  2 --
 arch/nios2/Kconfig                |  2 --
 arch/openrisc/Kconfig             |  2 --
 arch/parisc/Kconfig               |  2 +-
 arch/powerpc/Kconfig              |  2 --
 arch/riscv/Kconfig                |  2 --
 arch/s390/Kconfig                 |  2 ++
 arch/sh/Kconfig                   |  2 --
 arch/sparc/Kconfig                |  2 --
 arch/um/Kconfig                   |  2 ++
 arch/x86/Kconfig                  |  2 --
 arch/xtensa/Kconfig               |  3 ++-
 arch/xtensa/include/asm/uaccess.h |  3 +--
 lib/Kconfig                       | 10 ++++++++--
 25 files changed, 20 insertions(+), 40 deletions(-)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 77d3280dc678..62935da8e69e 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -29,8 +29,6 @@ config ALPHA
 	select AUDIT_ARCH
 	select GENERIC_CPU_VULNERABILITIES
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_MOD_ARCH_SPECIFIC
 	select MODULES_USE_ELF_RELA
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 64e5f9366401..d8f51eb8963b 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -27,8 +27,6 @@ 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/arm/Kconfig b/arch/arm/Kconfig
index 82f908fa5676..e8ebbb9ededf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -63,8 +63,6 @@ config ARM
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HANDLE_DOMAIN_IRQ
 	select HARDIRQS_SW_RESEND
 	select HAVE_ARCH_AUDITSYSCALL if AEABI && !OABI_COMPAT
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index b5b13a932561..e0c6c14a21d0 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -130,8 +130,6 @@ config ARM64
 	select GENERIC_PTDUMP
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_VDSO_TIME_NS
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 5043e221ced4..2716f6395ba7 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -35,8 +35,6 @@ config CSKY
 	select GENERIC_IRQ_MULTI_HANDLER
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_VDSO_32
 	select GENERIC_GETTIMEOFDAY
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 53dfd2d47e0e..3e3e0f16f7e0 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -11,8 +11,6 @@ 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/hexagon/Kconfig b/arch/hexagon/Kconfig
index 3bf4845fed4b..e5a852080730 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -19,8 +19,6 @@ 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/ia64/Kconfig b/arch/ia64/Kconfig
index cf425c2c63af..7aa5b94464c6 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -9,6 +9,8 @@ menu "Processor type and features"
 config IA64
 	bool
 	select ARCH_HAS_DMA_MARK_CLEAN
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_MIGHT_HAVE_PC_PARPORT
 	select ARCH_MIGHT_HAVE_PC_SERIO
 	select ACPI
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 37a65bed6dfa..7970d316dc9b 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -16,8 +16,6 @@ config M68K
 	select GENERIC_CPU_DEVICES
 	select GENERIC_IOMAP
 	select GENERIC_IRQ_SHOW
-	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/microblaze/Kconfig b/arch/microblaze/Kconfig
index 10dfa7b4feff..14a67a42fcae 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -21,8 +21,6 @@ config MICROBLAZE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index cee6087cd686..22aa4d75fa34 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -12,6 +12,8 @@ config MIPS
 	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_GCOV_PROFILE_ALL
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_KEEP_MEMBLOCK
 	select ARCH_SUPPORTS_UPROBES
 	select ARCH_USE_BUILTIN_BSWAP
diff --git a/arch/nds32/Kconfig b/arch/nds32/Kconfig
index 62313902d75d..9c9f3877abf9 100644
--- a/arch/nds32/Kconfig
+++ b/arch/nds32/Kconfig
@@ -26,8 +26,6 @@ config NDS32
 	select GENERIC_LIB_LSHRDI3
 	select GENERIC_LIB_MULDI3
 	select GENERIC_LIB_UCMPDI2
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select HANDLE_DOMAIN_IRQ
 	select HAVE_ARCH_TRACEHOOK
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
index c24955c81c92..3efe5533ea1c 100644
--- a/arch/nios2/Kconfig
+++ b/arch/nios2/Kconfig
@@ -13,8 +13,6 @@ config NIOS2
 	select GENERIC_CPU_DEVICES
 	select GENERIC_IRQ_PROBE
 	select GENERIC_IRQ_SHOW
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_TRACEHOOK
 	select HAVE_ARCH_KGDB
 	select IRQ_DOMAIN
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 591acc5990dc..50035a9816c8 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -25,8 +25,6 @@ config OPENRISC
 	select HAVE_UID16
 	select GENERIC_ATOMIC64
 	select GENERIC_CLOCKEVENTS_BROADCAST
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_SMP_IDLE_THREAD
 	select MODULES_USE_ELF_RELA
 	select HAVE_DEBUG_STACKOVERFLOW
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index bde9907bc5b2..727c823f866e 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -11,6 +11,7 @@ config PARISC
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_NO_SG_CHAIN
 	select ARCH_SUPPORTS_HUGETLBFS if PA20
 	select ARCH_SUPPORTS_MEMORY_FAILURE
@@ -34,7 +35,6 @@ config PARISC
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_SMP_IDLE_THREAD
 	select GENERIC_CPU_DEVICES
-	select GENERIC_STRNCPY_FROM_USER
 	select GENERIC_LIB_DEVMEM_IS_ALLOWED
 	select SYSCTL_ARCH_UNALIGN_ALLOW
 	select SYSCTL_EXCEPTION_TRACE
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index d01e3401581d..d2df3d2db3eb 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -183,8 +183,6 @@ config PPC
 	select GENERIC_IRQ_SHOW_LEVEL
 	select GENERIC_PCI_IOMAP		if PCI
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_VDSO_TIME_NS
 	select HAVE_ARCH_AUDITSYSCALL
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 47bbbcab91b2..49d642df6ab9 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -56,8 +56,6 @@ config RISCV
 	select GENERIC_PTDUMP if MMU
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
-	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/arch/s390/Kconfig b/arch/s390/Kconfig
index a0e2130f0100..f4f39087cad0 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -75,6 +75,8 @@ config S390
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_HAS_SYSCALL_WRAPPER
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_VDSO_DATA
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 45a0549421cd..5d20509e5556 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -22,8 +22,6 @@ config SUPERH
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP if PCI
 	select GENERIC_SCHED_CLOCK
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_SMP_IDLE_THREAD
 	select GUP_GET_PTE_LOW_HIGH if X2TLB
 	select HAVE_ARCH_AUDITSYSCALL
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index c5fa7932b550..9f78822562eb 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -38,8 +38,6 @@ config SPARC
 	select HAVE_EBPF_JIT if SPARC64
 	select HAVE_DEBUG_BUGVERBOSE
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select MODULES_USE_ELF_RELA
 	select PCI_SYSCALL if PCI
 	select PCI_MSI_ARCH_FALLBACKS if PCI_MSI
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 0561b73cfd9a..77e66d3719f6 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -7,6 +7,8 @@ config UML
 	default y
 	select ARCH_EPHEMERAL_INODES
 	select ARCH_HAS_KCOV
+	select ARCH_HAS_STRNCPY_FROM_USER
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_NO_PREEMPT
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_SECCOMP_FILTER
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 49270655e827..5509c828bc93 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -144,8 +144,6 @@ config X86
 	select GENERIC_PENDING_IRQ		if SMP
 	select GENERIC_PTDUMP
 	select GENERIC_SMP_IDLE_THREAD
-	select GENERIC_STRNCPY_FROM_USER
-	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
 	select GENERIC_VDSO_TIME_NS
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 2332b2156993..282fc195680e 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -7,6 +7,8 @@ config XTENSA
 	select ARCH_HAS_SYNC_DMA_FOR_CPU if MMU
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE if MMU
 	select ARCH_HAS_DMA_SET_UNCACHED if MMU
+	select ARCH_HAS_STRNCPY_FROM_USER if !KASAN
+	select ARCH_HAS_STRNLEN_USER
 	select ARCH_USE_MEMTEST
 	select ARCH_USE_QUEUED_RWLOCKS
 	select ARCH_USE_QUEUED_SPINLOCKS
@@ -20,7 +22,6 @@ config XTENSA
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
-	select GENERIC_STRNCPY_FROM_USER if KASAN
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
 	select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL
diff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/uaccess.h
index 5c9fb8005aa8..250ee68e9d82 100644
--- a/arch/xtensa/include/asm/uaccess.h
+++ b/arch/xtensa/include/asm/uaccess.h
@@ -290,8 +290,7 @@ clear_user(void __user *addr, unsigned long size)
 #define __clear_user  __xtensa_clear_user
 
 
-#ifndef CONFIG_GENERIC_STRNCPY_FROM_USER
-
+#ifdef CONFIG_HAS_STRNCPY_FROM_USER
 extern long __strncpy_user(char *dst, const char __user *src, long count);
 
 static inline long
diff --git a/lib/Kconfig b/lib/Kconfig
index d241fe476fda..0e66c9fa636b 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -50,12 +50,18 @@ config HAVE_ARCH_BITREVERSE
 	  This option enables the use of hardware bit-reversal instructions on
 	  architectures which support such operations.
 
-config GENERIC_STRNCPY_FROM_USER
+config ARCH_HAS_STRNCPY_FROM_USER
 	bool
 
-config GENERIC_STRNLEN_USER
+config ARCH_HAS_STRNLEN_USER
 	bool
 
+config GENERIC_STRNCPY_FROM_USER
+	def_bool !ARCH_HAS_STRNCPY_FROM_USER
+
+config GENERIC_STRNLEN_USER
+	def_bool !ARCH_HAS_STRNLEN_USER
+
 config GENERIC_NET_UTILS
 	bool
 
-- 
2.29.2


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

* Re: [PATCH v3 1/9] asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
  2021-07-22 12:48   ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 12:59     ` Christoph Hellwig
  -1 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 12:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

Note that the uml version has a minor conflict with my pending set_fs()
removal for uml, but that should be easy to resolve.

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

* Re: [PATCH v3 1/9] asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
@ 2021-07-22 12:59     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 12:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

Note that the uml version has a minor conflict with my pending set_fs()
removal for uml, but that should be easy to resolve.

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 1/9] asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
@ 2021-07-22 12:59     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 12:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

Note that the uml version has a minor conflict with my pending set_fs()
removal for uml, but that should be easy to resolve.

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

* Re: [PATCH v3 1/9] asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
@ 2021-07-22 12:59     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 12:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

Note that the uml version has a minor conflict with my pending set_fs()
removal for uml, but that should be easy to resolve.

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

* Re: [PATCH v3 2/9] h8300: remove stale strncpy_from_user
  2021-07-22 12:48   ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 12:59     ` Christoph Hellwig
  -1 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 12:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:07PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> This function is never called because h8300 uses the asm-generic
> inline function version.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 2/9] h8300: remove stale strncpy_from_user
@ 2021-07-22 12:59     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 12:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:07PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> This function is never called because h8300 uses the asm-generic
> inline function version.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 2/9] h8300: remove stale strncpy_from_user
@ 2021-07-22 12:59     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 12:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:07PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> This function is never called because h8300 uses the asm-generic
> inline function version.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 2/9] h8300: remove stale strncpy_from_user
@ 2021-07-22 12:59     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 12:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori

On Thu, Jul 22, 2021 at 02:48:07PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> This function is never called because h8300 uses the asm-generic
> inline function version.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 3/9] hexagon: use generic strncpy/strnlen from_user
  2021-07-22 12:48   ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 13:00     ` Christoph Hellwig
  -1 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:00 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:08PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the hexagon implementation of strncpy/strnlen and instead use
> the generic version.  The hexagon 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 <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 3/9] hexagon: use generic strncpy/strnlen from_user
@ 2021-07-22 13:00     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:00 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:08PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the hexagon implementation of strncpy/strnlen and instead use
> the generic version.  The hexagon 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 <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 3/9] hexagon: use generic strncpy/strnlen from_user
@ 2021-07-22 13:00     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:00 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:08PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the hexagon implementation of strncpy/strnlen and instead use
> the generic version.  The hexagon 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 <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 3/9] hexagon: use generic strncpy/strnlen from_user
@ 2021-07-22 13:00     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:00 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori

On Thu, Jul 22, 2021 at 02:48:08PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the hexagon implementation of strncpy/strnlen and instead use
> the generic version.  The hexagon 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 <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
  2021-07-22 12:48   ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 13:00     ` Christoph Hellwig
  -1 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:00 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:09PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the arc implemenation of strncpy/strnlen and instead use the
> generic versions.  The arc 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.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
@ 2021-07-22 13:00     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:00 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:09PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the arc implemenation of strncpy/strnlen and instead use the
> generic versions.  The arc 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.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
@ 2021-07-22 13:00     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:00 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:09PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the arc implemenation of strncpy/strnlen and instead use the
> generic versions.  The arc 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.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
@ 2021-07-22 13:00     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:00 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori

On Thu, Jul 22, 2021 at 02:48:09PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the arc implemenation of strncpy/strnlen and instead use the
> generic versions.  The arc 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.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 5/9] csky: use generic strncpy/strnlen from_user
  2021-07-22 12:48   ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 13:01     ` Christoph Hellwig
  -1 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:10PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the csky implemenation of strncpy/strnlen and instead use the
> generic versions.  The csky version is fairly slow because it always does
> byte accesses even for aligned data, and it lacks a checks for
> user_addr_max().

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 5/9] csky: use generic strncpy/strnlen from_user
@ 2021-07-22 13:01     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:10PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the csky implemenation of strncpy/strnlen and instead use the
> generic versions.  The csky version is fairly slow because it always does
> byte accesses even for aligned data, and it lacks a checks for
> user_addr_max().

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 5/9] csky: use generic strncpy/strnlen from_user
@ 2021-07-22 13:01     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:10PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the csky implemenation of strncpy/strnlen and instead use the
> generic versions.  The csky version is fairly slow because it always does
> byte accesses even for aligned data, and it lacks a checks for
> user_addr_max().

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 5/9] csky: use generic strncpy/strnlen from_user
@ 2021-07-22 13:01     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori

On Thu, Jul 22, 2021 at 02:48:10PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the csky implemenation of strncpy/strnlen and instead use the
> generic versions.  The csky version is fairly slow because it always does
> byte accesses even for aligned data, and it lacks a checks for
> user_addr_max().

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
  2021-07-22 12:48   ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 13:01     ` Christoph Hellwig
  -1 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:11PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the microblaze implemenation of strncpy/strnlen and instead use
> the generic versions.  The microblaze version is fairly slow because it
> always does byte accesses even for aligned data, and it lacks a checks
> for user_addr_max().

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
@ 2021-07-22 13:01     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:11PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the microblaze implemenation of strncpy/strnlen and instead use
> the generic versions.  The microblaze version is fairly slow because it
> always does byte accesses even for aligned data, and it lacks a checks
> for user_addr_max().

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
@ 2021-07-22 13:01     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:11PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the microblaze implemenation of strncpy/strnlen and instead use
> the generic versions.  The microblaze version is fairly slow because it
> always does byte accesses even for aligned data, and it lacks a checks
> for user_addr_max().

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
@ 2021-07-22 13:01     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori

On Thu, Jul 22, 2021 at 02:48:11PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Remove the microblaze implemenation of strncpy/strnlen and instead use
> the generic versions.  The microblaze version is fairly slow because it
> always does byte accesses even for aligned data, and it lacks a checks
> for user_addr_max().

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 7/9] asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
  2021-07-22 12:48   ` Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 13:02     ` Christoph Hellwig
  -1 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:02 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel,
	Geert Uytterhoeven

On Thu, Jul 22, 2021 at 02:48:12PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The inline version is used on three NOMMU architectures and is
> particularly inefficient when it scans the string one byte at a time
> twice. It also lacks a check for user_addr_max(), but this is
> probably ok on NOMMU targets.
> 
> Consolidate the asm-generic implementation with the library version
> that is used everywhere else.  This version is generalized enough to
> work efficiently on both MMU and NOMMU targets, and using the
> same code everywhere reduces the potential for subtle bugs.
> 
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 7/9] asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
@ 2021-07-22 13:02     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:02 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel,
	Geert Uytterhoeven

On Thu, Jul 22, 2021 at 02:48:12PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The inline version is used on three NOMMU architectures and is
> particularly inefficient when it scans the string one byte at a time
> twice. It also lacks a check for user_addr_max(), but this is
> probably ok on NOMMU targets.
> 
> Consolidate the asm-generic implementation with the library version
> that is used everywhere else.  This version is generalized enough to
> work efficiently on both MMU and NOMMU targets, and using the
> same code everywhere reduces the potential for subtle bugs.
> 
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 7/9] asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
@ 2021-07-22 13:02     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:02 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel,
	Geert Uytterhoeven

On Thu, Jul 22, 2021 at 02:48:12PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The inline version is used on three NOMMU architectures and is
> particularly inefficient when it scans the string one byte at a time
> twice. It also lacks a check for user_addr_max(), but this is
> probably ok on NOMMU targets.
> 
> Consolidate the asm-generic implementation with the library version
> that is used everywhere else.  This version is generalized enough to
> work efficiently on both MMU and NOMMU targets, and using the
> same code everywhere reduces the potential for subtle bugs.
> 
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 7/9] asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
@ 2021-07-22 13:02     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:02 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori

On Thu, Jul 22, 2021 at 02:48:12PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The inline version is used on three NOMMU architectures and is
> particularly inefficient when it scans the string one byte at a time
> twice. It also lacks a check for user_addr_max(), but this is
> probably ok on NOMMU targets.
> 
> Consolidate the asm-generic implementation with the library version
> that is used everywhere else.  This version is generalized enough to
> work efficiently on both MMU and NOMMU targets, and using the
> same code everywhere reduces the potential for subtle bugs.
> 
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from,len}_user declarations
  2021-07-22 12:48   ` [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from, len}_user declarations Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 13:02     ` Christoph Hellwig
  -1 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:02 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:13PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> As these are now in asm-generic, it's no longer necessary to
> declare them in the architecture.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from,len}_user declarations
@ 2021-07-22 13:02     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:02 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:13PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> As these are now in asm-generic, it's no longer necessary to
> declare them in the architecture.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from,len}_user declarations
@ 2021-07-22 13:02     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:02 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:13PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> As these are now in asm-generic, it's no longer necessary to
> declare them in the architecture.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from,len}_user declarations
@ 2021-07-22 13:02     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:02 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori

On Thu, Jul 22, 2021 at 02:48:13PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> As these are now in asm-generic, it's no longer necessary to
> declare them in the architecture.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
  2021-07-22 12:48   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols Arnd Bergmann
  (?)
  (?)
@ 2021-07-22 13:03     ` Christoph Hellwig
  -1 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:03 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:14PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
> 
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
> 
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
@ 2021-07-22 13:03     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:03 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:14PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
> 
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
> 
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
@ 2021-07-22 13:03     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:03 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On Thu, Jul 22, 2021 at 02:48:14PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
> 
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
> 
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
@ 2021-07-22 13:03     ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-22 13:03 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori

On Thu, Jul 22, 2021 at 02:48:14PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
> 
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
> 
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
  2021-07-22 12:48   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols Arnd Bergmann
                       ` (2 preceding siblings ...)
  (?)
@ 2021-07-22 13:57     ` Johannes Berg
  -1 siblings, 0 replies; 116+ messages in thread
From: Johannes Berg @ 2021-07-22 13:57 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

> 
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but

I'm not sure it makes sense to convert um, the implementation uses
strncpy(), and that should use the libc implementation, which is tuned
for the actual hardware that the binary is running on, so performance
wise that might be better.

OTOH, maybe this is all in the noise given the huge syscall overhead in
um, so maybe unifying it would make more sense.

johannes


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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 13:57     ` Johannes Berg
  0 siblings, 0 replies; 116+ messages in thread
From: Johannes Berg @ 2021-07-22 13:57 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

> 
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but

I'm not sure it makes sense to convert um, the implementation uses
strncpy(), and that should use the libc implementation, which is tuned
for the actual hardware that the binary is running on, so performance
wise that might be better.

OTOH, maybe this is all in the noise given the huge syscall overhead in
um, so maybe unifying it would make more sense.

johannes


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 13:57     ` Johannes Berg
  0 siblings, 0 replies; 116+ messages in thread
From: Johannes Berg @ 2021-07-22 13:57 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

> 
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but

I'm not sure it makes sense to convert um, the implementation uses
strncpy(), and that should use the libc implementation, which is tuned
for the actual hardware that the binary is running on, so performance
wise that might be better.

OTOH, maybe this is all in the noise given the huge syscall overhead in
um, so maybe unifying it would make more sense.

johannes


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 13:57     ` Johannes Berg
  0 siblings, 0 replies; 116+ messages in thread
From: Johannes Berg @ 2021-07-22 13:57 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky, linux-hexagon,
	linux-ia64, linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

> 
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but

I'm not sure it makes sense to convert um, the implementation uses
strncpy(), and that should use the libc implementation, which is tuned
for the actual hardware that the binary is running on, so performance
wise that might be better.

OTOH, maybe this is all in the noise given the huge syscall overhead in
um, so maybe unifying it would make more sense.

johannes

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 13:57     ` Johannes Berg
  0 siblings, 0 replies; 116+ messages in thread
From: Johannes Berg @ 2021-07-22 13:57 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato

> 
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but

I'm not sure it makes sense to convert um, the implementation uses
strncpy(), and that should use the libc implementation, which is tuned
for the actual hardware that the binary is running on, so performance
wise that might be better.

OTOH, maybe this is all in the noise given the huge syscall overhead in
um, so maybe unifying it would make more sense.

johannes


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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
  2021-07-22 13:57     ` Johannes Berg
                         ` (2 preceding siblings ...)
  (?)
@ 2021-07-22 14:01       ` Arnd Bergmann
  -1 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 14:01 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390,
	open list:SYNOPSYS ARC ARCHITECTURE, linux-um,
	open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 3:57 PM Johannes Berg <johannes@sipsolutions.net> wrote:
>
> >
> > The remaining architectures at the moment are: ia64, mips, parisc,
> > s390, um and xtensa. We should probably convert these as well, but
>
> I'm not sure it makes sense to convert um, the implementation uses
> strncpy(), and that should use the libc implementation, which is tuned
> for the actual hardware that the binary is running on, so performance
> wise that might be better.
>
> OTOH, maybe this is all in the noise given the huge syscall overhead in
> um, so maybe unifying it would make more sense.

Right, makes sense. I suppose if we end up converting mips and s390,
we should just do arch/um and the others as well for consistency, even
if that adds some overhead.

      Arnd

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 14:01       ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 14:01 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390,
	open list:SYNOPSYS ARC ARCHITECTURE, linux-um,
	open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 3:57 PM Johannes Berg <johannes@sipsolutions.net> wrote:
>
> >
> > The remaining architectures at the moment are: ia64, mips, parisc,
> > s390, um and xtensa. We should probably convert these as well, but
>
> I'm not sure it makes sense to convert um, the implementation uses
> strncpy(), and that should use the libc implementation, which is tuned
> for the actual hardware that the binary is running on, so performance
> wise that might be better.
>
> OTOH, maybe this is all in the noise given the huge syscall overhead in
> um, so maybe unifying it would make more sense.

Right, makes sense. I suppose if we end up converting mips and s390,
we should just do arch/um and the others as well for consistency, even
if that adds some overhead.

      Arnd

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 14:01       ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 14:01 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390,
	open list:SYNOPSYS ARC ARCHITECTURE, linux-um,
	open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 3:57 PM Johannes Berg <johannes@sipsolutions.net> wrote:
>
> >
> > The remaining architectures at the moment are: ia64, mips, parisc,
> > s390, um and xtensa. We should probably convert these as well, but
>
> I'm not sure it makes sense to convert um, the implementation uses
> strncpy(), and that should use the libc implementation, which is tuned
> for the actual hardware that the binary is running on, so performance
> wise that might be better.
>
> OTOH, maybe this is all in the noise given the huge syscall overhead in
> um, so maybe unifying it would make more sense.

Right, makes sense. I suppose if we end up converting mips and s390,
we should just do arch/um and the others as well for consistency, even
if that adds some overhead.

      Arnd

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 14:01       ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 14:01 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390,
	open list:SYNOPSYS ARC ARCHITECTURE, linux-um,
	open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 3:57 PM Johannes Berg <johannes@sipsolutions.net> wrote:
>
> >
> > The remaining architectures at the moment are: ia64, mips, parisc,
> > s390, um and xtensa. We should probably convert these as well, but
>
> I'm not sure it makes sense to convert um, the implementation uses
> strncpy(), and that should use the libc implementation, which is tuned
> for the actual hardware that the binary is running on, so performance
> wise that might be better.
>
> OTOH, maybe this is all in the noise given the huge syscall overhead in
> um, so maybe unifying it would make more sense.

Right, makes sense. I suppose if we end up converting mips and s390,
we should just do arch/um and the others as well for consistency, even
if that adds some overhead.

      Arnd

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 14:01       ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-22 14:01 UTC (permalink / raw)
  To: Johannes Berg
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta

On Thu, Jul 22, 2021 at 3:57 PM Johannes Berg <johannes@sipsolutions.net> wrote:
>
> >
> > The remaining architectures at the moment are: ia64, mips, parisc,
> > s390, um and xtensa. We should probably convert these as well, but
>
> I'm not sure it makes sense to convert um, the implementation uses
> strncpy(), and that should use the libc implementation, which is tuned
> for the actual hardware that the binary is running on, so performance
> wise that might be better.
>
> OTOH, maybe this is all in the noise given the huge syscall overhead in
> um, so maybe unifying it would make more sense.

Right, makes sense. I suppose if we end up converting mips and s390,
we should just do arch/um and the others as well for consistency, even
if that adds some overhead.

      Arnd

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

* Re: [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
  2021-07-22 12:48   ` Arnd Bergmann
                       ` (2 preceding siblings ...)
  (?)
@ 2021-07-22 15:34     ` Vineet Gupta
  -1 siblings, 0 replies; 116+ messages in thread
From: Vineet Gupta @ 2021-07-22 15:34 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Yoshinori Sato, linux-csky, linux-hexagon, linux-ia64,
	linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On 7/22/21 5:48 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Remove the arc implemenation of strncpy/strnlen and instead use the
> generic versions.  The arc 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.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

LGTM. Thx for doing this Arnd !

Acked-by: Vineet Gupta <vgupta@synopsys.com>

-Vineet

> ---
>   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 d8f51eb8963b..64e5f9366401 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 <asm/segment.h>
>   #include <asm-generic/uaccess.h>
>   
> 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


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

* Re: [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
@ 2021-07-22 15:34     ` Vineet Gupta
  0 siblings, 0 replies; 116+ messages in thread
From: Vineet Gupta @ 2021-07-22 15:34 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Yoshinori Sato, linux-csky, linux-hexagon, linux-ia64,
	linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On 7/22/21 5:48 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Remove the arc implemenation of strncpy/strnlen and instead use the
> generic versions.  The arc 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.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

LGTM. Thx for doing this Arnd !

Acked-by: Vineet Gupta <vgupta@synopsys.com>

-Vineet

> ---
>   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 d8f51eb8963b..64e5f9366401 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 <asm/segment.h>
>   #include <asm-generic/uaccess.h>
>   
> 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

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
@ 2021-07-22 15:34     ` Vineet Gupta
  0 siblings, 0 replies; 116+ messages in thread
From: Vineet Gupta @ 2021-07-22 15:34 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Yoshinori Sato, linux-csky, linux-hexagon, linux-ia64,
	linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

On 7/22/21 5:48 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Remove the arc implemenation of strncpy/strnlen and instead use the
> generic versions.  The arc 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.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

LGTM. Thx for doing this Arnd !

Acked-by: Vineet Gupta <vgupta@synopsys.com>

-Vineet

> ---
>   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 d8f51eb8963b..64e5f9366401 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 <asm/segment.h>
>   #include <asm-generic/uaccess.h>
>   
> 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

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

* Re: [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
@ 2021-07-22 15:34     ` Vineet Gupta
  0 siblings, 0 replies; 116+ messages in thread
From: Vineet Gupta @ 2021-07-22 15:34 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Yoshinori Sato, linux-csky, linux-hexagon, linux-ia64,
	linux-kernel, linux-mips, linux-parisc, linux-s390,
	linux-snps-arc, linux-um, linux-xtensa, uclinux-h8-devel

T24gNy8yMi8yMSA1OjQ4IEFNLCBBcm5kIEJlcmdtYW5uIHdyb3RlOg0KPiBGcm9tOiBBcm5kIEJl
cmdtYW5uIDxhcm5kQGFybmRiLmRlPg0KPg0KPiBSZW1vdmUgdGhlIGFyYyBpbXBsZW1lbmF0aW9u
IG9mIHN0cm5jcHkvc3RybmxlbiBhbmQgaW5zdGVhZCB1c2UgdGhlDQo+IGdlbmVyaWMgdmVyc2lv
bnMuICBUaGUgYXJjIHZlcnNpb24gaXMgZmFpcmx5IHNsb3cgYmVjYXVzZSBpdCBhbHdheXMgZG9l
cw0KPiBieXRlIGFjY2Vzc2VzIGV2ZW4gZm9yIGFsaWduZWQgZGF0YSwgYW5kIGl0cyBjaGVja3Mg
Zm9yIHVzZXJfYWRkcl9tYXgoKQ0KPiBkaWZmZXIgZnJvbSB0aGUgZ2VuZXJpYyBjb2RlLg0KPg0K
PiBTaWduZWQtb2ZmLWJ5OiBBcm5kIEJlcmdtYW5uIDxhcm5kQGFybmRiLmRlPg0KDQpMR1RNLiBU
aHggZm9yIGRvaW5nIHRoaXMgQXJuZCAhDQoNCkFja2VkLWJ5OiBWaW5lZXQgR3VwdGEgPHZndXB0
YUBzeW5vcHN5cy5jb20+DQoNCi1WaW5lZXQNCg0KPiAtLS0NCj4gICBhcmNoL2FyYy9LY29uZmln
ICAgICAgICAgICAgICAgfCAgMiArDQo+ICAgYXJjaC9hcmMvaW5jbHVkZS9hc20vdWFjY2Vzcy5o
IHwgODMgKystLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQ0KPiAgIGFyY2gvYXJjL21t
L2V4dGFibGUuYyAgICAgICAgICB8IDEyIC0tLS0tDQo+ICAgMyBmaWxlcyBjaGFuZ2VkLCA3IGlu
c2VydGlvbnMoKyksIDkwIGRlbGV0aW9ucygtKQ0KPg0KPiBkaWZmIC0tZ2l0IGEvYXJjaC9hcmMv
S2NvbmZpZyBiL2FyY2gvYXJjL0tjb25maWcNCj4gaW5kZXggZDhmNTFlYjg5NjNiLi42NGU1Zjkz
NjY0MDEgMTAwNjQ0DQo+IC0tLSBhL2FyY2gvYXJjL0tjb25maWcNCj4gKysrIGIvYXJjaC9hcmMv
S2NvbmZpZw0KPiBAQCAtMjcsNiArMjcsOCBAQCBjb25maWcgQVJDDQo+ICAgCXNlbGVjdCBHRU5F
UklDX1BFTkRJTkdfSVJRIGlmIFNNUA0KPiAgIAlzZWxlY3QgR0VORVJJQ19TQ0hFRF9DTE9DSw0K
PiAgIAlzZWxlY3QgR0VORVJJQ19TTVBfSURMRV9USFJFQUQNCj4gKwlzZWxlY3QgR0VORVJJQ19T
VFJOQ1BZX0ZST01fVVNFUg0KPiArCXNlbGVjdCBHRU5FUklDX1NUUk5MRU5fVVNFUg0KPiAgIAlz
ZWxlY3QgSEFWRV9BUkNIX0tHREINCj4gICAJc2VsZWN0IEhBVkVfQVJDSF9UUkFDRUhPT0sNCj4g
ICAJc2VsZWN0IEhBVkVfQVJDSF9UUkFOU1BBUkVOVF9IVUdFUEFHRSBpZiBBUkNfTU1VX1Y0DQo+
IGRpZmYgLS1naXQgYS9hcmNoL2FyYy9pbmNsdWRlL2FzbS91YWNjZXNzLmggYi9hcmNoL2FyYy9p
bmNsdWRlL2FzbS91YWNjZXNzLmgNCj4gaW5kZXggMzQ3NjM0OGYzNjFlLi43NTRhMjNmMjY3MzYg
MTAwNjQ0DQo+IC0tLSBhL2FyY2gvYXJjL2luY2x1ZGUvYXNtL3VhY2Nlc3MuaA0KPiArKysgYi9h
cmNoL2FyYy9pbmNsdWRlL2FzbS91YWNjZXNzLmgNCj4gQEAgLTY1NSw5NiArNjU1LDIzIEBAIHN0
YXRpYyBpbmxpbmUgdW5zaWduZWQgbG9uZyBfX2FyY19jbGVhcl91c2VyKHZvaWQgX191c2VyICp0
bywgdW5zaWduZWQgbG9uZyBuKQ0KPiAgIAlyZXR1cm4gcmVzOw0KPiAgIH0NCj4gICANCj4gLXN0
YXRpYyBpbmxpbmUgbG9uZw0KPiAtX19hcmNfc3RybmNweV9mcm9tX3VzZXIoY2hhciAqZHN0LCBj
b25zdCBjaGFyIF9fdXNlciAqc3JjLCBsb25nIGNvdW50KQ0KPiAtew0KPiAtCWxvbmcgcmVzID0g
MDsNCj4gLQljaGFyIHZhbDsNCj4gLQ0KPiAtCWlmICghYWNjZXNzX29rKHNyYywgMSkpDQo+IC0J
CXJldHVybiAtRUZBVUxUOw0KPiAtDQo+IC0JaWYgKGNvdW50ID09IDApDQo+IC0JCXJldHVybiAw
Ow0KPiAtDQo+IC0JX19hc21fXyBfX3ZvbGF0aWxlX18oDQo+IC0JIgltb3YJbHBfY291bnQsICU1
CQlcbiINCj4gLQkiCWxwCTNmCQkJXG4iDQo+IC0JIjE6CWxkYi5hYiAgJTMsIFslMiwgMV0JCVxu
Ig0KPiAtCSIJYnJlcS5kCSUzLCAwLCAzZiAgICAgICAgICAgICAgIFxuIg0KPiAtCSIJc3RiLmFi
ICAlMywgWyUxLCAxXQkJXG4iDQo+IC0JIglhZGQJJTAsICUwLCAxCSMgTnVtIG9mIE5PTiBOVUxM
IGJ5dGVzIGNvcGllZAlcbiINCj4gLQkiMzoJCQkJCQkJCVxuIg0KPiAtCSIJLnNlY3Rpb24gLmZp
eHVwLCBcImF4XCIJCVxuIg0KPiAtCSIJLmFsaWduIDQJCQlcbiINCj4gLQkiNDoJbW92ICUwLCAl
NAkJIyBzZXRzIEByZXMgYXMgLUVGQVVMVAlcbiINCj4gLQkiCWogICAzYgkJCQlcbiINCj4gLQki
CS5wcmV2aW91cwkJCVxuIg0KPiAtCSIJLnNlY3Rpb24gX19leF90YWJsZSwgXCJhXCIJXG4iDQo+
IC0JIgkuYWxpZ24gNAkJCVxuIg0KPiAtCSIJLndvcmQgICAxYiwgNGIJCQlcbiINCj4gLQkiCS5w
cmV2aW91cwkJCVxuIg0KPiAtCTogIityIihyZXMpLCAiK3IiKGRzdCksICIrciIoc3JjKSwgIj1y
Iih2YWwpDQo+IC0JOiAiZyIoLUVGQVVMVCksICJyIihjb3VudCkNCj4gLQk6ICJscF9jb3VudCIs
ICJtZW1vcnkiKTsNCj4gLQ0KPiAtCXJldHVybiByZXM7DQo+IC19DQo+IC0NCj4gLXN0YXRpYyBp
bmxpbmUgbG9uZyBfX2FyY19zdHJubGVuX3VzZXIoY29uc3QgY2hhciBfX3VzZXIgKnMsIGxvbmcg
bikNCj4gLXsNCj4gLQlsb25nIHJlcywgdG1wMSwgY250Ow0KPiAtCWNoYXIgdmFsOw0KPiAtDQo+
IC0JaWYgKCFhY2Nlc3Nfb2socywgMSkpDQo+IC0JCXJldHVybiAwOw0KPiAtDQo+IC0JX19hc21f
XyBfX3ZvbGF0aWxlX18oDQo+IC0JIgltb3YgJTIsICUxCQkJXG4iDQo+IC0JIjE6CWxkYi5hYiAg
JTMsIFslMCwgMV0JCVxuIg0KPiAtCSIJYnJlcS5kICAlMywgMCwgMmYJCVxuIg0KPiAtCSIJc3Vi
LmYgICAlMiwgJTIsIDEJCVxuIg0KPiAtCSIJYm56IDFiCQkJCVxuIg0KPiAtCSIJc3ViICUyLCAl
MiwgMQkJCVxuIg0KPiAtCSIyOglzdWIgJTAsICUxLCAlMgkJCVxuIg0KPiAtCSIzOgk7bm9wCQkJ
CVxuIg0KPiAtCSIJLnNlY3Rpb24gLmZpeHVwLCBcImF4XCIJCVxuIg0KPiAtCSIJLmFsaWduIDQJ
CQlcbiINCj4gLQkiNDoJbW92ICUwLCAwCQkJXG4iDQo+IC0JIglqICAgM2IJCQkJXG4iDQo+IC0J
IgkucHJldmlvdXMJCQlcbiINCj4gLQkiCS5zZWN0aW9uIF9fZXhfdGFibGUsIFwiYVwiCVxuIg0K
PiAtCSIJLmFsaWduIDQJCQlcbiINCj4gLQkiCS53b3JkIDFiLCA0YgkJCVxuIg0KPiAtCSIJLnBy
ZXZpb3VzCQkJXG4iDQo+IC0JOiAiPXIiKHJlcyksICI9ciIodG1wMSksICI9ciIoY250KSwgIj1y
Iih2YWwpDQo+IC0JOiAiMCIocyksICIxIihuKQ0KPiAtCTogIm1lbW9yeSIpOw0KPiAtDQo+IC0J
cmV0dXJuIHJlczsNCj4gLX0NCj4gLQ0KPiAgICNpZm5kZWYgQ09ORklHX0NDX09QVElNSVpFX0ZP
Ul9TSVpFDQo+ICAgDQo+ICAgI2RlZmluZSBJTkxJTkVfQ09QWV9UT19VU0VSDQo+ICAgI2RlZmlu
ZSBJTkxJTkVfQ09QWV9GUk9NX1VTRVINCj4gICANCj4gICAjZGVmaW5lIF9fY2xlYXJfdXNlcihk
LCBuKQkJX19hcmNfY2xlYXJfdXNlcihkLCBuKQ0KPiAtI2RlZmluZSBzdHJuY3B5X2Zyb21fdXNl
cihkLCBzLCBuKQlfX2FyY19zdHJuY3B5X2Zyb21fdXNlcihkLCBzLCBuKQ0KPiAtI2RlZmluZSBz
dHJubGVuX3VzZXIocywgbikJCV9fYXJjX3N0cm5sZW5fdXNlcihzLCBuKQ0KPiAgICNlbHNlDQo+
ICAgZXh0ZXJuIHVuc2lnbmVkIGxvbmcgYXJjX2NsZWFyX3VzZXJfbm9pbmxpbmUodm9pZCBfX3Vz
ZXIgKnRvLA0KPiAgIAkJdW5zaWduZWQgbG9uZyBuKTsNCj4gLWV4dGVybiBsb25nIGFyY19zdHJu
Y3B5X2Zyb21fdXNlcl9ub2lubGluZSAoY2hhciAqZHN0LCBjb25zdCBjaGFyIF9fdXNlciAqc3Jj
LA0KPiAtCQlsb25nIGNvdW50KTsNCj4gLWV4dGVybiBsb25nIGFyY19zdHJubGVuX3VzZXJfbm9p
bmxpbmUoY29uc3QgY2hhciBfX3VzZXIgKnNyYywgbG9uZyBuKTsNCj4gLQ0KPiAgICNkZWZpbmUg
X19jbGVhcl91c2VyKGQsIG4pCQlhcmNfY2xlYXJfdXNlcl9ub2lubGluZShkLCBuKQ0KPiAtI2Rl
ZmluZSBzdHJuY3B5X2Zyb21fdXNlcihkLCBzLCBuKQlhcmNfc3RybmNweV9mcm9tX3VzZXJfbm9p
bmxpbmUoZCwgcywgbikNCj4gLSNkZWZpbmUgc3Rybmxlbl91c2VyKHMsIG4pCQlhcmNfc3Rybmxl
bl91c2VyX25vaW5saW5lKHMsIG4pDQo+IC0NCj4gICAjZW5kaWYNCj4gICANCj4gK2V4dGVybiBs
b25nIHN0cm5jcHlfZnJvbV91c2VyKGNoYXIgKmRzdCwgY29uc3QgY2hhciBfX3VzZXIgKnNyYywg
bG9uZyBjb3VudCk7DQo+ICsjZGVmaW5lIHN0cm5jcHlfZnJvbV91c2VyKGQsIHMsIG4pCXN0cm5j
cHlfZnJvbV91c2VyKGQsIHMsIG4pDQo+ICtleHRlcm4gbG9uZyBzdHJubGVuX3VzZXIoY29uc3Qg
Y2hhciBfX3VzZXIgKnNyYywgbG9uZyBuKTsNCj4gKyNkZWZpbmUgc3Rybmxlbl91c2VyKHMsIG4p
CQlzdHJubGVuX3VzZXIocywgbikNCj4gKw0KPiAgICNpbmNsdWRlIDxhc20vc2VnbWVudC5oPg0K
PiAgICNpbmNsdWRlIDxhc20tZ2VuZXJpYy91YWNjZXNzLmg+DQo+ICAgDQo+IGRpZmYgLS1naXQg
YS9hcmNoL2FyYy9tbS9leHRhYmxlLmMgYi9hcmNoL2FyYy9tbS9leHRhYmxlLmMNCj4gaW5kZXgg
YjA2YjA5ZGRmOTI0Li40ZTE0YzQyNDRlYTIgMTAwNjQ0DQo+IC0tLSBhL2FyY2gvYXJjL21tL2V4
dGFibGUuYw0KPiArKysgYi9hcmNoL2FyYy9tbS9leHRhYmxlLmMNCj4gQEAgLTMyLDE2ICszMiw0
IEBAIHVuc2lnbmVkIGxvbmcgYXJjX2NsZWFyX3VzZXJfbm9pbmxpbmUodm9pZCBfX3VzZXIgKnRv
LA0KPiAgIH0NCj4gICBFWFBPUlRfU1lNQk9MKGFyY19jbGVhcl91c2VyX25vaW5saW5lKTsNCj4g
ICANCj4gLWxvbmcgYXJjX3N0cm5jcHlfZnJvbV91c2VyX25vaW5saW5lKGNoYXIgKmRzdCwgY29u
c3QgY2hhciBfX3VzZXIgKnNyYywNCj4gLQkJbG9uZyBjb3VudCkNCj4gLXsNCj4gLQlyZXR1cm4g
X19hcmNfc3RybmNweV9mcm9tX3VzZXIoZHN0LCBzcmMsIGNvdW50KTsNCj4gLX0NCj4gLUVYUE9S
VF9TWU1CT0woYXJjX3N0cm5jcHlfZnJvbV91c2VyX25vaW5saW5lKTsNCj4gLQ0KPiAtbG9uZyBh
cmNfc3Rybmxlbl91c2VyX25vaW5saW5lKGNvbnN0IGNoYXIgX191c2VyICpzcmMsIGxvbmcgbikN
Cj4gLXsNCj4gLQlyZXR1cm4gX19hcmNfc3Rybmxlbl91c2VyKHNyYywgbik7DQo+IC19DQo+IC1F
WFBPUlRfU1lNQk9MKGFyY19zdHJubGVuX3VzZXJfbm9pbmxpbmUpOw0KPiAgICNlbmRpZg0KDQo

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

* Re: [PATCH v3 4/9] arc: use generic strncpy/strnlen from_user
@ 2021-07-22 15:34     ` Vineet Gupta
  0 siblings, 0 replies; 116+ messages in thread
From: Vineet Gupta @ 2021-07-22 15:34 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Yoshinori Sato, linux-csky@vger.kernel.org

On 7/22/21 5:48 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Remove the arc implemenation of strncpy/strnlen and instead use the
> generic versions.  The arc 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.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

LGTM. Thx for doing this Arnd !

Acked-by: Vineet Gupta <vgupta@synopsys.com>

-Vineet

> ---
>   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 d8f51eb8963b..64e5f9366401 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 <asm/segment.h>
>   #include <asm-generic/uaccess.h>
>   
> 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


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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
  2021-07-22 14:01       ` Arnd Bergmann
                           ` (2 preceding siblings ...)
  (?)
@ 2021-07-22 20:07         ` Heiko Carstens
  -1 siblings, 0 replies; 116+ messages in thread
From: Heiko Carstens @ 2021-07-22 20:07 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Johannes Berg, linux-arch, Arnd Bergmann, James E.J. Bottomley,
	Al Viro, Anton Ivanov, Brian Cain, Chris Zankel,
	Christian Borntraeger, Christoph Hellwig, Guo Ren, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390,
	open list:SYNOPSYS ARC ARCHITECTURE, linux-um,
	open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 04:01:39PM +0200, Arnd Bergmann wrote:
> On Thu, Jul 22, 2021 at 3:57 PM Johannes Berg <johannes@sipsolutions.net> wrote:
> >
> > >
> > > The remaining architectures at the moment are: ia64, mips, parisc,
> > > s390, um and xtensa. We should probably convert these as well, but
> >
> > I'm not sure it makes sense to convert um, the implementation uses
> > strncpy(), and that should use the libc implementation, which is tuned
> > for the actual hardware that the binary is running on, so performance
> > wise that might be better.
> >
> > OTOH, maybe this is all in the noise given the huge syscall overhead in
> > um, so maybe unifying it would make more sense.
> 
> Right, makes sense. I suppose if we end up converting mips and s390,
> we should just do arch/um and the others as well for consistency, even
> if that adds some overhead.

Feel free to add the s390 patch below on top of your series. However
one question: the strncpy_from_user() prototype now comes everywhere
without the __must_check attribute. Is there any reason for that?

At least for s390 I want to keep that.

From 03ad679909af58e1dc6864f47ce67210f0534c39 Mon Sep 17 00:00:00 2001
From: Heiko Carstens <hca@linux.ibm.com>
Date: Thu, 22 Jul 2021 21:48:18 +0200
Subject: [PATCH] s390: use generic strncpy/strnlen from_user

The s390 variant of strncpy_from_user() is slightly faster than the
generic variant, however convert to the generic variant now to follow
most if not all other architectures.

Converting to the generic variant was already considered a couple of
years ago. See commit f5c8b9601036 ("s390/uaccess: use sane length for
__strncpy_from_user()").

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
 arch/s390/Kconfig               |  2 --
 arch/s390/include/asm/uaccess.h | 18 ++----------
 arch/s390/lib/uaccess.c         | 52 ---------------------------------
 3 files changed, 2 insertions(+), 70 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index f4f39087cad0..a0e2130f0100 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -75,8 +75,6 @@ config S390
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
-	select ARCH_HAS_STRNCPY_FROM_USER
-	select ARCH_HAS_STRNLEN_USER
 	select ARCH_HAS_SYSCALL_WRAPPER
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_VDSO_DATA
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
index 2316f2440881..9ed9aa37e836 100644
--- a/arch/s390/include/asm/uaccess.h
+++ b/arch/s390/include/asm/uaccess.h
@@ -233,23 +233,9 @@ raw_copy_in_user(void __user *to, const void __user *from, unsigned long n);
 /*
  * Copy a null terminated string from userspace.
  */
+long __must_check strncpy_from_user(char *dst, const char __user *src, long count);
 
-long __strncpy_from_user(char *dst, const char __user *src, long count);
-
-static inline long __must_check
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	might_fault();
-	return __strncpy_from_user(dst, src, count);
-}
-
-unsigned long __must_check __strnlen_user(const char __user *src, unsigned long count);
-
-static inline unsigned long strnlen_user(const char __user *src, unsigned long n)
-{
-	might_fault();
-	return __strnlen_user(src, n);
-}
+long __must_check strnlen_user(const char __user *src, long count);
 
 /*
  * Zero Userspace
diff --git a/arch/s390/lib/uaccess.c b/arch/s390/lib/uaccess.c
index 7ec8b1fa0f08..94ca99bde59d 100644
--- a/arch/s390/lib/uaccess.c
+++ b/arch/s390/lib/uaccess.c
@@ -338,55 +338,3 @@ unsigned long __clear_user(void __user *to, unsigned long size)
 	return clear_user_xc(to, size);
 }
 EXPORT_SYMBOL(__clear_user);
-
-static inline unsigned long strnlen_user_srst(const char __user *src,
-					      unsigned long size)
-{
-	unsigned long tmp1, tmp2;
-
-	asm volatile(
-		"   lghi  0,0\n"
-		"   la    %2,0(%1)\n"
-		"   la    %3,0(%0,%1)\n"
-		"   slgr  %0,%0\n"
-		"   sacf  256\n"
-		"0: srst  %3,%2\n"
-		"   jo    0b\n"
-		"   la    %0,1(%3)\n"	/* strnlen_user results includes \0 */
-		"   slgr  %0,%1\n"
-		"1: sacf  768\n"
-		EX_TABLE(0b,1b)
-		: "+a" (size), "+a" (src), "=a" (tmp1), "=a" (tmp2)
-		:
-		: "cc", "memory", "0");
-	return size;
-}
-
-unsigned long __strnlen_user(const char __user *src, unsigned long size)
-{
-	if (unlikely(!size))
-		return 0;
-	return strnlen_user_srst(src, size);
-}
-EXPORT_SYMBOL(__strnlen_user);
-
-long __strncpy_from_user(char *dst, const char __user *src, long size)
-{
-	size_t done, len, offset, len_str;
-
-	if (unlikely(size <= 0))
-		return 0;
-	done = 0;
-	do {
-		offset = (size_t)src & (L1_CACHE_BYTES - 1);
-		len = min(size - done, L1_CACHE_BYTES - offset);
-		if (copy_from_user(dst, src, len))
-			return -EFAULT;
-		len_str = strnlen(dst, len);
-		done += len_str;
-		src += len_str;
-		dst += len_str;
-	} while ((len_str == len) && (done < size));
-	return done;
-}
-EXPORT_SYMBOL(__strncpy_from_user);
-- 
2.25.1


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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 20:07         ` Heiko Carstens
  0 siblings, 0 replies; 116+ messages in thread
From: Heiko Carstens @ 2021-07-22 20:07 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Johannes Berg, linux-arch, Arnd Bergmann, James E.J. Bottomley,
	Al Viro, Anton Ivanov, Brian Cain, Chris Zankel,
	Christian Borntraeger, Christoph Hellwig, Guo Ren, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390,
	open list:SYNOPSYS ARC ARCHITECTURE, linux-um,
	open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 04:01:39PM +0200, Arnd Bergmann wrote:
> On Thu, Jul 22, 2021 at 3:57 PM Johannes Berg <johannes@sipsolutions.net> wrote:
> >
> > >
> > > The remaining architectures at the moment are: ia64, mips, parisc,
> > > s390, um and xtensa. We should probably convert these as well, but
> >
> > I'm not sure it makes sense to convert um, the implementation uses
> > strncpy(), and that should use the libc implementation, which is tuned
> > for the actual hardware that the binary is running on, so performance
> > wise that might be better.
> >
> > OTOH, maybe this is all in the noise given the huge syscall overhead in
> > um, so maybe unifying it would make more sense.
> 
> Right, makes sense. I suppose if we end up converting mips and s390,
> we should just do arch/um and the others as well for consistency, even
> if that adds some overhead.

Feel free to add the s390 patch below on top of your series. However
one question: the strncpy_from_user() prototype now comes everywhere
without the __must_check attribute. Is there any reason for that?

At least for s390 I want to keep that.

From 03ad679909af58e1dc6864f47ce67210f0534c39 Mon Sep 17 00:00:00 2001
From: Heiko Carstens <hca@linux.ibm.com>
Date: Thu, 22 Jul 2021 21:48:18 +0200
Subject: [PATCH] s390: use generic strncpy/strnlen from_user

The s390 variant of strncpy_from_user() is slightly faster than the
generic variant, however convert to the generic variant now to follow
most if not all other architectures.

Converting to the generic variant was already considered a couple of
years ago. See commit f5c8b9601036 ("s390/uaccess: use sane length for
__strncpy_from_user()").

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
 arch/s390/Kconfig               |  2 --
 arch/s390/include/asm/uaccess.h | 18 ++----------
 arch/s390/lib/uaccess.c         | 52 ---------------------------------
 3 files changed, 2 insertions(+), 70 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index f4f39087cad0..a0e2130f0100 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -75,8 +75,6 @@ config S390
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
-	select ARCH_HAS_STRNCPY_FROM_USER
-	select ARCH_HAS_STRNLEN_USER
 	select ARCH_HAS_SYSCALL_WRAPPER
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_VDSO_DATA
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
index 2316f2440881..9ed9aa37e836 100644
--- a/arch/s390/include/asm/uaccess.h
+++ b/arch/s390/include/asm/uaccess.h
@@ -233,23 +233,9 @@ raw_copy_in_user(void __user *to, const void __user *from, unsigned long n);
 /*
  * Copy a null terminated string from userspace.
  */
+long __must_check strncpy_from_user(char *dst, const char __user *src, long count);
 
-long __strncpy_from_user(char *dst, const char __user *src, long count);
-
-static inline long __must_check
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	might_fault();
-	return __strncpy_from_user(dst, src, count);
-}
-
-unsigned long __must_check __strnlen_user(const char __user *src, unsigned long count);
-
-static inline unsigned long strnlen_user(const char __user *src, unsigned long n)
-{
-	might_fault();
-	return __strnlen_user(src, n);
-}
+long __must_check strnlen_user(const char __user *src, long count);
 
 /*
  * Zero Userspace
diff --git a/arch/s390/lib/uaccess.c b/arch/s390/lib/uaccess.c
index 7ec8b1fa0f08..94ca99bde59d 100644
--- a/arch/s390/lib/uaccess.c
+++ b/arch/s390/lib/uaccess.c
@@ -338,55 +338,3 @@ unsigned long __clear_user(void __user *to, unsigned long size)
 	return clear_user_xc(to, size);
 }
 EXPORT_SYMBOL(__clear_user);
-
-static inline unsigned long strnlen_user_srst(const char __user *src,
-					      unsigned long size)
-{
-	unsigned long tmp1, tmp2;
-
-	asm volatile(
-		"   lghi  0,0\n"
-		"   la    %2,0(%1)\n"
-		"   la    %3,0(%0,%1)\n"
-		"   slgr  %0,%0\n"
-		"   sacf  256\n"
-		"0: srst  %3,%2\n"
-		"   jo    0b\n"
-		"   la    %0,1(%3)\n"	/* strnlen_user results includes \0 */
-		"   slgr  %0,%1\n"
-		"1: sacf  768\n"
-		EX_TABLE(0b,1b)
-		: "+a" (size), "+a" (src), "=a" (tmp1), "=a" (tmp2)
-		:
-		: "cc", "memory", "0");
-	return size;
-}
-
-unsigned long __strnlen_user(const char __user *src, unsigned long size)
-{
-	if (unlikely(!size))
-		return 0;
-	return strnlen_user_srst(src, size);
-}
-EXPORT_SYMBOL(__strnlen_user);
-
-long __strncpy_from_user(char *dst, const char __user *src, long size)
-{
-	size_t done, len, offset, len_str;
-
-	if (unlikely(size <= 0))
-		return 0;
-	done = 0;
-	do {
-		offset = (size_t)src & (L1_CACHE_BYTES - 1);
-		len = min(size - done, L1_CACHE_BYTES - offset);
-		if (copy_from_user(dst, src, len))
-			return -EFAULT;
-		len_str = strnlen(dst, len);
-		done += len_str;
-		src += len_str;
-		dst += len_str;
-	} while ((len_str == len) && (done < size));
-	return done;
-}
-EXPORT_SYMBOL(__strncpy_from_user);
-- 
2.25.1


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 20:07         ` Heiko Carstens
  0 siblings, 0 replies; 116+ messages in thread
From: Heiko Carstens @ 2021-07-22 20:07 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Johannes Berg, linux-arch, Arnd Bergmann, James E.J. Bottomley,
	Al Viro, Anton Ivanov, Brian Cain, Chris Zankel,
	Christian Borntraeger, Christoph Hellwig, Guo Ren, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390,
	open list:SYNOPSYS ARC ARCHITECTURE, linux-um,
	open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 04:01:39PM +0200, Arnd Bergmann wrote:
> On Thu, Jul 22, 2021 at 3:57 PM Johannes Berg <johannes@sipsolutions.net> wrote:
> >
> > >
> > > The remaining architectures at the moment are: ia64, mips, parisc,
> > > s390, um and xtensa. We should probably convert these as well, but
> >
> > I'm not sure it makes sense to convert um, the implementation uses
> > strncpy(), and that should use the libc implementation, which is tuned
> > for the actual hardware that the binary is running on, so performance
> > wise that might be better.
> >
> > OTOH, maybe this is all in the noise given the huge syscall overhead in
> > um, so maybe unifying it would make more sense.
> 
> Right, makes sense. I suppose if we end up converting mips and s390,
> we should just do arch/um and the others as well for consistency, even
> if that adds some overhead.

Feel free to add the s390 patch below on top of your series. However
one question: the strncpy_from_user() prototype now comes everywhere
without the __must_check attribute. Is there any reason for that?

At least for s390 I want to keep that.

From 03ad679909af58e1dc6864f47ce67210f0534c39 Mon Sep 17 00:00:00 2001
From: Heiko Carstens <hca@linux.ibm.com>
Date: Thu, 22 Jul 2021 21:48:18 +0200
Subject: [PATCH] s390: use generic strncpy/strnlen from_user

The s390 variant of strncpy_from_user() is slightly faster than the
generic variant, however convert to the generic variant now to follow
most if not all other architectures.

Converting to the generic variant was already considered a couple of
years ago. See commit f5c8b9601036 ("s390/uaccess: use sane length for
__strncpy_from_user()").

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
 arch/s390/Kconfig               |  2 --
 arch/s390/include/asm/uaccess.h | 18 ++----------
 arch/s390/lib/uaccess.c         | 52 ---------------------------------
 3 files changed, 2 insertions(+), 70 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index f4f39087cad0..a0e2130f0100 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -75,8 +75,6 @@ config S390
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
-	select ARCH_HAS_STRNCPY_FROM_USER
-	select ARCH_HAS_STRNLEN_USER
 	select ARCH_HAS_SYSCALL_WRAPPER
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_VDSO_DATA
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
index 2316f2440881..9ed9aa37e836 100644
--- a/arch/s390/include/asm/uaccess.h
+++ b/arch/s390/include/asm/uaccess.h
@@ -233,23 +233,9 @@ raw_copy_in_user(void __user *to, const void __user *from, unsigned long n);
 /*
  * Copy a null terminated string from userspace.
  */
+long __must_check strncpy_from_user(char *dst, const char __user *src, long count);
 
-long __strncpy_from_user(char *dst, const char __user *src, long count);
-
-static inline long __must_check
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	might_fault();
-	return __strncpy_from_user(dst, src, count);
-}
-
-unsigned long __must_check __strnlen_user(const char __user *src, unsigned long count);
-
-static inline unsigned long strnlen_user(const char __user *src, unsigned long n)
-{
-	might_fault();
-	return __strnlen_user(src, n);
-}
+long __must_check strnlen_user(const char __user *src, long count);
 
 /*
  * Zero Userspace
diff --git a/arch/s390/lib/uaccess.c b/arch/s390/lib/uaccess.c
index 7ec8b1fa0f08..94ca99bde59d 100644
--- a/arch/s390/lib/uaccess.c
+++ b/arch/s390/lib/uaccess.c
@@ -338,55 +338,3 @@ unsigned long __clear_user(void __user *to, unsigned long size)
 	return clear_user_xc(to, size);
 }
 EXPORT_SYMBOL(__clear_user);
-
-static inline unsigned long strnlen_user_srst(const char __user *src,
-					      unsigned long size)
-{
-	unsigned long tmp1, tmp2;
-
-	asm volatile(
-		"   lghi  0,0\n"
-		"   la    %2,0(%1)\n"
-		"   la    %3,0(%0,%1)\n"
-		"   slgr  %0,%0\n"
-		"   sacf  256\n"
-		"0: srst  %3,%2\n"
-		"   jo    0b\n"
-		"   la    %0,1(%3)\n"	/* strnlen_user results includes \0 */
-		"   slgr  %0,%1\n"
-		"1: sacf  768\n"
-		EX_TABLE(0b,1b)
-		: "+a" (size), "+a" (src), "=a" (tmp1), "=a" (tmp2)
-		:
-		: "cc", "memory", "0");
-	return size;
-}
-
-unsigned long __strnlen_user(const char __user *src, unsigned long size)
-{
-	if (unlikely(!size))
-		return 0;
-	return strnlen_user_srst(src, size);
-}
-EXPORT_SYMBOL(__strnlen_user);
-
-long __strncpy_from_user(char *dst, const char __user *src, long size)
-{
-	size_t done, len, offset, len_str;
-
-	if (unlikely(size <= 0))
-		return 0;
-	done = 0;
-	do {
-		offset = (size_t)src & (L1_CACHE_BYTES - 1);
-		len = min(size - done, L1_CACHE_BYTES - offset);
-		if (copy_from_user(dst, src, len))
-			return -EFAULT;
-		len_str = strnlen(dst, len);
-		done += len_str;
-		src += len_str;
-		dst += len_str;
-	} while ((len_str == len) && (done < size));
-	return done;
-}
-EXPORT_SYMBOL(__strncpy_from_user);
-- 
2.25.1


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 20:07         ` Heiko Carstens
  0 siblings, 0 replies; 116+ messages in thread
From: Heiko Carstens @ 2021-07-22 20:07 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Johannes Berg, linux-arch, Arnd Bergmann, James E.J. Bottomley,
	Al Viro, Anton Ivanov, Brian Cain, Chris Zankel,
	Christian Borntraeger, Christoph Hellwig, Guo Ren, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390,
	open list:SYNOPSYS ARC ARCHITECTURE, linux-um,
	open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 04:01:39PM +0200, Arnd Bergmann wrote:
> On Thu, Jul 22, 2021 at 3:57 PM Johannes Berg <johannes@sipsolutions.net> wrote:
> >
> > >
> > > The remaining architectures at the moment are: ia64, mips, parisc,
> > > s390, um and xtensa. We should probably convert these as well, but
> >
> > I'm not sure it makes sense to convert um, the implementation uses
> > strncpy(), and that should use the libc implementation, which is tuned
> > for the actual hardware that the binary is running on, so performance
> > wise that might be better.
> >
> > OTOH, maybe this is all in the noise given the huge syscall overhead in
> > um, so maybe unifying it would make more sense.
> 
> Right, makes sense. I suppose if we end up converting mips and s390,
> we should just do arch/um and the others as well for consistency, even
> if that adds some overhead.

Feel free to add the s390 patch below on top of your series. However
one question: the strncpy_from_user() prototype now comes everywhere
without the __must_check attribute. Is there any reason for that?

At least for s390 I want to keep that.

From 03ad679909af58e1dc6864f47ce67210f0534c39 Mon Sep 17 00:00:00 2001
From: Heiko Carstens <hca@linux.ibm.com>
Date: Thu, 22 Jul 2021 21:48:18 +0200
Subject: [PATCH] s390: use generic strncpy/strnlen from_user

The s390 variant of strncpy_from_user() is slightly faster than the
generic variant, however convert to the generic variant now to follow
most if not all other architectures.

Converting to the generic variant was already considered a couple of
years ago. See commit f5c8b9601036 ("s390/uaccess: use sane length for
__strncpy_from_user()").

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
 arch/s390/Kconfig               |  2 --
 arch/s390/include/asm/uaccess.h | 18 ++----------
 arch/s390/lib/uaccess.c         | 52 ---------------------------------
 3 files changed, 2 insertions(+), 70 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index f4f39087cad0..a0e2130f0100 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -75,8 +75,6 @@ config S390
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
-	select ARCH_HAS_STRNCPY_FROM_USER
-	select ARCH_HAS_STRNLEN_USER
 	select ARCH_HAS_SYSCALL_WRAPPER
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_VDSO_DATA
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
index 2316f2440881..9ed9aa37e836 100644
--- a/arch/s390/include/asm/uaccess.h
+++ b/arch/s390/include/asm/uaccess.h
@@ -233,23 +233,9 @@ raw_copy_in_user(void __user *to, const void __user *from, unsigned long n);
 /*
  * Copy a null terminated string from userspace.
  */
+long __must_check strncpy_from_user(char *dst, const char __user *src, long count);
 
-long __strncpy_from_user(char *dst, const char __user *src, long count);
-
-static inline long __must_check
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	might_fault();
-	return __strncpy_from_user(dst, src, count);
-}
-
-unsigned long __must_check __strnlen_user(const char __user *src, unsigned long count);
-
-static inline unsigned long strnlen_user(const char __user *src, unsigned long n)
-{
-	might_fault();
-	return __strnlen_user(src, n);
-}
+long __must_check strnlen_user(const char __user *src, long count);
 
 /*
  * Zero Userspace
diff --git a/arch/s390/lib/uaccess.c b/arch/s390/lib/uaccess.c
index 7ec8b1fa0f08..94ca99bde59d 100644
--- a/arch/s390/lib/uaccess.c
+++ b/arch/s390/lib/uaccess.c
@@ -338,55 +338,3 @@ unsigned long __clear_user(void __user *to, unsigned long size)
 	return clear_user_xc(to, size);
 }
 EXPORT_SYMBOL(__clear_user);
-
-static inline unsigned long strnlen_user_srst(const char __user *src,
-					      unsigned long size)
-{
-	unsigned long tmp1, tmp2;
-
-	asm volatile(
-		"   lghi  0,0\n"
-		"   la    %2,0(%1)\n"
-		"   la    %3,0(%0,%1)\n"
-		"   slgr  %0,%0\n"
-		"   sacf  256\n"
-		"0: srst  %3,%2\n"
-		"   jo    0b\n"
-		"   la    %0,1(%3)\n"	/* strnlen_user results includes \0 */
-		"   slgr  %0,%1\n"
-		"1: sacf  768\n"
-		EX_TABLE(0b,1b)
-		: "+a" (size), "+a" (src), "=a" (tmp1), "=a" (tmp2)
-		:
-		: "cc", "memory", "0");
-	return size;
-}
-
-unsigned long __strnlen_user(const char __user *src, unsigned long size)
-{
-	if (unlikely(!size))
-		return 0;
-	return strnlen_user_srst(src, size);
-}
-EXPORT_SYMBOL(__strnlen_user);
-
-long __strncpy_from_user(char *dst, const char __user *src, long size)
-{
-	size_t done, len, offset, len_str;
-
-	if (unlikely(size <= 0))
-		return 0;
-	done = 0;
-	do {
-		offset = (size_t)src & (L1_CACHE_BYTES - 1);
-		len = min(size - done, L1_CACHE_BYTES - offset);
-		if (copy_from_user(dst, src, len))
-			return -EFAULT;
-		len_str = strnlen(dst, len);
-		done += len_str;
-		src += len_str;
-		dst += len_str;
-	} while ((len_str = len) && (done < size));
-	return done;
-}
-EXPORT_SYMBOL(__strncpy_from_user);
-- 
2.25.1

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-22 20:07         ` Heiko Carstens
  0 siblings, 0 replies; 116+ messages in thread
From: Heiko Carstens @ 2021-07-22 20:07 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Johannes Berg, linux-arch, Arnd Bergmann, James E.J. Bottomley,
	Al Viro, Anton Ivanov, Brian Cain, Chris Zankel,
	Christian Borntraeger, Christoph Hellwig, Guo Ren, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...

On Thu, Jul 22, 2021 at 04:01:39PM +0200, Arnd Bergmann wrote:
> On Thu, Jul 22, 2021 at 3:57 PM Johannes Berg <johannes@sipsolutions.net> wrote:
> >
> > >
> > > The remaining architectures at the moment are: ia64, mips, parisc,
> > > s390, um and xtensa. We should probably convert these as well, but
> >
> > I'm not sure it makes sense to convert um, the implementation uses
> > strncpy(), and that should use the libc implementation, which is tuned
> > for the actual hardware that the binary is running on, so performance
> > wise that might be better.
> >
> > OTOH, maybe this is all in the noise given the huge syscall overhead in
> > um, so maybe unifying it would make more sense.
> 
> Right, makes sense. I suppose if we end up converting mips and s390,
> we should just do arch/um and the others as well for consistency, even
> if that adds some overhead.

Feel free to add the s390 patch below on top of your series. However
one question: the strncpy_from_user() prototype now comes everywhere
without the __must_check attribute. Is there any reason for that?

At least for s390 I want to keep that.

From 03ad679909af58e1dc6864f47ce67210f0534c39 Mon Sep 17 00:00:00 2001
From: Heiko Carstens <hca@linux.ibm.com>
Date: Thu, 22 Jul 2021 21:48:18 +0200
Subject: [PATCH] s390: use generic strncpy/strnlen from_user

The s390 variant of strncpy_from_user() is slightly faster than the
generic variant, however convert to the generic variant now to follow
most if not all other architectures.

Converting to the generic variant was already considered a couple of
years ago. See commit f5c8b9601036 ("s390/uaccess: use sane length for
__strncpy_from_user()").

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
 arch/s390/Kconfig               |  2 --
 arch/s390/include/asm/uaccess.h | 18 ++----------
 arch/s390/lib/uaccess.c         | 52 ---------------------------------
 3 files changed, 2 insertions(+), 70 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index f4f39087cad0..a0e2130f0100 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -75,8 +75,6 @@ config S390
 	select ARCH_HAS_SET_MEMORY
 	select ARCH_HAS_STRICT_KERNEL_RWX
 	select ARCH_HAS_STRICT_MODULE_RWX
-	select ARCH_HAS_STRNCPY_FROM_USER
-	select ARCH_HAS_STRNLEN_USER
 	select ARCH_HAS_SYSCALL_WRAPPER
 	select ARCH_HAS_UBSAN_SANITIZE_ALL
 	select ARCH_HAS_VDSO_DATA
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
index 2316f2440881..9ed9aa37e836 100644
--- a/arch/s390/include/asm/uaccess.h
+++ b/arch/s390/include/asm/uaccess.h
@@ -233,23 +233,9 @@ raw_copy_in_user(void __user *to, const void __user *from, unsigned long n);
 /*
  * Copy a null terminated string from userspace.
  */
+long __must_check strncpy_from_user(char *dst, const char __user *src, long count);
 
-long __strncpy_from_user(char *dst, const char __user *src, long count);
-
-static inline long __must_check
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	might_fault();
-	return __strncpy_from_user(dst, src, count);
-}
-
-unsigned long __must_check __strnlen_user(const char __user *src, unsigned long count);
-
-static inline unsigned long strnlen_user(const char __user *src, unsigned long n)
-{
-	might_fault();
-	return __strnlen_user(src, n);
-}
+long __must_check strnlen_user(const char __user *src, long count);
 
 /*
  * Zero Userspace
diff --git a/arch/s390/lib/uaccess.c b/arch/s390/lib/uaccess.c
index 7ec8b1fa0f08..94ca99bde59d 100644
--- a/arch/s390/lib/uaccess.c
+++ b/arch/s390/lib/uaccess.c
@@ -338,55 +338,3 @@ unsigned long __clear_user(void __user *to, unsigned long size)
 	return clear_user_xc(to, size);
 }
 EXPORT_SYMBOL(__clear_user);
-
-static inline unsigned long strnlen_user_srst(const char __user *src,
-					      unsigned long size)
-{
-	unsigned long tmp1, tmp2;
-
-	asm volatile(
-		"   lghi  0,0\n"
-		"   la    %2,0(%1)\n"
-		"   la    %3,0(%0,%1)\n"
-		"   slgr  %0,%0\n"
-		"   sacf  256\n"
-		"0: srst  %3,%2\n"
-		"   jo    0b\n"
-		"   la    %0,1(%3)\n"	/* strnlen_user results includes \0 */
-		"   slgr  %0,%1\n"
-		"1: sacf  768\n"
-		EX_TABLE(0b,1b)
-		: "+a" (size), "+a" (src), "=a" (tmp1), "=a" (tmp2)
-		:
-		: "cc", "memory", "0");
-	return size;
-}
-
-unsigned long __strnlen_user(const char __user *src, unsigned long size)
-{
-	if (unlikely(!size))
-		return 0;
-	return strnlen_user_srst(src, size);
-}
-EXPORT_SYMBOL(__strnlen_user);
-
-long __strncpy_from_user(char *dst, const char __user *src, long size)
-{
-	size_t done, len, offset, len_str;
-
-	if (unlikely(size <= 0))
-		return 0;
-	done = 0;
-	do {
-		offset = (size_t)src & (L1_CACHE_BYTES - 1);
-		len = min(size - done, L1_CACHE_BYTES - offset);
-		if (copy_from_user(dst, src, len))
-			return -EFAULT;
-		len_str = strnlen(dst, len);
-		done += len_str;
-		src += len_str;
-		dst += len_str;
-	} while ((len_str == len) && (done < size));
-	return done;
-}
-EXPORT_SYMBOL(__strncpy_from_user);
-- 
2.25.1

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

* Re: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
  2021-07-22 12:48   ` Arnd Bergmann
                     ` (3 preceding siblings ...)
  (?)
@ 2021-07-22 20:48   ` kernel test robot
  2021-07-23 12:36       ` Arnd Bergmann
  -1 siblings, 1 reply; 116+ messages in thread
From: kernel test robot @ 2021-07-22 20:48 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5475 bytes --]

Hi Arnd,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.14-rc2 next-20210722]
[cannot apply to asm-generic/master arc/for-next uclinux-h8/h8300-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Arnd-Bergmann/asm-generic-uaccess-h-remove-__strncpy_from_user-__strnlen_user/20210722-214839
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 3d5895cd351757f69c9a66fb5fc8cf19f454d773
config: microblaze-buildonly-randconfig-r005-20210722 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/50efd0b2c40f098c1c02453d22bc3f3ef58d8a76
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Arnd-Bergmann/asm-generic-uaccess-h-remove-__strncpy_from_user-__strnlen_user/20210722-214839
        git checkout 50efd0b2c40f098c1c02453d22bc3f3ef58d8a76
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross O=build_dir ARCH=microblaze SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   lib/strncpy_from_user.c: In function 'strncpy_from_user':
>> lib/strncpy_from_user.c:123:13: error: implicit declaration of function 'user_addr_max' [-Werror=implicit-function-declaration]
     123 |  max_addr = user_addr_max();
         |             ^~~~~~~~~~~~~
   cc1: some warnings being treated as errors
--
>> lib/strnlen_user.c:92:6: error: conflicting types for 'strnlen_user'
      92 | long strnlen_user(const char __user *str, long count)
         |      ^~~~~~~~~~~~
   In file included from include/linux/uaccess.h:11,
                    from lib/strnlen_user.c:4:
   arch/microblaze/include/asm/uaccess.h:306:13: note: previous declaration of 'strnlen_user' was here
     306 | extern long strnlen_user(const char __user *sstr, int len);
         |             ^~~~~~~~~~~~
   lib/strnlen_user.c: In function 'strnlen_user':
>> lib/strnlen_user.c:99:13: error: implicit declaration of function 'user_addr_max' [-Werror=implicit-function-declaration]
      99 |  max_addr = user_addr_max();
         |             ^~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/strnlen_user +92 lib/strnlen_user.c

a08c5356a3aaf6 Linus Torvalds    2012-05-26  70  
a08c5356a3aaf6 Linus Torvalds    2012-05-26  71  /**
a08c5356a3aaf6 Linus Torvalds    2012-05-26  72   * strnlen_user: - Get the size of a user string INCLUDING final NUL.
a08c5356a3aaf6 Linus Torvalds    2012-05-26  73   * @str: The string to measure.
a08c5356a3aaf6 Linus Torvalds    2012-05-26  74   * @count: Maximum count (including NUL character)
a08c5356a3aaf6 Linus Torvalds    2012-05-26  75   *
b3c395ef5556a6 David Hildenbrand 2015-05-11  76   * Context: User context only. This function may sleep if pagefaults are
b3c395ef5556a6 David Hildenbrand 2015-05-11  77   *          enabled.
a08c5356a3aaf6 Linus Torvalds    2012-05-26  78   *
a08c5356a3aaf6 Linus Torvalds    2012-05-26  79   * Get the size of a NUL-terminated string in user space.
a08c5356a3aaf6 Linus Torvalds    2012-05-26  80   *
a08c5356a3aaf6 Linus Torvalds    2012-05-26  81   * Returns the size of the string INCLUDING the terminating NUL.
226a07ef0a5a2d Jan Kara          2015-06-03  82   * If the string is too long, returns a number larger than @count. User
226a07ef0a5a2d Jan Kara          2015-06-03  83   * has to check the return value against "> count".
a08c5356a3aaf6 Linus Torvalds    2012-05-26  84   * On exception (or invalid count), returns 0.
226a07ef0a5a2d Jan Kara          2015-06-03  85   *
226a07ef0a5a2d Jan Kara          2015-06-03  86   * NOTE! You should basically never use this function. There is
226a07ef0a5a2d Jan Kara          2015-06-03  87   * almost never any valid case for using the length of a user space
226a07ef0a5a2d Jan Kara          2015-06-03  88   * string, since the string can be changed at any time by other
226a07ef0a5a2d Jan Kara          2015-06-03  89   * threads. Use "strncpy_from_user()" instead to get a stable copy
226a07ef0a5a2d Jan Kara          2015-06-03  90   * of the string.
a08c5356a3aaf6 Linus Torvalds    2012-05-26  91   */
a08c5356a3aaf6 Linus Torvalds    2012-05-26 @92  long strnlen_user(const char __user *str, long count)
a08c5356a3aaf6 Linus Torvalds    2012-05-26  93  {
a08c5356a3aaf6 Linus Torvalds    2012-05-26  94  	unsigned long max_addr, src_addr;
a08c5356a3aaf6 Linus Torvalds    2012-05-26  95  
a08c5356a3aaf6 Linus Torvalds    2012-05-26  96  	if (unlikely(count <= 0))
a08c5356a3aaf6 Linus Torvalds    2012-05-26  97  		return 0;
a08c5356a3aaf6 Linus Torvalds    2012-05-26  98  
a08c5356a3aaf6 Linus Torvalds    2012-05-26 @99  	max_addr = user_addr_max();

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33408 bytes --]

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

* Re: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
  2021-07-22 20:48   ` kernel test robot
@ 2021-07-23 12:36       ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-23 12:36 UTC (permalink / raw)
  To: kernel test robot, Christoph Hellwig, linux-arch; +Cc: kbuild-all

On Thu, Jul 22, 2021 at 10:48 PM kernel test robot <lkp@intel.com> wrote:
>
> All errors (new ones prefixed by >>):
>
>    lib/strncpy_from_user.c: In function 'strncpy_from_user':
> >> lib/strncpy_from_user.c:123:13: error: implicit declaration of function 'user_addr_max' [-Werror=implicit-function-declaration]
>      123 |  max_addr = user_addr_max();
>          |             ^~~~~~~~~~~~~
>    cc1: some warnings being treated as errors

> --
> >> lib/strnlen_user.c:92:6: error: conflicting types for 'strnlen_user'
>       92 | long strnlen_user(const char __user *str, long count)
>          |      ^~~~~~~~~~~~
>    In file included from include/linux/uaccess.h:11,
>                     from lib/strnlen_user.c:4:
>    arch/microblaze/include/asm/uaccess.h:306:13: note: previous declaration of 'strnlen_user' was here
>      306 | extern long strnlen_user(const char __user *sstr, int len);

Fixed both now, thanks for the report.

I had to add a user_addr_max() definition here, which unfortunately
will also conflict
with the get_fs() removal if Christoph plans to have that merged
through the microblaze
tree.

If this becomes a problem, I could merge both series through the
asm-generic tree.

     Arnd

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

* Re: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
@ 2021-07-23 12:36       ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-23 12:36 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1249 bytes --]

On Thu, Jul 22, 2021 at 10:48 PM kernel test robot <lkp@intel.com> wrote:
>
> All errors (new ones prefixed by >>):
>
>    lib/strncpy_from_user.c: In function 'strncpy_from_user':
> >> lib/strncpy_from_user.c:123:13: error: implicit declaration of function 'user_addr_max' [-Werror=implicit-function-declaration]
>      123 |  max_addr = user_addr_max();
>          |             ^~~~~~~~~~~~~
>    cc1: some warnings being treated as errors

> --
> >> lib/strnlen_user.c:92:6: error: conflicting types for 'strnlen_user'
>       92 | long strnlen_user(const char __user *str, long count)
>          |      ^~~~~~~~~~~~
>    In file included from include/linux/uaccess.h:11,
>                     from lib/strnlen_user.c:4:
>    arch/microblaze/include/asm/uaccess.h:306:13: note: previous declaration of 'strnlen_user' was here
>      306 | extern long strnlen_user(const char __user *sstr, int len);

Fixed both now, thanks for the report.

I had to add a user_addr_max() definition here, which unfortunately
will also conflict
with the get_fs() removal if Christoph plans to have that merged
through the microblaze
tree.

If this becomes a problem, I could merge both series through the
asm-generic tree.

     Arnd

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

* Re: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
  2021-07-23 12:36       ` Arnd Bergmann
@ 2021-07-23 12:42         ` Christoph Hellwig
  -1 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-23 12:42 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: kernel test robot, Christoph Hellwig, linux-arch, kbuild-all

On Fri, Jul 23, 2021 at 02:36:15PM +0200, Arnd Bergmann wrote:
> I had to add a user_addr_max() definition here, which unfortunately
> will also conflict
> with the get_fs() removal if Christoph plans to have that merged
> through the microblaze
> tree.

I don't have any patches to remove set_fs for microblaze so far.

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

* Re: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
@ 2021-07-23 12:42         ` Christoph Hellwig
  0 siblings, 0 replies; 116+ messages in thread
From: Christoph Hellwig @ 2021-07-23 12:42 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 326 bytes --]

On Fri, Jul 23, 2021 at 02:36:15PM +0200, Arnd Bergmann wrote:
> I had to add a user_addr_max() definition here, which unfortunately
> will also conflict
> with the get_fs() removal if Christoph plans to have that merged
> through the microblaze
> tree.

I don't have any patches to remove set_fs for microblaze so far.

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
  2021-07-22 20:07         ` Heiko Carstens
  (?)
  (?)
@ 2021-07-23 12:44           ` Arnd Bergmann
  -1 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-23 12:44 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Johannes Berg, linux-arch, Arnd Bergmann, James E.J. Bottomley,
	Al Viro, Anton Ivanov, Brian Cain, Chris Zankel,
	Christian Borntraeger, Christoph Hellwig, Guo Ren, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390,
	open list:SYNOPSYS ARC ARCHITECTURE, linux-um,
	open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 10:07 PM Heiko Carstens <hca@linux.ibm.com> wrote:
>
> Feel free to add the s390 patch below on top of your series.

Thanks a lot, added now.

> However one question: the strncpy_from_user() prototype now comes everywhere
> without the __must_check attribute. Is there any reason for that?
>
> At least for s390 I want to keep that.

Makes sense, I'll add a patch for that as well.

        Arnd

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-23 12:44           ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-23 12:44 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Johannes Berg, linux-arch, Arnd Bergmann, James E.J. Bottomley,
	Al Viro, Anton Ivanov, Brian Cain, Chris Zankel,
	Christian Borntraeger, Christoph Hellwig, Guo Ren, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390,
	open list:SYNOPSYS ARC ARCHITECTURE, linux-um,
	open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 10:07 PM Heiko Carstens <hca@linux.ibm.com> wrote:
>
> Feel free to add the s390 patch below on top of your series.

Thanks a lot, added now.

> However one question: the strncpy_from_user() prototype now comes everywhere
> without the __must_check attribute. Is there any reason for that?
>
> At least for s390 I want to keep that.

Makes sense, I'll add a patch for that as well.

        Arnd

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-23 12:44           ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-23 12:44 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Johannes Berg, linux-arch, Arnd Bergmann, James E.J. Bottomley,
	Al Viro, Anton Ivanov, Brian Cain, Chris Zankel,
	Christian Borntraeger, Christoph Hellwig, Guo Ren, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390,
	open list:SYNOPSYS ARC ARCHITECTURE, linux-um,
	open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 10:07 PM Heiko Carstens <hca@linux.ibm.com> wrote:
>
> Feel free to add the s390 patch below on top of your series.

Thanks a lot, added now.

> However one question: the strncpy_from_user() prototype now comes everywhere
> without the __must_check attribute. Is there any reason for that?
>
> At least for s390 I want to keep that.

Makes sense, I'll add a patch for that as well.

        Arnd

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-23 12:44           ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-07-23 12:44 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Johannes Berg, linux-arch, Arnd Bergmann, James E.J. Bottomley,
	Al Viro, Anton Ivanov, Brian Cain, Chris Zankel,
	Christian Borntraeger, Christoph Hellwig, Guo Ren, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta

On Thu, Jul 22, 2021 at 10:07 PM Heiko Carstens <hca@linux.ibm.com> wrote:
>
> Feel free to add the s390 patch below on top of your series.

Thanks a lot, added now.

> However one question: the strncpy_from_user() prototype now comes everywhere
> without the __must_check attribute. Is there any reason for that?
>
> At least for s390 I want to keep that.

Makes sense, I'll add a patch for that as well.

        Arnd

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
  2021-07-22 12:48   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols Arnd Bergmann
  (?)
  (?)
@ 2021-07-24  9:44     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 116+ messages in thread
From: Geert Uytterhoeven @ 2021-07-24  9:44 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linux-Arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390, arcml,
	linux-um, open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 2:50 PM Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
>
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
>
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.
>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Helge Deller <deller@gmx.de>
> Cc: Jeff Dike <jdike@addtoit.com>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: Richard Weinberger <richard@nod.at>
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: linux-ia64@vger.kernel.org
> Cc: linux-mips@vger.kernel.org
> Cc: linux-parisc@vger.kernel.org
> Cc: linux-s390@vger.kernel.org
> Cc: linux-um@lists.infradead.org
> Cc: linux-xtensa@linux-xtensa.org
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

>  arch/m68k/Kconfig                 |  2 --

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols
@ 2021-07-24  9:44     ` Geert Uytterhoeven
  0 siblings, 0 replies; 116+ messages in thread
From: Geert Uytterhoeven @ 2021-07-24  9:44 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linux-Arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390, arcml,
	linux-um, open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 2:50 PM Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
>
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
>
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.
>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Helge Deller <deller@gmx.de>
> Cc: Jeff Dike <jdike@addtoit.com>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: Richard Weinberger <richard@nod.at>
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: linux-ia64@vger.kernel.org
> Cc: linux-mips@vger.kernel.org
> Cc: linux-parisc@vger.kernel.org
> Cc: linux-s390@vger.kernel.org
> Cc: linux-um@lists.infradead.org
> Cc: linux-xtensa@linux-xtensa.org
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

>  arch/m68k/Kconfig                 |  2 --

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
@ 2021-07-24  9:44     ` Geert Uytterhoeven
  0 siblings, 0 replies; 116+ messages in thread
From: Geert Uytterhoeven @ 2021-07-24  9:44 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linux-Arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta, Yoshinori Sato, linux-csky,
	open list:QUALCOMM HEXAGON...,
	linux-ia64, Linux Kernel Mailing List,
	open list:BROADCOM NVRAM DRIVER, Parisc List, linux-s390, arcml,
	linux-um, open list:TENSILICA XTENSA PORT (xtensa),
	moderated list:H8/300 ARCHITECTURE

On Thu, Jul 22, 2021 at 2:50 PM Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
>
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
>
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.
>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Helge Deller <deller@gmx.de>
> Cc: Jeff Dike <jdike@addtoit.com>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: Richard Weinberger <richard@nod.at>
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: linux-ia64@vger.kernel.org
> Cc: linux-mips@vger.kernel.org
> Cc: linux-parisc@vger.kernel.org
> Cc: linux-s390@vger.kernel.org
> Cc: linux-um@lists.infradead.org
> Cc: linux-xtensa@linux-xtensa.org
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

>  arch/m68k/Kconfig                 |  2 --

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
@ 2021-07-24  9:44     ` Geert Uytterhoeven
  0 siblings, 0 replies; 116+ messages in thread
From: Geert Uytterhoeven @ 2021-07-24  9:44 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linux-Arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Vineet Gupta

On Thu, Jul 22, 2021 at 2:50 PM Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
>
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
>
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.
>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Helge Deller <deller@gmx.de>
> Cc: Jeff Dike <jdike@addtoit.com>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: Richard Weinberger <richard@nod.at>
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: linux-ia64@vger.kernel.org
> Cc: linux-mips@vger.kernel.org
> Cc: linux-parisc@vger.kernel.org
> Cc: linux-s390@vger.kernel.org
> Cc: linux-um@lists.infradead.org
> Cc: linux-xtensa@linux-xtensa.org
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

>  arch/m68k/Kconfig                 |  2 --

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
  2021-07-22 12:48   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols Arnd Bergmann
                       ` (2 preceding siblings ...)
  (?)
@ 2021-07-26  8:55     ` Helge Deller
  -1 siblings, 0 replies; 116+ messages in thread
From: Helge Deller @ 2021-07-26  8:55 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Jeff Dike,
	Linus Walleij, Max Filippov, Michal Simek, Richard Weinberger,
	Thomas Bogendoerfer, Vasily Gorbik, Vineet Gupta, Yoshinori Sato,
	linux-csky, linux-hexagon, linux-ia64, linux-kernel, linux-mips,
	linux-parisc, linux-s390, linux-snps-arc, linux-um, linux-xtensa,
	uclinux-h8-devel

On 7/22/21 2:48 PM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
>
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
>
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.

Acked-by: Helge Deller <deller@gmx.de> # parisc

Thanks!
Helge

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
@ 2021-07-26  8:55     ` Helge Deller
  0 siblings, 0 replies; 116+ messages in thread
From: Helge Deller @ 2021-07-26  8:55 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Jeff Dike,
	Linus Walleij, Max Filippov, Michal Simek, Richard Weinberger,
	Thomas Bogendoerfer, Vasily Gorbik, Vineet Gupta, Yoshinori Sato,
	linux-csky, linux-hexagon, linux-ia64, linux-kernel, linux-mips,
	linux-parisc, linux-s390, linux-snps-arc, linux-um, linux-xtensa,
	uclinux-h8-devel

On 7/22/21 2:48 PM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
>
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
>
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.

Acked-by: Helge Deller <deller@gmx.de> # parisc

Thanks!
Helge

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
@ 2021-07-26  8:55     ` Helge Deller
  0 siblings, 0 replies; 116+ messages in thread
From: Helge Deller @ 2021-07-26  8:55 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Jeff Dike,
	Linus Walleij, Max Filippov, Michal Simek, Richard Weinberger,
	Thomas Bogendoerfer, Vasily Gorbik, Vineet Gupta, Yoshinori Sato,
	linux-csky, linux-hexagon, linux-ia64, linux-kernel, linux-mips,
	linux-parisc, linux-s390, linux-snps-arc, linux-um, linux-xtensa,
	uclinux-h8-devel

On 7/22/21 2:48 PM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
>
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
>
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.

Acked-by: Helge Deller <deller@gmx.de> # parisc

Thanks!
Helge

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
@ 2021-07-26  8:55     ` Helge Deller
  0 siblings, 0 replies; 116+ messages in thread
From: Helge Deller @ 2021-07-26  8:55 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Jeff Dike,
	Linus Walleij, Max Filippov, Michal Simek, Richard Weinberger,
	Thomas Bogendoerfer, Vasily Gorbik, Vineet Gupta, Yoshinori Sato,
	linux-csky, linux-hexagon, linux-ia64, linux-kernel, linux-mips,
	linux-parisc, linux-s390, linux-snps-arc, linux-um, linux-xtensa,
	uclinux-h8-devel

On 7/22/21 2:48 PM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
>
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
>
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.

Acked-by: Helge Deller <deller@gmx.de> # parisc

Thanks!
Helge

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

* Re: [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
@ 2021-07-26  8:55     ` Helge Deller
  0 siblings, 0 replies; 116+ messages in thread
From: Helge Deller @ 2021-07-26  8:55 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Jeff Dike,
	Linus Walleij, Max Filippov, Michal Simek, Richard Weinberger,
	Thomas Bogendoerfer, Vasily Gorbik, Vineet Gupta, Yoshinori Sato,
	linux-csky

On 7/22/21 2:48 PM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Most architectures do not need a custom implementation, and in most
> cases the generic implementation is preferred, so change the polariy
> on these Kconfig symbols to require architectures to select them when
> they provide their own version.
>
> The new name is CONFIG_ARCH_HAS_{STRNCPY_FROM,STRNLEN}_USER.
>
> The remaining architectures at the moment are: ia64, mips, parisc,
> s390, um and xtensa. We should probably convert these as well, but
> I was not sure how far to take this series.

Acked-by: Helge Deller <deller@gmx.de> # parisc

Thanks!
Helge

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

* Re: [PATCH v3 0/6] asm-generic: strncpy_from_user/strnlen_user cleanup
  2021-07-22 12:48 ` Arnd Bergmann
                   ` (11 preceding siblings ...)
  (?)
@ 2021-08-14  1:04 ` Vineet Gupta
  2021-08-14 11:10   ` Arnd Bergmann
  -1 siblings, 1 reply; 116+ messages in thread
From: Vineet Gupta @ 2021-08-14  1:04 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch
  Cc: Arnd Bergmann, James E.J. Bottomley, Al Viro, Anton Ivanov,
	Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Yoshinori Sato, Will Deacon, Peter Zijlstra

Hi Arnd,

On 7/22/21 5:48 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> I had run into some regressions for the previous version of this
> series, the new version is based on v5.14-rc2 instead.
> 
> These two functions appear to be unnecessarily different between
> architectures, and the asm-generic version is a bit questionable,
> even for NOMMU architectures.
> 
> Clean this up to just use the generic library version for anything
> that uses the generic version today. I've expanded on the patch
> descriptions a little, as suggested by Christoph Hellwig, but I
> suspect a more detailed review would uncover additional problems
> with the custom versions that are getting removed.
> 
> I ended up adding patches for csky and microblaze as they had the
> same implementation that I removed elsewhere, these are now gone
> as well.
> 
> If I hear no objections from architecture maintainers or new
> build regressions, I'll queue these up in the asm-generic tree
> for 5.15.
> 
>         Arnd
> 
> Link: https://lore.kernel.org/linux-arch/20210515101803.924427-1-arnd@kernel.org/

Are you planning to add this to asm-generic tree for 5.15 anytime soon.
Also while there, any chance you could pick up [1] too which was Acked 
by Will.

Thx,
-Vineet

[1] 
https://lore.kernel.org/linux-arch/20210805191408.2003237-1-vgupta@synopsys.com/


> 
> Arnd Bergmann (9):
>    asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
>    h8300: remove stale strncpy_from_user
>    hexagon: use generic strncpy/strnlen from_user
>    arc: use generic strncpy/strnlen from_user
>    csky: use generic strncpy/strnlen from_user
>    microblaze: use generic strncpy/strnlen from_user
>    asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user
>    asm-generic: remove extra strn{cpy_from,len}_user declarations
>    asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols
> 
>   arch/alpha/Kconfig                        |   2 -
>   arch/arc/include/asm/uaccess.h            |  72 -------------
>   arch/arc/mm/extable.c                     |  12 ---
>   arch/arm/Kconfig                          |   2 -
>   arch/arm64/Kconfig                        |   2 -
>   arch/csky/include/asm/uaccess.h           |   6 --
>   arch/csky/lib/usercopy.c                  | 102 ------------------
>   arch/h8300/kernel/h8300_ksyms.c           |   2 -
>   arch/h8300/lib/Makefile                   |   2 +-
>   arch/h8300/lib/strncpy.S                  |  35 ------
>   arch/hexagon/include/asm/uaccess.h        |  31 ------
>   arch/hexagon/kernel/hexagon_ksyms.c       |   1 -
>   arch/hexagon/mm/Makefile                  |   2 +-
>   arch/hexagon/mm/strnlen_user.S            | 126 ----------------------
>   arch/ia64/Kconfig                         |   2 +
>   arch/m68k/Kconfig                         |   2 -
>   arch/microblaze/include/asm/uaccess.h     |  19 +---
>   arch/microblaze/kernel/microblaze_ksyms.c |   3 -
>   arch/microblaze/lib/uaccess_old.S         |  90 ----------------
>   arch/mips/Kconfig                         |   2 +
>   arch/nds32/Kconfig                        |   2 -
>   arch/nios2/Kconfig                        |   2 -
>   arch/openrisc/Kconfig                     |   2 -
>   arch/parisc/Kconfig                       |   2 +-
>   arch/powerpc/Kconfig                      |   2 -
>   arch/riscv/Kconfig                        |   2 -
>   arch/s390/Kconfig                         |   2 +
>   arch/sh/Kconfig                           |   2 -
>   arch/sparc/Kconfig                        |   2 -
>   arch/um/Kconfig                           |   2 +
>   arch/um/include/asm/uaccess.h             |   5 +-
>   arch/um/kernel/skas/uaccess.c             |  14 ++-
>   arch/x86/Kconfig                          |   2 -
>   arch/xtensa/Kconfig                       |   3 +-
>   arch/xtensa/include/asm/uaccess.h         |   3 +-
>   include/asm-generic/uaccess.h             |  52 ++-------
>   lib/Kconfig                               |  10 +-
>   37 files changed, 43 insertions(+), 581 deletions(-)
>   delete mode 100644 arch/h8300/lib/strncpy.S
>   delete mode 100644 arch/hexagon/mm/strnlen_user.S
> 


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

* Re: [PATCH v3 0/6] asm-generic: strncpy_from_user/strnlen_user cleanup
  2021-08-14  1:04 ` [PATCH v3 0/6] asm-generic: strncpy_from_user/strnlen_user cleanup Vineet Gupta
@ 2021-08-14 11:10   ` Arnd Bergmann
  0 siblings, 0 replies; 116+ messages in thread
From: Arnd Bergmann @ 2021-08-14 11:10 UTC (permalink / raw)
  To: Vineet Gupta
  Cc: linux-arch, Arnd Bergmann, James E.J. Bottomley, Al Viro,
	Anton Ivanov, Brian Cain, Chris Zankel, Christian Borntraeger,
	Christoph Hellwig, Guo Ren, Heiko Carstens, Helge Deller,
	Jeff Dike, Linus Walleij, Max Filippov, Michal Simek,
	Richard Weinberger, Thomas Bogendoerfer, Vasily Gorbik,
	Will Deacon, Peter Zijlstra

On Sat, Aug 14, 2021 at 3:04 AM Vineet Gupta <vgupta@kernel.org> wrote:
> On 7/22/21 5:48 AM, Arnd Bergmann wrote:
> > If I hear no objections from architecture maintainers or new
> > build regressions, I'll queue these up in the asm-generic tree
> > for 5.15.
> >
> >         Arnd
> >
> > Link: https://lore.kernel.org/linux-arch/20210515101803.924427-1-arnd@kernel.org/
>
> Are you planning to add this to asm-generic tree for 5.15 anytime soon.

Actually I just did that yesterday, but it was too late for linux-next
that day. ;-)

> Also while there, any chance you could pick up [1] too which was Acked
> by Will.

Done now as well, thanks for the pointer.

       Arnd

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

end of thread, other threads:[~2021-08-14 11:10 UTC | newest]

Thread overview: 116+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-22 12:48 [PATCH v3 0/6] asm-generic: strncpy_from_user/strnlen_user cleanup Arnd Bergmann
2021-07-22 12:48 ` Arnd Bergmann
2021-07-22 12:48 ` Arnd Bergmann
2021-07-22 12:48 ` Arnd Bergmann
2021-07-22 12:48 ` [PATCH v3 1/9] asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:59   ` Christoph Hellwig
2021-07-22 12:59     ` Christoph Hellwig
2021-07-22 12:59     ` Christoph Hellwig
2021-07-22 12:59     ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 2/9] h8300: remove stale strncpy_from_user Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:59   ` Christoph Hellwig
2021-07-22 12:59     ` Christoph Hellwig
2021-07-22 12:59     ` Christoph Hellwig
2021-07-22 12:59     ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 3/9] hexagon: use generic strncpy/strnlen from_user Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 13:00   ` Christoph Hellwig
2021-07-22 13:00     ` Christoph Hellwig
2021-07-22 13:00     ` Christoph Hellwig
2021-07-22 13:00     ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 4/9] arc: " Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 13:00   ` Christoph Hellwig
2021-07-22 13:00     ` Christoph Hellwig
2021-07-22 13:00     ` Christoph Hellwig
2021-07-22 13:00     ` Christoph Hellwig
2021-07-22 15:34   ` Vineet Gupta
2021-07-22 15:34     ` Vineet Gupta
2021-07-22 15:34     ` Vineet Gupta
2021-07-22 15:34     ` Vineet Gupta
2021-07-22 15:34     ` Vineet Gupta
2021-07-22 12:48 ` [PATCH v3 5/9] csky: " Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 13:01   ` Christoph Hellwig
2021-07-22 13:01     ` Christoph Hellwig
2021-07-22 13:01     ` Christoph Hellwig
2021-07-22 13:01     ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 6/9] microblaze: " Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 13:01   ` Christoph Hellwig
2021-07-22 13:01     ` Christoph Hellwig
2021-07-22 13:01     ` Christoph Hellwig
2021-07-22 13:01     ` Christoph Hellwig
2021-07-22 20:48   ` kernel test robot
2021-07-23 12:36     ` Arnd Bergmann
2021-07-23 12:36       ` Arnd Bergmann
2021-07-23 12:42       ` Christoph Hellwig
2021-07-23 12:42         ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 7/9] asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 13:02   ` Christoph Hellwig
2021-07-22 13:02     ` Christoph Hellwig
2021-07-22 13:02     ` Christoph Hellwig
2021-07-22 13:02     ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from,len}_user declarations Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from, len}_user declarations Arnd Bergmann
2021-07-22 13:02   ` [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from,len}_user declarations Christoph Hellwig
2021-07-22 13:02     ` Christoph Hellwig
2021-07-22 13:02     ` Christoph Hellwig
2021-07-22 13:02     ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols Arnd Bergmann
2021-07-22 13:03   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols Christoph Hellwig
2021-07-22 13:03     ` Christoph Hellwig
2021-07-22 13:03     ` Christoph Hellwig
2021-07-22 13:03     ` Christoph Hellwig
2021-07-22 13:57   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols Johannes Berg
2021-07-22 13:57     ` Johannes Berg
2021-07-22 13:57     ` Johannes Berg
2021-07-22 13:57     ` Johannes Berg
2021-07-22 13:57     ` Johannes Berg
2021-07-22 14:01     ` Arnd Bergmann
2021-07-22 14:01       ` Arnd Bergmann
2021-07-22 14:01       ` Arnd Bergmann
2021-07-22 14:01       ` Arnd Bergmann
2021-07-22 14:01       ` Arnd Bergmann
2021-07-22 20:07       ` Heiko Carstens
2021-07-22 20:07         ` Heiko Carstens
2021-07-22 20:07         ` Heiko Carstens
2021-07-22 20:07         ` Heiko Carstens
2021-07-22 20:07         ` Heiko Carstens
2021-07-23 12:44         ` Arnd Bergmann
2021-07-23 12:44           ` Arnd Bergmann
2021-07-23 12:44           ` Arnd Bergmann
2021-07-23 12:44           ` Arnd Bergmann
2021-07-24  9:44   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols Geert Uytterhoeven
2021-07-24  9:44     ` Geert Uytterhoeven
2021-07-24  9:44     ` Geert Uytterhoeven
2021-07-24  9:44     ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols Geert Uytterhoeven
2021-07-26  8:55   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols Helge Deller
2021-07-26  8:55     ` Helge Deller
2021-07-26  8:55     ` Helge Deller
2021-07-26  8:55     ` Helge Deller
2021-07-26  8:55     ` Helge Deller
2021-08-14  1:04 ` [PATCH v3 0/6] asm-generic: strncpy_from_user/strnlen_user cleanup Vineet Gupta
2021-08-14 11:10   ` Arnd Bergmann

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.