Skip to content

Commit

Permalink
[NET]: File descriptor loss while receiving SCM_RIGHTS
Browse files Browse the repository at this point in the history
If more than one file descriptor was sent with an SCM_RIGHTS message,
and on the receiving end, after installing a nonzero (but not all)
file descritpors the process runs out of fds, then the already
installed fds will be lost (userspace will have no way of knowing
about them).

The following patch makes sure, that at least the already installed
fds are sent to userspace.  It doesn't solve the issue of losing file
descriptors in case of an EFAULT on the userspace buffer.

Signed-off-by: Miklos Szeredi <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
szmi authored and David S. Miller committed Oct 12, 2006
1 parent 6aa2551 commit effee6a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions net/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)

if (i > 0) {
int cmlen = CMSG_COMPAT_LEN(i * sizeof(int));
if (!err)
err = put_user(SOL_SOCKET, &cm->cmsg_level);
err = put_user(SOL_SOCKET, &cm->cmsg_level);
if (!err)
err = put_user(SCM_RIGHTS, &cm->cmsg_type);
if (!err)
Expand Down
3 changes: 1 addition & 2 deletions net/core/scm.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
if (i > 0)
{
int cmlen = CMSG_LEN(i*sizeof(int));
if (!err)
err = put_user(SOL_SOCKET, &cm->cmsg_level);
err = put_user(SOL_SOCKET, &cm->cmsg_level);
if (!err)
err = put_user(SCM_RIGHTS, &cm->cmsg_type);
if (!err)
Expand Down

0 comments on commit effee6a

Please sign in to comment.