Re: [PATCH] minor socket ioctl cleanup for 2.5.30

2 messages, 2 authors, 2002-08-08 · open the first message on its own page

Re: [PATCH] minor socket ioctl cleanup for 2.5.30

From: Matthew Wilcox <hidden>
Date: 2002-08-08 17:42:06

On Fri, Aug 09, 2002 at 03:26:10AM +1000, James Morris wrote:
Yes, this patch is complete (see below), but is waiting on another fix to
go in (which I sent you recently).  The unification of the ioctl code also
now means SIOCSPGRP works exactly the same as F_SETOWN (i.e. it also works
now for sigio).
this patch is for information purposes only, right?  ;-)
quoted hunk
diff -urN -X dontdiff linux-2.5.27.orig/fs/fcntl.c linux-2.5.27.w1/fs/fcntl.c
--- linux-2.5.27.orig/fs/fcntl.c	Sun Jul 21 10:57:51 2002
+++ linux-2.5.27.w1/fs/fcntl.c	Sun Jul 28 18:23:03 2002
@@ -259,6 +259,18 @@
 	return 0;
 }
 
+long f_getown(struct file *filp)
+{
+	return filp->f_owner.pid;
+}
i still think this function shouldn't exist -- a direct reference is
no problem.
 		case F_SETOWN:
-			lock_kernel();
-			filp->f_owner.pid = arg;
-			filp->f_owner.uid = current->uid;
-			filp->f_owner.euid = current->euid;
 			err = 0;
-			if (S_ISSOCK (filp->f_dentry->d_inode->i_mode))
-				err = sock_fcntl (filp, F_SETOWN, arg);
+			lock_kernel();
+			f_setown(filp, arg);
 			unlock_kernel();
this is now hooked by the LSM folks so patch will need to be updated for
2.5.30.
quoted hunk
diff -urN -X dontdiff linux-2.5.27.orig/net/socket.c linux-2.5.27.w1/net/socket.c
--- linux-2.5.27.orig/net/socket.c	Sat Jul  6 11:01:02 2002
+++ linux-2.5.27.w1/net/socket.c	Sun Jul 28 22:08:37 2002
+	switch(cmd) {
+	case FIOSETOWN:
+	case SIOCSPGRP:
+		if (get_user(pid, (int *)arg))
+			err = -EFAULT;
+		else
+			f_setown(sock->file, pid);
+		break;
i'm pretty sure you need a lock_kernel + unlock_kernel around the else.
if two people are doing a F_SETOWN / SIOCSPGRP at the same time, you could
have a race.

-- 
Revolutions do not require corporate support.

Re: [PATCH] minor socket ioctl cleanup for 2.5.30

From: James Morris <hidden>
Date: 2002-08-08 17:46:05

On Thu, 8 Aug 2002, Matthew Wilcox wrote:
this patch is for information purposes only, right?  ;-)
Yes.
quoted
+long f_getown(struct file *filp)
+{
+	return filp->f_owner.pid;
+}
i still think this function shouldn't exist -- a direct reference is
no problem.
Agreed.
quoted
+			f_setown(filp, arg);
this is now hooked by the LSM folks so patch will need to be updated for
2.5.30.
Yep, a more recent version of this patch consolidates the LSM 
file_set_fowner hook into f_setown().


- James
-- 
James Morris
[off-list ref]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help