linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types
@ 2015-01-06 15:43 Michael S. Tsirkin
  2015-01-06 15:43 ` Michael S. Tsirkin
                   ` (41 more replies)
  0 siblings, 42 replies; 134+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch

changes from v1:

- xtensa and powerpc patches have been merged by maintainers, drop them
- added patches to fix put_user on a bunch of architectures
- add acks received since v1
- a bunch of whitespace tweaks


At the moment, if p and x are both tagged as bitwise types,
some of get_user(x, p), put_user(x, p), __get_user(x, p), __put_user(x, p)
produce a sparse warning on many architectures.
This is a false positive: *p on these architectures is loaded into long
(typically using asm), then cast back to typeof(*p).

When typeof(*p) is a bitwise type (which is uncommon), such a cast needs
__force, otherwise sparse produces a warning.

Some architectures already have the __force tag, add it
where it's missing.

I verified that adding these __force casts does not supress any useful warnings.

Specifically, vhost wants to read/write bitwise types in userspace memory
using get_user/put_user.
At the moment this triggers sparse errors, since the value is passed through an
integer.

For example:
    __le32 __user *p;
    __u32 x;

both
    put_user(x, p);
and
    get_user(x, p);
should be safe, but produce warnings on some architectures.


While there, I noticed that a bunch of architectures violated
coding style rules within uaccess macros.
Added patches to fix them up.


I tested this on x86 only. Since it's just adding __force, should be
trivially safe everywhere?


Arnd, did you merge v1 already? If yes, can you please replace with
this version?

Michael S. Tsirkin (40):
  x86/uaccess: fix sparse errors
  alpha/uaccess: fix sparse errors
  arm64/uaccess: fix sparse errors
  avr32/uaccess: fix sparse errors
  blackfin/uaccess: fix sparse errors
  cris/uaccess: fix sparse errors
  ia64/uaccess: fix sparse errors
  m32r/uaccess: fix sparse errors
  metag/uaccess: fix sparse errors
  microblaze/uaccess: fix sparse errors
  openrisc/uaccess: fix sparse errors
  parisc/uaccess: fix sparse errors
  sh/uaccess: fix sparse errors
  sparc32/uaccess: fix sparse errors
  sparc64/uaccess: fix sparse errors
  m68k/uaccess: fix sparse errors
  arm: fix put_user sparse errors
  blackfin: fix put_user sparse errors
  ia64: fix put_user sparse errors
  metag: fix put_user sparse errors
  sh: fix put_user sparse errors
  tile: fix put_user sparse errors
  tile: enable sparse checks for get/put_user
  avr32: whitespace fix
  arch/sparc: uaccess_32 macro whitespace fixes
  arch/sparc: uaccess_64 macro whitespace fixes
  blackfin: macro whitespace fixes
  microblaze: whitespace fix
  alpha: macro whitespace fixes
  arm: macro whitespace fixes
  arm64: macro whitespace fixes
  avr32: macro whitespace fixes
  cris: macro whitespace fixes
  frv: macro whitespace fixes
  m32r: macro whitespace fixes
  m68k: macro whitespace fixes
  parisc: macro whitespace fixes
  s390: macro whitespace fixes
  sh: macro whitespace fixes
  xtensa: macro whitespace fixes

 arch/alpha/include/asm/uaccess.h      |  86 ++++----
 arch/arm/include/asm/uaccess.h        |  96 ++++-----
 arch/arm64/include/asm/uaccess.h      |   4 +-
 arch/avr32/include/asm/uaccess.h      |  24 +--
 arch/blackfin/include/asm/uaccess.h   |  32 +--
 arch/cris/include/asm/uaccess.h       | 117 +++++------
 arch/frv/include/asm/segment.h        |   2 +-
 arch/ia64/include/asm/uaccess.h       |  11 +-
 arch/m32r/include/asm/uaccess.h       |  88 ++++----
 arch/m68k/include/asm/segment.h       |   2 +-
 arch/m68k/include/asm/uaccess_mm.h    |  40 ++--
 arch/metag/include/asm/uaccess.h      |  25 ++-
 arch/microblaze/include/asm/uaccess.h |   6 +-
 arch/openrisc/include/asm/uaccess.h   |   4 +-
 arch/parisc/include/asm/uaccess.h     | 116 +++++------
 arch/s390/include/asm/uaccess.h       |   4 +-
 arch/sh/include/asm/segment.h         |   2 +-
 arch/sh/include/asm/uaccess.h         |   4 +-
 arch/sh/include/asm/uaccess_64.h      |   8 +-
 arch/sparc/include/asm/uaccess_32.h   | 364 +++++++++++++++++++++-------------
 arch/sparc/include/asm/uaccess_64.h   | 246 +++++++++++++----------
 arch/tile/include/asm/uaccess.h       |   6 +-
 arch/x86/include/asm/uaccess.h        |   2 +-
 arch/xtensa/include/asm/uaccess.h     |  90 ++++-----
 24 files changed, 759 insertions(+), 620 deletions(-)

-- 
MST

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

end of thread, other threads:[~2015-01-27 16:28 UTC | newest]

Thread overview: 134+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
2015-01-06 15:43 ` Michael S. Tsirkin
2015-01-06 15:43 ` [PATCH v2 01/40] x86/uaccess: fix sparse errors Michael S. Tsirkin
2015-01-06 15:43   ` Michael S. Tsirkin
2015-01-13 12:33   ` Thomas Gleixner
2015-01-13 12:33     ` Thomas Gleixner
2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
2015-01-06 15:43   ` Michael S. Tsirkin
2015-01-06 15:43 ` [PATCH v2 03/40] arm64/uaccess: " Michael S. Tsirkin
2015-01-06 15:43   ` Michael S. Tsirkin
2015-01-06 19:14   ` Will Deacon
2015-01-06 19:14     ` Will Deacon
2015-01-06 21:48     ` Michael S. Tsirkin
2015-01-06 21:48       ` Michael S. Tsirkin
2015-01-06 21:51       ` Michael S. Tsirkin
2015-01-06 21:51         ` Michael S. Tsirkin
2015-01-07 10:09         ` Will Deacon
2015-01-06 15:43 ` [PATCH v2 04/40] avr32/uaccess: " Michael S. Tsirkin
2015-01-06 15:43   ` Michael S. Tsirkin
2015-01-06 15:43 ` [PATCH v2 05/40] blackfin/uaccess: " Michael S. Tsirkin
2015-01-06 15:43 ` [PATCH v2 06/40] cris/uaccess: " Michael S. Tsirkin
2015-01-06 15:43   ` Michael S. Tsirkin
2015-01-27 16:27   ` Jesper Nilsson
2015-01-06 15:43 ` [PATCH v2 07/40] ia64/uaccess: " Michael S. Tsirkin
2015-01-06 15:43   ` Michael S. Tsirkin
2015-01-06 15:43 ` [PATCH v2 08/40] m32r/uaccess: " Michael S. Tsirkin
2015-01-06 15:43 ` [PATCH v2 09/40] metag/uaccess: " Michael S. Tsirkin
2015-01-06 15:43   ` Michael S. Tsirkin
     [not found]   ` <1420558883-10131-10-git-send-email-mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-01-07  9:47     ` James Hogan
2015-01-07  9:47       ` James Hogan
     [not found]       ` <54AD00AC.2030801-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
2015-01-07  9:55         ` Michael S. Tsirkin
2015-01-07  9:55           ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 10/40] microblaze/uaccess: " Michael S. Tsirkin
2015-01-07 10:14   ` Michal Simek
2015-01-07 10:14     ` Michal Simek
2015-01-06 15:44 ` [PATCH v2 11/40] openrisc/uaccess: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 12/40] parisc/uaccess: " Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 13/40] sh/uaccess: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 14/40] sparc32/uaccess: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 18:21   ` David Miller
2015-01-06 18:21     ` David Miller
2015-01-06 15:44 ` [PATCH v2 15/40] sparc64/uaccess: " Michael S. Tsirkin
2015-01-06 18:21   ` David Miller
2015-01-06 18:21     ` David Miller
2015-01-06 15:44 ` [PATCH v2 16/40] m68k/uaccess: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-07 10:38   ` Geert Uytterhoeven
2015-01-07 10:38     ` Geert Uytterhoeven
2015-01-06 15:44 ` [PATCH v2 17/40] arm: fix put_user " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 18/40] blackfin: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 19/40] ia64: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 20/40] metag: " Michael S. Tsirkin
2015-01-07  9:55   ` James Hogan
2015-01-07  9:55     ` James Hogan
2015-01-06 15:44 ` [PATCH v2 21/40] sh: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 22/40] tile: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-12 21:56   ` Chris Metcalf
2015-01-12 21:56     ` Chris Metcalf
2015-01-13  9:35     ` Michael S. Tsirkin
2015-01-13  9:40       ` Michael S. Tsirkin
2015-01-13 13:30       ` Chris Metcalf
2015-01-13  9:50     ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 23/40] tile: enable sparse checks for get/put_user Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-13  0:08   ` Chris Metcalf
2015-01-13  9:45     ` Michael S. Tsirkin
2015-01-13 15:55       ` Chris Metcalf
2015-01-13 16:05         ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 24/40] avr32: whitespace fix Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-07  6:50   ` Hans-Christian Egtvedt
2015-01-06 15:44 ` [PATCH v2 25/40] arch/sparc: uaccess_32 macro whitespace fixes Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 18:22   ` David Miller
2015-01-06 18:22     ` David Miller
2015-01-06 15:44 ` [PATCH v2 26/40] arch/sparc: uaccess_64 " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 16:53   ` Sam Ravnborg
2015-01-06 17:19     ` Michael S. Tsirkin
2015-01-06 18:27       ` Sam Ravnborg
2015-01-06 18:27         ` Sam Ravnborg
2015-01-06 20:23         ` Michael S. Tsirkin
2015-01-06 20:46           ` Sam Ravnborg
2015-01-06 20:46             ` Sam Ravnborg
2015-01-06 21:44             ` Michael S. Tsirkin
2015-01-06 21:44               ` Michael S. Tsirkin
2015-01-06 18:22   ` David Miller
2015-01-06 18:22     ` David Miller
2015-01-06 15:45 ` [PATCH v2 27/40] blackfin: " Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 28/40] microblaze: whitespace fix Michael S. Tsirkin
2015-01-06 15:45   ` Michael S. Tsirkin
2015-01-07 10:14   ` Michal Simek
2015-01-06 15:45 ` [PATCH v2 29/40] alpha: macro whitespace fixes Michael S. Tsirkin
2015-01-06 15:45   ` Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 30/40] arm: " Michael S. Tsirkin
2015-01-06 15:45   ` Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 31/40] arm64: " Michael S. Tsirkin
2015-01-07 10:10   ` Will Deacon
2015-01-06 15:45 ` [PATCH v2 32/40] avr32: " Michael S. Tsirkin
2015-01-06 15:45   ` Michael S. Tsirkin
2015-01-07  6:52   ` Hans-Christian Egtvedt
2015-01-07  6:52     ` Hans-Christian Egtvedt
2015-01-06 15:45 ` [PATCH v2 33/40] cris: " Michael S. Tsirkin
2015-01-27 16:28   ` Jesper Nilsson
2015-01-06 15:45 ` [PATCH v2 34/40] frv: " Michael S. Tsirkin
2015-01-06 15:45   ` Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 35/40] m32r: " Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 36/40] m68k: " Michael S. Tsirkin
2015-01-06 15:45   ` Michael S. Tsirkin
2015-01-07  9:56   ` Geert Uytterhoeven
2015-01-07  9:56     ` Geert Uytterhoeven
2015-01-06 15:45 ` [PATCH v2 37/40] parisc: " Michael S. Tsirkin
2015-01-06 15:45   ` Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 38/40] s390: " Michael S. Tsirkin
2015-01-07  8:33   ` Heiko Carstens
2015-01-07  9:07     ` Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 39/40] sh: " Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 40/40] xtensa: " Michael S. Tsirkin
2015-01-06 15:45   ` Michael S. Tsirkin
2015-01-06 23:12   ` Max Filippov
2015-01-06 19:08 ` [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Arnd Bergmann
2015-01-06 19:08   ` Arnd Bergmann
2015-01-06 21:54   ` Michael S. Tsirkin
2015-01-06 21:54     ` Michael S. Tsirkin
2015-01-11 11:55   ` Michael S. Tsirkin
2015-01-13 10:19     ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).