public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* NULL deref in drivers/md/dm-crypt.c:crypt_convert()
@ 2011-02-06 22:31 Jesper Juhl
  2011-02-06 22:50 ` Milan Broz
  0 siblings, 1 reply; 7+ messages in thread
From: Jesper Juhl @ 2011-02-06 22:31 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alexander Kjeldaas, David Woodhouse, Herbert Xu, Pekka Enberg

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.

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);
  	
  			atomic_inc(&ctx->pending);
  	
  			r = crypt_convert_block(cc, ctx, this_cc->req);
  	
  			switch (r) {
  			/* async */
 			case -EBUSY:
  				wait_for_completion(&ctx->restart);
  				INIT_COMPLETION(ctx->restart);
  				/* fall through*/
  			case -EINPROGRESS:
  				this_cc->req = NULL;
  				ctx->sector++;
  				continue;
...

If we take the first pass through the 'while' loop and hit the 
'-EINPROGRESS' case of the switch, then the second time around we'll pass 
a NULL 'this_cc->req' to 'crypt_convert_block()'. 'crypt_convert_block()' 
passes the pointer to 'ablkcipher_request_set_crypt()' which dereferences
it:
...
  	static inline void ablkcipher_request_set_crypt(
  		struct ablkcipher_request *req,
  		struct scatterlist *src, struct scatterlist *dst,
  		unsigned int nbytes, void *iv)
  	{
  		req->src = src;
...

That's going to go "BOOM" - definately no what we want, so we need a fix 
somehow...

-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-02-11 11:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-06 22:31 NULL deref in drivers/md/dm-crypt.c:crypt_convert() Jesper Juhl
2011-02-06 22:50 ` Milan Broz
2011-02-10 19:14   ` Jesper Juhl
2011-02-11  7:37     ` Milan Broz
2011-02-11  9:26       ` Jesper Juhl
2011-02-11 10:01         ` Milan Broz
2011-02-11 11:04           ` Jesper Juhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox