lkml.org 
[lkml]   [2007]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCHv5 4/5] Allow setting O_NONBLOCK flag for new sockets
Ulrich Drepper a écrit :
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Eric Dumazet wrote:
>> 1) Can the fd passing with recvmsg() on AF_UNIX also gets O_CLOEXEC
>> support ?
>
> Already there, see MSG_CMSG_CLOEXEC.

OK, but maybe for consistency, we might accept the two mechanisms.

The one added in 2.6.23, and the more general indirect() way.

(See attached untested patch for the general idea, you'll have to also add
#if INDSYSCALL(recvmsg)
case INDSYSCALL(recvmsg):
#endif
)

>> 2) Why this O_NONBLOCK ability is needed for sockets ? Is it a security
>> issue, and if yes could you remind it to me ?
>
> No security issue. But look at any correct network program, all need to
> set the mode to non-blocking. Adding this support to the syscall comes
> at almost no cost and it cuts the cost for every program down by one or
> two syscalls.
>

OK, thank you.

diff --git a/net/core/scm.c b/net/core/scm.c
index 100ba6d..38a0b77 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -230,11 +230,12 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
i++, cmfptr++)
{
int new_fd;
+ int flags = INDIRECT_PARAM(file_flags, flags) & O_CLOEXEC;
err = security_file_receive(fp[i]);
if (err)
break;
err = get_unused_fd_flags(MSG_CMSG_CLOEXEC & msg->msg_flags
- ? O_CLOEXEC : 0);
+ ? O_CLOEXEC : flags);
if (err < 0)
break;
new_fd = err;
\
 
 \ /
  Last update: 2007-11-24 09:33    [W:0.083 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site