1. 05 Oct, 2018 2 commits
  2. 28 Sep, 2018 1 commit
  3. 21 Sep, 2018 2 commits
  4. 13 Sep, 2018 1 commit
    • Brijesh Singh's avatar
      crypto: ccp - add timeout support in the SEV command · 3702a058
      Brijesh Singh authored
      Currently, the CCP driver assumes that the SEV command issued to the PSP
      will always return (i.e. it will never hang).  But recently, firmware bugs
      have shown that a command can hang.  Since of the SEV commands are used
      in probe routines, this can cause boot hangs and/or loss of virtualization
      capabilities.
      
      To protect against firmware bugs, add a timeout in the SEV command
      execution flow.  If a command does not complete within the specified
      timeout then return -ETIMEOUT and stop the driver from executing any
      further commands since the state of the SEV firmware is unknown.
      
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: Gary Hook <Gary.Hook@amd.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarBrijesh Singh <brijesh.singh@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      3702a058
  5. 04 Sep, 2018 1 commit
    • Brijesh Singh's avatar
      crypto: ccp - add timeout support in the SEV command · e82867fd
      Brijesh Singh authored
      Currently, the CCP driver assumes that the SEV command issued to the PSP
      will always return (i.e. it will never hang).  But recently, firmware bugs
      have shown that a command can hang.  Since of the SEV commands are used
      in probe routines, this can cause boot hangs and/or loss of virtualization
      capabilities.
      
      To protect against firmware bugs, add a timeout in the SEV command
      execution flow.  If a command does not complete within the specified
      timeout then return -ETIMEOUT and stop the driver from executing any
      further commands since the state of the SEV firmware is unknown.
      
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: Gary Hook <Gary.Hook@amd.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarBrijesh Singh <brijesh.singh@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      e82867fd
  6. 03 Aug, 2018 1 commit
  7. 13 Jul, 2018 5 commits
  8. 08 Jul, 2018 2 commits
  9. 30 May, 2018 2 commits
  10. 16 Mar, 2018 2 commits
  11. 09 Mar, 2018 1 commit
  12. 02 Mar, 2018 4 commits
    • Brijesh Singh's avatar
      crypto: ccp - Fix sparse, use plain integer as NULL pointer · e385b5b7
      Brijesh Singh authored
      Fix sparse warning: Using plain integer as NULL pointer. Replaces
      assignment of 0 to pointer with NULL assignment.
      
      Fixes: 200664d5 (Add Secure Encrypted Virtualization ...)
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Gary Hook <gary.hook@amd.com>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Signed-off-by: default avatarBrijesh Singh <brijesh.singh@amd.com>
      Acked-by: default avatarGary R Hook <gary.hook@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      e385b5b7
    • Maciej S. Szmigiero's avatar
      crypto: ccp - return an actual key size from RSA max_size callback · 0a9eb80e
      Maciej S. Szmigiero authored
      rsa-pkcs1pad uses a value returned from a RSA implementation max_size
      callback as a size of an input buffer passed to the RSA implementation for
      encrypt and sign operations.
      
      CCP RSA implementation uses a hardware input buffer which size depends only
      on the current RSA key length, so it should return this key length in
      the max_size callback, too.
      This also matches what the kernel software RSA implementation does.
      
      Previously, the value returned from this callback was always the maximum
      RSA key size the CCP hardware supports.
      This resulted in this huge buffer being passed by rsa-pkcs1pad to CCP even
      for smaller key sizes and then in a buffer overflow when ccp_run_rsa_cmd()
      tried to copy this large input buffer into a RSA key length-sized hardware
      input buffer.
      Signed-off-by: default avatarMaciej S. Szmigiero <mail@maciej.szmigiero.name>
      Fixes: ceeec0af ("crypto: ccp - Add support for RSA on the CCP")
      Cc: stable@vger.kernel.org
      Acked-by: default avatarGary R Hook <gary.hook@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      0a9eb80e
    • Sebastian Andrzej Siewior's avatar
      crypto: ccp - don't disable interrupts while setting up debugfs · 79eb382b
      Sebastian Andrzej Siewior authored
      I don't why we need take a single write lock and disable interrupts
      while setting up debugfs. This is what what happens when we try anyway:
      
      |ccp 0000:03:00.2: enabling device (0000 -> 0002)
      |BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:69
      |in_atomic(): 1, irqs_disabled(): 1, pid: 3, name: kworker/0:0
      |irq event stamp: 17150
      |hardirqs last  enabled at (17149): [<0000000097a18c49>] restore_regs_and_return_to_kernel+0x0/0x23
      |hardirqs last disabled at (17150): [<000000000773b3a9>] _raw_write_lock_irqsave+0x1b/0x50
      |softirqs last  enabled at (17148): [<0000000064d56155>] __do_softirq+0x3b8/0x4c1
      |softirqs last disabled at (17125): [<0000000092633c18>] irq_exit+0xb1/0xc0
      |CPU: 0 PID: 3 Comm: kworker/0:0 Not tainted 4.16.0-rc2+ #30
      |Workqueue: events work_for_cpu_fn
      |Call Trace:
      | dump_stack+0x7d/0xb6
      | ___might_sleep+0x1eb/0x250
      | down_write+0x17/0x60
      | start_creating+0x4c/0xe0
      | debugfs_create_dir+0x9/0x100
      | ccp5_debugfs_setup+0x191/0x1b0
      | ccp5_init+0x8a7/0x8c0
      | ccp_dev_init+0xb8/0xe0
      | sp_init+0x6c/0x90
      | sp_pci_probe+0x26e/0x590
      | local_pci_probe+0x3f/0x90
      | work_for_cpu_fn+0x11/0x20
      | process_one_work+0x1ff/0x650
      | worker_thread+0x1d4/0x3a0
      | kthread+0xfe/0x130
      | ret_from_fork+0x27/0x50
      
      If any locking is required, a simple mutex will do it.
      
      Cc: Gary R Hook <gary.hook@amd.com>
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Acked-by: default avatarGary R Hook <gary.hook@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      79eb382b
    • Brijesh Singh's avatar
      crypto: ccp - add check to get PSP master only when PSP is detected · 716c7c32
      Brijesh Singh authored
      Paulian reported the below kernel crash on Ryzen 5 system:
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000073
      RIP: 0010:.LC0+0x41f/0xa00
      RSP: 0018:ffffa9968003bdd0 EFLAGS: 00010002
      RAX: ffffffffb113b130 RBX: 0000000000000000 RCX: 00000000000005a7
      RDX: 00000000000000ff RSI: ffff8b46dee651a0 RDI: ffffffffb1bd617c
      RBP: 0000000000000246 R08: 00000000000251a0 R09: 0000000000000000
      R10: ffffd81f11a38200 R11: ffff8b52e8e0a161 R12: ffffffffb19db220
      R13: 0000000000000007 R14: ffffffffb17e4888 R15: 5dccd7affc30a31e
      FS:  0000000000000000(0000) GS:ffff8b46dee40000(0000) knlGS:0000000000000000
      CR2: 0000000000000073 CR3: 000080128120a000 CR4: 00000000003406e0
      Call Trace:
       ? sp_get_psp_master_device+0x56/0x80
       ? map_properties+0x540/0x540
       ? psp_pci_init+0x20/0xe0
       ? map_properties+0x540/0x540
       ? sp_mod_init+0x16/0x1a
       ? do_one_initcall+0x4b/0x190
       ? kernel_init_freeable+0x19b/0x23c
       ? rest_init+0xb0/0xb0
       ? kernel_init+0xa/0x100
       ? ret_from_fork+0x22/0x40
      
      Since Ryzen does not support PSP/SEV firmware hence i->psp_data will
      NULL in all sp instances. In those cases, 'i' will point to the
      list head after list_for_each_entry(). Dereferencing the head will
      cause kernel crash.
      
      Add check to call get master device only when PSP/SEV is detected.
      Reported-by: default avatarPaulian Bogdan Marinca <paulian@marinca.net>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      CC: Gary R Hook <gary.hook@amd.com>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarBrijesh Singh <brijesh.singh@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      716c7c32
  13. 24 Feb, 2018 1 commit
  14. 15 Feb, 2018 1 commit
  15. 22 Dec, 2017 1 commit
  16. 04 Dec, 2017 10 commits
  17. 03 Nov, 2017 2 commits
  18. 02 Nov, 2017 1 commit
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318