06 Feb, 2016

4 commits

  • The async path cannot use MAY_BACKLOG because it is not meant to
    block, which is what MAY_BACKLOG does. On the other hand, both
    the sync and async paths can make use of MAY_SLEEP.

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

    Herbert Xu
     
  • Any access to non-constant bits of the private context must be
    done under the socket lock, in particular, this includes ctx->req.

    This patch moves such accesses under the lock, and fetches the
    tfm from the parent socket which is guaranteed to be constant,
    rather than from ctx->req.

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

    Herbert Xu
     
  • The async path in algif_skcipher assumes that the crypto completion
    function will be called with the original request. This is not
    necessarily the case. In fact there is no need for this anyway
    since we already embed information into the request with struct
    skcipher_async_req.

    This patch adds a pointer to that struct and then passes it as
    the data to the callback function.

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

    Herbert Xu
     
  • We miss to take the crypto_alg_sem semaphore when traversing the
    crypto_alg_list for CRYPTO_MSG_GETALG dumps. This allows a race with
    crypto_unregister_alg() removing algorithms from the list while we're
    still traversing it, thereby leading to a use-after-free as show below:

    [ 3482.071639] general protection fault: 0000 [#1] SMP
    [ 3482.075639] Modules linked in: aes_x86_64 glue_helper lrw ablk_helper cryptd gf128mul ipv6 pcspkr serio_raw virtio_net microcode virtio_pci virtio_ring virtio sr_mod cdrom [last unloaded: aesni_intel]
    [ 3482.075639] CPU: 1 PID: 11065 Comm: crconf Not tainted 4.3.4-grsec+ #126
    [ 3482.075639] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
    [ 3482.075639] task: ffff88001cd41a40 ti: ffff88001cd422c8 task.ti: ffff88001cd422c8
    [ 3482.075639] RIP: 0010:[] [] strncpy+0x13/0x30
    [ 3482.075639] RSP: 0018:ffff88001f713b60 EFLAGS: 00010202
    [ 3482.075639] RAX: ffff88001f6c4430 RBX: ffff88001f6c43a0 RCX: ffff88001f6c4430
    [ 3482.075639] RDX: 0000000000000040 RSI: fefefefefefeff16 RDI: ffff88001f6c4430
    [ 3482.075639] RBP: ffff88001f713b60 R08: ffff88001f6c4470 R09: ffff88001f6c4480
    [ 3482.075639] R10: 0000000000000002 R11: 0000000000000246 R12: ffff88001ce2aa28
    [ 3482.075639] R13: ffff880000093700 R14: ffff88001f5e4bf8 R15: 0000000000003b20
    [ 3482.075639] FS: 0000033826fa2700(0000) GS:ffff88001e900000(0000) knlGS:0000000000000000
    [ 3482.075639] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 3482.075639] CR2: ffffffffff600400 CR3: 00000000139ec000 CR4: 00000000001606f0
    [ 3482.075639] Stack:
    [ 3482.075639] ffff88001f713bd8 ffffffff936ccd00 ffff88001e5c4200 ffff880000093700
    [ 3482.075639] ffff88001f713bd0 ffffffff938ef4bf 0000000000000000 0000000000003b20
    [ 3482.075639] ffff88001f5e4bf8 ffff88001f5e4848 0000000000000000 0000000000003b20
    [ 3482.075639] Call Trace:
    [ 3482.075639] [] crypto_report_alg+0xc0/0x3e0
    [ 3482.075639] [] ? __alloc_skb+0x16f/0x300
    [ 3482.075639] [] crypto_dump_report+0x6a/0x90
    [ 3482.075639] [] netlink_dump+0x147/0x2e0
    [ 3482.075639] [] __netlink_dump_start+0x159/0x190
    [ 3482.075639] [] crypto_user_rcv_msg+0xc3/0x130
    [ 3482.075639] [] ? crypto_report_alg+0x3e0/0x3e0
    [ 3482.075639] [] ? alg_test_crc32c+0x120/0x120
    [ 3482.075639] [] ? __netlink_lookup+0xd5/0x120
    [ 3482.075639] [] ? crypto_add_alg+0x1d0/0x1d0
    [ 3482.075639] [] netlink_rcv_skb+0xe1/0x130
    [ 3482.075639] [] crypto_netlink_rcv+0x28/0x40
    [ 3482.075639] [] netlink_unicast+0x108/0x180
    [ 3482.075639] [] netlink_sendmsg+0x541/0x770
    [ 3482.075639] [] sock_sendmsg+0x21/0x40
    [ 3482.075639] [] SyS_sendto+0xf3/0x130
    [ 3482.075639] [] ? bad_area_nosemaphore+0x13/0x20
    [ 3482.075639] [] ? __do_page_fault+0x80/0x3a0
    [ 3482.075639] [] entry_SYSCALL_64_fastpath+0x12/0x6e
    [ 3482.075639] Code: 88 4a ff 75 ed 5d 48 0f ba 2c 24 3f c3 66 66 2e 0f 1f 84 00 00 00 00 00 55 48 85 d2 48 89 f8 48 89 f9 4c 8d 04 17 48 89 e5 74 15 b6 16 80 fa 01 88 11 48 83 de ff 48 83 c1 01 4c 39 c1 75 eb
    [ 3482.075639] RIP [] strncpy+0x13/0x30

    To trigger the race run the following loops simultaneously for a while:
    $ while : ; do modprobe aesni-intel; rmmod aesni-intel; done
    $ while : ; do crconf show all > /dev/null; done

    Fix the race by taking the crypto_alg_sem read lock, thereby preventing
    crypto_unregister_alg() from modifying the algorithm list during the
    dump.

    This bug has been detected by the PaX memory sanitize feature.

    Cc: stable@vger.kernel.org
    Signed-off-by: Mathias Krause
    Cc: Steffen Klassert
    Cc: PaX Team
    Signed-off-by: Herbert Xu

    Mathias Krause
     

30 Jan, 2016

1 commit


27 Jan, 2016

1 commit

  • The has_key logic is wrong for shash algorithms as they always
    have a setkey function. So we should instead be testing against
    shash_no_setkey.

    Fixes: a5596d633278 ("crypto: hash - Add crypto_ahash_has_setkey")
    Cc: stable@vger.kernel.org
    Reported-by: Stephan Mueller
    Signed-off-by: Herbert Xu
    Tested-by: Stephan Mueller

    Herbert Xu
     

26 Jan, 2016

1 commit

  • The ghash and poly1305 hash implementations can be enabled when
    CONFIG_CRYPTO_HASH is turned off, causing a link error:

    crypto/built-in.o: In function `ghash_mod_init':
    (.init.text+0xd0): undefined reference to `crypto_register_shash'
    crypto/built-in.o: In function `ghash_mod_exit':
    (.exit.text+0xb4): undefined reference to `crypto_unregister_shash'
    crypto/built-in.o: In function `poly1305_mod_init':
    (.init.text+0xb4): undefined reference to `crypto_register_shash'
    crypto/built-in.o: In function `poly1305_mod_exit':
    (.exit.text+0x98): undefined reference to `crypto_unregister_shash'

    This adds an explicit 'select', like all other hashes have it.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Herbert Xu

    Arnd Bergmann
     

25 Jan, 2016

1 commit

  • Dave Young reported:
    > Hi,
    >
    > I saw the warning "Missing required AuthAttr" when testing kexec,
    > known issue? Idea about how to fix it?
    >
    > The kernel is latest linus tree plus sevral patches from Toshi to
    > cleanup io resource structure.
    >
    > in function pkcs7_sig_note_set_of_authattrs():
    > if (!test_bit(sinfo_has_content_type, &sinfo->aa_set) ||
    > !test_bit(sinfo_has_message_digest, &sinfo->aa_set) ||
    > (ctx->msg->data_type == OID_msIndirectData &&
    > !test_bit(sinfo_has_ms_opus_info, &sinfo->aa_set))) {
    > pr_warn("Missing required AuthAttr\n");
    > return -EBADMSG;
    > }
    >
    > The third condition below is true:
    > (ctx->msg->data_type == OID_msIndirectData &&
    > !test_bit(sinfo_has_ms_opus_info, &sinfo->aa_set))
    >
    > I signed the kernel with redhat test key like below:
    > pesign -c 'Red Hat Test Certificate' -i arch/x86/boot/bzImage -o /boot/vmlinuz-4.4.0-rc8+ -s --force

    And right he is! The Authenticode specification is a paragon amongst
    technical documents, and has this pearl of wisdom to offer:

    ---------------------------------
    Authenticode-Specific SignerInfo UnauthenticatedAttributes Structures

    The following Authenticode-specific data structures are present in
    SignerInfo authenticated attributes.

    SpcSpOpusInfo
    SpcSpOpusInfo is identified by SPC_SP_OPUS_INFO_OBJID
    (1.3.6.1.4.1.311.2.1.12) and is defined as follows:
    SpcSpOpusInfo ::= SEQUENCE {
    programName [0] EXPLICIT SpcString OPTIONAL,
    moreInfo [1] EXPLICIT SpcLink OPTIONAL,
    } --#public--

    SpcSpOpusInfo has two fields:
    programName
    This field contains the program description:
    If publisher chooses not to specify a description, the SpcString
    structure contains a zero-length program name.
    If the publisher chooses to specify a
    description, the SpcString structure contains a Unicode string.
    moreInfo
    This field is set to an SPCLink structure that contains a URL for
    a Web site with more information about the signer. The URL is an
    ASCII string.
    ---------------------------------

    Which is to say that this is an optional *unauthenticated* field which
    may be present in the Authenticated Attribute list. This is not how
    pkcs7 is supposed to work, so when David implemented this, he didn't
    appreciate the subtlety the original spec author was working with, and
    missed the part of the sublime prose that says this Authenticated
    Attribute is an Unauthenticated Attribute. As a result, the code in
    question simply takes as given that the Authenticated Attributes should
    be authenticated.

    But this one should not, individually. Because it says it's not
    authenticated.

    It still has to hash right so the TBS digest is correct. So it is both
    authenticated and unauthenticated, all at once. Truly, a wonder of
    technical accomplishment.

    Additionally, pesign's implementation has always attempted to be
    compatible with the signatures emitted from contemporary versions of
    Microsoft's signtool.exe. During the initial implementation, Microsoft
    signatures always produced the same values for SpcSpOpusInfo -
    {U"Microsoft Windows", "http://www.microsoft.com"} - without regard to
    who the signer was.

    Sometime between Windows 8 and Windows 8.1 they stopped including the
    field in their signatures altogether, and as such pesign stopped
    producing them in commits c0c4da6 and d79cb0c, sometime around June of
    2012. The theory here is that anything that breaks with
    pesign signatures would also be breaking with signtool.exe sigs as well,
    and that'll be a more noticed problem for firmwares parsing it, so it'll
    get fixed. The fact that we've done exactly this bug in Linux code is
    first class, grade A irony.

    So anyway, we should not be checking this field for presence or any
    particular value: if the field exists, it should be at the right place,
    but aside from that, as long as the hash matches the field is good.

    Signed-off-by: Peter Jones
    Tested-by: Dave Young
    Signed-off-by: Herbert Xu

    Peter Jones
     

23 Jan, 2016

1 commit

  • Pull crypto fixes from Herbert Xu:
    "This fixes the following issues:

    API:
    - A large number of bug fixes for the af_alg interface, credit goes
    to Dmitry Vyukov for discovering and reporting these issues.

    Algorithms:
    - sw842 needs to select crc32.
    - The soft dependency on crc32c is now in the correct spot.

    Drivers:
    - The atmel AES driver needs HAS_DMA.
    - The atmel AES driver was a missing break statement, fortunately
    it's only a debug function.
    - A number of bug fixes for the Intel qat driver"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (24 commits)
    crypto: algif_skcipher - sendmsg SG marking is off by one
    crypto: crc32c - Fix crc32c soft dependency
    crypto: algif_skcipher - Load TX SG list after waiting
    crypto: atmel-aes - Add missing break to atmel_aes_reg_name
    crypto: algif_skcipher - Fix race condition in skcipher_check_key
    crypto: algif_hash - Fix race condition in hash_check_key
    crypto: CRYPTO_DEV_ATMEL_AES should depend on HAS_DMA
    lib: sw842: select crc32
    crypto: af_alg - Forbid bind(2) when nokey child sockets are present
    crypto: algif_skcipher - Remove custom release parent function
    crypto: algif_hash - Remove custom release parent function
    crypto: af_alg - Allow af_af_alg_release_parent to be called on nokey path
    crypto: qat - update init_esram for C3xxx dev type
    crypto: qat - fix timeout issues
    crypto: qat - remove to call get_sram_bar_id for qat_c3xxx
    crypto: algif_skcipher - Add key check exception for cipher_null
    crypto: skcipher - Add crypto_skcipher_has_setkey
    crypto: algif_hash - Require setkey before accept(2)
    crypto: hash - Add crypto_ahash_has_setkey
    crypto: algif_skcipher - Add nokey compatibility path
    ...

    Linus Torvalds
     

20 Jan, 2016

1 commit

  • We mark the end of the SG list in sendmsg and sendpage and unmark
    it on the next send call. Unfortunately the unmarking in sendmsg
    is off-by-one, leading to an SG list that is too short.

    Fixes: 0f477b655a52 ("crypto: algif - Mark sgl end at the end of data")
    Cc: stable@vger.kernel.org
    Signed-off-by: Herbert Xu

    Herbert Xu
     

19 Jan, 2016

2 commits

  • I don't think it makes sense for a module to have a soft dependency
    on itself. This seems quite cyclic by nature and I can't see what
    purpose it could serve.

    OTOH libcrc32c calls crypto_alloc_shash("crc32c", 0, 0) so it pretty
    much assumes that some incarnation of the "crc32c" hash algorithm has
    been loaded. Therefore it makes sense to have the soft dependency
    there (as crc-t10dif does.)

    Cc: stable@vger.kernel.org
    Cc: Tim Chen
    Cc: "David S. Miller"
    Signed-off-by: Jean Delvare
    Signed-off-by: Herbert Xu

    Jean Delvare
     
  • We need to load the TX SG list in sendmsg(2) after waiting for
    incoming data, not before.

    Cc: stable@vger.kernel.org
    Reported-by: Dmitry Vyukov
    Signed-off-by: Herbert Xu
    Tested-by: Dmitry Vyukov

    Herbert Xu
     

18 Jan, 2016

16 commits


13 Jan, 2016

2 commits

  • Pull networking updates from Davic Miller:

    1) Support busy polling generically, for all NAPI drivers. From Eric
    Dumazet.

    2) Add byte/packet counter support to nft_ct, from Floriani Westphal.

    3) Add RSS/XPS support to mvneta driver, from Gregory Clement.

    4) Implement IPV6_HDRINCL socket option for raw sockets, from Hannes
    Frederic Sowa.

    5) Add support for T6 adapter to cxgb4 driver, from Hariprasad Shenai.

    6) Add support for VLAN device bridging to mlxsw switch driver, from
    Ido Schimmel.

    7) Add driver for Netronome NFP4000/NFP6000, from Jakub Kicinski.

    8) Provide hwmon interface to mlxsw switch driver, from Jiri Pirko.

    9) Reorganize wireless drivers into per-vendor directories just like we
    do for ethernet drivers. From Kalle Valo.

    10) Provide a way for administrators "destroy" connected sockets via the
    SOCK_DESTROY socket netlink diag operation. From Lorenzo Colitti.

    11) Add support to add/remove multicast routes via netlink, from Nikolay
    Aleksandrov.

    12) Make TCP keepalive settings per-namespace, from Nikolay Borisov.

    13) Add forwarding and packet duplication facilities to nf_tables, from
    Pablo Neira Ayuso.

    14) Dead route support in MPLS, from Roopa Prabhu.

    15) TSO support for thunderx chips, from Sunil Goutham.

    16) Add driver for IBM's System i/p VNIC protocol, from Thomas Falcon.

    17) Rationalize, consolidate, and more completely document the checksum
    offloading facilities in the networking stack. From Tom Herbert.

    18) Support aborting an ongoing scan in mac80211/cfg80211, from
    Vidyullatha Kanchanapally.

    19) Use per-bucket spinlock for bpf hash facility, from Tom Leiming.

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1375 commits)
    net: bnxt: always return values from _bnxt_get_max_rings
    net: bpf: reject invalid shifts
    phonet: properly unshare skbs in phonet_rcv()
    dwc_eth_qos: Fix dma address for multi-fragment skbs
    phy: remove an unneeded condition
    mdio: remove an unneed condition
    mdio_bus: NULL dereference on allocation error
    net: Fix typo in netdev_intersect_features
    net: freescale: mac-fec: Fix build error from phy_device API change
    net: freescale: ucc_geth: Fix build error from phy_device API change
    bonding: Prevent IPv6 link local address on enslaved devices
    IB/mlx5: Add flow steering support
    net/mlx5_core: Export flow steering API
    net/mlx5_core: Make ipv4/ipv6 location more clear
    net/mlx5_core: Enable flow steering support for the IB driver
    net/mlx5_core: Initialize namespaces only when supported by device
    net/mlx5_core: Set priority attributes
    net/mlx5_core: Connect flow tables
    net/mlx5_core: Introduce modify flow table command
    net/mlx5_core: Managing root flow table
    ...

    Linus Torvalds
     
  • Pull crypto update from Herbert Xu:
    "Algorithms:
    - Add RSA padding algorithm

    Drivers:
    - Add GCM mode support to atmel
    - Add atmel support for SAMA5D2 devices
    - Add cipher modes to talitos
    - Add rockchip driver for rk3288
    - Add qat support for C3XXX and C62X"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (103 commits)
    crypto: hifn_795x, picoxcell - use ablkcipher_request_cast
    crypto: qat - fix SKU definiftion for c3xxx dev
    crypto: qat - Fix random config build issue
    crypto: ccp - use to_pci_dev and to_platform_device
    crypto: qat - Rename dh895xcc mmp firmware
    crypto: 842 - remove WARN inside printk
    crypto: atmel-aes - add debug facilities to monitor register accesses.
    crypto: atmel-aes - add support to GCM mode
    crypto: atmel-aes - change the DMA threshold
    crypto: atmel-aes - fix the counter overflow in CTR mode
    crypto: atmel-aes - fix atmel-ctr-aes driver for RFC 3686
    crypto: atmel-aes - create sections to regroup functions by usage
    crypto: atmel-aes - fix typo and indentation
    crypto: atmel-aes - use SIZE_IN_WORDS() helper macro
    crypto: atmel-aes - improve performances of data transfer
    crypto: atmel-aes - fix atmel_aes_remove()
    crypto: atmel-aes - remove useless AES_FLAGS_DMA flag
    crypto: atmel-aes - reduce latency of DMA completion
    crypto: atmel-aes - remove unused 'err' member of struct atmel_aes_dev
    crypto: atmel-aes - rework crypto request completion
    ...

    Linus Torvalds
     

07 Jan, 2016

1 commit

  • These async_XX functions are called from md/raid5 in an atomic
    section, between get_cpu() and put_cpu(), so they must not sleep.
    So use GFP_NOWAIT rather than GFP_IO.

    Dan Williams writes: Longer term async_tx needs to be merged into md
    directly as we can allocate this unmap data statically per-stripe
    rather than per request.

    Fixed: 7476bd79fc01 ("async_pq: convert to dmaengine_unmap_data")
    Cc: stable@vger.kernel.org (v3.13+)
    Reported-and-tested-by: Stanislav Samsonov
    Acked-by: Dan Williams
    Signed-off-by: NeilBrown
    Signed-off-by: Vinod Koul

    NeilBrown
     

01 Jan, 2016

1 commit


29 Dec, 2015

1 commit


26 Dec, 2015

1 commit


22 Dec, 2015

3 commits


20 Dec, 2015

1 commit

  • Added 'hash=' option for selecting the hash algorithm for add_key()
    syscall and documentation for it.

    Added entry for sm3-256 to the following tables in order to support
    TPM_ALG_SM3_256:

    * hash_algo_name
    * hash_digest_size

    Includes support for the following hash algorithms:

    * sha1
    * sha256
    * sha384
    * sha512
    * sm3-256

    Signed-off-by: Jarkko Sakkinen
    Tested-by: Colin Ian King
    Reviewed-by: James Morris
    Reviewed-by: Mimi Zohar
    Acked-by: Peter Huewe

    Jarkko Sakkinen
     

18 Dec, 2015

1 commit


16 Dec, 2015

1 commit