linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* sg_set_buf
@ 2016-10-18 21:37 J. Bruce Fields
  2016-10-20 10:22 ` sg_set_buf Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: J. Bruce Fields @ 2016-10-18 21:37 UTC (permalink / raw)
  To: Rusty Russell; +Cc: linux-nfs

The NFS code is using sg_set_buf to turn a bit of stack menory into a
scatterlist it can pass to the crypto code.  That started BUG()ing as of
ac4e97abce9b "scatterlist: sg_set_buf() argument must be in linear
mapping".

Is that BUG() being overly strict, or is this something we should never
have been doing in the first place?

--b.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sg_set_buf
  2016-10-18 21:37 sg_set_buf J. Bruce Fields
@ 2016-10-20 10:22 ` Christoph Hellwig
  2016-10-20 13:20   ` sg_set_buf J. Bruce Fields
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2016-10-20 10:22 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Rusty Russell, linux-nfs

On Tue, Oct 18, 2016 at 05:37:55PM -0400, J. Bruce Fields wrote:
> The NFS code is using sg_set_buf to turn a bit of stack menory into a
> scatterlist it can pass to the crypto code.  That started BUG()ing as of
> ac4e97abce9b "scatterlist: sg_set_buf() argument must be in linear
> mapping".
> 
> Is that BUG() being overly strict, or is this something we should never
> have been doing in the first place?

In general we use scatterlists to pass dma addresses to hardware, so
yes, they should not point to the stack. 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sg_set_buf
  2016-10-20 10:22 ` sg_set_buf Christoph Hellwig
@ 2016-10-20 13:20   ` J. Bruce Fields
  2016-10-20 13:31     ` sg_set_buf Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: J. Bruce Fields @ 2016-10-20 13:20 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Rusty Russell, linux-nfs

On Thu, Oct 20, 2016 at 03:22:00AM -0700, Christoph Hellwig wrote:
> On Tue, Oct 18, 2016 at 05:37:55PM -0400, J. Bruce Fields wrote:
> > The NFS code is using sg_set_buf to turn a bit of stack menory into a
> > scatterlist it can pass to the crypto code.  That started BUG()ing as of
> > ac4e97abce9b "scatterlist: sg_set_buf() argument must be in linear
> > mapping".
> > 
> > Is that BUG() being overly strict, or is this something we should never
> > have been doing in the first place?
> 
> In general we use scatterlists to pass dma addresses to hardware, so
> yes, they should not point to the stack. 

The crypto code isn't actually doing that though, is it?

(Or is there a chance it could be passing the data to separate crypto
hardware?  Do people do that these days?)

--b.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sg_set_buf
  2016-10-20 13:20   ` sg_set_buf J. Bruce Fields
@ 2016-10-20 13:31     ` Christoph Hellwig
  2016-10-20 21:42       ` sg_set_buf J. Bruce Fields
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2016-10-20 13:31 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Christoph Hellwig, Rusty Russell, linux-nfs

On Thu, Oct 20, 2016 at 09:20:30AM -0400, J. Bruce Fields wrote:
> The crypto code isn't actually doing that though, is it?
> 
> (Or is there a chance it could be passing the data to separate crypto
> hardware?  Do people do that these days?)

Yes, there are tons of crypto accelarators, and they are built around
using struct scatterlist.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sg_set_buf
  2016-10-20 13:31     ` sg_set_buf Christoph Hellwig
@ 2016-10-20 21:42       ` J. Bruce Fields
  2016-10-21 12:26         ` sg_set_buf Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: J. Bruce Fields @ 2016-10-20 21:42 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Rusty Russell, linux-nfs

On Thu, Oct 20, 2016 at 06:31:07AM -0700, Christoph Hellwig wrote:
> On Thu, Oct 20, 2016 at 09:20:30AM -0400, J. Bruce Fields wrote:
> > The crypto code isn't actually doing that though, is it?
> > 
> > (Or is there a chance it could be passing the data to separate crypto
> > hardware?  Do people do that these days?)
> 
> Yes, there are tons of crypto accelarators, and they are built around
> using struct scatterlist.

OK, thanks.

Turns out there are several places in the kerberos code where it just
needs to encrypt one small checksum or sequence number, and it's been
doing that on the stack.

For now I'll just sprinkle kmalloc()'s all over.  Eventually we'll need
to find something better.

--b.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sg_set_buf
  2016-10-20 21:42       ` sg_set_buf J. Bruce Fields
@ 2016-10-21 12:26         ` Christoph Hellwig
  0 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2016-10-21 12:26 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Christoph Hellwig, Rusty Russell, linux-nfs, linux-crypto

On Thu, Oct 20, 2016 at 05:42:19PM -0400, J. Bruce Fields wrote:
> Turns out there are several places in the kerberos code where it just
> needs to encrypt one small checksum or sequence number, and it's been
> doing that on the stack.
> 
> For now I'll just sprinkle kmalloc()'s all over.  Eventually we'll need
> to find something better.

I agree that it would be nice to be able to hash small objects on the
stack.  But unless I've missed something there is no way to do that
without using struct scatterlist.  I've added linux-crypto to the cc
list to confirm that I really didn't miss anything.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-10-21 12:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-18 21:37 sg_set_buf J. Bruce Fields
2016-10-20 10:22 ` sg_set_buf Christoph Hellwig
2016-10-20 13:20   ` sg_set_buf J. Bruce Fields
2016-10-20 13:31     ` sg_set_buf Christoph Hellwig
2016-10-20 21:42       ` sg_set_buf J. Bruce Fields
2016-10-21 12:26         ` sg_set_buf Christoph Hellwig

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).