diff mbox

crypto: nx - off by one bug in nx_of_update_msc()

Message ID 20160715110912.GE9258@mwanda (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Dan Carpenter July 15, 2016, 11:09 a.m. UTC
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>

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Herbert Xu July 18, 2016, 10:23 a.m. UTC | #1
On Fri, Jul 15, 2016 at 02:09:13PM +0300, Dan Carpenter wrote:
> 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>

Patch applied.  Thanks.
diff mbox

Patch

diff --git a/drivers/crypto/nx/nx.c b/drivers/crypto/nx/nx.c
index 0794f1c..42f0f22 100644
--- a/drivers/crypto/nx/nx.c
+++ b/drivers/crypto/nx/nx.c
@@ -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);