Re: SCTP_SOCKOPT_PEELOFF is missing SOCK_CLOEXEC (and SOCK_NONBLOCK)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 20, 2017 at 03:24:13PM +0200, Andreas Steinmetz wrote:
> [please CC me, I'm not subscribed]
> 
> It seems that if one does a getsockopt(SCTP_SOCKOPT_PEELOFF) a.k.a.
> sctp_peeloff(), even if the socket descriptor from which the
> association is to be peeled off has SOCK_CLOEXEC/SOCK_NONBLOCK set,
> the peeled off socket descriptor doesn't have so.
> 
> It would be advisable to either clone these flags or add an atomic
> version of SCTP_SOCKOPT_PEELOFF (accept4() style).
> 
> The missing SOCK_CLOEXEC requires unintentional additional locking
> which typically is prone to errors and can slow down processing.
> -- 
> Andreas Steinmetz                       SPAMmers use robotrap@xxxxxxxx
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


Try this patch, and confirm that it fixes the problem please?

Thanks!
Neil


diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index f16c8d9..a95e3d6 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4912,7 +4912,7 @@ int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp)
 		return -EINVAL;
 
 	/* Create a new socket.  */
-	err = sock_create(sk->sk_family, SOCK_SEQPACKET, IPPROTO_SCTP, &sock);
+	err = sock_create(sk->sk_family, sk->sk_type, IPPROTO_SCTP, &sock);
 	if (err < 0)
 		return err;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Networking Development]     [Linux OMAP]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux