* cryptoapi incorrect struct page usage
@ 2003-08-09 20:33 Mika Penttilä
2003-08-09 20:36 ` David S. Miller
0 siblings, 1 reply; 2+ messages in thread
From: Mika Penttilä @ 2003-08-09 20:33 UTC (permalink / raw)
To: linux-kernel, linux-net
It seems that cryptoapi usage wrt mm is not safe. At least both ipsec
and cryptoloop practise these kinds of things :
example from net/xfrm/xfrm_algo.c
int
skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset,
int len)
{
int start = skb_headlen(skb);
int i, copy = start - offset;
int elt = 0;
if (copy > 0) {
if (copy > len)
copy = len;
sg[elt].page = virt_to_page(skb->data + offset);
sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
sg[elt].length = copy;
so unpinned pages are passed to cryptoapi. Nothing prevents these pages
from being swapped out. Something like get_user_pages() is needed to pin
these pages for the duration of crypto operations. Comments?
--Mika
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: cryptoapi incorrect struct page usage
2003-08-09 20:33 cryptoapi incorrect struct page usage Mika Penttilä
@ 2003-08-09 20:36 ` David S. Miller
0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2003-08-09 20:36 UTC (permalink / raw)
To: Mika Penttilä; +Cc: linux-kernel, linux-net
On Sat, 09 Aug 2003 23:33:52 +0300
Mika Penttilä <mika.penttila@kolumbus.fi> wrote:
> sg[elt].page = virt_to_page(skb->data + offset);
> sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
> sg[elt].length = copy;
>
> so unpinned pages are passed to cryptoapi. Nothing prevents these pages
> from being swapped out. Something like get_user_pages() is needed to pin
> these pages for the duration of crypto operations. Comments?
The page at skb->data was allocated by the skbuff allocation
layer, it has therefore a lifetime the size of the SKB itself.
The crypto API call is finished before we can possibly free up
the SKB, so nothing bad can happen.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-08-09 20:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-09 20:33 cryptoapi incorrect struct page usage Mika Penttilä
2003-08-09 20:36 ` David S. Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.