All of lore.kernel.org
 help / color / mirror / Atom feed
* copy_from_user_*() and buffer zeroing
@ 2013-11-26 21:07 H. Peter Anvin
  2013-11-26 21:54 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: H. Peter Anvin @ 2013-11-26 21:07 UTC (permalink / raw)
  To: Ingo Molnar, Al Viro, Thomas Gleixner, Andrew Morton,
	Linux Kernel Mailing List
  Cc: Vitaly Mayatskikh

I just started looking into the horribly confused state of buffer
zeroing for the various copy_from_user variants.  This came up after we
did some minor tuning last week.

copy_from_user_inatomic() seems to be documented to not zero the buffer.
 This is definitely *NOT* true on x86-64, although it does seem to be
true on i386 -- on x86-64, we carry along a "zerorest" flag but in all
possible codepaths it will be set to true unless the remaining byte
count is zero anyway.

Furthermore, on at least x86-64, if we do an early bailout, we don't
zero the entire buffer in the case of a hard-coded 10- or 16-byte buffer
(why only those sizes is anybody's guess.)  See lines 71-88 of uaccess_64.h.

I'd like to figure out what is the required and what is the desirable
behavior here, and then fix the code accordingly.

	-hpa

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

end of thread, other threads:[~2013-11-26 23:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-26 21:07 copy_from_user_*() and buffer zeroing H. Peter Anvin
2013-11-26 21:54 ` Andrew Morton
2013-11-26 22:28   ` H. Peter Anvin
2013-11-26 23:04     ` NeilBrown
2013-11-26 23:08       ` H. Peter Anvin

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.