Skip to contentSkip to conversation

simplify networking fcntl

PATCH In review Matthew Wilcox 2 participants 4 messages Jul 7, 2002

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 simplify networking fcntl

Sockets haven't had their own special ioctls since before linux 2.0.29. sock_no_fcntl is only called for F_SETOWN, so it can stand some simplification.

fs/fcntl.c +0 -4
diff -urNX dontdiff linux-2.5.24/fs/fcntl.c linux-2.5.24-mm/fs/fcntl.c
@@ -347,10 +345,6 @@
 			err = fcntl_dirnotify(fd, filp, arg);
 			break;
 		default:
-			/* sockets need a few special fcntls. */
-			err = -EINVAL;
-			if (S_ISSOCK (filp->f_dentry->d_inode->i_mode))
-				err = sock_fcntl (filp, cmd, arg);
 			break;
 	}
 
net/core/sock.c +9 -24
diff -urNX dontdiff linux-2.5.24/net/core/sock.c linux-2.5.24-mm/net/core/sock.c
@@ -1048,32 +1048,17 @@
 	return -EOPNOTSUPP;
 }
 
-/* 
- * Note: if you add something that sleeps here then change sock_fcntl()
- *       to do proper fd locking.
- */
 int sock_no_fcntl(struct socket *sock, unsigned int cmd, unsigned long arg)
 {
-	struct sock *sk = sock->sk;
-
-	switch(cmd)
-	{
-		case F_SETOWN:
-			/*
-			 * This is a little restrictive, but it's the only
-			 * way to make sure that you can't send a sigurg to
-			 * another process.
-			 */
-			if (current->pgrp != -arg &&
-				current->pid != arg &&
-				!capable(CAP_KILL)) return(-EPERM);
-			sk->proc = arg;
-			return(0);
-		case F_GETOWN:
-			return(sk->proc);
-		default:
-			return(-EINVAL);
-	}
+	/*
+	 * TCP doesn't use the standard fasync method to deliver
+	 * SIGURG and SIGIO, so we check permissions at setup time.
+	 * This should be fixed.
+	 */
+	if (current->pgrp != -arg && current->pid != arg && !capable(CAP_KILL))
+		return -EPERM;
+	sock->sk->proc = arg;
+	return 0;
 }
 
 int sock_no_sendmsg(struct socket *sock, struct msghdr *m, int flags,
Signature · 1 line
Revolutions do not require corporate support.
#1 lore raw

Hello!

Quoted 2 lines

sock_no_fcntl is only called for F_SETOWN, so it can stand some simplification.

sk->proc. Sorry, generic F_SETOWN does not handle SIGURG.

Alexey

#2 lore raw
Quoted 6 lines · On Sun, Jul 07, 2002 at 09:09:02PM +0400, [email protected] wrote:

Hello!

Quoted 2 lines

sock_no_fcntl is only called for F_SETOWN, so it can stand some simplification.

sk->proc. Sorry, generic F_SETOWN does not handle SIGURG.

indeed -- did you read the patch? i simplified sock_no_fcntl so it _only_ handled F_SETOWN, which is the only time it's called.

Signature · 1 line
Revolutions do not require corporate support.
#3 lore raw

Hello!

Quoted 2 lines

indeed -- did you read the patch? i simplified sock_no_fcntl so it _only_ handled F_SETOWN, which is the only time it's called.

Pardon, I interpreted it wrongly, decided you removed the call down, which would be right thing to do, only taking care of SIGURG. SIGIO is not a problem, this handled by generic code.

Andi reminded about patch by James Morris doing something with this.

Alexey