The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@debian.org>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel@vger.kernel.org, linux-net@vger.kernel.org
Subject: [PATCH] simplify networking fcntl
Date: Sun, 7 Jul 2002 17:15:55 +0100	[thread overview]
Message-ID: <20020707171555.L27706@parcelfarce.linux.theplanet.co.uk> (raw)


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.

diff -urNX dontdiff linux-2.5.24/fs/fcntl.c linux-2.5.24-mm/fs/fcntl.c
--- linux-2.5.24/fs/fcntl.c	Sun Jun  9 06:09:49 2002
+++ linux-2.5.24-mm/fs/fcntl.c	Tue Jul  2 10:55:29 2002
@@ -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;
 	}
 
diff -urNX dontdiff linux-2.5.24/net/core/sock.c linux-2.5.24-mm/net/core/sock.c
--- linux-2.5.24/net/core/sock.c	Sun Jun  2 18:44:52 2002
+++ linux-2.5.24-mm/net/core/sock.c	Tue Jul  2 10:37:58 2002
@@ -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,

-- 
Revolutions do not require corporate support.

             reply	other threads:[~2002-07-07 16:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-07 16:15 Matthew Wilcox [this message]
2002-07-07 17:09 ` [PATCH] simplify networking fcntl kuznet
2002-07-07 18:55   ` Matthew Wilcox
2002-07-07 20:31     ` kuznet
     [not found] <20020707171555.L27706@parcelfarce.linux.theplanet.co.uk.suse.lists.linux.kernel>
2002-07-07 16:54 ` Andi Kleen
2002-07-07 18:53   ` Matthew Wilcox
2002-07-08  6:04   ` James Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020707171555.L27706@parcelfarce.linux.theplanet.co.uk \
    --to=willy@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-net@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox