• Jakub Kicinski's avatar
    tls: cap the output scatter list to something reasonable · b93235e6
    Jakub Kicinski authored
    TLS recvmsg() passes user pages as destination for decrypt.
    The decrypt operation is repeated record by record, each
    record being 16kB, max. TLS allocates an sg_table and uses
    iov_iter_get_pages() to populate it with enough pages to
    fit the decrypted record.
    
    Even though we decrypt a single message at a time we size
    the sg_table based on the entire length of the iovec.
    This leads to unnecessarily large allocations, risking
    triggering OOM conditions.
    
    Use iov_iter_truncate() / iov_iter_reexpand() to construct
    a "capped" version of iov_iter_npages(). Alternatively we
    could parametrize iov_iter_npages() to take the size as
    arg instead of using i->count, or do something else..
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    b93235e6
tls_sw.c 64.9 KB