10 May, 2019

3 commits

  • At the time padding_length() is called the record header
    is still part of the message. If malicious TLS 1.3 peer
    sends an all-zero record padding_length() will stop at
    the record header, and return full length of the data
    including the tail_size.

    Subsequent subtraction of prot->overhead_size from rxm->full_len
    will cause rxm->full_len to turn negative. skb accessors,
    however, will always catch resulting out-of-bounds operation,
    so in practice this fix comes down to returning the correct
    error code. It also fixes a set but not used warning.

    This code was added by commit 130b392c6cd6 ("net: tls: Add tls 1.3 support").

    CC: Dave Watson
    Signed-off-by: Jakub Kicinski
    Reviewed-by: Dirk van der Merwe
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Commit 4504ab0e6eb8 ("net/tls: Inform user space about send buffer availability")
    made us report write_space regardless whether partial record
    push was successful or not. Remove the now unused return value
    to clean up the following W=1 warning:

    net/tls/tls_device.c: In function ‘tls_device_write_space’:
    net/tls/tls_device.c:546:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
    int rc = 0;
    ^~

    CC: Vakul Garg
    CC: Boris Pismenny
    Signed-off-by: Jakub Kicinski
    Reviewed-by: Dirk van der Merwe
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • User space can flip the clean_acked_data_enabled static branch
    on and off with TLS offload when CONFIG_TLS_DEVICE is enabled.
    jump_label.h suggests we use the delayed version in this case.

    Deferred branches now also don't take the branch mutex on
    decrement, so we avoid potential locking issues.

    Signed-off-by: Jakub Kicinski
    Reviewed-by: Simon Horman
    Reviewed-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

03 May, 2019

1 commit


01 May, 2019

1 commit


28 Apr, 2019

5 commits

  • Fragments may contain data from other records so we have to account
    for that when we calculate the destination and max length of copy we
    can perform. Note that 'offset' is the offset within the message,
    so it can't be passed as offset within the frag..

    Here skb_store_bits() would have realised the call is wrong and
    simply not copy data.

    Fixes: 4799ac81e52a ("tls: Add rx inline crypto offload")
    Signed-off-by: Jakub Kicinski
    Reviewed-by: John Hurley
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • There is no guarantee the record starts before the skb frags.
    If we don't check for this condition copy amount will get
    negative, leading to reads and writes to random memory locations.
    Familiar hilarity ensues.

    Fixes: 4799ac81e52a ("tls: Add rx inline crypto offload")
    Signed-off-by: Jakub Kicinski
    Reviewed-by: John Hurley
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • To avoid a sparse warning byteswap the be32 sequence number
    before it's stored in the atomic value. While at it drop
    unnecessary brackets and use kernel's u64 type.

    Signed-off-by: Jakub Kicinski
    Reviewed-by: Simon Horman
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • tls_device_sk_destruct being set on a socket used to indicate
    that socket is a kTLS device one. That is no longer true -
    now we use sk_validate_xmit_skb pointer for that purpose.
    Remove the export. tls_device_attach() needs to be moved.

    While at it, remove the dead declaration of tls_sk_destruct().

    Signed-off-by: Jakub Kicinski
    Reviewed-by: Dirk van der Merwe
    Reviewed-by: Simon Horman
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Currently when CONFIG_TLS_DEVICE is set each time kTLS
    connection is opened and the offload is not successful
    (either because the underlying device doesn't support
    it or e.g. it's tables are full) a rate limited error
    will be printed to the logs.

    There is nothing wrong with failing TLS offload. SW
    path will process the packets just fine, drop the
    noisy messages.

    Signed-off-by: Jakub Kicinski
    Reviewed-by: Simon Horman
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

26 Apr, 2019

1 commit


21 Apr, 2019

2 commits

  • When device refuses the offload in tls_set_device_offload_rx()
    it calls tls_sw_free_resources_rx() to clean up software context
    state.

    Unfortunately, tls_sw_free_resources_rx() does not free all
    the state tls_set_sw_offload() allocated - it leaks IV and
    sequence number buffers. All other code paths which lead to
    tls_sw_release_resources_rx() (which tls_sw_free_resources_rx()
    calls) free those right before the call.

    Avoid the leak by moving freeing of iv and rec_seq into
    tls_sw_release_resources_rx().

    Fixes: 4799ac81e52a ("tls: Add rx inline crypto offload")
    Signed-off-by: Jakub Kicinski
    Reviewed-by: Dirk van der Merwe
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • If device supports offload, but offload fails tls_set_device_offload_rx()
    will call tls_sw_free_resources_rx() which (unhelpfully) releases
    and reacquires the socket lock.

    For a small fix release and reacquire the device_offload_lock.

    Fixes: 4799ac81e52a ("tls: Add rx inline crypto offload")
    Signed-off-by: Jakub Kicinski
    Reviewed-by: Dirk van der Merwe
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

19 Apr, 2019

1 commit

  • Unlike atomic_add(), refcount_add() does not deal well
    with a negative argument. TLS fallback code reallocates
    the skb and is very likely to shrink the truesize, leading to:

    [ 189.513254] WARNING: CPU: 5 PID: 0 at lib/refcount.c:81 refcount_add_not_zero_checked+0x15c/0x180
    Call Trace:
    refcount_add_checked+0x6/0x40
    tls_enc_skb+0xb93/0x13e0 [tls]

    Once wmem_allocated count saturates the application can no longer
    send data on the socket. This is similar to Eric's fixes for GSO,
    TCP:
    commit 7ec318feeed1 ("tcp: gso: avoid refcount_t warning from tcp_gso_segment()")
    and UDP:
    commit 575b65bc5bff ("udp: avoid refcount_t saturation in __udp_gso_segment()").

    Unlike the GSO case, for TLS fallback it's likely that the skb has
    shrunk, so the "likely" annotation is the other way around (likely
    branch being "sub").

    Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure")
    Signed-off-by: Jakub Kicinski
    Reviewed-by: John Hurley
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

18 Apr, 2019

1 commit


11 Apr, 2019

3 commits

  • buildbot noticed that TLS_HW is not defined if CONFIG_TLS_DEVICE=n.
    Wrap the cleanup branch into an ifdef, tls_device_free_resources_tx()
    wouldn't be compiled either in this case.

    Fixes: 35b71a34ada6 ("net/tls: don't leak partially sent record in device mode")
    Signed-off-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • David reports that tls triggers warnings related to
    sk->sk_forward_alloc not being zero at destruction time:

    WARNING: CPU: 5 PID: 6831 at net/core/stream.c:206 sk_stream_kill_queues+0x103/0x110
    WARNING: CPU: 5 PID: 6831 at net/ipv4/af_inet.c:160 inet_sock_destruct+0x15b/0x170

    When sender fills up the write buffer and dies from
    SIGPIPE. This is due to the device implementation
    not cleaning up the partially_sent_record.

    This is because commit a42055e8d2c3 ("net/tls: Add support for async encryption of records for performance")
    moved the partial record cleanup to the SW-only path.

    Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption of records for performance")
    Reported-by: David Beckett
    Signed-off-by: Jakub Kicinski
    Reviewed-by: Dirk van der Merwe
    Reviewed-by: Simon Horman
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Commit f66de3ee2c16 ("net/tls: Split conf to rx + tx") made
    freeing of IV and record sequence number conditional to SW
    path only, but commit e8f69799810c ("net/tls: Add generic NIC
    offload infrastructure") also allocates that state for the
    device offload configuration. Remember to free it.

    Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure")
    Signed-off-by: Jakub Kicinski
    Reviewed-by: Dirk van der Merwe
    Reviewed-by: Simon Horman
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

06 Apr, 2019

1 commit


30 Mar, 2019

1 commit

  • Only decrypt_internal() performs zero copy on rx, all paths
    which don't hit decrypt_internal() must set zc to false,
    otherwise tls_sw_recvmsg() may return 0 causing the application
    to believe that that connection got closed.

    Currently this happens with device offload when new record
    is first read from.

    Fixes: d069b780e367 ("tls: Fix tls_device receive")
    Signed-off-by: Jakub Kicinski
    Reviewed-by: Simon Horman
    Reported-by: David Beckett
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

22 Mar, 2019

1 commit


21 Mar, 2019

1 commit

  • Added support for AES128-CCM based record encryption. AES128-CCM is
    similar to AES128-GCM. Both of them have same salt/iv/mac size. The
    notable difference between the two is that while invoking AES128-CCM
    operation, the salt||nonce (which is passed as IV) has to be prefixed
    with a hardcoded value '2'. Further, CCM implementation in kernel
    requires IV passed in crypto_aead_request() to be full '16' bytes.
    Therefore, the record structure 'struct tls_rec' has been modified to
    reserve '16' bytes for IV. This works for both GCM and CCM based cipher.

    Signed-off-by: Vakul Garg
    Signed-off-by: David S. Miller

    Vakul Garg
     

14 Mar, 2019

1 commit

  • A previous fix ("tls: Fix write space handling") assumed that
    user space application gets informed about the socket send buffer
    availability when tls_push_sg() gets called. Inside tls_push_sg(), in
    case do_tcp_sendpages() returns 0, the function returns without calling
    ctx->sk_write_space. Further, the new function tls_sw_write_space()
    did not invoke ctx->sk_write_space. This leads to situation that user
    space application encounters a lockup always waiting for socket send
    buffer to become available.

    Rather than call ctx->sk_write_space from tls_push_sg(), it should be
    called from tls_write_space. So whenever tcp stack invokes
    sk->sk_write_space after freeing socket send buffer, we always declare
    the same to user space by the way of invoking ctx->sk_write_space.

    Fixes: 7463d3a2db0ef ("tls: Fix write space handling")
    Signed-off-by: Vakul Garg
    Reviewed-by: Boris Pismenny
    Signed-off-by: David S. Miller

    Vakul Garg
     

04 Mar, 2019

4 commits

  • Currently, the receive function fails to handle records already
    decrypted by the device due to the commit mentioned below.

    This commit advances the TLS record sequence number and prepares the context
    to handle the next record.

    Fixes: fedf201e1296 ("net: tls: Refactor control message handling on recv")
    Signed-off-by: Boris Pismenny
    Reviewed-by: Eran Ben Elisha
    Signed-off-by: David S. Miller

    Boris Pismenny
     
  • Today, tls_sw_recvmsg is capable of using asynchronous mode to handle
    application data TLS records. Moreover, it assumes that if the cipher
    can be handled asynchronously, then all packets will be processed
    asynchronously.

    However, this assumption is not always true. Specifically, for AES-GCM
    in TLS1.2, it causes data corruption, and breaks user applications.

    This patch fixes this problem by separating the async capability from
    the decryption operation result.

    Fixes: c0ab4732d4c6 ("net/tls: Do not use async crypto for non-data records")
    Signed-off-by: Eran Ben Elisha
    Reviewed-by: Boris Pismenny
    Signed-off-by: David S. Miller

    Eran Ben Elisha
     
  • TLS device cannot use the sw context. This patch returns the original
    tls device write space handler and moves the sw/device specific portions
    to the relevant files.

    Also, we remove the write_space call for the tls_sw flow, because it
    handles partial records in its delayed tx work handler.

    Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption of records for performance")
    Signed-off-by: Boris Pismenny
    Reviewed-by: Eran Ben Elisha
    Signed-off-by: David S. Miller

    Boris Pismenny
     
  • Cleanup the handling of partial records while fixing a bug where the
    tls_push_pending_closed_record function is using the software tls
    context instead of the hardware context.

    The bug resulted in the following crash:
    [ 88.791229] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
    [ 88.793271] #PF error: [normal kernel read fault]
    [ 88.794449] PGD 800000022a426067 P4D 800000022a426067 PUD 22a156067 PMD 0
    [ 88.795958] Oops: 0000 [#1] SMP PTI
    [ 88.796884] CPU: 2 PID: 4973 Comm: openssl Not tainted 5.0.0-rc4+ #3
    [ 88.798314] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
    [ 88.800067] RIP: 0010:tls_tx_records+0xef/0x1d0 [tls]
    [ 88.801256] Code: 00 02 48 89 43 08 e8 a0 0b 96 d9 48 89 df e8 48 dd
    4d d9 4c 89 f8 4d 8b bf 98 00 00 00 48 05 98 00 00 00 48 89 04 24 49 39
    c7 8b 1f 4d 89 fd 0f 84 af 00 00 00 41 8b 47 10 85 c0 0f 85 8d 00
    [ 88.805179] RSP: 0018:ffffbd888186fca8 EFLAGS: 00010213
    [ 88.806458] RAX: ffff9af1ed657c98 RBX: ffff9af1e88a1980 RCX: 0000000000000000
    [ 88.808050] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff9af1e88a1980
    [ 88.809724] RBP: ffff9af1e88a1980 R08: 0000000000000017 R09: ffff9af1ebeeb700
    [ 88.811294] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
    [ 88.812917] R13: ffff9af1e88a1980 R14: ffff9af1ec13f800 R15: 0000000000000000
    [ 88.814506] FS: 00007fcad2240740(0000) GS:ffff9af1f7880000(0000) knlGS:0000000000000000
    [ 88.816337] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 88.817717] CR2: 0000000000000000 CR3: 0000000228b3e000 CR4: 00000000001406e0
    [ 88.819328] Call Trace:
    [ 88.820123] tls_push_data+0x628/0x6a0 [tls]
    [ 88.821283] ? remove_wait_queue+0x20/0x60
    [ 88.822383] ? n_tty_read+0x683/0x910
    [ 88.823363] tls_device_sendmsg+0x53/0xa0 [tls]
    [ 88.824505] sock_sendmsg+0x36/0x50
    [ 88.825492] sock_write_iter+0x87/0x100
    [ 88.826521] __vfs_write+0x127/0x1b0
    [ 88.827499] vfs_write+0xad/0x1b0
    [ 88.828454] ksys_write+0x52/0xc0
    [ 88.829378] do_syscall_64+0x5b/0x180
    [ 88.830369] entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [ 88.831603] RIP: 0033:0x7fcad1451680

    [ 1248.470626] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
    [ 1248.472564] #PF error: [normal kernel read fault]
    [ 1248.473790] PGD 0 P4D 0
    [ 1248.474642] Oops: 0000 [#1] SMP PTI
    [ 1248.475651] CPU: 3 PID: 7197 Comm: openssl Tainted: G OE 5.0.0-rc4+ #3
    [ 1248.477426] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
    [ 1248.479310] RIP: 0010:tls_tx_records+0x110/0x1f0 [tls]
    [ 1248.480644] Code: 00 02 48 89 43 08 e8 4f cb 63 d7 48 89 df e8 f7 9c
    1b d7 4c 89 f8 4d 8b bf 98 00 00 00 48 05 98 00 00 00 48 89 04 24 49 39
    c7 8b 1f 4d 89 fd 0f 84 af 00 00 00 41 8b 47 10 85 c0 0f 85 8d 00
    [ 1248.484825] RSP: 0018:ffffaa0a41543c08 EFLAGS: 00010213
    [ 1248.486154] RAX: ffff955a2755dc98 RBX: ffff955a36031980 RCX: 0000000000000006
    [ 1248.487855] RDX: 0000000000000000 RSI: 000000000000002b RDI: 0000000000000286
    [ 1248.489524] RBP: ffff955a36031980 R08: 0000000000000000 R09: 00000000000002b1
    [ 1248.491394] R10: 0000000000000003 R11: 00000000ad55ad55 R12: 0000000000000000
    [ 1248.493162] R13: 0000000000000000 R14: ffff955a2abe6c00 R15: 0000000000000000
    [ 1248.494923] FS: 0000000000000000(0000) GS:ffff955a378c0000(0000) knlGS:0000000000000000
    [ 1248.496847] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 1248.498357] CR2: 0000000000000000 CR3: 000000020c40e000 CR4: 00000000001406e0
    [ 1248.500136] Call Trace:
    [ 1248.500998] ? tcp_check_oom+0xd0/0xd0
    [ 1248.502106] tls_sk_proto_close+0x127/0x1e0 [tls]
    [ 1248.503411] inet_release+0x3c/0x60
    [ 1248.504530] __sock_release+0x3d/0xb0
    [ 1248.505611] sock_close+0x11/0x20
    [ 1248.506612] __fput+0xb4/0x220
    [ 1248.507559] task_work_run+0x88/0xa0
    [ 1248.508617] do_exit+0x2cb/0xbc0
    [ 1248.509597] ? core_sys_select+0x17a/0x280
    [ 1248.510740] do_group_exit+0x39/0xb0
    [ 1248.511789] get_signal+0x1d0/0x630
    [ 1248.512823] do_signal+0x36/0x620
    [ 1248.513822] exit_to_usermode_loop+0x5c/0xc6
    [ 1248.515003] do_syscall_64+0x157/0x180
    [ 1248.516094] entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [ 1248.517456] RIP: 0033:0x7fb398bd3f53
    [ 1248.518537] Code: Bad RIP value.

    Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption of records for performance")
    Signed-off-by: Boris Pismenny
    Signed-off-by: Eran Ben Elisha
    Signed-off-by: David S. Miller

    Boris Pismenny
     

25 Feb, 2019

1 commit

  • The patch enables returning 'type' in msghdr for records that are
    retrieved with MSG_PEEK in recvmsg. Further it prevents records peeked
    from socket from getting clubbed with any other record of different
    type when records are subsequently dequeued from strparser.

    For each record, we now retain its type in sk_buff's control buffer
    cb[]. Inside control buffer, record's full length and offset are already
    stored by strparser in 'struct strp_msg'. We store record type after
    'struct strp_msg' inside 'struct tls_msg'. For tls1.2, the type is
    stored just after record dequeue. For tls1.3, the type is stored after
    record has been decrypted.

    Inside process_rx_list(), before processing a non-data record, we check
    that we must be able to return back the record type to the user
    application. If not, the decrypted records in tls context's rx_list is
    left there without consuming any data.

    Fixes: 692d7b5d1f912 ("tls: Fix recvmsg() to be able to peek across multiple records")
    Signed-off-by: Vakul Garg
    Signed-off-by: David S. Miller

    Vakul Garg
     

20 Feb, 2019

1 commit

  • Each tls context maintains two cipher contexts (one each for tx and rx
    directions). For each tls session, the constants such as protocol
    version, ciphersuite, iv size, associated data size etc are same for
    both the directions and need to be stored only once per tls context.
    Hence these are moved from 'struct cipher_context' to 'struct
    tls_prot_info' and stored only once in 'struct tls_context'.

    Signed-off-by: Vakul Garg
    Signed-off-by: David S. Miller

    Vakul Garg
     

13 Feb, 2019

1 commit

  • Addition of tls1.3 support broke tls1.2 handshake when async crypto
    accelerator is used. This is because the record type for non-data
    records is not propagated to user application. Also when async
    decryption happens, the decryption does not stop when two different
    types of records get dequeued and submitted for decryption. To address
    it, we decrypt tls1.2 non-data records in synchronous way. We check
    whether the record we just processed has same type as the previous one
    before checking for async condition and jumping to dequeue next record.

    Fixes: 130b392c6cd6b ("net: tls: Add tls 1.3 support")
    Signed-off-by: Vakul Garg
    Signed-off-by: David S. Miller

    Vakul Garg
     

10 Feb, 2019

1 commit

  • Function tls_sw_recvmsg() dequeues multiple records from stream parser
    and decrypts them. In case the decryption is done by async accelerator,
    the records may get submitted for decryption while the previous ones may
    not have been decryted yet. For tls1.3, the record type is known only
    after decryption. Therefore, for tls1.3, tls_sw_recvmsg() may submit
    records for decryption even if it gets 'handshake' records after 'data'
    records. These intermediate 'handshake' records may do a key updation.
    By the time new keys are given to ktls by userspace, it is possible that
    ktls has already submitted some records i(which are encrypted with new
    keys) for decryption using old keys. This would lead to decrypt failure.
    Therefore, async decryption of records should be disabled for tls1.3.

    Fixes: 130b392c6cd6b ("net: tls: Add tls 1.3 support")
    Signed-off-by: Vakul Garg
    Signed-off-by: David S. Miller

    Vakul Garg
     

02 Feb, 2019

5 commits

  • Currently we don't zerocopy if the crypto framework async bit is set.
    However some crypto algorithms (such as x86 AESNI) support async,
    but in the context of sendmsg, will never run asynchronously. Instead,
    check for actual EINPROGRESS return code before assuming algorithm is
    async.

    Signed-off-by: Dave Watson
    Signed-off-by: David S. Miller

    Dave Watson
     
  • TLS 1.3 has minor changes from TLS 1.2 at the record layer.

    * Header now hardcodes the same version and application content type in
    the header.
    * The real content type is appended after the data, before encryption (or
    after decryption).
    * The IV is xored with the sequence number, instead of concatinating four
    bytes of IV with the explicit IV.
    * Zero-padding: No exlicit length is given, we search backwards from the
    end of the decrypted data for the first non-zero byte, which is the
    content type. Currently recv supports reading zero-padding, but there
    is no way for send to add zero padding.

    Signed-off-by: Dave Watson
    Signed-off-by: David S. Miller

    Dave Watson
     
  • For TLS 1.3, the control message is encrypted. Handle control
    message checks after decryption.

    Signed-off-by: Dave Watson
    Signed-off-by: David S. Miller

    Dave Watson
     
  • TLS 1.3 has a different AAD size, use a variable in the code to
    make TLS 1.3 support easy.

    Signed-off-by: Dave Watson
    Signed-off-by: David S. Miller

    Dave Watson
     
  • Wire up support for 256 bit keys from the setsockopt to the crypto
    framework

    Signed-off-by: Dave Watson
    Signed-off-by: David S. Miller

    Dave Watson
     

30 Jan, 2019

1 commit


29 Jan, 2019

2 commits

  • If there are outstanding async tx requests (when crypto returns EINPROGRESS),
    there is a potential deadlock: the tx work acquires the lock, while we
    cancel_delayed_work_sync() while holding the lock. Drop the lock while waiting
    for the work to complete.

    Fixes: a42055e8d2c30 ("Add support for async encryption of records...")
    Signed-off-by: Dave Watson
    Signed-off-by: David S. Miller

    Dave Watson
     
  • aead_request_set_crypt takes an iv pointer, and we change the iv
    soon after setting it. Some async crypto algorithms don't save the iv,
    so we need to save it in the tls_rec for async requests.

    Found by hardcoding x64 aesni to use async crypto manager (to test the async
    codepath), however I don't think this combination can happen in the wild.
    Presumably other hardware offloads will need this fix, but there have been
    no user reports.

    Fixes: a42055e8d2c30 ("Add support for async encryption of records...")
    Signed-off-by: Dave Watson
    Signed-off-by: David S. Miller

    Dave Watson
     

23 Jan, 2019

1 commit

  • free tls context in sock destruct. close may not be the last
    call to free sock but force releasing the ctx in close
    will result in GPF when ctx referred again in tcp_done

    [ 515.330477] general protection fault: 0000 [#1] SMP PTI
    [ 515.330539] CPU: 5 PID: 0 Comm: swapper/5 Not tainted 4.20.0-rc7+ #10
    [ 515.330657] Hardware name: Supermicro X8ST3/X8ST3, BIOS 2.0b
    11/07/2013
    [ 515.330844] RIP: 0010:tls_hw_unhash+0xbf/0xd0
    [
    [ 515.332220] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 515.332340] CR2: 00007fab32c55000 CR3: 000000009261e000 CR4:
    00000000000006e0
    [ 515.332519] Call Trace:
    [ 515.332632]
    [ 515.332793] tcp_set_state+0x5a/0x190
    [ 515.332907] ? tcp_update_metrics+0xe3/0x350
    [ 515.333023] tcp_done+0x31/0xd0
    [ 515.333130] tcp_rcv_state_process+0xc27/0x111a
    [ 515.333242] ? __lock_is_held+0x4f/0x90
    [ 515.333350] ? tcp_v4_do_rcv+0xaf/0x1e0
    [ 515.333456] tcp_v4_do_rcv+0xaf/0x1e0

    Signed-off-by: Atul Gupta
    Signed-off-by: David S. Miller

    Atul Gupta