mtd/drivers/mtd mtdchar-compat.c,1.2,1.3

spse at infradead.org spse at infradead.org
Tue Jul 16 12:52:03 EDT 2002


Update of /home/cvs/mtd/drivers/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv17564

Modified Files:
	mtdchar-compat.c 
Log Message:


- Set the default permissions on /dev/mtd/*ro to 444
- Disallow MEMWRITEOOB & MEMERASE ioctls if the device
  is not opened with write permissions.


Index: mtdchar-compat.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtdchar-compat.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- mtdchar-compat.c	2 Oct 2001 15:05:11 -0000	1.2
+++ mtdchar-compat.c	16 Jul 2002 16:52:01 -0000	1.3
@@ -330,7 +330,12 @@
 
 	case MEMERASE:
 	{
-		struct erase_info *erase=kmalloc(sizeof(struct erase_info),GFP_KERNEL);
+		struct erase_info *erase;
+
+		if(!(file->f_mode & 2))
+			return -EPERM;
+
+		erase=kmalloc(sizeof(struct erase_info),GFP_KERNEL);
 		if (!erase)
 			ret = -ENOMEM;
 		else {
@@ -381,6 +386,9 @@
 		void *databuf;
 		ssize_t retlen;
 		
+		if(!(file->f_mode & 2))
+			return -EPERM;
+
 		if (copy_from_user(&buf, (struct mtd_oob_buf *)arg, sizeof(struct mtd_oob_buf)))
 			return -EFAULT;
 		
@@ -523,7 +531,7 @@
 	sprintf(name, "%dro", mtd->index);
 	devfs_ro_handle[mtd->index] = devfs_register(devfs_dir_handle, name,
 			DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2+1,
-			S_IFCHR | S_IRUGO | S_IWUGO,
+			S_IFCHR | S_IRUGO,
 			&mtd_fops, NULL);
 }
 





More information about the linux-mtd-cvs mailing list