double unlock in rng_dev_read()
It seems like we unlock rng_mutex twice (2.6.33-rc1).
drivers/char/hw_random/core.c
151 mutex_unlock(&rng_mutex);
152
153 if (need_resched())
154 schedule_timeout_interruptible(1);
155
156 if (signal_pending(current)) {
157 err = -ERESTARTSYS;
158 goto out;
159 }
160 }
161 out_unlock:
162 mutex_unlock(&rng_mutex);
regards,
dan carpenter
Herbert Xu
maintainerQuoted 15 lines · Dan Carpenter
It seems like we unlock
rng_mutextwice (2.6.33-rc1).
drivers/char/hw_random/core.c151 mutex_unlock(&rng_mutex); 152 153 if (need_resched()) 154 schedule_timeout_interruptible(1); 155 156 if (signal_pending(current)) { 157 err = -ERESTARTSYS; 158 goto out; 159 } 160 } 161 out_unlock: 162 mutex_unlock(&rng_mutex);
Hmm, are you sure you didn't mistake out for out_unlock? :)
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 17 lines · Herbert Xu
Quoted 15 lines · Dan Carpenter
It seems like we unlock
rng_mutextwice (2.6.33-rc1).
drivers/char/hw_random/core.c151 mutex_unlock(&rng_mutex); 152 153 if (need_resched()) 154 schedule_timeout_interruptible(1); 155 156 if (signal_pending(current)) { 157 err = -ERESTARTSYS; 158 goto out; 159 } 160 } 161 out_unlock: 162 mutex_unlock(&rng_mutex);
Quoted 1 line
Hmm, are you sure you didn't mistake out for
out_unlock? :)
No no. I mean when size hits zero we are rng_mutex is unlocked.
regards,
dan carpenter
Quoted 5 lines
Signature · 4 lines
Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Herbert Xu
maintainerQuoted 2 lines · Dan Carpenter
No no. I mean when size hits zero we are
rng_mutexis unlocked.
Good catch! I'll add this patch to the tree. Please take a look at it. Thanks!
commit f5908267b67917b8cbd98b27fd2be9b5f62ec76f
Author: Herbert Xu <[email protected]> Date: Wed Dec 23 23:22:34 2009 +0800
hwrng: core - Fix double unlock in rng_dev_read
When the loop terminates with size == 0 in rng_dev_read we will unlock the rng mutex twice.
drivers/char/hw_random/core.c +3 -3
@@ -158,10 +158,11 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf, goto out; } } -out_unlock: -mutex_unlock (&rng_mutex); out:return ret ? : err; +out_unlock: +mutex_unlock (&rng_mutex); + goto out; } --
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Dan Carpenter
Acked-byQuoted 7 lines · Herbert Xu
Quoted 2 lines · Dan Carpenter
No no. I mean when size hits zero we are
rng_mutexis unlocked.Good catch! I'll add this patch to the tree. Please take a look at it. Thanks!
Great.
regards,
dan carpenter
Quoted 34 lines
commit
f5908267b67917b8cbd98b27fd2be9b5f62ec76fAuthor: Herbert Xu <[email protected]> Date: Wed Dec 23 23:22:34 2009 +0800hwrng: core - Fix double unlock in
rng_dev_readWhen the loop terminates with size == 0 in
rng_dev_readwe will unlock the rng mutex twice.Reported-by Dan Carpenter <[email protected]>Signed-off-by Herbert Xu <[email protected]>drivers/char/hw_random/core.c +3
-3@@ -158,10 +158,11 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf, goto out; } } -out_unlock: -mutex_unlock (&rng_mutex); out:return ret ? : err; +out_unlock: +mutex_unlock (&rng_mutex); + goto out; } --Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt