1. 17 10月, 2014 1 次提交
    • D
      random: add and use memzero_explicit() for clearing data · d4c5efdb
      Daniel Borkmann 提交于
      zatimend has reported that in his environment (3.16/gcc4.8.3/corei7)
      memset() calls which clear out sensitive data in extract_{buf,entropy,
      entropy_user}() in random driver are being optimized away by gcc.
      
      Add a helper memzero_explicit() (similarly as explicit_bzero() variants)
      that can be used in such cases where a variable with sensitive data is
      being cleared out in the end. Other use cases might also be in crypto
      code. [ I have put this into lib/string.c though, as it's always built-in
      and doesn't need any dependencies then. ]
      
      Fixes kernel bugzilla: 82041
      
      Reported-by: zatimend@hotmail.co.uk
      Signed-off-by: NDaniel Borkmann <dborkman@redhat.com>
      Acked-by: NHannes Frederic Sowa <hannes@stressinduktion.org>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@vger.kernel.org
      d4c5efdb
  2. 14 10月, 2014 1 次提交
  3. 23 5月, 2014 1 次提交
    • G
      lib: add glibc style strchrnul() variant · 11d200e9
      Grant Likely 提交于
      The strchrnul() variant helpfully returns a the end of the string
      instead of a NULL if the requested character is not found. This can
      simplify string parsing code since it doesn't need to expicitly check
      for a NULL return. If a valid string pointer is passed in, then a valid
      null terminated string will always come back out.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      11d200e9
  4. 18 12月, 2012 1 次提交
  5. 13 10月, 2012 1 次提交
  6. 22 8月, 2012 1 次提交
  7. 31 7月, 2012 1 次提交
    • A
      string: introduce memweight() · 639b9e34
      Akinobu Mita 提交于
      memweight() is the function that counts the total number of bits set in
      memory area.  Unlike bitmap_weight(), memweight() takes pointer and size
      in bytes to specify a memory area which does not need to be aligned to
      long-word boundary.
      
      [akpm@linux-foundation.org: rename `w' to `ret']
      Signed-off-by: NAkinobu Mita <akinobu.mita@gmail.com>
      Cc: Anders Larsen <al@alarsen.net>
      Cc: Alasdair Kergon <agk@redhat.com>
      Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: Mark Fasheh <mfasheh@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Andreas Dilger <adilger.kernel@dilger.ca>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Matthew Wilcox <matthew@wil.cx>
      Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
      Cc: Tony Luck <tony.luck@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      639b9e34
  8. 01 11月, 2011 1 次提交
  9. 19 5月, 2011 1 次提交
  10. 26 4月, 2011 1 次提交
  11. 15 1月, 2010 1 次提交
  12. 16 12月, 2009 2 次提交
  13. 29 10月, 2009 1 次提交
  14. 01 4月, 2009 1 次提交
    • L
      memdup_user(): introduce · 610a77e0
      Li Zefan 提交于
      I notice there are many places doing copy_from_user() which follows
      kmalloc():
      
              dst = kmalloc(len, GFP_KERNEL);
              if (!dst)
                      return -ENOMEM;
              if (copy_from_user(dst, src, len)) {
      		kfree(dst);
      		return -EFAULT
      	}
      
      memdup_user() is a wrapper of the above code.  With this new function, we
      don't have to write 'len' twice, which can lead to typos/mistakes.  It
      also produces smaller code and kernel text.
      
      A quick grep shows 250+ places where memdup_user() *may* be used.  I'll
      prepare a patchset to do this conversion.
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Americo Wang <xiyou.wangcong@gmail.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      610a77e0
  15. 31 3月, 2009 1 次提交
  16. 07 3月, 2009 1 次提交
  17. 03 11月, 2008 1 次提交
  18. 25 7月, 2008 1 次提交
  19. 01 5月, 2008 1 次提交
  20. 31 10月, 2007 1 次提交
  21. 18 7月, 2007 2 次提交
    • J
      add argv_split() · d84d1cc7
      Jeremy Fitzhardinge 提交于
      argv_split() is a helper function which takes a string, splits it at
      whitespace, and returns a NULL-terminated argv vector.  This is
      deliberately simple - it does no quote processing of any kind.
      
      [ Seems to me that this is something which is already being done in
        the kernel, but I couldn't find any other implementations, either to
        steal or replace.  Keep an eye out. ]
      Signed-off-by: NJeremy Fitzhardinge <jeremy@xensource.com>
      Signed-off-by: NChris Wright <chrisw@sous-sol.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Randy Dunlap <randy.dunlap@oracle.com>
      d84d1cc7
    • J
      add kstrndup · 1e66df3e
      Jeremy Fitzhardinge 提交于
      Add a kstrndup function, modelled on strndup.  Like strndup this
      returns a string copied into its own allocated memory, but it copies
      no more than the specified number of bytes from the source.
      
      Remove private strndup() from irda code.
      Signed-off-by: NJeremy Fitzhardinge <jeremy@xensource.com>
      Signed-off-by: NChris Wright <chrisw@sous-sol.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Randy Dunlap <randy.dunlap@oracle.com>
      Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
      Cc: Akinobu Mita <akinobu.mita@gmail.com>
      Cc: Arnaldo Carvalho de Melo <acme@mandriva.com>
      Cc: Al Viro <viro@ftp.linux.org.uk>
      Cc: Panagiotis Issaris <takis@issaris.org>
      Cc: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
      1e66df3e
  22. 26 4月, 2007 1 次提交
  23. 01 10月, 2006 1 次提交
    • A
      [PATCH] kmemdup: introduce · 1a2f67b4
      Alexey Dobriyan 提交于
      One of idiomatic ways to duplicate a region of memory is
      
      	dst = kmalloc(len, GFP_KERNEL);
      	if (!dst)
      		return -ENOMEM;
      	memcpy(dst, src, len);
      
      which is neat code except a programmer needs to write size twice.  Which
      sometimes leads to mistakes.  If len passed to kmalloc is smaller that len
      passed to memcpy, it's straight overwrite-beyond-end.  If len passed to
      memcpy is smaller than len passed to kmalloc, it's either a) legit
      behaviour ;-), or b) cloned buffer will contain garbage in second half.
      
      Slight trolling of commit lists shows several duplications bugs
      done exactly because of diverged lenghts:
      
      	Linux:
      		[CRYPTO]: Fix memcpy/memset args.
      		[PATCH] memcpy/memset fixes
      	OpenBSD:
      		kerberosV/src/lib/asn1: der_copy.c:1.4
      
      If programmer is given only one place to play with lengths, I believe, such
      mistakes could be avoided.
      
      With kmemdup, the snippet above will be rewritten as:
      
      	dst = kmemdup(src, len, GFP_KERNEL);
      	if (!dst)
      		return -ENOMEM;
      
      This also leads to smaller code (kzalloc effect). Quick grep shows
      200+ places where kmemdup() can be used.
      Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      1a2f67b4
  24. 23 6月, 2006 1 次提交
  25. 11 4月, 2006 1 次提交
  26. 24 3月, 2006 1 次提交
  27. 09 10月, 2005 1 次提交
  28. 08 7月, 2005 1 次提交
  29. 24 6月, 2005 1 次提交
  30. 17 4月, 2005 1 次提交
    • L
      Linux-2.6.12-rc2 · 1da177e4
      Linus Torvalds 提交于
      Initial git repository build. I'm not bothering with the full history,
      even though we have it. We can create a separate "historical" git
      archive of that later if we want to, and in the meantime it's about
      3.2GB when imported into git - space that would just make the early
      git days unnecessarily complicated, when we don't have a lot of good
      infrastructure for it.
      
      Let it rip!
      1da177e4