From: Tom Lendacky <thomas.lendacky@amd.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: <linux-crypto@vger.kernel.org>, <davem@davemloft.net>
Subject: Re: [PATCH v1 3/3] crypto: ccp - Protect against poorly marked end of sg list
Date: Wed, 27 May 2015 09:15:16 -0500 [thread overview]
Message-ID: <5565D174.5070107@amd.com> (raw)
In-Reply-To: <20150527094554.GA28211@gondor.apana.org.au>
On 05/27/2015 04:45 AM, Herbert Xu wrote:
> On Wed, May 27, 2015 at 05:43:05PM +0800, Herbert Xu wrote:
>> Tom Lendacky <thomas.lendacky@amd.com> wrote:
>>> Scatter gather lists can be created with more available entries than are
>>> actually used (e.g. using sg_init_table() to reserve a specific number
>>> of sg entries, but in actuality using something less than that based on
>>> the data length). The caller sometimes fails to mark the last entry
>>> with sg_mark_end(). In these cases, sg_nents() will return the original
>>> size of the sg list as opposed to the actual number of sg entries that
>>> contain valid data.
>>>
>>> On arm64, if the sg_nents() value is used in a call to dma_map_sg() in
>>> this situation, then it causes a BUG_ON in lib/swiotlb.c because an
>>> "empty" sg list entry results in dma_capable() returning false and
>>> swiotlb trying to create a bounce buffer of size 0. This occurred in
>>> the userspace crypto interface before being fixed by
>>>
>>> 0f477b655a52 ("crypto: algif - Mark sgl end at the end of data")
>>>
>>> Protect against this in the future by counting the number of sg entries
>>> needed to meet the length requirement and supplying that value to
>>> dma_map_sg().
>>
>> Is this needed for any reason other than this bug that's already
>> been fixed?
>
> Could this be needed if you have a properly marked SG list say of
> 100 bytes but len is only 10 bytes?
I don't think that situation matters because the DMA mapping should
succeed just fine at 100 bytes even if only needing/using 10 bytes.
Thanks,
Tom
>
> Cheers,
>
next prev parent reply other threads:[~2015-05-27 14:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-26 18:06 [PATCH v1 0/3] crypto: ccp - CCP driver updates 2015-05-26 Tom Lendacky
2015-05-26 18:06 ` [PATCH v1 1/3] crypto: ccp - Remove manual check and set of dma_mask pointer Tom Lendacky
2015-05-26 18:06 ` [PATCH v1 2/3] crypto: ccp - Remove unused structure field Tom Lendacky
2015-05-26 18:06 ` [PATCH v1 3/3] crypto: ccp - Protect against poorly marked end of sg list Tom Lendacky
2015-05-27 9:43 ` Herbert Xu
2015-05-27 9:45 ` Herbert Xu
2015-05-27 14:15 ` Tom Lendacky [this message]
2015-05-27 14:12 ` Tom Lendacky
2015-05-28 0:36 ` Herbert Xu
2015-05-28 17:30 ` Tom Lendacky
2015-05-27 9:55 ` [PATCH v1 0/3] crypto: ccp - CCP driver updates 2015-05-26 Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5565D174.5070107@amd.com \
--to=thomas.lendacky@amd.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).