diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2012-10-21 13:42:28 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2012-10-24 09:21:18 -0400 |
commit | 9efade1b3e981f5064f9db9ca971b4dc7557ae42 (patch) | |
tree | 189522000152bea31874b18516290fb482f321e8 /crypto | |
parent | ddffeb8c4d0331609ef2581d84de4d763607bd37 (diff) |
crypto: cryptd - disable softirqs in cryptd_queue_worker to prevent data corruption
cryptd_queue_worker attempts to prevent simultaneous accesses to crypto
workqueue by cryptd_enqueue_request using preempt_disable/preempt_enable.
However cryptd_enqueue_request might be called from softirq context,
so add local_bh_disable/local_bh_enable to prevent data corruption and
panics.
Bug report at http://marc.info/?l=linux-crypto-vger&m=134858649616319&w=2
v2:
- Disable software interrupts instead of hardware interrupts
Cc: stable@vger.kernel.org
Reported-by: Gurucharan Shetty <gurucharan.shetty@gmail.com>
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/cryptd.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/crypto/cryptd.c b/crypto/cryptd.c index 671d4d6d14df..7bdd61b867c8 100644 --- a/crypto/cryptd.c +++ b/crypto/cryptd.c | |||
@@ -137,13 +137,18 @@ static void cryptd_queue_worker(struct work_struct *work) | |||
137 | struct crypto_async_request *req, *backlog; | 137 | struct crypto_async_request *req, *backlog; |
138 | 138 | ||
139 | cpu_queue = container_of(work, struct cryptd_cpu_queue, work); | 139 | cpu_queue = container_of(work, struct cryptd_cpu_queue, work); |
140 | /* Only handle one request at a time to avoid hogging crypto | 140 | /* |
141 | * workqueue. preempt_disable/enable is used to prevent | 141 | * Only handle one request at a time to avoid hogging crypto workqueue. |
142 | * being preempted by cryptd_enqueue_request() */ | 142 | * preempt_disable/enable is used to prevent being preempted by |
143 | * cryptd_enqueue_request(). local_bh_disable/enable is used to prevent | ||
144 | * cryptd_enqueue_request() being accessed from software interrupts. | ||
145 | */ | ||
146 | local_bh_disable(); | ||
143 | preempt_disable(); | 147 | preempt_disable(); |
144 | backlog = crypto_get_backlog(&cpu_queue->queue); | 148 | backlog = crypto_get_backlog(&cpu_queue->queue); |
145 | req = crypto_dequeue_request(&cpu_queue->queue); | 149 | req = crypto_dequeue_request(&cpu_queue->queue); |
146 | preempt_enable(); | 150 | preempt_enable(); |
151 | local_bh_enable(); | ||
147 | 152 | ||
148 | if (!req) | 153 | if (!req) |
149 | return; | 154 | return; |