This list is closed, nobody may subscribe to it.
2007 |
Jan
|
Feb
(10) |
Mar
(26) |
Apr
(8) |
May
(3) |
Jun
|
Jul
(26) |
Aug
(10) |
Sep
|
Oct
|
Nov
(2) |
Dec
(4) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
|
Feb
(13) |
Mar
(4) |
Apr
(3) |
May
(5) |
Jun
|
Jul
(7) |
Aug
(8) |
Sep
(5) |
Oct
(16) |
Nov
|
Dec
(6) |
2009 |
Jan
(2) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(19) |
Jul
(4) |
Aug
|
Sep
(13) |
Oct
(10) |
Nov
(12) |
Dec
(2) |
2010 |
Jan
|
Feb
(2) |
Mar
(17) |
Apr
(28) |
May
|
Jun
(17) |
Jul
(11) |
Aug
(12) |
Sep
(2) |
Oct
|
Nov
|
Dec
(1) |
2011 |
Jan
|
Feb
|
Mar
(20) |
Apr
(10) |
May
(1) |
Jun
|
Jul
|
Aug
(15) |
Sep
(14) |
Oct
(2) |
Nov
|
Dec
|
2012 |
Jan
(1) |
Feb
(53) |
Mar
(15) |
Apr
(4) |
May
(2) |
Jun
(13) |
Jul
|
Aug
|
Sep
(12) |
Oct
|
Nov
|
Dec
(6) |
2013 |
Jan
(7) |
Feb
(8) |
Mar
(4) |
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(6) |
Oct
|
Nov
(5) |
Dec
(8) |
2014 |
Jan
(17) |
Feb
(24) |
Mar
(8) |
Apr
(7) |
May
(18) |
Jun
(15) |
Jul
(5) |
Aug
(2) |
Sep
(49) |
Oct
(28) |
Nov
(7) |
Dec
(30) |
2015 |
Jan
(40) |
Feb
|
Mar
(9) |
Apr
(2) |
May
(9) |
Jun
(31) |
Jul
(33) |
Aug
(5) |
Sep
(20) |
Oct
|
Nov
(3) |
Dec
(12) |
2016 |
Jan
(14) |
Feb
(29) |
Mar
(10) |
Apr
(4) |
May
(4) |
Jun
|
Jul
(5) |
Aug
(19) |
Sep
(21) |
Oct
(2) |
Nov
(36) |
Dec
(30) |
2017 |
Jan
(101) |
Feb
(12) |
Mar
(7) |
Apr
(2) |
May
(29) |
Jun
(22) |
Jul
(7) |
Aug
(93) |
Sep
(27) |
Oct
(39) |
Nov
|
Dec
|
From: Gilad Ben-Y. <gi...@be...> - 2017-08-08 12:17:32
|
The talitos driver starts several async crypto ops and waits for their completions. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef <gi...@be...> --- drivers/crypto/talitos.c | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 79791c6..194a307 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -2037,22 +2037,6 @@ static int ahash_import(struct ahash_request *areq, const void *in) return 0; } -struct keyhash_result { - struct completion completion; - int err; -}; - -static void keyhash_complete(struct crypto_async_request *req, int err) -{ - struct keyhash_result *res = req->data; - - if (err == -EINPROGRESS) - return; - - res->err = err; - complete(&res->completion); -} - static int keyhash(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen, u8 *hash) { @@ -2060,10 +2044,10 @@ static int keyhash(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen, struct scatterlist sg[1]; struct ahash_request *req; - struct keyhash_result hresult; + struct crypto_wait wait; int ret; - init_completion(&hresult.completion); + crypto_init_wait(&wait); req = ahash_request_alloc(tfm, GFP_KERNEL); if (!req) @@ -2072,25 +2056,13 @@ static int keyhash(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen, /* Keep tfm keylen == 0 during hash of the long key */ ctx->keylen = 0; ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - keyhash_complete, &hresult); + crypto_req_done, &wait); sg_init_one(&sg[0], key, keylen); ahash_request_set_crypt(req, sg, hash, keylen); - ret = crypto_ahash_digest(req); - switch (ret) { - case 0: - break; - case -EINPROGRESS: - case -EBUSY: - ret = wait_for_completion_interruptible( - &hresult.completion); - if (!ret) - ret = hresult.err; - break; - default: - break; - } + ret = crypto_wait_req(crypto_ahash_digest(req), &wait); + ahash_request_free(req); return ret; -- 2.1.4 |
From: Gilad Ben-Y. <gi...@be...> - 2017-08-08 12:17:32
|
dm-verity is starting async. crypto ops and waiting for them to complete. Move it over to generic code doing the same. This also fixes a possible data coruption bug created by the use of wait_for_completion_interruptible() without dealing correctly with an interrupt aborting the wait prior to the async op finishing. Signed-off-by: Gilad Ben-Yossef <gi...@be...> --- drivers/md/dm-verity-target.c | 81 +++++++++++-------------------------------- drivers/md/dm-verity.h | 5 --- 2 files changed, 20 insertions(+), 66 deletions(-) diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index 79f18d4..8df08a8 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -92,74 +92,33 @@ static sector_t verity_position_at_level(struct dm_verity *v, sector_t block, return block >> (level * v->hash_per_block_bits); } -/* - * Callback function for asynchrnous crypto API completion notification - */ -static void verity_op_done(struct crypto_async_request *base, int err) -{ - struct verity_result *res = (struct verity_result *)base->data; - - if (err == -EINPROGRESS) - return; - - res->err = err; - complete(&res->completion); -} - -/* - * Wait for async crypto API callback - */ -static inline int verity_complete_op(struct verity_result *res, int ret) -{ - switch (ret) { - case 0: - break; - - case -EINPROGRESS: - case -EBUSY: - ret = wait_for_completion_interruptible(&res->completion); - if (!ret) - ret = res->err; - reinit_completion(&res->completion); - break; - - default: - DMERR("verity_wait_hash: crypto op submission failed: %d", ret); - } - - if (unlikely(ret < 0)) - DMERR("verity_wait_hash: crypto op failed: %d", ret); - - return ret; -} - static int verity_hash_update(struct dm_verity *v, struct ahash_request *req, const u8 *data, size_t len, - struct verity_result *res) + struct crypto_wait *wait) { struct scatterlist sg; sg_init_one(&sg, data, len); ahash_request_set_crypt(req, &sg, NULL, len); - return verity_complete_op(res, crypto_ahash_update(req)); + return crypto_wait_req(crypto_ahash_update(req), wait); } /* * Wrapper for crypto_ahash_init, which handles verity salting. */ static int verity_hash_init(struct dm_verity *v, struct ahash_request *req, - struct verity_result *res) + struct crypto_wait *wait) { int r; ahash_request_set_tfm(req, v->tfm); ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP | CRYPTO_TFM_REQ_MAY_BACKLOG, - verity_op_done, (void *)res); - init_completion(&res->completion); + crypto_req_done, (void *)wait); + crypto_init_wait(wait); - r = verity_complete_op(res, crypto_ahash_init(req)); + r = crypto_wait_req(crypto_ahash_init(req), wait); if (unlikely(r < 0)) { DMERR("crypto_ahash_init failed: %d", r); @@ -167,18 +126,18 @@ static int verity_hash_init(struct dm_verity *v, struct ahash_request *req, } if (likely(v->salt_size && (v->version >= 1))) - r = verity_hash_update(v, req, v->salt, v->salt_size, res); + r = verity_hash_update(v, req, v->salt, v->salt_size, wait); return r; } static int verity_hash_final(struct dm_verity *v, struct ahash_request *req, - u8 *digest, struct verity_result *res) + u8 *digest, struct crypto_wait *wait) { int r; if (unlikely(v->salt_size && (!v->version))) { - r = verity_hash_update(v, req, v->salt, v->salt_size, res); + r = verity_hash_update(v, req, v->salt, v->salt_size, wait); if (r < 0) { DMERR("verity_hash_final failed updating salt: %d", r); @@ -187,7 +146,7 @@ static int verity_hash_final(struct dm_verity *v, struct ahash_request *req, } ahash_request_set_crypt(req, NULL, digest, 0); - r = verity_complete_op(res, crypto_ahash_final(req)); + r = crypto_wait_req(crypto_ahash_final(req), wait); out: return r; } @@ -196,17 +155,17 @@ int verity_hash(struct dm_verity *v, struct ahash_request *req, const u8 *data, size_t len, u8 *digest) { int r; - struct verity_result res; + struct crypto_wait wait; - r = verity_hash_init(v, req, &res); + r = verity_hash_init(v, req, &wait); if (unlikely(r < 0)) goto out; - r = verity_hash_update(v, req, data, len, &res); + r = verity_hash_update(v, req, data, len, &wait); if (unlikely(r < 0)) goto out; - r = verity_hash_final(v, req, digest, &res); + r = verity_hash_final(v, req, digest, &wait); out: return r; @@ -389,7 +348,7 @@ int verity_hash_for_block(struct dm_verity *v, struct dm_verity_io *io, * Calculates the digest for the given bio */ int verity_for_io_block(struct dm_verity *v, struct dm_verity_io *io, - struct bvec_iter *iter, struct verity_result *res) + struct bvec_iter *iter, struct crypto_wait *wait) { unsigned int todo = 1 << v->data_dev_block_bits; struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size); @@ -414,7 +373,7 @@ int verity_for_io_block(struct dm_verity *v, struct dm_verity_io *io, */ sg_set_page(&sg, bv.bv_page, len, bv.bv_offset); ahash_request_set_crypt(req, &sg, NULL, len); - r = verity_complete_op(res, crypto_ahash_update(req)); + r = crypto_wait_req(crypto_ahash_update(req), wait); if (unlikely(r < 0)) { DMERR("verity_for_io_block crypto op failed: %d", r); @@ -482,7 +441,7 @@ static int verity_verify_io(struct dm_verity_io *io) struct dm_verity *v = io->v; struct bvec_iter start; unsigned b; - struct verity_result res; + struct crypto_wait wait; for (b = 0; b < io->n_blocks; b++) { int r; @@ -507,17 +466,17 @@ static int verity_verify_io(struct dm_verity_io *io) continue; } - r = verity_hash_init(v, req, &res); + r = verity_hash_init(v, req, &wait); if (unlikely(r < 0)) return r; start = io->iter; - r = verity_for_io_block(v, io, &io->iter, &res); + r = verity_for_io_block(v, io, &io->iter, &wait); if (unlikely(r < 0)) return r; r = verity_hash_final(v, req, verity_io_real_digest(v, io), - &res); + &wait); if (unlikely(r < 0)) return r; diff --git a/drivers/md/dm-verity.h b/drivers/md/dm-verity.h index a59e0ad..b675bc0 100644 --- a/drivers/md/dm-verity.h +++ b/drivers/md/dm-verity.h @@ -90,11 +90,6 @@ struct dm_verity_io { */ }; -struct verity_result { - struct completion completion; - int err; -}; - static inline struct ahash_request *verity_io_hash_req(struct dm_verity *v, struct dm_verity_io *io) { -- 2.1.4 |
From: Gilad Ben-Y. <gi...@be...> - 2017-08-08 12:17:32
|
The code sample is waiting for an async. crypto op completion. Adapt sample to use the new generic infrastructure to do the same. This also fixes a possible data coruption bug created by the use of wait_for_completion_interruptible() without dealing correctly with an interrupt aborting the wait prior to the async op finishing. Signed-off-by: Gilad Ben-Yossef <gi...@be...> --- Documentation/crypto/api-samples.rst | 52 +++++++----------------------------- 1 file changed, 10 insertions(+), 42 deletions(-) diff --git a/Documentation/crypto/api-samples.rst b/Documentation/crypto/api-samples.rst index 2531948..006827e 100644 --- a/Documentation/crypto/api-samples.rst +++ b/Documentation/crypto/api-samples.rst @@ -7,59 +7,27 @@ Code Example For Symmetric Key Cipher Operation :: - struct tcrypt_result { - struct completion completion; - int err; - }; - /* tie all data structures together */ struct skcipher_def { struct scatterlist sg; struct crypto_skcipher *tfm; struct skcipher_request *req; - struct tcrypt_result result; + struct crypto_wait wait; }; - /* Callback function */ - static void test_skcipher_cb(struct crypto_async_request *req, int error) - { - struct tcrypt_result *result = req->data; - - if (error == -EINPROGRESS) - return; - result->err = error; - complete(&result->completion); - pr_info("Encryption finished successfully\n"); - } - /* Perform cipher operation */ static unsigned int test_skcipher_encdec(struct skcipher_def *sk, int enc) { - int rc = 0; + int rc; if (enc) - rc = crypto_skcipher_encrypt(sk->req); + rc = crypto_wait_req(crypto_skcipher_encrypt(sk->req), &sk->wait); else - rc = crypto_skcipher_decrypt(sk->req); - - switch (rc) { - case 0: - break; - case -EINPROGRESS: - case -EBUSY: - rc = wait_for_completion_interruptible( - &sk->result.completion); - if (!rc && !sk->result.err) { - reinit_completion(&sk->result.completion); - break; - } - default: - pr_info("skcipher encrypt returned with %d result %d\n", - rc, sk->result.err); - break; - } - init_completion(&sk->result.completion); + rc = crypto_wait_req(crypto_skcipher_decrypt(sk->req), &sk->wait); + + if (rc) + pr_info("skcipher encrypt returned with result %d\n", rc); return rc; } @@ -89,8 +57,8 @@ Code Example For Symmetric Key Cipher Operation } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - test_skcipher_cb, - &sk.result); + crypto_req_done, + &sk.wait); /* AES 256 with random key */ get_random_bytes(&key, 32); @@ -122,7 +90,7 @@ Code Example For Symmetric Key Cipher Operation /* We encrypt one block */ sg_init_one(&sk.sg, scratchpad, 16); skcipher_request_set_crypt(req, &sk.sg, &sk.sg, 16, ivdata); - init_completion(&sk.result.completion); + crypto_init_wait(&sk.wait); /* encrypt data */ ret = test_skcipher_encdec(&sk, 1); -- 2.1.4 |
From: Gilad Ben-Y. <gi...@be...> - 2017-08-08 12:17:32
|
The qce driver starts several async crypto ops and waits for their completions. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef <gi...@be...> --- drivers/crypto/qce/sha.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 47e114a..53227d7 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -349,28 +349,12 @@ static int qce_ahash_digest(struct ahash_request *req) return qce->async_req_enqueue(tmpl->qce, &req->base); } -struct qce_ahash_result { - struct completion completion; - int error; -}; - -static void qce_digest_complete(struct crypto_async_request *req, int error) -{ - struct qce_ahash_result *result = req->data; - - if (error == -EINPROGRESS) - return; - - result->error = error; - complete(&result->completion); -} - static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen) { unsigned int digestsize = crypto_ahash_digestsize(tfm); struct qce_sha_ctx *ctx = crypto_tfm_ctx(&tfm->base); - struct qce_ahash_result result; + struct crypto_wait wait; struct ahash_request *req; struct scatterlist sg; unsigned int blocksize; @@ -405,9 +389,9 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, goto err_free_ahash; } - init_completion(&result.completion); + crypto_init_wait(&wait); ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - qce_digest_complete, &result); + crypto_req_done, &wait); crypto_ahash_clear_flags(ahash_tfm, ~0); buf = kzalloc(keylen + QCE_MAX_ALIGN_SIZE, GFP_KERNEL); @@ -420,13 +404,7 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key, sg_init_one(&sg, buf, keylen); ahash_request_set_crypt(req, &sg, ctx->authkey, keylen); - ret = crypto_ahash_digest(req); - if (ret == -EINPROGRESS || ret == -EBUSY) { - ret = wait_for_completion_interruptible(&result.completion); - if (!ret) - ret = result.error; - } - + ret = crypto_wait_req(crypto_ahash_digest(req), &wait); if (ret) crypto_ahash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); -- 2.1.4 |
From: Gilad Ben-Y. <gi...@be...> - 2017-08-08 12:17:30
|
testmgr is starting async. crypto ops and waiting for them to complete. Move it over to generic code doing the same. This also provides a test of the generic crypto async. wait code. Signed-off-by: Gilad Ben-Yossef <gi...@be...> --- crypto/testmgr.c | 204 ++++++++++++++++++------------------------------------- 1 file changed, 66 insertions(+), 138 deletions(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 7125ba3..a65b4d5 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -76,11 +76,6 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask) #define ENCRYPT 1 #define DECRYPT 0 -struct tcrypt_result { - struct completion completion; - int err; -}; - struct aead_test_suite { struct { const struct aead_testvec *vecs; @@ -155,17 +150,6 @@ static void hexdump(unsigned char *buf, unsigned int len) buf, len, false); } -static void tcrypt_complete(struct crypto_async_request *req, int err) -{ - struct tcrypt_result *res = req->data; - - if (err == -EINPROGRESS) - return; - - res->err = err; - complete(&res->completion); -} - static int testmgr_alloc_buf(char *buf[XBUFSIZE]) { int i; @@ -193,20 +177,10 @@ static void testmgr_free_buf(char *buf[XBUFSIZE]) free_page((unsigned long)buf[i]); } -static int wait_async_op(struct tcrypt_result *tr, int ret) -{ - if (ret == -EINPROGRESS || ret == -EBUSY) { - wait_for_completion(&tr->completion); - reinit_completion(&tr->completion); - ret = tr->err; - } - return ret; -} - static int ahash_partial_update(struct ahash_request **preq, struct crypto_ahash *tfm, const struct hash_testvec *template, void *hash_buff, int k, int temp, struct scatterlist *sg, - const char *algo, char *result, struct tcrypt_result *tresult) + const char *algo, char *result, struct crypto_wait *wait) { char *state; struct ahash_request *req; @@ -236,7 +210,7 @@ static int ahash_partial_update(struct ahash_request **preq, } ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, tresult); + crypto_req_done, wait); memcpy(hash_buff, template->plaintext + temp, template->tap[k]); @@ -247,7 +221,7 @@ static int ahash_partial_update(struct ahash_request **preq, pr_err("alg: hash: Failed to import() for %s\n", algo); goto out; } - ret = wait_async_op(tresult, crypto_ahash_update(req)); + ret = crypto_wait_req(crypto_ahash_update(req), wait); if (ret) goto out; *preq = req; @@ -272,7 +246,7 @@ static int __test_hash(struct crypto_ahash *tfm, char *result; char *key; struct ahash_request *req; - struct tcrypt_result tresult; + struct crypto_wait wait; void *hash_buff; char *xbuf[XBUFSIZE]; int ret = -ENOMEM; @@ -286,7 +260,7 @@ static int __test_hash(struct crypto_ahash *tfm, if (testmgr_alloc_buf(xbuf)) goto out_nobuf; - init_completion(&tresult.completion); + crypto_init_wait(&wait); req = ahash_request_alloc(tfm, GFP_KERNEL); if (!req) { @@ -295,7 +269,7 @@ static int __test_hash(struct crypto_ahash *tfm, goto out_noreq; } ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &tresult); + crypto_req_done, &wait); j = 0; for (i = 0; i < tcount; i++) { @@ -335,26 +309,26 @@ static int __test_hash(struct crypto_ahash *tfm, ahash_request_set_crypt(req, sg, result, template[i].psize); if (use_digest) { - ret = wait_async_op(&tresult, crypto_ahash_digest(req)); + ret = crypto_wait_req(crypto_ahash_digest(req), &wait); if (ret) { pr_err("alg: hash: digest failed on test %d " "for %s: ret=%d\n", j, algo, -ret); goto out; } } else { - ret = wait_async_op(&tresult, crypto_ahash_init(req)); + ret = crypto_wait_req(crypto_ahash_init(req), &wait); if (ret) { pr_err("alg: hash: init failed on test %d " "for %s: ret=%d\n", j, algo, -ret); goto out; } - ret = wait_async_op(&tresult, crypto_ahash_update(req)); + ret = crypto_wait_req(crypto_ahash_update(req), &wait); if (ret) { pr_err("alg: hash: update failed on test %d " "for %s: ret=%d\n", j, algo, -ret); goto out; } - ret = wait_async_op(&tresult, crypto_ahash_final(req)); + ret = crypto_wait_req(crypto_ahash_final(req), &wait); if (ret) { pr_err("alg: hash: final failed on test %d " "for %s: ret=%d\n", j, algo, -ret); @@ -420,22 +394,10 @@ static int __test_hash(struct crypto_ahash *tfm, } ahash_request_set_crypt(req, sg, result, template[i].psize); - ret = crypto_ahash_digest(req); - switch (ret) { - case 0: - break; - case -EINPROGRESS: - case -EBUSY: - wait_for_completion(&tresult.completion); - reinit_completion(&tresult.completion); - ret = tresult.err; - if (!ret) - break; - /* fall through */ - default: - printk(KERN_ERR "alg: hash: digest failed " - "on chunking test %d for %s: " - "ret=%d\n", j, algo, -ret); + ret = crypto_wait_req(crypto_ahash_digest(req), &wait); + if (ret) { + pr_err("alg: hash: digest failed on chunking test %d for %s: ret=%d\n", + j, algo, -ret); goto out; } @@ -486,13 +448,13 @@ static int __test_hash(struct crypto_ahash *tfm, } ahash_request_set_crypt(req, sg, result, template[i].tap[0]); - ret = wait_async_op(&tresult, crypto_ahash_init(req)); + ret = crypto_wait_req(crypto_ahash_init(req), &wait); if (ret) { pr_err("alg: hash: init failed on test %d for %s: ret=%d\n", j, algo, -ret); goto out; } - ret = wait_async_op(&tresult, crypto_ahash_update(req)); + ret = crypto_wait_req(crypto_ahash_update(req), &wait); if (ret) { pr_err("alg: hash: update failed on test %d for %s: ret=%d\n", j, algo, -ret); @@ -503,7 +465,7 @@ static int __test_hash(struct crypto_ahash *tfm, for (k = 1; k < template[i].np; k++) { ret = ahash_partial_update(&req, tfm, &template[i], hash_buff, k, temp, &sg[0], algo, result, - &tresult); + &wait); if (ret) { pr_err("alg: hash: partial update failed on test %d for %s: ret=%d\n", j, algo, -ret); @@ -511,7 +473,7 @@ static int __test_hash(struct crypto_ahash *tfm, } temp += template[i].tap[k]; } - ret = wait_async_op(&tresult, crypto_ahash_final(req)); + ret = crypto_wait_req(crypto_ahash_final(req), &wait); if (ret) { pr_err("alg: hash: final failed on test %d for %s: ret=%d\n", j, algo, -ret); @@ -580,7 +542,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc, struct scatterlist *sg; struct scatterlist *sgout; const char *e, *d; - struct tcrypt_result result; + struct crypto_wait wait; unsigned int authsize, iv_len; void *input; void *output; @@ -619,7 +581,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc, else e = "decryption"; - init_completion(&result.completion); + crypto_init_wait(&wait); req = aead_request_alloc(tfm, GFP_KERNEL); if (!req) { @@ -629,7 +591,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc, } aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); iv_len = crypto_aead_ivsize(tfm); @@ -709,7 +671,8 @@ static int __test_aead(struct crypto_aead *tfm, int enc, aead_request_set_ad(req, template[i].alen); - ret = enc ? crypto_aead_encrypt(req) : crypto_aead_decrypt(req); + ret = crypto_wait_req(enc ? crypto_aead_encrypt(req) + : crypto_aead_decrypt(req), &wait); switch (ret) { case 0: @@ -722,13 +685,6 @@ static int __test_aead(struct crypto_aead *tfm, int enc, goto out; } break; - case -EINPROGRESS: - case -EBUSY: - wait_for_completion(&result.completion); - reinit_completion(&result.completion); - ret = result.err; - if (!ret) - break; case -EBADMSG: if (template[i].novrfy) /* verification failure was expected */ @@ -866,7 +822,8 @@ static int __test_aead(struct crypto_aead *tfm, int enc, aead_request_set_ad(req, template[i].alen); - ret = enc ? crypto_aead_encrypt(req) : crypto_aead_decrypt(req); + ret = crypto_wait_req(enc ? crypto_aead_encrypt(req) + : crypto_aead_decrypt(req), &wait); switch (ret) { case 0: @@ -879,13 +836,6 @@ static int __test_aead(struct crypto_aead *tfm, int enc, goto out; } break; - case -EINPROGRESS: - case -EBUSY: - wait_for_completion(&result.completion); - reinit_completion(&result.completion); - ret = result.err; - if (!ret) - break; case -EBADMSG: if (template[i].novrfy) /* verification failure was expected */ @@ -1083,7 +1033,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, struct scatterlist sg[8]; struct scatterlist sgout[8]; const char *e, *d; - struct tcrypt_result result; + struct crypto_wait wait; void *data; char iv[MAX_IVLEN]; char *xbuf[XBUFSIZE]; @@ -1107,7 +1057,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, else e = "decryption"; - init_completion(&result.completion); + crypto_init_wait(&wait); req = skcipher_request_alloc(tfm, GFP_KERNEL); if (!req) { @@ -1117,7 +1067,7 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); j = 0; for (i = 0; i < tcount; i++) { @@ -1164,21 +1114,10 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, skcipher_request_set_crypt(req, sg, (diff_dst) ? sgout : sg, template[i].ilen, iv); - ret = enc ? crypto_skcipher_encrypt(req) : - crypto_skcipher_decrypt(req); + ret = crypto_wait_req(enc ? crypto_skcipher_encrypt(req) : + crypto_skcipher_decrypt(req), &wait); - switch (ret) { - case 0: - break; - case -EINPROGRESS: - case -EBUSY: - wait_for_completion(&result.completion); - reinit_completion(&result.completion); - ret = result.err; - if (!ret) - break; - /* fall through */ - default: + if (ret) { pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n", d, e, j, algo, -ret); goto out; @@ -1272,21 +1211,10 @@ static int __test_skcipher(struct crypto_skcipher *tfm, int enc, skcipher_request_set_crypt(req, sg, (diff_dst) ? sgout : sg, template[i].ilen, iv); - ret = enc ? crypto_skcipher_encrypt(req) : - crypto_skcipher_decrypt(req); + ret = crypto_wait_req(enc ? crypto_skcipher_encrypt(req) : + crypto_skcipher_decrypt(req), &wait); - switch (ret) { - case 0: - break; - case -EINPROGRESS: - case -EBUSY: - wait_for_completion(&result.completion); - reinit_completion(&result.completion); - ret = result.err; - if (!ret) - break; - /* fall through */ - default: + if (ret) { pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n", d, e, j, algo, -ret); goto out; @@ -1462,7 +1390,7 @@ static int test_acomp(struct crypto_acomp *tfm, int ret; struct scatterlist src, dst; struct acomp_req *req; - struct tcrypt_result result; + struct crypto_wait wait; output = kmalloc(COMP_BUF_SIZE, GFP_KERNEL); if (!output) @@ -1486,7 +1414,7 @@ static int test_acomp(struct crypto_acomp *tfm, } memset(output, 0, dlen); - init_completion(&result.completion); + crypto_init_wait(&wait); sg_init_one(&src, input_vec, ilen); sg_init_one(&dst, output, dlen); @@ -1501,9 +1429,9 @@ static int test_acomp(struct crypto_acomp *tfm, acomp_request_set_params(req, &src, &dst, ilen, dlen); acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); - ret = wait_async_op(&result, crypto_acomp_compress(req)); + ret = crypto_wait_req(crypto_acomp_compress(req), &wait); if (ret) { pr_err("alg: acomp: compression failed on test %d for %s: ret=%d\n", i + 1, algo, -ret); @@ -1516,10 +1444,10 @@ static int test_acomp(struct crypto_acomp *tfm, dlen = COMP_BUF_SIZE; sg_init_one(&src, output, ilen); sg_init_one(&dst, decomp_out, dlen); - init_completion(&result.completion); + crypto_init_wait(&wait); acomp_request_set_params(req, &src, &dst, ilen, dlen); - ret = wait_async_op(&result, crypto_acomp_decompress(req)); + ret = crypto_wait_req(crypto_acomp_decompress(req), &wait); if (ret) { pr_err("alg: acomp: compression failed on test %d for %s: ret=%d\n", i + 1, algo, -ret); @@ -1563,7 +1491,7 @@ static int test_acomp(struct crypto_acomp *tfm, } memset(output, 0, dlen); - init_completion(&result.completion); + crypto_init_wait(&wait); sg_init_one(&src, input_vec, ilen); sg_init_one(&dst, output, dlen); @@ -1578,9 +1506,9 @@ static int test_acomp(struct crypto_acomp *tfm, acomp_request_set_params(req, &src, &dst, ilen, dlen); acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); - ret = wait_async_op(&result, crypto_acomp_decompress(req)); + ret = crypto_wait_req(crypto_acomp_decompress(req), &wait); if (ret) { pr_err("alg: acomp: decompression failed on test %d for %s: ret=%d\n", i + 1, algo, -ret); @@ -2000,7 +1928,7 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec, void *a_public = NULL; void *a_ss = NULL; void *shared_secret = NULL; - struct tcrypt_result result; + struct crypto_wait wait; unsigned int out_len_max; int err = -ENOMEM; struct scatterlist src, dst; @@ -2009,7 +1937,7 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec, if (!req) return err; - init_completion(&result.completion); + crypto_init_wait(&wait); err = crypto_kpp_set_secret(tfm, vec->secret, vec->secret_size); if (err < 0) @@ -2027,10 +1955,10 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec, sg_init_one(&dst, output_buf, out_len_max); kpp_request_set_output(req, &dst, out_len_max); kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); /* Compute party A's public key */ - err = wait_async_op(&result, crypto_kpp_generate_public_key(req)); + err = crypto_wait_req(crypto_kpp_generate_public_key(req), &wait); if (err) { pr_err("alg: %s: Party A: generate public key test failed. err %d\n", alg, err); @@ -2069,8 +1997,8 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec, kpp_request_set_input(req, &src, vec->b_public_size); kpp_request_set_output(req, &dst, out_len_max); kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); - err = wait_async_op(&result, crypto_kpp_compute_shared_secret(req)); + crypto_req_done, &wait); + err = crypto_wait_req(crypto_kpp_compute_shared_secret(req), &wait); if (err) { pr_err("alg: %s: Party A: compute shared secret test failed. err %d\n", alg, err); @@ -2100,9 +2028,9 @@ static int do_test_kpp(struct crypto_kpp *tfm, const struct kpp_testvec *vec, kpp_request_set_input(req, &src, vec->expected_a_public_size); kpp_request_set_output(req, &dst, out_len_max); kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); - err = wait_async_op(&result, - crypto_kpp_compute_shared_secret(req)); + crypto_req_done, &wait); + err = crypto_wait_req(crypto_kpp_compute_shared_secret(req), + &wait); if (err) { pr_err("alg: %s: Party B: compute shared secret failed. err %d\n", alg, err); @@ -2179,7 +2107,7 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, struct akcipher_request *req; void *outbuf_enc = NULL; void *outbuf_dec = NULL; - struct tcrypt_result result; + struct crypto_wait wait; unsigned int out_len_max, out_len = 0; int err = -ENOMEM; struct scatterlist src, dst, src_tab[2]; @@ -2191,7 +2119,7 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, if (!req) goto free_xbuf; - init_completion(&result.completion); + crypto_init_wait(&wait); if (vecs->public_key_vec) err = crypto_akcipher_set_pub_key(tfm, vecs->key, @@ -2220,13 +2148,13 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, akcipher_request_set_crypt(req, src_tab, &dst, vecs->m_size, out_len_max); akcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); - err = wait_async_op(&result, vecs->siggen_sigver_test ? - /* Run asymmetric signature generation */ - crypto_akcipher_sign(req) : - /* Run asymmetric encrypt */ - crypto_akcipher_encrypt(req)); + err = crypto_wait_req(vecs->siggen_sigver_test ? + /* Run asymmetric signature generation */ + crypto_akcipher_sign(req) : + /* Run asymmetric encrypt */ + crypto_akcipher_encrypt(req), &wait); if (err) { pr_err("alg: akcipher: encrypt test failed. err %d\n", err); goto free_all; @@ -2261,14 +2189,14 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, sg_init_one(&src, xbuf[0], vecs->c_size); sg_init_one(&dst, outbuf_dec, out_len_max); - init_completion(&result.completion); + crypto_init_wait(&wait); akcipher_request_set_crypt(req, &src, &dst, vecs->c_size, out_len_max); - err = wait_async_op(&result, vecs->siggen_sigver_test ? - /* Run asymmetric signature verification */ - crypto_akcipher_verify(req) : - /* Run asymmetric decrypt */ - crypto_akcipher_decrypt(req)); + err = crypto_wait_req(vecs->siggen_sigver_test ? + /* Run asymmetric signature verification */ + crypto_akcipher_verify(req) : + /* Run asymmetric decrypt */ + crypto_akcipher_decrypt(req), &wait); if (err) { pr_err("alg: akcipher: decrypt test failed. err %d\n", err); goto free_all; -- 2.1.4 |
From: Gilad Ben-Y. <gi...@be...> - 2017-08-08 12:17:26
|
cifs starts an async. crypto op and waits for their completion. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef <gi...@be...> Acked-by: Pavel Shilovsky <ps...@mi...> --- fs/cifs/smb2ops.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index cfacf2c..16fb041 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1878,22 +1878,6 @@ init_sg(struct smb_rqst *rqst, u8 *sign) return sg; } -struct cifs_crypt_result { - int err; - struct completion completion; -}; - -static void cifs_crypt_complete(struct crypto_async_request *req, int err) -{ - struct cifs_crypt_result *res = req->data; - - if (err == -EINPROGRESS) - return; - - res->err = err; - complete(&res->completion); -} - static int smb2_get_enc_key(struct TCP_Server_Info *server, __u64 ses_id, int enc, u8 *key) { @@ -1934,12 +1918,10 @@ crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc) struct aead_request *req; char *iv; unsigned int iv_len; - struct cifs_crypt_result result = {0, }; + DECLARE_CRYPTO_WAIT(wait); struct crypto_aead *tfm; unsigned int crypt_len = le32_to_cpu(tr_hdr->OriginalMessageSize); - init_completion(&result.completion); - rc = smb2_get_enc_key(server, tr_hdr->SessionId, enc, key); if (rc) { cifs_dbg(VFS, "%s: Could not get %scryption key\n", __func__, @@ -1999,14 +1981,10 @@ crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc) aead_request_set_ad(req, assoc_data_len); aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - cifs_crypt_complete, &result); + crypto_req_done, &wait); - rc = enc ? crypto_aead_encrypt(req) : crypto_aead_decrypt(req); - - if (rc == -EINPROGRESS || rc == -EBUSY) { - wait_for_completion(&result.completion); - rc = result.err; - } + rc = crypto_wait_req(enc ? crypto_aead_encrypt(req) + : crypto_aead_decrypt(req), &wait); if (!rc && enc) memcpy(&tr_hdr->Signature, sign, SMB2_SIGNATURE_SIZE); -- 2.1.4 |
From: Gilad Ben-Y. <gi...@be...> - 2017-08-08 12:17:26
|
tcrypt starts several async crypto ops and waits for their completions. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef <gi...@be...> --- crypto/tcrypt.c | 84 +++++++++++++++++---------------------------------------- 1 file changed, 25 insertions(+), 59 deletions(-) diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 0022a18..802aa81 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -79,34 +79,11 @@ static char *check[] = { NULL }; -struct tcrypt_result { - struct completion completion; - int err; -}; - -static void tcrypt_complete(struct crypto_async_request *req, int err) -{ - struct tcrypt_result *res = req->data; - - if (err == -EINPROGRESS) - return; - - res->err = err; - complete(&res->completion); -} - static inline int do_one_aead_op(struct aead_request *req, int ret) { - if (ret == -EINPROGRESS || ret == -EBUSY) { - struct tcrypt_result *tr = req->base.data; + struct crypto_wait *wait = req->base.data; - ret = wait_for_completion_interruptible(&tr->completion); - if (!ret) - ret = tr->err; - reinit_completion(&tr->completion); - } - - return ret; + return crypto_wait_req(ret, wait); } static int test_aead_jiffies(struct aead_request *req, int enc, @@ -248,7 +225,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, char *axbuf[XBUFSIZE]; unsigned int *b_size; unsigned int iv_len; - struct tcrypt_result result; + struct crypto_wait wait; iv = kzalloc(MAX_IVLEN, GFP_KERNEL); if (!iv) @@ -284,7 +261,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, goto out_notfm; } - init_completion(&result.completion); + crypto_init_wait(&wait); printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo, get_driver_name(crypto_aead, tfm), e); @@ -296,7 +273,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, } aead_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &result); + crypto_req_done, &wait); i = 0; do { @@ -397,21 +374,16 @@ static void test_hash_sg_init(struct scatterlist *sg) static inline int do_one_ahash_op(struct ahash_request *req, int ret) { - if (ret == -EINPROGRESS || ret == -EBUSY) { - struct tcrypt_result *tr = req->base.data; + struct crypto_wait *wait = req->base.data; - wait_for_completion(&tr->completion); - reinit_completion(&tr->completion); - ret = tr->err; - } - return ret; + return crypto_wait_req(ret, wait); } struct test_mb_ahash_data { struct scatterlist sg[TVMEMSIZE]; char result[64]; struct ahash_request *req; - struct tcrypt_result tresult; + struct crypto_wait wait; char *xbuf[XBUFSIZE]; }; @@ -440,7 +412,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, if (testmgr_alloc_buf(data[i].xbuf)) goto out; - init_completion(&data[i].tresult.completion); + crypto_init_wait(&data[i].wait); data[i].req = ahash_request_alloc(tfm, GFP_KERNEL); if (!data[i].req) { @@ -449,8 +421,8 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, goto out; } - ahash_request_set_callback(data[i].req, 0, - tcrypt_complete, &data[i].tresult); + ahash_request_set_callback(data[i].req, 0, crypto_req_done, + &data[i].wait); test_hash_sg_init(data[i].sg); } @@ -492,16 +464,16 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, if (ret) break; - complete(&data[k].tresult.completion); - data[k].tresult.err = 0; + crypto_req_done(&data[k].req->base, 0); } for (j = 0; j < k; j++) { - struct tcrypt_result *tr = &data[j].tresult; + struct crypto_wait *wait = &data[j].wait; + int wait_ret; - wait_for_completion(&tr->completion); - if (tr->err) - ret = tr->err; + wait_ret = crypto_wait_req(-EINPROGRESS, wait); + if (wait_ret) + ret = wait_ret; } end = get_cycles(); @@ -679,7 +651,7 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs, struct hash_speed *speed, unsigned mask) { struct scatterlist sg[TVMEMSIZE]; - struct tcrypt_result tresult; + struct crypto_wait wait; struct ahash_request *req; struct crypto_ahash *tfm; char *output; @@ -708,9 +680,9 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs, goto out; } - init_completion(&tresult.completion); + crypto_init_wait(&wait); ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &tresult); + crypto_req_done, &wait); output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL); if (!output) @@ -765,15 +737,9 @@ static void test_hash_speed(const char *algo, unsigned int secs, static inline int do_one_acipher_op(struct skcipher_request *req, int ret) { - if (ret == -EINPROGRESS || ret == -EBUSY) { - struct tcrypt_result *tr = req->base.data; - - wait_for_completion(&tr->completion); - reinit_completion(&tr->completion); - ret = tr->err; - } + struct crypto_wait *wait = req->base.data; - return ret; + return crypto_wait_req(ret, wait); } static int test_acipher_jiffies(struct skcipher_request *req, int enc, @@ -853,7 +819,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, unsigned int tcount, u8 *keysize, bool async) { unsigned int ret, i, j, k, iv_len; - struct tcrypt_result tresult; + struct crypto_wait wait; const char *key; char iv[128]; struct skcipher_request *req; @@ -866,7 +832,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, else e = "decryption"; - init_completion(&tresult.completion); + crypto_init_wait(&wait); tfm = crypto_alloc_skcipher(algo, 0, async ? 0 : CRYPTO_ALG_ASYNC); @@ -887,7 +853,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, } skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, - tcrypt_complete, &tresult); + crypto_req_done, &wait); i = 0; do { -- 2.1.4 |
From: Gilad Ben-Y. <gi...@be...> - 2017-08-08 12:17:26
|
ima starts several async crypto ops and waits for their completions. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef <gi...@be...> Acked-by: Mimi Zohar <zo...@li...> --- security/integrity/ima/ima_crypto.c | 56 +++++++++++-------------------------- 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c index 802d5d2..0e4db1fe 100644 --- a/security/integrity/ima/ima_crypto.c +++ b/security/integrity/ima/ima_crypto.c @@ -27,11 +27,6 @@ #include "ima.h" -struct ahash_completion { - struct completion completion; - int err; -}; - /* minimum file size for ahash use */ static unsigned long ima_ahash_minsize; module_param_named(ahash_minsize, ima_ahash_minsize, ulong, 0644); @@ -196,30 +191,13 @@ static void ima_free_atfm(struct crypto_ahash *tfm) crypto_free_ahash(tfm); } -static void ahash_complete(struct crypto_async_request *req, int err) +static inline int ahash_wait(int err, struct crypto_wait *wait) { - struct ahash_completion *res = req->data; - if (err == -EINPROGRESS) - return; - res->err = err; - complete(&res->completion); -} + err = crypto_wait_req(err, wait); -static int ahash_wait(int err, struct ahash_completion *res) -{ - switch (err) { - case 0: - break; - case -EINPROGRESS: - case -EBUSY: - wait_for_completion(&res->completion); - reinit_completion(&res->completion); - err = res->err; - /* fall through */ - default: + if (err) pr_crit_ratelimited("ahash calculation failed: err: %d\n", err); - } return err; } @@ -233,7 +211,7 @@ static int ima_calc_file_hash_atfm(struct file *file, int rc, read = 0, rbuf_len, active = 0, ahash_rc = 0; struct ahash_request *req; struct scatterlist sg[1]; - struct ahash_completion res; + struct crypto_wait wait; size_t rbuf_size[2]; hash->length = crypto_ahash_digestsize(tfm); @@ -242,12 +220,12 @@ static int ima_calc_file_hash_atfm(struct file *file, if (!req) return -ENOMEM; - init_completion(&res.completion); + crypto_init_wait(&wait); ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - ahash_complete, &res); + crypto_req_done, &wait); - rc = ahash_wait(crypto_ahash_init(req), &res); + rc = ahash_wait(crypto_ahash_init(req), &wait); if (rc) goto out1; @@ -288,7 +266,7 @@ static int ima_calc_file_hash_atfm(struct file *file, * read/request, wait for the completion of the * previous ahash_update() request. */ - rc = ahash_wait(ahash_rc, &res); + rc = ahash_wait(ahash_rc, &wait); if (rc) goto out3; } @@ -304,7 +282,7 @@ static int ima_calc_file_hash_atfm(struct file *file, * read/request, wait for the completion of the * previous ahash_update() request. */ - rc = ahash_wait(ahash_rc, &res); + rc = ahash_wait(ahash_rc, &wait); if (rc) goto out3; } @@ -318,7 +296,7 @@ static int ima_calc_file_hash_atfm(struct file *file, active = !active; /* swap buffers, if we use two */ } /* wait for the last update request to complete */ - rc = ahash_wait(ahash_rc, &res); + rc = ahash_wait(ahash_rc, &wait); out3: if (read) file->f_mode &= ~FMODE_READ; @@ -327,7 +305,7 @@ static int ima_calc_file_hash_atfm(struct file *file, out2: if (!rc) { ahash_request_set_crypt(req, NULL, hash->digest, 0); - rc = ahash_wait(crypto_ahash_final(req), &res); + rc = ahash_wait(crypto_ahash_final(req), &wait); } out1: ahash_request_free(req); @@ -527,7 +505,7 @@ static int calc_buffer_ahash_atfm(const void *buf, loff_t len, { struct ahash_request *req; struct scatterlist sg; - struct ahash_completion res; + struct crypto_wait wait; int rc, ahash_rc = 0; hash->length = crypto_ahash_digestsize(tfm); @@ -536,12 +514,12 @@ static int calc_buffer_ahash_atfm(const void *buf, loff_t len, if (!req) return -ENOMEM; - init_completion(&res.completion); + crypto_init_wait(&wait); ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP, - ahash_complete, &res); + crypto_req_done, &wait); - rc = ahash_wait(crypto_ahash_init(req), &res); + rc = ahash_wait(crypto_ahash_init(req), &wait); if (rc) goto out; @@ -551,10 +529,10 @@ static int calc_buffer_ahash_atfm(const void *buf, loff_t len, ahash_rc = crypto_ahash_update(req); /* wait for the update request to complete */ - rc = ahash_wait(ahash_rc, &res); + rc = ahash_wait(ahash_rc, &wait); if (!rc) { ahash_request_set_crypt(req, NULL, hash->digest, 0); - rc = ahash_wait(crypto_ahash_final(req), &res); + rc = ahash_wait(crypto_ahash_final(req), &wait); } out: ahash_request_free(req); -- 2.1.4 |
From: Gilad Ben-Y. <gi...@be...> - 2017-08-08 12:17:26
|
The mediatek driver starts several async crypto ops and waits for their completions. Move it over to generic code doing the same. Signed-off-by: Gilad Ben-Yossef <gi...@be...> --- drivers/crypto/mediatek/mtk-aes.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/drivers/crypto/mediatek/mtk-aes.c b/drivers/crypto/mediatek/mtk-aes.c index 9e845e8..e2c7c95 100644 --- a/drivers/crypto/mediatek/mtk-aes.c +++ b/drivers/crypto/mediatek/mtk-aes.c @@ -137,11 +137,6 @@ struct mtk_aes_gcm_ctx { struct crypto_skcipher *ctr; }; -struct mtk_aes_gcm_setkey_result { - int err; - struct completion completion; -}; - struct mtk_aes_drv { struct list_head dev_list; /* Device list lock */ @@ -936,17 +931,6 @@ static int mtk_aes_gcm_crypt(struct aead_request *req, u64 mode) &req->base); } -static void mtk_gcm_setkey_done(struct crypto_async_request *req, int err) -{ - struct mtk_aes_gcm_setkey_result *result = req->data; - - if (err == -EINPROGRESS) - return; - - result->err = err; - complete(&result->completion); -} - /* * Because of the hardware limitation, we need to pre-calculate key(H) * for the GHASH operation. The result of the encryption operation @@ -962,7 +946,7 @@ static int mtk_aes_gcm_setkey(struct crypto_aead *aead, const u8 *key, u32 hash[4]; u8 iv[8]; - struct mtk_aes_gcm_setkey_result result; + struct crypto_wait wait; struct scatterlist sg[1]; struct skcipher_request req; @@ -1002,22 +986,17 @@ static int mtk_aes_gcm_setkey(struct crypto_aead *aead, const u8 *key, if (!data) return -ENOMEM; - init_completion(&data->result.completion); + crypto_init_wait(&data->wait); sg_init_one(data->sg, &data->hash, AES_BLOCK_SIZE); skcipher_request_set_tfm(&data->req, ctr); skcipher_request_set_callback(&data->req, CRYPTO_TFM_REQ_MAY_SLEEP | CRYPTO_TFM_REQ_MAY_BACKLOG, - mtk_gcm_setkey_done, &data->result); + crypto_req_done, &data->wait); skcipher_request_set_crypt(&data->req, data->sg, data->sg, AES_BLOCK_SIZE, data->iv); - err = crypto_skcipher_encrypt(&data->req); - if (err == -EINPROGRESS || err == -EBUSY) { - err = wait_for_completion_interruptible( - &data->result.completion); - if (!err) - err = data->result.err; - } + err = crypto_wait_req(crypto_skcipher_encrypt(&data->req), + &data->wait); if (err) goto out; -- 2.1.4 |
From: Mehmet K. <mka...@li...> - 2017-07-11 16:30:42
|
This IMA namespacing patch set was initially implemented by Yuqiong Sun, while at IBM Research as a summer intern working with David Safford. It was subsequently modified and rebased by Stefan Berger and Mehmet Kayaalp. The resulting patches are being made available from the "next-namespacing-experimental" branch on https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git as a proof of concept, but will not be upstreamed. Namespacing IMA is complex. It involves differentiating the IMA global information (e.g. file hashes) from the IMA namespace specific information (e.g. collected, measured, appraised). This information needs to be created, updated, and freed as namespaces come and go, and also freed when files are removed from the file system. In addition, namespacing IMA properly also requires namespacing the securityfs files (eg. policy, ascii/binary measurement lists), keyrings needed for validating file signatures, and the hash table used to prevent the same file from being measured multiple times within the same namespace, yet separately in each namespace. This requires some form of capability/permission checking. Currently, only root with CAP_SYS_ADMIN permission is able to write securityfs files and security xattrs. In addition, the IMA security xattrs need to be namespace aware. (Other LSM subsystems are making similar changes.) Like other initial subsystem namespacing, this IMA namespacing patch set defines a new IMA namespace that is created with a new clone flag (this needs to be changed). An unprivileged user can create an IMA namespace in a new user namespace. The IMA securityfs policy file can be read and set by a user with CAP_SYS_ADMIN within the user namespace, where the IMA namespace is created. The policy can define the namespace measurement and appraisal rules. Measurement is done recursively for each nested IMA namespace. If the file to be measured is in policy for multiple IMA namespaces, it is measured for each namespace. The list of measurements are available to the CAP_SYS_ADMIN under the owner user namespace. For appraisal, the non-init IMA namespaces use the "_ima" session keyring. If the keyring is created and populated with keys, these keys will be used for the appraisal rules defined in the policy of the IMA namespace. Attestation for the IMA namespace is not supported in this patchset. For testing, we modified "runc" to create an IMA namespace and initialized the policy and the keyring inside the container between the clone() and exec() system calls. For accessing the IMA files in securityfs inside the container, CAP_SYS_ADMIN is required to be added to the list of capabilities in the config.json file. "runc" tries loading the policy from /etc/default/ima-policy, and keys from /etc/keys/ima/ inside the rootfs of the container. The runc patches are available at the "imans" branch on https://github.com/stefanberger/runc. Major changes include: * Keyring creation is moved to userspace. * Policy file is changed back from procfs to securityfs. * Temporarily the IMA files are only accessible to CAP_SYS_ADMIN with permissions set to user, group, and other. * Patches should now be bisect-safe. Regards, Mehmet |
From: Mimi Z. <zo...@li...> - 2017-07-06 18:10:54
|
This patch defines simple_read_iter_from_buffer(), replaces the existing efivarfs ->read method with ->read_iter method, and defines an ->integrity_read file operation method to read data for integrity hash collection. (Posting separately for review, before being squashed with the others.) Changelog v1: - totally re-written based on Al's comments, containing source code. Signed-off-by: Mimi Zohar <zo...@li...> --- fs/efivarfs/file.c | 12 +++++++----- fs/libfs.c | 32 ++++++++++++++++++++++++++++++++ include/linux/fs.h | 2 ++ 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c index 5f22e74bbade..17955a92a5b3 100644 --- a/fs/efivarfs/file.c +++ b/fs/efivarfs/file.c @@ -64,9 +64,10 @@ static ssize_t efivarfs_file_write(struct file *file, return bytes; } -static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, - size_t count, loff_t *ppos) +static ssize_t efivarfs_file_read_iter(struct kiocb *iocb, + struct iov_iter *iter) { + struct file *file = iocb->ki_filp; struct efivar_entry *var = file->private_data; unsigned long datasize = 0; u32 attributes; @@ -96,8 +97,8 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, goto out_free; memcpy(data, &attributes, sizeof(attributes)); - size = simple_read_from_buffer(userbuf, count, ppos, - data, datasize + sizeof(attributes)); + size = simple_read_iter_from_buffer(iocb, iter, data, + datasize + sizeof(attributes)); out_free: kfree(data); @@ -174,8 +175,9 @@ efivarfs_file_ioctl(struct file *file, unsigned int cmd, unsigned long p) const struct file_operations efivarfs_file_operations = { .open = simple_open, - .read = efivarfs_file_read, + .read_iter = efivarfs_file_read_iter, .write = efivarfs_file_write, .llseek = no_llseek, .unlocked_ioctl = efivarfs_file_ioctl, + .integrity_read = efivarfs_file_read_iter, }; diff --git a/fs/libfs.c b/fs/libfs.c index a04395334bb1..e1b4f8695013 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -16,6 +16,7 @@ #include <linux/exportfs.h> #include <linux/writeback.h> #include <linux/buffer_head.h> /* sync_mapping_buffers */ +#include <linux/uio.h> #include <linux/uaccess.h> @@ -676,6 +677,37 @@ ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, EXPORT_SYMBOL(simple_write_to_buffer); /** + * simple_read_iter_from_buffer - copy data from the buffer to user space + * @iocb: struct containing the file, the current position and other info + * @to: the user space buffer to read to + * @from: the buffer to read from + * @available: the size of the buffer + * + * The simple_read_iter_from_buffer() function reads up to @available bytes + * from the current buffer into the user space buffer. + * + * On success, the current buffer offset is advanced by the number of bytes + * read, or a negative value is returned on error. + **/ +ssize_t simple_read_iter_from_buffer(struct kiocb *iocb, struct iov_iter *to, + const void *from, size_t available) +{ + loff_t pos = iocb->ki_pos; + size_t ret; + + if (pos < 0) + return -EINVAL; + if (pos >= available) + return 0; + ret = copy_to_iter(from + pos, available - pos, to); + if (!ret && iov_iter_count(to)) + return -EFAULT; + iocb->ki_pos = pos + ret; + return ret; +} +EXPORT_SYMBOL(simple_read_iter_from_buffer); + +/** * memory_read_from_buffer - copy data from the buffer * @to: the kernel space buffer to read to * @count: the maximum number of bytes to read diff --git a/include/linux/fs.h b/include/linux/fs.h index 36edfe84c4bf..d85d2c43afd9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3012,6 +3012,8 @@ extern void simple_release_fs(struct vfsmount **mount, int *count); extern ssize_t simple_read_from_buffer(void __user *to, size_t count, loff_t *ppos, const void *from, size_t available); +extern ssize_t simple_read_iter_from_buffer(struct kiocb *iocb, + struct iov_iter *to, const void *from, size_t available); extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, const void __user *from, size_t count); -- 2.7.4 |
From: Al V. <vi...@Ze...> - 2017-07-06 12:46:09
|
On Thu, Jul 06, 2017 at 08:14:01AM -0400, Mimi Zohar wrote: > This patch defines an ->integrity_read file operation method to read data for > integrity hash collection. > -static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, > - size_t count, loff_t *ppos) > +static ssize_t __efivarfs_file_read(struct file *file, char __user *userbuf, > + size_t count, loff_t *ppos, > + struct iov_iter *iter) > { > struct efivar_entry *var = file->private_data; > unsigned long datasize = 0; > @@ -96,14 +98,32 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, > goto out_free; > > memcpy(data, &attributes, sizeof(attributes)); > - size = simple_read_from_buffer(userbuf, count, ppos, > - data, datasize + sizeof(attributes)); > + > + if (!iter) > + size = simple_read_from_buffer(userbuf, count, ppos, data, > + datasize + sizeof(attributes)); > + else > + size = copy_to_iter(data, datasize + sizeof(attributes), iter); Egads... This kind of kludges is too ugly to exist. What the hell for? If you want to define something that looks like ->read_iter(), bloody make it proper read_iter. Really working one, that is - without this "our oh-so-special needs do not include file position" crap. Seriously, this kind of calling conventions alone is enough for a NAK with extreme prejudice. Something like ssize_t simple_read_iter_from_buffer(struct kiocb *iocb, struct iov_iter *to, const void *from, size_t available) { loff_t pos = iocb->ki_pos; size_t ret; if (pos < 0) return -EINVAL; if (pos >= available) return 0; ret = copy_to_iter(to, from + pos, available - pos); if (!ret && iov_iter_count(to)) return -EFAULT; iocb->ki_pos = pos + ret; return ret; } EXPORT_SYMBOL(simple_read_iter_from_buffer); in fs/libfs.c and turn the efivarfs_file_read() into a real ->read_iter() by replacing simple_read_from_buffer to simple_read_iter_from_buffer (and adjusting the arguments, of course). All there is to it. Sheesh... |
From: Mimi Z. <zo...@li...> - 2017-07-06 12:14:18
|
This patch defines an ->integrity_read file operation method to read data for integrity hash collection. (Posting separately for review, before being squashed with the others.) Signed-off-by: Mimi Zohar <zo...@li...> --- fs/efivarfs/file.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c index 5f22e74bbade..b687c982e0a1 100644 --- a/fs/efivarfs/file.c +++ b/fs/efivarfs/file.c @@ -10,6 +10,7 @@ #include <linux/efi.h> #include <linux/fs.h> #include <linux/slab.h> +#include <linux/uio.h> #include <linux/mount.h> #include "internal.h" @@ -64,8 +65,9 @@ static ssize_t efivarfs_file_write(struct file *file, return bytes; } -static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, - size_t count, loff_t *ppos) +static ssize_t __efivarfs_file_read(struct file *file, char __user *userbuf, + size_t count, loff_t *ppos, + struct iov_iter *iter) { struct efivar_entry *var = file->private_data; unsigned long datasize = 0; @@ -96,14 +98,32 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, goto out_free; memcpy(data, &attributes, sizeof(attributes)); - size = simple_read_from_buffer(userbuf, count, ppos, - data, datasize + sizeof(attributes)); + + if (!iter) + size = simple_read_from_buffer(userbuf, count, ppos, data, + datasize + sizeof(attributes)); + else + size = copy_to_iter(data, datasize + sizeof(attributes), iter); out_free: kfree(data); return size; } +static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, + size_t count, loff_t *ppos) +{ + return __efivarfs_file_read(file, userbuf, count, ppos, NULL); +} + +static ssize_t efivarfs_file_read_iter(struct kiocb *iocb, + struct iov_iter *iter) +{ + struct file *file = iocb->ki_filp; + + return __efivarfs_file_read(file, NULL, 0, NULL, iter); +} + static int efivarfs_ioc_getxflags(struct file *file, void __user *arg) { @@ -178,4 +198,5 @@ const struct file_operations efivarfs_file_operations = { .write = efivarfs_file_write, .llseek = no_llseek, .unlocked_ioctl = efivarfs_file_ioctl, + .integrity_read = efivarfs_file_read_iter, }; -- 2.7.4 |
From: Christoph H. <hc...@ls...> - 2017-07-05 17:19:06
|
On Wed, Jul 05, 2017 at 06:02:15PM +0100, Matthew Garrett wrote: > On Wed, Jul 05, 2017 at 10:50:09AM -0400, Mimi Zohar wrote: > > [Cc'ing linux-ima-users] > > > > On Wed, 2017-06-28 at 16:41 +0200, Christoph Hellwig wrote: > > > NAK - we'll need an explicit method for the integrity code. > > > > > > And just curious - what filesystem that you care about actually > > > implements ->read instead of ->read_iter? We shouldn't be doing that > > > for real file systems anymore. > > > > Right, pseudo filesystems are using ->read. The existing builtin > > measurement policies exclude a number of pseudo filesystems, but not > > efivarfs. Unfortunately, we do not know what type of custom policies > > are currently being used. > > efi variables contain information that may influence userspace behaviour > and can also be modified out of band, so I think there's a reasonable > argument that they should be measured. Then efivars should grow a ->integrity_read method. |
From: Matthew G. <mj...@sr...> - 2017-07-05 17:02:29
|
On Wed, Jul 05, 2017 at 10:50:09AM -0400, Mimi Zohar wrote: > [Cc'ing linux-ima-users] > > On Wed, 2017-06-28 at 16:41 +0200, Christoph Hellwig wrote: > > NAK - we'll need an explicit method for the integrity code. > > > > And just curious - what filesystem that you care about actually > > implements ->read instead of ->read_iter? We shouldn't be doing that > > for real file systems anymore. > > Right, pseudo filesystems are using ->read. The existing builtin > measurement policies exclude a number of pseudo filesystems, but not > efivarfs. Unfortunately, we do not know what type of custom policies > are currently being used. efi variables contain information that may influence userspace behaviour and can also be modified out of band, so I think there's a reasonable argument that they should be measured. -- Matthew Garrett | mj...@sr... |
From: Mimi Z. <zo...@li...> - 2017-07-05 14:50:31
|
[Cc'ing linux-ima-users] On Wed, 2017-06-28 at 16:41 +0200, Christoph Hellwig wrote: > NAK - we'll need an explicit method for the integrity code. > > And just curious - what filesystem that you care about actually > implements ->read instead of ->read_iter? We shouldn't be doing that > for real file systems anymore. Right, pseudo filesystems are using ->read. The existing builtin measurement policies exclude a number of pseudo filesystems, but not efivarfs. Unfortunately, we do not know what type of custom policies are currently being used. The contents of the IMA measurement list are verified against a reference manifest, provided at registration, or against a white list. Not measuring files that were previously measured could break userspace applications. Let's wait to hear back from the larger IMA community as to whether there is a need to measure files on pseudo filesystems, before implementing an explicit method. Mimi |
From: Mimi Z. <zo...@li...> - 2017-06-14 18:16:14
|
Hi Guilherme, On Wed, 2017-06-14 at 14:31 +0000, Magalhaes, Guilherme (Brazil R&D- CL) wrote: > Hi Mimi, > Thanks for the further explanations. > We now started to work on a solution for namespacing the IMA-audit > as you indicated as a first step and still aiming a bottom-up design > from this point to other IMA areas. > Talk to you soon. Mehmet Kayaalp is rebasing Yuqiong Sun's (a former summer intern at IBM Research) IMA original namespacing patches to a more recent kernel. As soon as he finishes, we'll push them out as reference. Mimi |
From: Magalhaes, G. (B. R&D-CL) <gui...@hp...> - 2017-06-14 14:31:29
|
Hi Mimi, Thanks for the further explanations. We now started to work on a solution for namespacing the IMA-audit as you indicated as a first step and still aiming a bottom-up design from this point to other IMA areas. Talk to you soon. -- Guilherme -----Original Message----- From: Mimi Zohar [mailto:zo...@li...] Sent: segunda-feira, 29 de maio de 2017 23:27 To: Magalhaes, Guilherme (Brazil R&D-CL) <gui...@hp...>; John Johansen <joh...@ca...>; dmi...@gm... Cc: lin...@li...; lin...@li...; ty...@do...; Souza, Joaquim (Brazil R&D-ECL) <joa...@hp...>; Edwards, Nigel <nig...@hp...> Subject: Re: [RFC 04/11] ima: add support to namespace securityfs file On Mon, 2017-05-29 at 20:34 +0000, Magalhaes, Guilherme (Brazil R&D- CL) wrote: <snip> > >- IMA-audit: > > >The IMA-audit messages can augment other file system security > >information used in security analytics/forensics. This information > >should be on a per namespace basis, meaning that each time a new file > >is accessed/executed, there needs to be a separate audit message, > >even if a message already exists in another namespace. Maintaining > >and cleaning up this per namespace cache information, allows > >development of the IMA namespace architecture independently of other issues. > My understanding is that the Audit subsystem manages on its own, by > using a daemon per user namespace, the separation of messages per > namespace. Audit API (audit_log_start, audit_log_end, etc) clients, on > its turn, must generate the proper record and then use the Audit API > to queue that record. What we did was to add enough fields to the > record to properly identify a pathname, considering multiple mount > namespaces. I thought this is what was missing on the IMA perspective. Please clarify. I'm referring to the IMA-audit messages that were introduced in e7c568e0fd0c "ima: audit log hashes". Appending the namespace identification information to the existing information is not enough. The IMA-audit message needs to be generated the first time in each namespace. This requires storing the per namespace information separately from the common information, for example the file hash. The main difficulties are in how the common information vs. the per namespace information are stored, referenced, and cleaned up. Cleanup will need to address when either the namespace itself or a dentry is deleted. All of the different IMA aspects require storing, on a per namespace basis, IMA namespace specific information (eg. audit status within the namespace, measurement status within the namespace, appraisal results based on different policies/keys). Once the architecture is defined, namespacing the other IMA aspects should be straight forward. Mimi |
From: Micka <mic...@gm...> - 2017-06-13 09:50:19
|
TPM 1.2 , I'm going to add a secure boot. Le mar. 13 juin 2017 à 11:16, Nayna <na...@li...> a écrit : > On 06/12/2017 06:46 PM, Micka wrote: > > I found out why I don't have TPM folder in the security folder : > > > > #if defined > > <http://elixir.free-electrons.com/linux/v4.8.17/ident/defined > >(CONFIG_TCG_IBMVTPM) > > || defined > > <http://elixir.free-electrons.com/linux/v4.8.17/ident/defined > >(CONFIG_TCG_IBMVTPM_MODULE) > > || \ > > defined > > <http://elixir.free-electrons.com/linux/v4.8.17/ident/defined > >(CONFIG_ACPI) > > extern struct dentry **tpm_bios_log_setup > > <http://elixir.free-electrons.com/linux/v4.8.17/ident/tpm_bios_log_setup>(const > char *); > > extern void tpm_bios_log_teardown > > < > http://elixir.free-electrons.com/linux/v4.8.17/ident/tpm_bios_log_teardown>(struct > dentry **); > > #else > > static inline struct dentry **tpm_bios_log_setup > > <http://elixir.free-electrons.com/linux/v4.8.17/ident/tpm_bios_log_setup>(const > char *name) > > { > > return NULL; > > } > > static inline void tpm_bios_log_teardown > > < > http://elixir.free-electrons.com/linux/v4.8.17/ident/tpm_bios_log_teardown>(struct > dentry **dir <http://elixir.free-electrons.com/linux/v4.8.17/ident/dir>) > > { > > } > > #endif > > > > I wonder why other TPM can't use this feature ? > > > > > > What version of TPM are you using ? TPM 1.2 or TPM 2.0 ? > > Thanks & Regards, > - Nayna > > > > > Le lun. 12 juin 2017 à 09:36, Micka <mic...@gm... > > <mailto:mic...@gm...>> a écrit : > > > > I just compiled the tools, but I don't have this folder : > > > > /sys/kernel/security/tpm0 > > > > > > I have the folder: > > > > /sys/class/tpm/tpm0/ > > > > I'm working with the kernel 4.4 . > > > > I tried also : > > > > ./ima_boot_aggregate > > /sys/kernel/security/ima/binary_runtime_measurements > > 010 dc3bd4ee300406cd93181c5a2187b59b06000000 > > Error event too longPCR-00: 0000000000000000000000000000000000000000 > > PCR-01: 0000000000000000000000000000000000000000 > > PCR-02: 0000000000000000000000000000000000000000 > > PCR-03: 0000000000000000000000000000000000000000 > > PCR-04: 0000000000000000000000000000000000000000 > > PCR-05: 0000000000000000000000000000000000000000 > > PCR-06: 0000000000000000000000000000000000000000 > > PCR-07: 0000000000000000000000000000000000000000 > > boot_aggregate:9797edf8d0eed36b1cf92547816051c8af4e45ee > > > > > > Le lun. 12 juin 2017 à 08:06, Nayna <na...@li... > > <mailto:na...@li...>> a écrit : > > > > > > > > On 06/10/2017 03:39 PM, Micka wrote: > > > Thx, but my PCRS 0-7 are set to zero for the moment. I don't > > have yet a > > > secure boot. Is it the secure boot that provide the PCRS 0-7? > > > > > > > Trusted boot will provide PCRS 0-7. > > Did you try to execute the ima-tests which I shared and verified > ? > > > > Thanks & Regards, > > - Nayna > > > > > > > > Micka, > > > > > > Le ven. 9 juin 2017 à 15:43, Nayna <na...@li... > > <mailto:na...@li...> > > > <mailto:na...@li... > > <mailto:na...@li...>>> a écrit : > > > > > > > > > > > > On 06/08/2017 02:25 PM, Micka wrote: > > > > Hi, > > > > > > > > I would like to know what boot aggregate measure means > ? > > > > > > It is an aggregated hash of PCRS 0-7. > > > > > > > > > > > I have a problem, my PCR 10 is changing every time I > > reboot my > > > device: > > > > > > > > 10 ddee6404dc3bd4ee300406cd93181c5a2187b59b ima-ng > > > > sha1:9797edf8d9eed36b1cf92547816a51c8af4e45ee > > boot_aggregate > > > > > > > > > > You can verify your boot_aggregate by using the test > > scripts from > > > package ltp-ima-standalone-v2.tar.gz as available on: > > > https://sourceforge.net/projects/linux-ima/ > > > > > > Steps to use it are specified in below link: > > > http://linux-ima.sourceforge.net/linux-ima-measurements.html > > > > > > Thanks & Regards, > > > - Nayna > > > > > > > I have only activated: ima_audit=1 > > > > > > > > Michael Musset, > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------------ > > > > Check out the vibrant tech community on one of the > > world's most > > > > engaging tech sites, Slashdot.org! > > http://sdm.link/slashdot > > > > > > > > > > > > > > > > _______________________________________________ > > > > Linux-ima-user mailing list > > > > Lin...@li... > > <mailto:Lin...@li...> > > > <mailto:Lin...@li... > > <mailto:Lin...@li...>> > > > > > > https://lists.sourceforge.net/lists/listinfo/linux-ima-user > > > > > > > > > > > |
From: Nayna <na...@li...> - 2017-06-13 09:16:26
|
On 06/12/2017 06:46 PM, Micka wrote: > I found out why I don't have TPM folder in the security folder : > > #if defined > <http://elixir.free-electrons.com/linux/v4.8.17/ident/defined>(CONFIG_TCG_IBMVTPM) > || defined > <http://elixir.free-electrons.com/linux/v4.8.17/ident/defined>(CONFIG_TCG_IBMVTPM_MODULE) > || \ > defined > <http://elixir.free-electrons.com/linux/v4.8.17/ident/defined>(CONFIG_ACPI) > extern struct dentry **tpm_bios_log_setup > <http://elixir.free-electrons.com/linux/v4.8.17/ident/tpm_bios_log_setup>(const char *); > extern void tpm_bios_log_teardown > <http://elixir.free-electrons.com/linux/v4.8.17/ident/tpm_bios_log_teardown>(struct dentry **); > #else > static inline struct dentry **tpm_bios_log_setup > <http://elixir.free-electrons.com/linux/v4.8.17/ident/tpm_bios_log_setup>(const char *name) > { > return NULL; > } > static inline void tpm_bios_log_teardown > <http://elixir.free-electrons.com/linux/v4.8.17/ident/tpm_bios_log_teardown>(struct dentry **dir <http://elixir.free-electrons.com/linux/v4.8.17/ident/dir>) > { > } > #endif > > I wonder why other TPM can't use this feature ? > > What version of TPM are you using ? TPM 1.2 or TPM 2.0 ? Thanks & Regards, - Nayna > > Le lun. 12 juin 2017 à 09:36, Micka <mic...@gm... > <mailto:mic...@gm...>> a écrit : > > I just compiled the tools, but I don't have this folder : > > /sys/kernel/security/tpm0 > > > I have the folder: > > /sys/class/tpm/tpm0/ > > I'm working with the kernel 4.4 . > > I tried also : > > ./ima_boot_aggregate > /sys/kernel/security/ima/binary_runtime_measurements > 010 dc3bd4ee300406cd93181c5a2187b59b06000000 > Error event too longPCR-00: 0000000000000000000000000000000000000000 > PCR-01: 0000000000000000000000000000000000000000 > PCR-02: 0000000000000000000000000000000000000000 > PCR-03: 0000000000000000000000000000000000000000 > PCR-04: 0000000000000000000000000000000000000000 > PCR-05: 0000000000000000000000000000000000000000 > PCR-06: 0000000000000000000000000000000000000000 > PCR-07: 0000000000000000000000000000000000000000 > boot_aggregate:9797edf8d0eed36b1cf92547816051c8af4e45ee > > > Le lun. 12 juin 2017 à 08:06, Nayna <na...@li... > <mailto:na...@li...>> a écrit : > > > > On 06/10/2017 03:39 PM, Micka wrote: > > Thx, but my PCRS 0-7 are set to zero for the moment. I don't > have yet a > > secure boot. Is it the secure boot that provide the PCRS 0-7? > > > > Trusted boot will provide PCRS 0-7. > Did you try to execute the ima-tests which I shared and verified ? > > Thanks & Regards, > - Nayna > > > > > Micka, > > > > Le ven. 9 juin 2017 à 15:43, Nayna <na...@li... > <mailto:na...@li...> > > <mailto:na...@li... > <mailto:na...@li...>>> a écrit : > > > > > > > > On 06/08/2017 02:25 PM, Micka wrote: > > > Hi, > > > > > > I would like to know what boot aggregate measure means ? > > > > It is an aggregated hash of PCRS 0-7. > > > > > > > > I have a problem, my PCR 10 is changing every time I > reboot my > > device: > > > > > > 10 ddee6404dc3bd4ee300406cd93181c5a2187b59b ima-ng > > > sha1:9797edf8d9eed36b1cf92547816a51c8af4e45ee > boot_aggregate > > > > > > > You can verify your boot_aggregate by using the test > scripts from > > package ltp-ima-standalone-v2.tar.gz as available on: > > https://sourceforge.net/projects/linux-ima/ > > > > Steps to use it are specified in below link: > > http://linux-ima.sourceforge.net/linux-ima-measurements.html > > > > Thanks & Regards, > > - Nayna > > > > > I have only activated: ima_audit=1 > > > > > > Michael Musset, > > > > > > > > > > > > ------------------------------------------------------------------------------ > > > Check out the vibrant tech community on one of the > world's most > > > engaging tech sites, Slashdot.org! > http://sdm.link/slashdot > > > > > > > > > > > > _______________________________________________ > > > Linux-ima-user mailing list > > > Lin...@li... > <mailto:Lin...@li...> > > <mailto:Lin...@li... > <mailto:Lin...@li...>> > > > > https://lists.sourceforge.net/lists/listinfo/linux-ima-user > > > > > > |
From: Micka <mic...@gm...> - 2017-06-12 13:16:53
|
I found out why I don't have TPM folder in the security folder : #if defined <http://elixir.free-electrons.com/linux/v4.8.17/ident/defined>(CONFIG_TCG_IBMVTPM) || defined <http://elixir.free-electrons.com/linux/v4.8.17/ident/defined>(CONFIG_TCG_IBMVTPM_MODULE) || \ defined <http://elixir.free-electrons.com/linux/v4.8.17/ident/defined>(CONFIG_ACPI)extern struct dentry **tpm_bios_log_setup <http://elixir.free-electrons.com/linux/v4.8.17/ident/tpm_bios_log_setup>(const char *);extern void tpm_bios_log_teardown <http://elixir.free-electrons.com/linux/v4.8.17/ident/tpm_bios_log_teardown>(struct dentry **);#elsestatic inline struct dentry **tpm_bios_log_setup <http://elixir.free-electrons.com/linux/v4.8.17/ident/tpm_bios_log_setup>(const char *name){ return NULL;}static inline void tpm_bios_log_teardown <http://elixir.free-electrons.com/linux/v4.8.17/ident/tpm_bios_log_teardown>(struct dentry **dir <http://elixir.free-electrons.com/linux/v4.8.17/ident/dir>){}#endif I wonder why other TPM can't use this feature ? Le lun. 12 juin 2017 à 09:36, Micka <mic...@gm...> a écrit : > I just compiled the tools, but I don't have this folder : > > /sys/kernel/security/tpm0 > > > I have the folder: > > /sys/class/tpm/tpm0/ > > I'm working with the kernel 4.4 . > > I tried also : > > ./ima_boot_aggregate /sys/kernel/security/ima/binary_runtime_measurements > 010 dc3bd4ee300406cd93181c5a2187b59b06000000 > Error event too longPCR-00: 0000000000000000000000000000000000000000 > PCR-01: 0000000000000000000000000000000000000000 > PCR-02: 0000000000000000000000000000000000000000 > PCR-03: 0000000000000000000000000000000000000000 > PCR-04: 0000000000000000000000000000000000000000 > PCR-05: 0000000000000000000000000000000000000000 > PCR-06: 0000000000000000000000000000000000000000 > PCR-07: 0000000000000000000000000000000000000000 > boot_aggregate:9797edf8d0eed36b1cf92547816051c8af4e45ee > > > Le lun. 12 juin 2017 à 08:06, Nayna <na...@li...> a écrit : > >> >> >> On 06/10/2017 03:39 PM, Micka wrote: >> > Thx, but my PCRS 0-7 are set to zero for the moment. I don't have yet a >> > secure boot. Is it the secure boot that provide the PCRS 0-7? >> > >> >> Trusted boot will provide PCRS 0-7. >> Did you try to execute the ima-tests which I shared and verified ? >> >> Thanks & Regards, >> - Nayna >> >> > >> > Micka, >> > >> > Le ven. 9 juin 2017 à 15:43, Nayna <na...@li... >> > <mailto:na...@li...>> a écrit : >> > >> > >> > >> > On 06/08/2017 02:25 PM, Micka wrote: >> > > Hi, >> > > >> > > I would like to know what boot aggregate measure means ? >> > >> > It is an aggregated hash of PCRS 0-7. >> > >> > > >> > > I have a problem, my PCR 10 is changing every time I reboot my >> > device: >> > > >> > > 10 ddee6404dc3bd4ee300406cd93181c5a2187b59b ima-ng >> > > sha1:9797edf8d9eed36b1cf92547816a51c8af4e45ee boot_aggregate >> > > >> > >> > You can verify your boot_aggregate by using the test scripts from >> > package ltp-ima-standalone-v2.tar.gz as available on: >> > https://sourceforge.net/projects/linux-ima/ >> > >> > Steps to use it are specified in below link: >> > http://linux-ima.sourceforge.net/linux-ima-measurements.html >> > >> > Thanks & Regards, >> > - Nayna >> > >> > > I have only activated: ima_audit=1 >> > > >> > > Michael Musset, >> > > >> > > >> > > >> > >> ------------------------------------------------------------------------------ >> > > Check out the vibrant tech community on one of the world's most >> > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot >> > > >> > > >> > > >> > > _______________________________________________ >> > > Linux-ima-user mailing list >> > > Lin...@li... >> > <mailto:Lin...@li...> >> > > https://lists.sourceforge.net/lists/listinfo/linux-ima-user >> > > >> > >> >> |
From: Micka <mic...@gm...> - 2017-06-12 07:37:03
|
I just compiled the tools, but I don't have this folder : /sys/kernel/security/tpm0 I have the folder: /sys/class/tpm/tpm0/ I'm working with the kernel 4.4 . I tried also : ./ima_boot_aggregate /sys/kernel/security/ima/binary_runtime_measurements 010 dc3bd4ee300406cd93181c5a2187b59b06000000 Error event too longPCR-00: 0000000000000000000000000000000000000000 PCR-01: 0000000000000000000000000000000000000000 PCR-02: 0000000000000000000000000000000000000000 PCR-03: 0000000000000000000000000000000000000000 PCR-04: 0000000000000000000000000000000000000000 PCR-05: 0000000000000000000000000000000000000000 PCR-06: 0000000000000000000000000000000000000000 PCR-07: 0000000000000000000000000000000000000000 boot_aggregate:9797edf8d0eed36b1cf92547816051c8af4e45ee Le lun. 12 juin 2017 à 08:06, Nayna <na...@li...> a écrit : > > > On 06/10/2017 03:39 PM, Micka wrote: > > Thx, but my PCRS 0-7 are set to zero for the moment. I don't have yet a > > secure boot. Is it the secure boot that provide the PCRS 0-7? > > > > Trusted boot will provide PCRS 0-7. > Did you try to execute the ima-tests which I shared and verified ? > > Thanks & Regards, > - Nayna > > > > > Micka, > > > > Le ven. 9 juin 2017 à 15:43, Nayna <na...@li... > > <mailto:na...@li...>> a écrit : > > > > > > > > On 06/08/2017 02:25 PM, Micka wrote: > > > Hi, > > > > > > I would like to know what boot aggregate measure means ? > > > > It is an aggregated hash of PCRS 0-7. > > > > > > > > I have a problem, my PCR 10 is changing every time I reboot my > > device: > > > > > > 10 ddee6404dc3bd4ee300406cd93181c5a2187b59b ima-ng > > > sha1:9797edf8d9eed36b1cf92547816a51c8af4e45ee boot_aggregate > > > > > > > You can verify your boot_aggregate by using the test scripts from > > package ltp-ima-standalone-v2.tar.gz as available on: > > https://sourceforge.net/projects/linux-ima/ > > > > Steps to use it are specified in below link: > > http://linux-ima.sourceforge.net/linux-ima-measurements.html > > > > Thanks & Regards, > > - Nayna > > > > > I have only activated: ima_audit=1 > > > > > > Michael Musset, > > > > > > > > > > > > ------------------------------------------------------------------------------ > > > Check out the vibrant tech community on one of the world's most > > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > > > > > > > > > > _______________________________________________ > > > Linux-ima-user mailing list > > > Lin...@li... > > <mailto:Lin...@li...> > > > https://lists.sourceforge.net/lists/listinfo/linux-ima-user > > > > > > > |
From: Nayna <na...@li...> - 2017-06-12 06:06:14
|
On 06/10/2017 03:39 PM, Micka wrote: > Thx, but my PCRS 0-7 are set to zero for the moment. I don't have yet a > secure boot. Is it the secure boot that provide the PCRS 0-7? > Trusted boot will provide PCRS 0-7. Did you try to execute the ima-tests which I shared and verified ? Thanks & Regards, - Nayna > > Micka, > > Le ven. 9 juin 2017 à 15:43, Nayna <na...@li... > <mailto:na...@li...>> a écrit : > > > > On 06/08/2017 02:25 PM, Micka wrote: > > Hi, > > > > I would like to know what boot aggregate measure means ? > > It is an aggregated hash of PCRS 0-7. > > > > > I have a problem, my PCR 10 is changing every time I reboot my > device: > > > > 10 ddee6404dc3bd4ee300406cd93181c5a2187b59b ima-ng > > sha1:9797edf8d9eed36b1cf92547816a51c8af4e45ee boot_aggregate > > > > You can verify your boot_aggregate by using the test scripts from > package ltp-ima-standalone-v2.tar.gz as available on: > https://sourceforge.net/projects/linux-ima/ > > Steps to use it are specified in below link: > http://linux-ima.sourceforge.net/linux-ima-measurements.html > > Thanks & Regards, > - Nayna > > > I have only activated: ima_audit=1 > > > > Michael Musset, > > > > > > > ------------------------------------------------------------------------------ > > Check out the vibrant tech community on one of the world's most > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > > > > > > _______________________________________________ > > Linux-ima-user mailing list > > Lin...@li... > <mailto:Lin...@li...> > > https://lists.sourceforge.net/lists/listinfo/linux-ima-user > > > |
From: Herbert Xu <he...@go...> - 2017-06-10 09:03:02
|
On Sat, Jun 10, 2017 at 11:05:39AM +0300, Gilad Ben-Yossef wrote: > > I guess there is a question if it really is important to know that > your request ended up > on the backlog, rather than being handled.I can imagine it can be used > as back pressure > indication but I wonder if someone is using that. Oh yes we do want it to return EBUSY if we put it on the backlog because in that case we want the user to stop sending us new requests. It's the other case where we dropped the request and returned EBUSY where I think we could return something other than EBUSY and get rid of the ambiguity. Thanks, -- Email: Herbert Xu <he...@go...> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt |
From: Gilad Ben-Y. <gi...@be...> - 2017-06-10 08:05:47
|
On Sat, Jun 10, 2017 at 6:43 AM, Herbert Xu <he...@go...> wrote: > On Mon, May 29, 2017 at 11:22:48AM +0300, Gilad Ben-Yossef wrote: >> >> +static inline int crypto_wait_req(int err, struct crypto_wait *wait) >> +{ >> + switch (err) { >> + case -EINPROGRESS: >> + case -EBUSY: >> + wait_for_completion(&wait->completion); >> + reinit_completion(&wait->completion); >> + err = wait->err; >> + break; >> + }; >> + >> + return err; >> +} > > This assumes that the request is used with backlog. For non-backlog > requests this would result in a memory leak as EBUSY in that case is > a fatal error. > > So this API can't be used without backlog. You are right, of course. I did not take that into account. > > We could introduce a flag to indicate whether we want backlog or not, > or maybe we should change our API so that in the non-backlog case we > return something other than EBUSY. > > Opinions? I guess there is a question if it really is important to know that your request ended up on the backlog, rather than being handled.I can imagine it can be used as back pressure indication but I wonder if someone is using that. If not, maybe we can simplify things and use EINPROGRESS asindication of a request being accepted by the next layer (either being processed or queued in the back log), whereas EBUSY would indicate failure. It does have a potential to make things simpler, I think. Gilad > > Thanks, > -- > Email: Herbert Xu <he...@go...> > Home Page: http://gondor.apana.org.au/~herbert/ > PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- Gilad Ben-Yossef Chief Coffee Drinker "If you take a class in large-scale robotics, can you end up in a situation where the homework eats your dog?" -- Jean-Baptiste Queru |