From: "Miloslav Trmač" <mitr@redhat.com>
To: eparis@redhat.com, herbert@gondor.hengli.com.au
Cc: linux-audit@redhat.com, linux-crypto@vger.kernel.org,
"Miloslav Trmač" <mitr@redhat.com>
Subject: [PATCH 4/5] Audit type-independent events
Date: Wed, 24 Nov 2010 18:05:54 +0100 [thread overview]
Message-ID: <1290618355-31193-5-git-send-email-mitr@redhat.com> (raw)
In-Reply-To: <1290618355-31193-1-git-send-email-mitr@redhat.com>
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
---
crypto/af_alg.c | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 490ae43..fc1b0f7 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -14,6 +14,7 @@
#include <asm/atomic.h>
#include <crypto/if_alg.h>
+#include <linux/audit.h>
#include <linux/crypto.h>
#include <linux/idr.h>
#include <linux/init.h>
@@ -160,6 +161,11 @@ static void alg_sk_destruct(struct sock *sk) {}
void af_alg_sk_destruct_child(struct sock *sk)
{
struct alg_sock *ask = alg_sk(sk);
+ struct alg_sock *parent_ask = alg_sk(ask->parent);
+
+ audit_log_crypto_op(AUDIT_CRYPTO_OP_CTX_DEL, parent_ask->id,
+ ask->id, -1,
+ ask->type->alg_name(parent_ask->private), NULL);
sock_put(ask->parent);
alg_sk_destruct(sk);
@@ -235,6 +241,11 @@ static int alg_setkey(struct sock *sk, char __user *ukey,
u8 *key;
int err;
+ err = audit_log_crypto_op(AUDIT_CRYPTO_OP_TFM_KEY_IMPORT, ask->id, -1,
+ -1, type->alg_name(ask->private), NULL);
+ if (err)
+ return err;
+
key = sock_kmalloc(sk, keylen, GFP_KERNEL);
if (!key)
return -ENOMEM;
@@ -315,6 +326,14 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)
alg_sk(sk2)->parent = sk;
alg_sk(sk2)->type = type;
+ err = audit_log_crypto_op(AUDIT_CRYPTO_OP_CTX_NEW, ask->id,
+ alg_sk(sk2)->id, -1,
+ type->alg_name(ask->private), NULL);
+ if (err) {
+ sk_free(sk2);
+ return err;
+ }
+
newsock->ops = type->ops;
newsock->state = SS_CONNECTED;
@@ -359,6 +378,9 @@ static void alg_sock_destruct(struct sock *sk)
{
struct alg_sock *ask = alg_sk(sk);
+ audit_log_crypto_op(AUDIT_CRYPTO_OP_TFM_DEL, ask->id, -1, -1, NULL,
+ NULL);
+
alg_do_release(ask->type, ask->private);
alg_sk_destruct(sk);
}
@@ -379,6 +401,14 @@ static int alg_create(struct net *net, struct socket *sock, int protocol,
if (!sk)
goto out;
+ err = audit_log_crypto_op(AUDIT_CRYPTO_OP_TFM_NEW, alg_sk(sk)->id, -1,
+ -1, NULL, NULL);
+ if (err) {
+ alg_sk_destruct(sk);
+ sk_free(sk);
+ goto out;
+ }
+
sock->ops = &alg_proto_ops;
sock_init_data(sock, sk);
--
1.7.3.2
next prev parent reply other threads:[~2010-11-24 17:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-24 17:05 [PATCH 0/5] RFC v2: AF_ALG auditing Miloslav Trmač
2010-11-24 17:05 ` [PATCH 1/5] Add general crypto auditing infrastructure Miloslav Trmač
2010-11-24 17:05 ` [PATCH 2/5] Add unique IDs to AF_ALG sockets Miloslav Trmač
2010-11-24 17:05 ` [PATCH 3/5] Add "alg_name" operation to af_alg_type Miloslav Trmač
2010-11-24 17:05 ` Miloslav Trmač [this message]
2010-11-24 17:05 ` [PATCH 5/5] Audit type-specific crypto operations Miloslav Trmač
2010-12-02 7:48 ` [PATCH 0/5] RFC v2: AF_ALG auditing Herbert Xu
-- strict thread matches above, loose matches on Subject: below --
2010-11-23 12:47 RFC: " Miloslav Trmac
2010-11-23 12:50 ` [PATCH 4/5] Audit type-independent events Miloslav Trmač
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=1290618355-31193-5-git-send-email-mitr@redhat.com \
--to=mitr@redhat.com \
--cc=eparis@redhat.com \
--cc=herbert@gondor.hengli.com.au \
--cc=linux-audit@redhat.com \
--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