]> git.ipfire.org Git - people/ms/linux.git/commit - crypto/algif_hash.c
crypto: algif - add and use sock_kzfree_s() instead of memzero_explicit()
authorDaniel Borkmann <dborkman@redhat.com>
Wed, 19 Nov 2014 16:13:11 +0000 (17:13 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 25 Nov 2014 14:50:39 +0000 (22:50 +0800)
commit79e886599e6416d0de26e8562e4464577d081c3d
tree83a545d589f1bb7ba5de28cc768ce549598fd0b2
parent5d26a105b5a73e5635eae0629b42fa0a90e07b7b
crypto: algif - add and use sock_kzfree_s() instead of memzero_explicit()

Commit e1bd95bf7c25 ("crypto: algif - zeroize IV buffer") and
2a6af25befd0 ("crypto: algif - zeroize message digest buffer")
added memzero_explicit() calls on buffers that are later on
passed back to sock_kfree_s().

This is a discussed follow-up that, instead, extends the sock
API and adds sock_kzfree_s(), which internally uses kzfree()
instead of kfree() for passing the buffers back to slab.

Having sock_kzfree_s() allows to keep the changes more minimal
by just having a drop-in replacement instead of adding
memzero_explicit() calls everywhere before sock_kfree_s().

In kzfree(), the compiler is not allowed to optimize the memset()
away and thus there's no need for memzero_explicit(). Both,
sock_kfree_s() and sock_kzfree_s() are wrappers for
__sock_kfree_s() and call into kfree() resp. kzfree(); here,
__sock_kfree_s() needs to be explicitly inlined as we want the
compiler to optimize the call and condition away and thus it
produces e.g. on x86_64 the _same_ assembler output for
sock_kfree_s() before and after, and thus also allows for
avoiding code duplication.

Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/algif_hash.c
crypto/algif_skcipher.c
include/net/sock.h
net/core/sock.c