[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200215062930.GA23230@ZenIV.linux.org.uk>
Date: Sat, 15 Feb 2020 06:29:30 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Atul Gupta <atul.gupta@...lsio.com>
Cc: linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC][PATCH] almost certain bug in
drivers/crypto/chelsio/chcr_algo.c:create_authenc_wr()
Another fairly bug in there (this time in
drivers/crypto/chelsio/chtls/chtls_io.c):
/* Read TLS header to find content type and data length */
static int tls_header_read(struct tls_hdr *thdr, struct iov_iter *from)
{
if (copy_from_iter(thdr, sizeof(*thdr), from) != sizeof(*thdr))
return -EFAULT;
return (__force int)cpu_to_be16(thdr->length);
}
For one thing, that kind of force-casts is pretty much always wrong.
This one clearly says "should've used be16_to_cpu()". And that includes
annotating tls_hdr ->length as __be16; no idea about the other field
in there (->version, that is).
For another, the only caller is
recordsz = tls_header_read(&hdr, &msg->msg_iter);
size -= TLS_HEADER_LENGTH;
copied += TLS_HEADER_LENGTH;
csk->tlshws.txleft = recordsz;
csk->tlshws.type = hdr.type;
if (skb)
ULP_SKB_CB(skb)->ulp.tls.type = hdr.type;
which doesn't look like something that'll work if you get -EFAULT out of
that function. If anything, that smells like we want
recordsz = tls_header_read(&hdr, &msg->msg_iter);
if (recordsz < 0)
goto do_fault;
...
What's more, we do *not* want a header that has faulted halfway through
to be consumed. IOW, we want copy_from_iter_full():
static int tls_header_read(struct tls_hdr *thdr, struct iov_iter *from)
{
if (!copy_from_iter_full(thdr, sizeof(*thdr), from))
return -EFAULT;
return be16_to_cpu(thdr->length);
}
in addition to that missing check in the caller...
Powered by blists - more mailing lists