[GIT] Digital signature library bugfix

From: James Morris
Date: Tue Sep 11 2012 - 23:41:02 EST


Please apply for v3.6.

The following changes since commit 0bd1189e239c76eb3a50e458548fbe7e4a5dfff1:
Linus Torvalds (1):
Merge branch 'for-3.6-fixes' of git://git.kernel.org/.../tj/wq

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git for-linus

Dmitry Kasatkin (1):
digsig: add hash size comparision on signature verification

lib/digsig.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

commit 83e7c8fb4347186f6723f4c7d176999becbb3830
Author: Dmitry Kasatkin <dmitry.kasatkin@xxxxxxxxx>
Date: Thu Sep 6 01:06:49 2012 +0300

digsig: add hash size comparision on signature verification

Commit b35e286a640f31d619a637332972498b51f3fd90 introduced the bug.

When pkcs_1_v1_5_decode_emsa() returns without error and hash sizes do not
match, hash comparision is not done and digsig_verify_rsa() returns no error.
This is a bug and this patch fixes it.

Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@xxxxxxxxx>
Signed-off-by: James Morris <james.l.morris@xxxxxxxxxx>

diff --git a/lib/digsig.c b/lib/digsig.c
index 286d558..77b1848 100644
--- a/lib/digsig.c
+++ b/lib/digsig.c
@@ -164,8 +164,12 @@ static int digsig_verify_rsa(struct key *key,

err = pkcs_1_v1_5_decode_emsa(out1, len, mblen, out2, &len);

- if (!err && len == hlen)
- err = memcmp(out2, h, hlen);
+ if (err || len != hlen) {
+ err = -EINVAL;
+ goto err;
+ }
+
+ err = memcmp(out2, h, hlen);

err:
mpi_free(in);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/