Skip to contentSkip to conversation

Subject: [PATCH] crypto: s390: Remove BKL in zcrypt_open

PATCH John Kacur 1 participant 2 messages Oct 18, 2009 – Oct 21, 2009

Subsystems (2)
lore
Share & tools
lore

John Kacur

author
#0 lore raw
Quoted 1 line

From 7673a4ec79b4b4edf3cead3ed88a93d6081c44f0 Mon Sep 17 00:00:00 2001

From: John Kacur <[email protected]>
Date: Mon, 19 Oct 2009 00:44:03 +0200
Subject: [PATCH] crypto: s390: Remove BKL in zcrypt_open

Do we really need to look an atomic_inc? I don't think so.

---
 drivers/s390/crypto/zcrypt_api.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/s390/crypto/zcrypt_api.c +0 -3
index 65b6a96..e55e311 100644
@@ -34,7 +34,6 @@
 #include <linux/fs.h>
 #include <linux/proc_fs.h>
 #include <linux/compat.h>
-#include <linux/smp_lock.h>
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
 #include <linux/hw_random.h>
@@ -299,9 +298,7 @@ static ssize_t zcrypt_write(struct file *filp, const char __user *buf,
  */
 static int zcrypt_open(struct inode *inode, struct file *filp)
 {
-	lock_kernel();
 	atomic_inc(&zcrypt_open_count);
-	unlock_kernel();
 	return 0;
 }
 
Signature · 1 line
1.6.0.6
author
#1 lore raw

I took a deeper look at this after all of the great information form folks like Arnd and Thomas about what to be careful of. I think this patch is safe to do. I have respun it and explicitly set llseek to nollseek.

It is still RFC, or pending an ack by the S390 zcrypt folks who can actually test it.

Thanks

From 6d3fad58dbeae2e37aeb093197c25a57018ab8fd Mon Sep 17 00:00:00 2001
From: John Kacur <[email protected]>
Date: Mon, 19 Oct 2009 00:44:03 +0200
Subject: [PATCH] crypto: s390: Remove BKL in zcrypt_open

Remove the BKL in zcrypt_open and explicitly set llseek = nollseek.

- zcrypt_read, zcrypt_write, just return -EPERM
- zcrypt_open only has an atomic_inc which doesn't need to be locked.
- The bkl in the zcrypt_open function could conceivably be serializing the misc_register() in zcrypt_api_init(). However, the rest of the code is protected by the zcrypt_rng_mutex and the ioctl is already an unlocked_ioctl kind.

---
 drivers/s390/crypto/zcrypt_api.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/s390/crypto/zcrypt_api.c +1 -3
index 65b6a96..22c9b0a 100644
@@ -34,7 +34,6 @@
 #include <linux/fs.h>
 #include <linux/proc_fs.h>
 #include <linux/compat.h>
-#include <linux/smp_lock.h>
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
 #include <linux/hw_random.h>
@@ -299,9 +298,7 @@ static ssize_t zcrypt_write(struct file *filp, const char __user *buf,
  */
 static int zcrypt_open(struct inode *inode, struct file *filp)
 {
-	lock_kernel();
 	atomic_inc(&zcrypt_open_count);
-	unlock_kernel();
 	return 0;
 }
 
@@ -888,6 +885,7 @@ static long zcrypt_compat_ioctl(struct file *filp, unsigned int cmd,
  */
 static const struct file_operations zcrypt_fops = {
 	.owner		= THIS_MODULE,
+	.llseek		= no_llseek,
 	.read		= zcrypt_read,
 	.write		= zcrypt_write,
 	.unlocked_ioctl	= zcrypt_unlocked_ioctl,
Signature · 1 line
1.6.0.6