|
|
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote: > PATCH 16/23 > ... > Should we check ctx.dsize < sizeof(ctx.descbuf) - 4 > in case caller is modified in the future? Probably. I'm going to assume that BUG_ON() is a good enough check for the moment as I assume the prefix will probably be generated at compile time. David --- diff --git a/security/keys/crypto/pgp_preload.c b/security/keys/crypto/pgp_preload.c index 25154e3..ef53902 100644 --- a/security/keys/crypto/pgp_preload.c +++ b/security/keys/crypto/pgp_preload.c @@ -35,6 +35,9 @@ static int __init found_pgp_key(struct pgp_parse_context *context, container_of(context, struct preload_pgp_keys_context, pgp); key_ref_t key; + if (ctx->key_n > 999) + return 0; /* Don't overrun descbuf */ + sprintf(ctx->descbuf + ctx->dsize, "%d", ctx->key_n++); key = key_create_or_update(ctx->keyring, "crypto", ctx->descbuf, @@ -84,6 +87,7 @@ int __init preload_pgp_keys(const u8 *pgpdata, size_t pgpdatalen, ctx.keyring = make_key_ref(keyring, 1); ctx.key_n = 0; ctx.dsize = strlen(descprefix); + BUG_ON(ctx.dsize > sizeof(ctx.descbuf) - 4); strcpy(ctx.descbuf, descprefix); return pgp_parse_packets(pgpdata, pgpdatalen, &ctx.pgp); -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
[Fedora Maintainers] [Fedora Desktop] [Fedora SELinux] [Yosemite News] [Yosemite Photos] [KDE Users] [Fedora Tools]