Re: random(4) and VMs

2018-09-19 Thread Theodore Y. Ts'o
On Tue, Sep 18, 2018 at 01:00:31PM -0400, Sandy Harris wrote:
> Solutions have been proposed by various people. If I understand them
> right, Ted Ts'o suggests modifying the boot loader to provide some
> entropy & John Denker suggests that every machine should be
> provisioned with some entropy in the kernel image at install time.
> Both are general solutions, but I think both would require updating
> the entropy store later. As far as I know, neither has yet been
> implemented as accepted patches
> 
> Is a fix that only deals with a subset of the problem worth
> considering? Just patch the VM support code so that any time a VM is
> either booted or re-started after a save, the host system drops in
> some entropy, This looks relatively easy to do, at least for Linux
> VMs, and some of the code might be the same as what the more general
> approaches would need.

That already exists.  It's called virtio-rng.  On the host side, using
kvm/qemu as an example, you just add the qemu options:

-object rng-random,filename=/dev/urandom,id=rng0 \
-device virtio-rng-pci,rng=rng0

On the guest kernel, enable CONFIG_HW_RANDOM_VIRTIO.

- Ted


[PATCH 1/1] crypto:chelsio: Fix memory corruption in DMA Mapped buffers.

2018-09-19 Thread Harsh Jain
Update PCI Id in "cpl_rx_phys_dsgl" header. In case pci_chan_id and
tx_chan_id are not derived from same queue, H/W can send request
completion indication before completing DMA Transfer.

Herbert, It would be good if fix can be merge to stable tree.
For 4.14 kernel, It requires some update to avoid mege conficts.

Signed-off-by: Harsh Jain 
---
 drivers/crypto/chelsio/chcr_algo.c   | 32 ++--
 drivers/crypto/chelsio/chcr_crypto.h |  2 ++
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/drivers/crypto/chelsio/chcr_algo.c 
b/drivers/crypto/chelsio/chcr_algo.c
index 5c539af..010bbf6 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -367,7 +367,8 @@ static inline void dsgl_walk_init(struct dsgl_walk *walk,
walk->to = (struct phys_sge_pairs *)(dsgl + 1);
 }
 
-static inline void dsgl_walk_end(struct dsgl_walk *walk, unsigned short qid)
+static inline void dsgl_walk_end(struct dsgl_walk *walk, unsigned short qid,
+int pci_chan_id)
 {
struct cpl_rx_phys_dsgl *phys_cpl;
 
@@ -385,6 +386,7 @@ static inline void dsgl_walk_end(struct dsgl_walk *walk, 
unsigned short qid)
phys_cpl->rss_hdr_int.opcode = CPL_RX_PHYS_ADDR;
phys_cpl->rss_hdr_int.qid = htons(qid);
phys_cpl->rss_hdr_int.hash_val = 0;
+   phys_cpl->rss_hdr_int.channel = pci_chan_id;
 }
 
 static inline void dsgl_walk_add_page(struct dsgl_walk *walk,
@@ -718,7 +720,7 @@ static inline void create_wreq(struct chcr_context *ctx,
FILL_WR_RX_Q_ID(ctx->dev->rx_channel_id, qid,
!!lcb, ctx->tx_qidx);
 
-   chcr_req->ulptx.cmd_dest = FILL_ULPTX_CMD_DEST(ctx->dev->tx_channel_id,
+   chcr_req->ulptx.cmd_dest = FILL_ULPTX_CMD_DEST(ctx->tx_chan_id,
   qid);
chcr_req->ulptx.len = htonl((DIV_ROUND_UP(len16, 16) -
 ((sizeof(chcr_req->wreq)) >> 4)));
@@ -1339,16 +1341,23 @@ static int chcr_device_init(struct chcr_context *ctx)
adap->vres.ncrypto_fc);
rxq_perchan = u_ctx->lldi.nrxq / u_ctx->lldi.nchan;
txq_perchan = ntxq / u_ctx->lldi.nchan;
-   rxq_idx = ctx->dev->tx_channel_id * rxq_perchan;
-   rxq_idx += id % rxq_perchan;
-   txq_idx = ctx->dev->tx_channel_id * txq_perchan;
-   txq_idx += id % txq_perchan;
spin_lock(>dev->lock_chcr_dev);
-   ctx->rx_qidx = rxq_idx;
-   ctx->tx_qidx = txq_idx;
+   ctx->tx_chan_id = ctx->dev->tx_channel_id;
ctx->dev->tx_channel_id = !ctx->dev->tx_channel_id;
ctx->dev->rx_channel_id = 0;
spin_unlock(>dev->lock_chcr_dev);
+   rxq_idx = ctx->tx_chan_id * rxq_perchan;
+   rxq_idx += id % rxq_perchan;
+   txq_idx = ctx->tx_chan_id * txq_perchan;
+   txq_idx += id % txq_perchan;
+   ctx->rx_qidx = rxq_idx;
+   ctx->tx_qidx = txq_idx;
+   /* Channel Id used by SGE to forward packet to Host.
+* Same value should be used in cpl_fw6_pld RSS_CH field
+* by FW. Driver programs PCI channel ID to be used in fw
+* at the time of queue allocation with value "pi->tx_chan"
+*/
+   ctx->pci_chan_id = txq_idx / txq_perchan;
}
 out:
return err;
@@ -2503,6 +2512,7 @@ void chcr_add_aead_dst_ent(struct aead_request *req,
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
struct dsgl_walk dsgl_walk;
unsigned int authsize = crypto_aead_authsize(tfm);
+   struct chcr_context *ctx = a_ctx(tfm);
u32 temp;
 
dsgl_walk_init(_walk, phys_cpl);
@@ -2512,7 +2522,7 @@ void chcr_add_aead_dst_ent(struct aead_request *req,
dsgl_walk_add_page(_walk, IV, >iv_dma);
temp = req->cryptlen + (reqctx->op ? -authsize : authsize);
dsgl_walk_add_sg(_walk, req->dst, temp, req->assoclen);
-   dsgl_walk_end(_walk, qid);
+   dsgl_walk_end(_walk, qid, ctx->pci_chan_id);
 }
 
 void chcr_add_cipher_src_ent(struct ablkcipher_request *req,
@@ -2544,6 +2554,8 @@ void chcr_add_cipher_dst_ent(struct ablkcipher_request 
*req,
 unsigned short qid)
 {
struct chcr_blkcipher_req_ctx *reqctx = ablkcipher_request_ctx(req);
+   struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(wrparam->req);
+   struct chcr_context *ctx = c_ctx(tfm);
struct dsgl_walk dsgl_walk;
 
dsgl_walk_init(_walk, phys_cpl);
@@ -2552,7 +2564,7 @@ void chcr_add_cipher_dst_ent(struct ablkcipher_request 
*req,
reqctx->dstsg = dsgl_walk.last_sg;
reqctx->dst_ofst = dsgl_walk.last_sg_len;
 
-   dsgl_walk_end(_walk, qid);
+   dsgl_walk_end(_walk, qid, ctx->pci_chan_id);
 }
 
 void 

[PATCH] crypto: tcrypt - remove remnants of pcomp-based zlib

2018-09-19 Thread Horia Geantă
Commit 110492183c4b ("crypto: compress - remove unused pcomp interface")
removed pcomp interface but missed cleaning up tcrypt.

Signed-off-by: Horia Geantă 
---
 crypto/tcrypt.c  | 7 +--
 crypto/testmgr.h | 2 --
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index bdde95e8d369..b4ed248095be 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -76,8 +76,7 @@ static char *check[] = {
"cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
"khazad", "wp512", "wp384", "wp256", "tnepres", "xeta",  "fcrypt",
"camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320",
-   "lzo", "cts", "zlib", "sha3-224", "sha3-256", "sha3-384", "sha3-512",
-   NULL
+   "lzo", "cts", "sha3-224", "sha3-256", "sha3-384", "sha3-512", NULL
 };
 
 static u32 block_sizes[] = { 16, 64, 256, 1024, 8192, 0 };
@@ -1878,10 +1877,6 @@ static int do_test(const char *alg, u32 type, u32 mask, 
int m, u32 num_mb)
ret += tcrypt_test("ecb(seed)");
break;
 
-   case 44:
-   ret += tcrypt_test("zlib");
-   break;
-
case 45:
ret += tcrypt_test("rfc4309(ccm(aes))");
break;
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index 0b3d7cadbe93..13b82af11bcd 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -24,8 +24,6 @@
 #ifndef _CRYPTO_TESTMGR_H
 #define _CRYPTO_TESTMGR_H
 
-#include 
-
 #define MAX_DIGEST_SIZE64
 #define MAX_TAP8
 
-- 
2.16.2



Hello Friend

2018-09-19 Thread Danny Chan
Dear,

I am working in financial firm in Asia. I have a business to transfer the sum 
of $19.000.000.00 of abandon fund in my office.
If you are,interested in the transaction reply on my email for more details.

Best Regards,
Danny Chan.