From: Martin Willi <martin@strongswan.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org
Subject: Re: [PATCH 4/4] crypto: algif_skcipher - User-space interface for skcipher operations
Date: Mon, 08 Nov 2010 10:10:20 +0100 [thread overview]
Message-ID: <1289207420.2013.16.camel@martin> (raw)
In-Reply-To: <20101107010813.GA20538@gondor.apana.org.au>
> Hmm, can you show me your test program and how you determined
> that it was leaking pages?
The test program below runs 1000 encryptions:
# grep nr_free /proc/vmstat
nr_free_pages 11031
# ./test
...
# grep nr_free /proc/vmstat
nr_free_pages 10026
# ./test
...
# grep nr_free /proc/vmstat
nr_free_pages 9027
# ./test
...
# grep nr_free /proc/vmstat
nr_free_pages 8025
Regards
Martin
--
#include <stdio.h>
#include <unistd.h>
#include <stddef.h>
#include <string.h>
#include <sys/socket.h>
#include <linux/if_alg.h>
int main()
{
int tfm, i;
char key[16];
struct sockaddr_alg sa = {
.salg_family = AF_ALG,
.salg_type = "skcipher",
.salg_name = "cbc(aes)",
};
tfm = socket(AF_ALG, SOCK_SEQPACKET, 0);
if (tfm == -1 ||
bind(tfm, (struct sockaddr*)&sa, sizeof(sa)) == -1)
{
return 1;
}
memset(key, 0x34, sizeof(key));
if (setsockopt(tfm, SOL_ALG, ALG_SET_KEY,
key, sizeof(key)) == -1)
{
return 1;
}
for (i = 0; i < 1000; i++)
{
struct msghdr msg = {};
struct cmsghdr *cmsg;
struct af_alg_iv *ivm;
u_int32_t type;
struct iovec iov;
char buf[CMSG_SPACE(sizeof(type)) +
CMSG_SPACE(offsetof(struct af_alg_iv, iv)+16)];
char data[64];
ssize_t len;
int op;
op = accept(tfm, NULL, 0);
if (op == -1)
{
return 1;
}
type = ALG_OP_ENCRYPT;
memset(data, 0x12, sizeof(data));
memset(buf, 0, sizeof(buf));
msg.msg_control = buf;
msg.msg_controllen = sizeof(buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = SOL_ALG;
cmsg->cmsg_type = ALG_SET_OP;
cmsg->cmsg_len = CMSG_LEN(sizeof(type));
*(u_int32_t*)CMSG_DATA(cmsg) = type;
cmsg = CMSG_NXTHDR(&msg, cmsg);
cmsg->cmsg_level = SOL_ALG;
cmsg->cmsg_type = ALG_SET_IV;
cmsg->cmsg_len = CMSG_LEN(
offsetof(struct af_alg_iv, iv) + 16);
ivm = (void*)CMSG_DATA(cmsg);
ivm->ivlen = 16;
memset(ivm->iv, 0x23, 16);
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
iov.iov_base = data;
iov.iov_len = sizeof(data);
len = sendmsg(op, &msg, 0);
if (len != sizeof(data))
{
return 1;
}
if (read(op, data, len) != len)
{
return 1;
}
printf(".");
fflush(stdout);
close(op);
}
close(tfm);
printf("\n");
return 0;
}
next prev parent reply other threads:[~2010-11-08 9:10 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-07 8:42 RFC: Crypto API User-interface Herbert Xu
2010-09-07 9:18 ` Tomas Mraz
2010-09-07 14:06 ` Christoph Hellwig
2010-09-07 14:11 ` Herbert Xu
2010-09-07 14:24 ` Christoph Hellwig
2010-09-07 14:39 ` Herbert Xu
2010-09-07 14:49 ` Nikos Mavrogiannopoulos
2010-09-07 14:57 ` Nikos Mavrogiannopoulos
2010-09-07 14:59 ` Christoph Hellwig
2010-10-19 13:44 ` Herbert Xu
2010-10-20 10:24 ` Nikos Mavrogiannopoulos
2010-11-04 17:34 ` Herbert Xu
2010-11-04 17:36 ` [PATCH 3/4] crypto: algif_hash - User-space interface for hash operations Herbert Xu
2010-11-04 19:23 ` David Miller
2010-11-04 17:36 ` [PATCH 2/4] crypto: af_alg - User-space interface for Crypto API Herbert Xu
2010-11-04 19:23 ` David Miller
2010-11-04 17:36 ` [PATCH 1/4] net - Add AF_ALG macros Herbert Xu
2010-11-04 19:22 ` David Miller
2010-11-04 17:36 ` [PATCH 4/4] crypto: algif_skcipher - User-space interface for skcipher operations Herbert Xu
2010-11-04 19:23 ` David Miller
2010-11-06 12:23 ` Martin Willi
2010-11-07 1:08 ` Herbert Xu
2010-11-08 9:10 ` Martin Willi [this message]
2010-11-15 11:51 ` Herbert Xu
2010-11-15 11:53 ` [PATCH 2/4] crypto: af_alg - User-space interface for Crypto API Herbert Xu
2010-11-15 14:56 ` Martin Willi
2010-11-15 11:53 ` [PATCH 1/4] net - Add AF_ALG macros Herbert Xu
2010-11-15 11:53 ` [PATCH 3/4] crypto: algif_hash - User-space interface for hash operations Herbert Xu
2010-11-15 14:56 ` Martin Willi
2010-11-15 11:53 ` [PATCH 4/4] crypto: algif_skcipher - User-space interface for skcipher operations Herbert Xu
2010-11-15 14:55 ` Martin Willi
2010-11-19 9:51 ` Herbert Xu
2010-11-19 9:52 ` [PATCH 1/4] net - Add AF_ALG macros Herbert Xu
2010-11-19 9:52 ` [PATCH 2/4] crypto: af_alg - User-space interface for Crypto API Herbert Xu
2010-11-19 9:52 ` [PATCH 3/4] crypto: algif_hash - User-space interface for hash operations Herbert Xu
2010-11-19 9:52 ` [PATCH 4/4] crypto: algif_skcipher - User-space interface for skcipher operations Herbert Xu
2010-11-26 12:57 ` Herbert Xu
2010-11-26 12:58 ` [PATCH 2/4] crypto: af_alg - User-space interface for Crypto API Herbert Xu
2010-11-26 12:58 ` [PATCH 1/4] net - Add AF_ALG macros Herbert Xu
2010-11-26 12:58 ` [PATCH 4/4] crypto: algif_skcipher - User-space interface for skcipher operations Herbert Xu
2010-11-26 12:58 ` [PATCH 3/4] crypto: algif_hash - User-space interface for hash operations Herbert Xu
2010-10-19 13:46 ` [PATCH 1/4] net - Add AF_ALG macros Herbert Xu
2010-10-20 9:01 ` David Miller
2010-10-19 13:46 ` [PATCH 2/4] crypto: af_alg - User-space interface for Crypto API Herbert Xu
2010-10-19 13:46 ` [PATCH 4/4] crypto: algif_skcipher - User-space interface for skcipher operations Herbert Xu
2010-10-19 13:46 ` [PATCH 3/4] crypto: algif_hash - User-space interface for hash operations Herbert Xu
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=1289207420.2013.16.camel@martin \
--to=martin@strongswan.org \
--cc=herbert@gondor.apana.org.au \
--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