Re: NULL deref in drivers/md/dm-crypt.c:crypt_convert()

From: Milan Broz
Date: Sun Feb 06 2011 - 17:51:40 EST


On 02/06/2011 11:31 PM, Jesper Juhl wrote:
> The coverity checker found this. I don't know how to fix it, so I'll just
> report it and hope that someone else can address the issue.

Hi,
can I see the plain output from the coverity check somewhere?

>
> In drivers/md/dm-crypt.c:crypt_convert() we have this code:
> ...
> while(ctx->idx_in < ctx->bio_in->bi_vcnt &&
> ctx->idx_out < ctx->bio_out->bi_vcnt) {
>
> crypt_alloc_req(cc, ctx);

Here in crypt_alloc_req() you have:

struct crypt_cpu *this_cc = this_crypt_config(cc);
if (!this_cc->req)
this_cc->req = mempool_alloc(cc->req_pool, GFP_NOIO);

>
> atomic_inc(&ctx->pending);
>
> r = crypt_convert_block(cc, ctx, this_cc->req);

this_cc is: struct crypt_cpu *this_cc = this_crypt_config(cc);
and because it is always running on the same CPU,
this_cc->req cannot be NULL here, because it was allocated
in crypt_alloc_req().

It is false positive here.

Milan
--
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/