09 Feb, 2017

1 commit


01 Jul, 2016

1 commit


25 Jan, 2016

1 commit


23 Nov, 2015

1 commit


20 Oct, 2015

1 commit

  • Currently a number of Crypto API operations may fail when a signal
    occurs. This causes nasty problems as the caller of those operations
    are often not in a good position to restart the operation.

    In fact there is currently no need for those operations to be
    interrupted by user signals at all. All we need is for them to
    be killable.

    This patch replaces the relevant calls of signal_pending with
    fatal_signal_pending, and wait_for_completion_interruptible with
    wait_for_completion_killable, respectively.

    Cc: stable@vger.kernel.org
    Signed-off-by: Herbert Xu

    Herbert Xu
     

14 Jul, 2015

2 commits


03 Jun, 2015

1 commit


13 May, 2015

1 commit

  • This patch adds a new primitive crypto_grab_spawn which is meant
    to replace crypto_init_spawn and crypto_init_spawn2. Under the
    new scheme the user no longer has to worry about reference counting
    the alg object before it is subsumed by the spawn.

    It is pretty much an exact copy of crypto_grab_aead.

    Prior to calling this function spawn->frontend and spawn->inst
    must have been set.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

26 Apr, 2015

1 commit

  • The commit 59afdc7b32143528524455039e7557a46b60e4c8 ("crypto:
    api - Move module sig ifdef into accessor function") broke the
    build when modules are completely disabled because we directly
    dereference module->name.

    This patch fixes this by using the accessor function module_name.

    Reported-by: Fengguang Wu
    Signed-off-by: Herbert Xu

    Herbert Xu
     

23 Apr, 2015

2 commits


21 Apr, 2015

1 commit


16 Apr, 2015

1 commit

  • Commit 9c521a200bc3 ("crypto: api - remove instance when test failed")
    tried to grab a module reference count before the module was even set.

    Worse, it then goes on to free the module reference count after it is
    set so you quickly end up with a negative module reference count which
    prevents people from using any instances belonging to that module.

    This patch moves the module initialisation before the reference
    count.

    Reported-by: Linus Torvalds
    Signed-off-by: Herbert Xu
    Signed-off-by: Linus Torvalds

    Herbert Xu
     

10 Apr, 2015

2 commits

  • A cipher instance is added to the list of instances unconditionally
    regardless of whether the associated test failed. However, a failed
    test implies that during another lookup, the cipher instance will
    be added to the list again as it will not be found by the lookup
    code.

    That means that the list can be filled up with instances whose tests
    failed.

    Note: tests only fail in reality in FIPS mode when a cipher is not
    marked as fips_allowed=1. This can be seen with cmac(des3_ede) that does
    not have a fips_allowed=1. When allocating the cipher, the allocation
    fails with -ENOENT due to the missing fips_allowed=1 flag (which
    causes the testmgr to return EINVAL). Yet, the instance of
    cmac(des3_ede) is shown in /proc/crypto. Allocating the cipher again
    fails again, but a 2nd instance is listed in /proc/crypto.

    The patch simply de-registers the instance when the testing failed.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     
  • We currently initialise the crypto_alg ref count in the function
    __crypto_register_alg. As one of the callers of that function
    crypto_register_instance needs to obtain a ref count before it
    calls __crypto_register_alg, we need to move the initialisation
    out of there.

    Since both callers of __crypto_register_alg call crypto_check_alg,
    this is the logical place to perform the initialisation.

    Signed-off-by: Herbert Xu
    Acked-by: Stephan Mueller

    Herbert Xu
     

03 Apr, 2015

2 commits


22 Dec, 2014

1 commit


26 Nov, 2014

1 commit

  • This adds the module loading prefix "crypto-" to the template lookup
    as well.

    For example, attempting to load 'vfat(blowfish)' via AF_ALG now correctly
    includes the "crypto-" prefix at every level, correctly rejecting "vfat":

    net-pf-38
    algif-hash
    crypto-vfat(blowfish)
    crypto-vfat(blowfish)-all
    crypto-vfat

    Reported-by: Mathias Krause
    Signed-off-by: Kees Cook
    Acked-by: Mathias Krause
    Signed-off-by: Herbert Xu

    Kees Cook
     

03 Jul, 2014

1 commit

  • Per further discussion with NIST, the requirements for FIPS state that
    we only need to panic the system on failed kernel module signature checks
    for crypto subsystem modules. This moves the fips-mode-only module
    signature check out of the generic module loading code, into the crypto
    subsystem, at points where we can catch both algorithm module loads and
    mode module loads. At the same time, make CONFIG_CRYPTO_FIPS dependent on
    CONFIG_MODULE_SIG, as this is entirely necessary for FIPS mode.

    v2: remove extraneous blank line, perform checks in static inline
    function, drop no longer necessary fips.h include.

    CC: "David S. Miller"
    CC: Rusty Russell
    CC: Stephan Mueller
    Signed-off-by: Jarod Wilson
    Acked-by: Neil Horman
    Signed-off-by: Herbert Xu

    Jarod Wilson
     

04 Jul, 2013

1 commit

  • The template lookup interface does not provide a way to use format
    strings, so make sure that the interface cannot be abused accidentally.

    Signed-off-by: Kees Cook
    Cc: Herbert Xu
    Cc: "David S. Miller"
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kees Cook
     

28 Feb, 2013

1 commit

  • I'm not sure why, but the hlist for each entry iterators were conceived

    list_for_each_entry(pos, head, member)

    The hlist ones were greedy and wanted an extra parameter:

    hlist_for_each_entry(tpos, pos, head, member)

    Why did they need an extra pos parameter? I'm not quite sure. Not only
    they don't really need it, it also prevents the iterator from looking
    exactly like the list iterator, which is unfortunate.

    Besides the semantic patch, there was some manual work required:

    - Fix up the actual hlist iterators in linux/list.h
    - Fix up the declaration of other iterators based on the hlist ones.
    - A very small amount of places were using the 'node' parameter, this
    was modified to use 'obj->member' instead.
    - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
    properly, so those had to be fixed up manually.

    The semantic patch which is mostly the work of Peter Senna Tschudin is here:

    @@
    iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;

    type T;
    expression a,c,d,e;
    identifier b;
    statement S;
    @@

    -T b;

    [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
    [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
    [akpm@linux-foundation.org: checkpatch fixes]
    [akpm@linux-foundation.org: fix warnings]
    [akpm@linux-foudnation.org: redo intrusive kvm changes]
    Tested-by: Peter Senna Tschudin
    Acked-by: Paul E. McKenney
    Signed-off-by: Sasha Levin
    Cc: Wu Fengguang
    Cc: Marcelo Tosatti
    Cc: Gleb Natapov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sasha Levin
     

04 Feb, 2013

1 commit

  • Replace PTR_ERR followed by ERR_PTR by ERR_CAST, to be more concise.

    The semantic patch that makes this change is as follows:
    (http://coccinelle.lip6.fr/)

    //
    @@
    expression err,x;
    @@
    - err = PTR_ERR(x);
    if (IS_ERR(x))
    - return ERR_PTR(err);
    + return ERR_CAST(x);
    //

    Signed-off-by: Julia Lawall
    Signed-off-by: Herbert Xu

    Julia Lawall
     

22 Jun, 2012

1 commit

  • It has been observed that sometimes the crypto allocation code
    will get stuck for 60 seconds or multiples thereof. This is
    usually caused by an algorithm failing to pass the self-test.

    If an algorithm fails to be constructed, we will immediately notify
    all larval waiters. However, if it succeeds in construction, but
    then fails the self-test, we won't notify anyone at all.

    This patch fixes this by merging the notification in the case
    where the algorithm fails to be constructed with that of the
    the case where it pases the self-test. This way regardless of
    what happens, we'll give the larval waiters an answer.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

26 Jan, 2012

1 commit

  • Hardware crypto engines frequently need to register a selection of
    different algorithms with the core. Simplify their code slightly,
    especially the error handling, by providing functions to register a
    number of algorithms in a single call.

    Signed-off-by: Mark Brown
    Signed-off-by: Herbert Xu

    Mark Brown
     

09 Nov, 2011

1 commit

  • We leak the crypto instance when we unregister an instance with
    crypto_del_alg(). Therefore we introduce crypto_unregister_instance()
    to unlink the crypto instance from the template's instances list and
    to free the recources of the instance properly.

    Signed-off-by: Steffen Klassert
    Signed-off-by: Herbert Xu

    Steffen Klassert
     

21 Oct, 2011

3 commits


03 May, 2010

2 commits


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

16 Feb, 2010

1 commit


12 Sep, 2009

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (102 commits)
    crypto: sha-s390 - Fix warnings in import function
    crypto: vmac - New hash algorithm for intel_txt support
    crypto: api - Do not displace newly registered algorithms
    crypto: ansi_cprng - Fix module initialization
    crypto: xcbc - Fix alignment calculation of xcbc_tfm_ctx
    crypto: fips - Depend on ansi_cprng
    crypto: blkcipher - Do not use eseqiv on stream ciphers
    crypto: ctr - Use chainiv on raw counter mode
    Revert crypto: fips - Select CPRNG
    crypto: rng - Fix typo
    crypto: talitos - add support for 36 bit addressing
    crypto: talitos - align locks on cache lines
    crypto: talitos - simplify hmac data size calculation
    crypto: mv_cesa - Add support for Orion5X crypto engine
    crypto: cryptd - Add support to access underlaying shash
    crypto: gcm - Use GHASH digest algorithm
    crypto: ghash - Add GHASH digest algorithm for GCM
    crypto: authenc - Convert to ahash
    crypto: api - Fix aligned ctx helper
    crypto: hmac - Prehash ipad/opad
    ...

    Linus Torvalds
     

31 Aug, 2009

1 commit

  • We have a mechanism where newly registered algorithms of a higher
    priority can displace existing instances that use a different
    implementation of the same algorithm with a lower priority.

    Unfortunately the same mechanism can cause a newly registered
    algorithm to displace itself if it depends on an existing version
    of the same algorithm.

    This patch fixes this by keeping all algorithms that the newly
    reigstered algorithm depends on, thus protecting them from being
    removed.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

29 Aug, 2009

1 commit

  • As struct skcipher_givcrypt_request includes struct crypto_request
    at a non-zero offset, testing for NULL after converting the pointer
    returned by crypto_dequeue_request does not work. This can result
    in IPsec crashes when the queue is depleted.

    This patch fixes it by doing the pointer conversion only when the
    return value is non-NULL. In particular, we create a new function
    __crypto_dequeue_request that does the pointer conversion.

    Reported-by: Brad Bosch
    Signed-off-by: Herbert Xu

    Herbert Xu
     

09 Jul, 2009

1 commit


08 Jul, 2009

2 commits