All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/2] crypto: AF_ALG memory management fix
@ 2017-02-17 22:31 Stephan Müller
  2017-02-17 22:31 ` [PATCH v5 1/2] crypto: skcipher AF_ALG - overhaul memory management Stephan Müller
  2017-02-17 22:32 ` [PATCH v5 2/2] crypto: aead " Stephan Müller
  0 siblings, 2 replies; 13+ messages in thread
From: Stephan Müller @ 2017-02-17 22:31 UTC (permalink / raw)
  To: herbert; +Cc: linux-crypto

Hi Herbert,

Changes v5:
* use list_for_each_entry_safe in aead_count_tsgl

Changes v4:
* replace ctx->processed with a maintenance of a private recvmsg
  TX SGL
* algif_skcipher: rename skcipher_sg_list into skcipher_tsgl to make
  it consistent with algif_aead to prepare for a code consolidation

Changes v3:
* in *_pull_tsgl: make sure ctx->processed cannot be less than zero
* perform fuzzing of all input parameters with bogus values

Changes v2:
* import fix from Harsh Jain <harsh@chelsio.com> to remove SG
  from list before freeing
* fix return code used for ki_complete to match AIO behavior
  with sync behavior
* rename variable list -> tsgl_list
* update the algif_aead patch to include a dynamic TX SGL
  allocation similar to what algif_skcipher does. This allows
  concurrent continuous read/write operations to the extent
  you requested. Although I have not implemented "pairs of
  TX/RX SGLs" as I think that is even more overhead, the
  implementation conceptually defines such pairs. The recvmsg
  call defines how much from the input data is processed.
  The caller can have arbitrary number of sendmsg calls
  where the data is added to the TX SGL before an recvmsg
  asks the kernel to process a given amount (or all) of the
  TX SGL.

With the changes, you will see a lot of code duplication now
as I deliberately tried to use the same struct and variable names,
the same function names and even the same oder of functions.
If you agree to this patch, I volunteer to provide a followup
patch that will extract the code duplication into common
functions.

Please find attached memory management updates to

- simplify the code: the old AIO memory management is very
  complex and seemingly very fragile -- the update now
  eliminates all reported bugs in the skcipher and AEAD
  interfaces which allowed the kernel to be crashed by
  an unprivileged user

- streamline the code: there is one code path for AIO and sync
  operation; the code between algif_skcipher and algif_aead
  is very similar (if that patch set is accepted, I volunteer
  to reduce code duplication by moving service operations
  into af_alg.c and to further unify the TX SGL handling)

- unify the AIO and sync operation which only differ in the
  kernel crypto API callback and whether to wait for the
  crypto operation or not

- fix all reported bugs regarding the handling of multiple
  IOCBs.

The following testing was performed:

- stress testing to verify that no memleaks exist

- testing using Tadeusz Struck AIO test tool (see
  https://github.com/tstruk/afalg_async_test) -- the AEAD test
  is not applicable any more due to the changed user space
  interface; the skcipher test works once the user space
  interface change is honored in the test code

- using the libkcapi test suite, all tests including the
  originally failing ones (AIO with multiple IOCBs) work now --
  the current libkcapi code artificially limits the AEAD
  operation to one IOCB. After altering the libkcapi code
  to allow multiple IOCBs, the testing works flawless.

Stephan Mueller (2):
  crypto: skcipher AF_ALG - overhaul memory management
  crypto: aead AF_ALG - overhaul memory management

 crypto/algif_aead.c     | 702 ++++++++++++++++++++++++++----------------------
 crypto/algif_skcipher.c | 540 +++++++++++++++++--------------------
 2 files changed, 637 insertions(+), 605 deletions(-)

-- 
2.9.3

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

end of thread, other threads:[~2017-03-31 10:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-17 22:31 [PATCH v5 0/2] crypto: AF_ALG memory management fix Stephan Müller
2017-02-17 22:31 ` [PATCH v5 1/2] crypto: skcipher AF_ALG - overhaul memory management Stephan Müller
2017-03-16  8:39   ` Herbert Xu
2017-03-16  8:55     ` Stephan Müller
2017-03-16  9:08       ` Herbert Xu
2017-03-16  9:23         ` Stephan Müller
2017-03-16  9:52           ` Herbert Xu
2017-03-16 10:18             ` Stephan Müller
2017-03-16 12:20               ` Stephan Müller
2017-03-31 10:33               ` Herbert Xu
2017-03-19  4:34             ` Stephan Müller
2017-03-30 13:59             ` Stephan Müller
2017-02-17 22:32 ` [PATCH v5 2/2] crypto: aead " Stephan Müller

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.