crypto: nx - off by one bug in nx_of_update_msc()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 15 Jul 2016 11:09:13 +0000 (14:09 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 19 Jul 2016 04:01:47 +0000 (12:01 +0800)
The props->ap[] array is defined like this:

struct alg_props ap[NX_MAX_FC][NX_MAX_MODE][3];

So we can see that if msc->fc and msc->mode are == to NX_MAX_FC or
NX_MAX_MODE then we're off by one.

Fixes: ae0222b7289d ('powerpc/crypto: nx driver code supporting nx encryption')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/nx/nx.c

index 0794f1cc00182f986f03673a1e2305ea1e15e094..42f0f229f7f776785b03bb1d4b80f7505dcd0502 100644 (file)
@@ -392,7 +392,7 @@ static void nx_of_update_msc(struct device   *dev,
                     ((bytes_so_far + sizeof(struct msc_triplet)) <= lenp) &&
                     i < msc->triplets;
                     i++) {
-                       if (msc->fc > NX_MAX_FC || msc->mode > NX_MAX_MODE) {
+                       if (msc->fc >= NX_MAX_FC || msc->mode >= NX_MAX_MODE) {
                                dev_err(dev, "unknown function code/mode "
                                        "combo: %d/%d (ignored)\n", msc->fc,
                                        msc->mode);