1. 18 Jun, 2015 1 commit
  2. 02 Jun, 2015 1 commit
    • Borislav Petkov's avatar
      x86/cpu: Trim model ID whitespace · ee098e1a
      Borislav Petkov authored
      We did try trimming whitespace surrounding the 'model name'
      field in /proc/cpuinfo since reportedly some userspace uses it
      in string comparisons and there were discrepancies:
      
        [thetango@prarit ~]# grep "^model name" /proc/cpuinfo | uniq -c | sed 's/\ /_/g'
        ______1_model_name      :_AMD_Opteron(TM)_Processor_6272
        _____63_model_name      :_AMD_Opteron(TM)_Processor_6272_________________
      
      However, there were issues with overlapping buffers, string
      sizes and non-byte-sized copies in the previous proposed
      solutions; see Link tags below for the whole farce.
      
      So, instead of diddling with this more, let's simply extend what
      was there originally with trimming any present trailing
      whitespace. Final result is really simple and obvious.
      
      Testing with the most insane model IDs qemu can generate, looks
      good:
      
        .model_id = "            My funny model ID CPU          ",
        ______4_model_name      :_My_funny_model_ID_CPU
      
        .model_id = "My funny model ID CPU          ",
        ______4_model_name      :_My_funny_model_ID_CPU
      
        .model_id = "            My funny model ID CPU",
        ______4_model_name      :_My_funny_model_ID_CPU
      
        .model_id = "            ",
        ______4_model_name      :__
      
        .model_id = "",
        ______4_model_name      :_15/02
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1432050210-32036-1-git-send-email-prarit@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      ee098e1a
  3. 27 May, 2015 1 commit
    • Prarit Bhargava's avatar
      x86/cpu: Strip any /proc/cpuinfo model name field whitespace · adafb98d
      Prarit Bhargava authored
      When comparing the 'model name' field of each core in
      /proc/cpuinfo it was noticed that there is a whitespace
      difference between the cores' model names.
      
      After some quick investigation it was noticed that the model
      name fields were actually different -- processor 0's model name
      field had trailing whitespace removed, while the other
      processors did not.
      
      Another way of seeing this behaviour is to convert spaces into
      underscores in the output of /proc/cpuinfo,
      
        [thetango@prarit ~]# grep "^model name" /proc/cpuinfo | uniq -c | sed 's/\ /_/g'
        ______1_model_name      :_AMD_Opteron(TM)_Processor_6272
        _____63_model_name      :_AMD_Opteron(TM)_Processor_6272_________________
      
      which shows the discrepancy.
      
      This occurs because the kernel calls strim() on cpu 0's
      x86_model_id field to output a pretty message to the console in
      print_cpu_info(), and as a result strips the whitespace at the
      end of the ->x86_model_id field.
      
      But, the ->x86_model_id field should be the same for the all
      identical CPUs in the box. Thus, we need to remove both leading
      and trailing whitespace.
      
      As a result, the print_cpu_info() output looks like
      
        smpboot: CPU0: AMD Opteron(TM) Processor 6272 (fam: 15, model: 01, stepping: 02)
      
      and the x86_model_id field is correct on all processors on AMD
      platforms:
      
        _____64_model_name      :_AMD_Opteron(TM)_Processor_6272
      
      Output is still correct on an Intel box:
      
        ____144_model_name      :_Intel(R)_Xeon(R)_CPU_E7-8890_v3_@_2.50GHz
      Signed-off-by: default avatarPrarit Bhargava <prarit@redhat.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1432050210-32036-1-git-send-email-prarit@redhat.com
      Link: http://lkml.kernel.org/r/1432628901-18044-15-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      adafb98d
  4. 06 May, 2015 26 commits
  5. 05 May, 2015 7 commits
  6. 04 May, 2015 4 commits
    • Álvaro Fernández Rojas's avatar
      hwrng: bcm63xx - Fix driver compilation · f440c4ee
      Álvaro Fernández Rojas authored
      - s/clk_didsable_unprepare/clk_disable_unprepare
      - s/prov/priv
      - s/error/ret (bcm63xx_rng_probe)
      
      Fixes: 6229c160 ("hwrng: bcm63xx - make use of devm_hwrng_register")
      Signed-off-by: default avatarÁlvaro Fernández Rojas <noltari@gmail.com>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      f440c4ee
    • Daniel Borkmann's avatar
      lib: make memzero_explicit more robust against dead store elimination · 7829fb09
      Daniel Borkmann authored
      In commit 0b053c95 ("lib: memzero_explicit: use barrier instead
      of OPTIMIZER_HIDE_VAR"), we made memzero_explicit() more robust in
      case LTO would decide to inline memzero_explicit() and eventually
      find out it could be elimiated as dead store.
      
      While using barrier() works well for the case of gcc, recent efforts
      from LLVMLinux people suggest to use llvm as an alternative to gcc,
      and there, Stephan found in a simple stand-alone user space example
      that llvm could nevertheless optimize and thus elimitate the memset().
      A similar issue has been observed in the referenced llvm bug report,
      which is regarded as not-a-bug.
      
      Based on some experiments, icc is a bit special on its own, while it
      doesn't seem to eliminate the memset(), it could do so with an own
      implementation, and then result in similar findings as with llvm.
      
      The fix in this patch now works for all three compilers (also tested
      with more aggressive optimization levels). Arguably, in the current
      kernel tree it's more of a theoretical issue, but imho, it's better
      to be pedantic about it.
      
      It's clearly visible with gcc/llvm though, with the below code: if we
      would have used barrier() only here, llvm would have omitted clearing,
      not so with barrier_data() variant:
      
        static inline void memzero_explicit(void *s, size_t count)
        {
          memset(s, 0, count);
          barrier_data(s);
        }
      
        int main(void)
        {
          char buff[20];
          memzero_explicit(buff, sizeof(buff));
          return 0;
        }
      
        $ gcc -O2 test.c
        $ gdb a.out
        (gdb) disassemble main
        Dump of assembler code for function main:
         0x0000000000400400  <+0>: lea   -0x28(%rsp),%rax
         0x0000000000400405  <+5>: movq  $0x0,-0x28(%rsp)
         0x000000000040040e <+14>: movq  $0x0,-0x20(%rsp)
         0x0000000000400417 <+23>: movl  $0x0,-0x18(%rsp)
         0x000000000040041f <+31>: xor   %eax,%eax
         0x0000000000400421 <+33>: retq
        End of assembler dump.
      
        $ clang -O2 test.c
        $ gdb a.out
        (gdb) disassemble main
        Dump of assembler code for function main:
         0x00000000004004f0  <+0>: xorps  %xmm0,%xmm0
         0x00000000004004f3  <+3>: movaps %xmm0,-0x18(%rsp)
         0x00000000004004f8  <+8>: movl   $0x0,-0x8(%rsp)
         0x0000000000400500 <+16>: lea    -0x18(%rsp),%rax
         0x0000000000400505 <+21>: xor    %eax,%eax
         0x0000000000400507 <+23>: retq
        End of assembler dump.
      
      As gcc, clang, but also icc defines __GNUC__, it's sufficient to define
      this in compiler-gcc.h only to be picked up. For a fallback or otherwise
      unsupported compiler, we define it as a barrier. Similarly, for ecc which
      does not support gcc inline asm.
      
      Reference: https://llvm.org/bugs/show_bug.cgi?id=15495Reported-by: default avatarStephan Mueller <smueller@chronox.de>
      Tested-by: default avatarStephan Mueller <smueller@chronox.de>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Cc: Theodore Ts'o <tytso@mit.edu>
      Cc: Stephan Mueller <smueller@chronox.de>
      Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
      Cc: mancha security <mancha1@zoho.com>
      Cc: Mark Charlebois <charlebm@gmail.com>
      Cc: Behan Webster <behanw@converseincode.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      7829fb09
    • Linus Torvalds's avatar
      Linux 4.1-rc2 · 5ebe6afa
      Linus Torvalds authored
      5ebe6afa
    • Linus Torvalds's avatar
      Merge tag 'for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 · 8663da2c
      Linus Torvalds authored
      Pull ext4 fixes from Ted Ts'o:
       "Some miscellaneous bug fixes and some final on-disk and ABI changes
        for ext4 encryption which provide better security and performance"
      
      * tag 'for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
        ext4: fix growing of tiny filesystems
        ext4: move check under lock scope to close a race.
        ext4: fix data corruption caused by unwritten and delayed extents
        ext4 crypto: remove duplicated encryption mode definitions
        ext4 crypto: do not select from EXT4_FS_ENCRYPTION
        ext4 crypto: add padding to filenames before encrypting
        ext4 crypto: simplify and speed up filename encryption
      8663da2c