All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xin Long <lucien.xin@gmail.com>
To: network dev <netdev@vger.kernel.org>, linux-sctp@vger.kernel.org
Cc: davem@davemloft.net,
	Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	Neil Horman <nhorman@tuxdriver.com>
Subject: [PATCH net 01/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt
Date: Mon, 18 Mar 2019 20:05:59 +0800	[thread overview]
Message-ID: <a866141aba7511710929fffd71b0b911ddda28f4.1552910681.git.lucien.xin@gmail.com> (raw)
In-Reply-To: <cover.1552910681.git.lucien.xin@gmail.com>
In-Reply-To: <cover.1552910681.git.lucien.xin@gmail.com>

From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

Currently if the user pass an invalid asoc_id to SCTP_DEFAULT_SEND_PARAM
on a TCP-style socket, it will silently ignore the new parameters.
That's because after not finding an asoc, it is checking asoc_id against
the known values of CURRENT/FUTURE/ALL values and that fails to match.

IOW, if the user supplies an invalid asoc id or not, it should either
match the current asoc or the socket itself so that it will inherit
these later. Fixes it by forcing asoc_id to SCTP_FUTURE_ASSOC in case it
is a TCP-style socket without an asoc, so that the values get set on the
socket.

Fixes: 707e45b3dc5a ("sctp: use SCTP_FUTURE_ASSOC and add SCTP_CURRENT_ASSOC for SCTP_DEFAULT_SEND_PARAM sockopt")
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
 net/sctp/socket.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 65b5386..d0e5c62 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3024,6 +3024,9 @@ static int sctp_setsockopt_default_send_param(struct sock *sk,
 		return 0;
 	}
 
+	if (sctp_style(sk, TCP))
+		info.sinfo_assoc_id = SCTP_FUTURE_ASSOC;
+
 	if (info.sinfo_assoc_id == SCTP_FUTURE_ASSOC ||
 	    info.sinfo_assoc_id == SCTP_ALL_ASSOC) {
 		sp->default_stream = info.sinfo_stream;
-- 
2.1.0


WARNING: multiple messages have this Message-ID (diff)
From: Xin Long <lucien.xin@gmail.com>
To: network dev <netdev@vger.kernel.org>, linux-sctp@vger.kernel.org
Cc: davem@davemloft.net,
	Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	Neil Horman <nhorman@tuxdriver.com>
Subject: [PATCH net 01/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockop
Date: Mon, 18 Mar 2019 12:05:59 +0000	[thread overview]
Message-ID: <a866141aba7511710929fffd71b0b911ddda28f4.1552910681.git.lucien.xin@gmail.com> (raw)
In-Reply-To: <cover.1552910681.git.lucien.xin@gmail.com>

From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

Currently if the user pass an invalid asoc_id to SCTP_DEFAULT_SEND_PARAM
on a TCP-style socket, it will silently ignore the new parameters.
That's because after not finding an asoc, it is checking asoc_id against
the known values of CURRENT/FUTURE/ALL values and that fails to match.

IOW, if the user supplies an invalid asoc id or not, it should either
match the current asoc or the socket itself so that it will inherit
these later. Fixes it by forcing asoc_id to SCTP_FUTURE_ASSOC in case it
is a TCP-style socket without an asoc, so that the values get set on the
socket.

Fixes: 707e45b3dc5a ("sctp: use SCTP_FUTURE_ASSOC and add SCTP_CURRENT_ASSOC for SCTP_DEFAULT_SEND_PARAM sockopt")
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
---
 net/sctp/socket.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 65b5386..d0e5c62 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3024,6 +3024,9 @@ static int sctp_setsockopt_default_send_param(struct sock *sk,
 		return 0;
 	}
 
+	if (sctp_style(sk, TCP))
+		info.sinfo_assoc_id = SCTP_FUTURE_ASSOC;
+
 	if (info.sinfo_assoc_id = SCTP_FUTURE_ASSOC ||
 	    info.sinfo_assoc_id = SCTP_ALL_ASSOC) {
 		sp->default_stream = info.sinfo_stream;
-- 
2.1.0

  reply	other threads:[~2019-03-18 12:06 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-18 12:05 [PATCH net 00/13] sctp: fix ignoring asoc_id for tcp-style sockets on some setsockopts Xin Long
2019-03-18 12:05 ` Xin Long
2019-03-18 12:05 ` Xin Long [this message]
2019-03-18 12:05   ` [PATCH net 01/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockop Xin Long
2019-03-18 12:06   ` [PATCH net 02/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DELAYED_SACK sockopt Xin Long
2019-03-18 12:06     ` Xin Long
2019-03-18 12:06     ` [PATCH net 03/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SNDINFO sockopt Xin Long
2019-03-18 12:06       ` Xin Long
2019-03-18 12:06       ` [PATCH net 04/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_CONTEXT sockopt Xin Long
2019-03-18 12:06         ` Xin Long
2019-03-18 12:06         ` [PATCH net 05/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_MAX_BURST sockopt Xin Long
2019-03-18 12:06           ` Xin Long
2019-03-18 12:06           ` [PATCH net 06/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_AUTH_KEY sockopt Xin Long
2019-03-18 12:06             ` Xin Long
2019-03-18 12:06             ` [PATCH net 07/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_AUTH_ACTIVE_KEY sockopt Xin Long
2019-03-18 12:06               ` Xin Long
2019-03-18 12:06               ` [PATCH net 08/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_AUTH_DELETE_KEY sockopt Xin Long
2019-03-18 12:06                 ` Xin Long
2019-03-18 12:06                 ` [PATCH net 09/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_AUTH_DEACTIVATE_KEY sockopt Xin Long
2019-03-18 12:06                   ` [PATCH net 09/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_AUTH_DEACTIVATE_KEY socko Xin Long
2019-03-18 12:06                   ` [PATCH net 10/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_PRINFO sockopt Xin Long
2019-03-18 12:06                     ` Xin Long
2019-03-18 12:06                     ` [PATCH net 11/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_ENABLE_STREAM_RESET sockopt Xin Long
2019-03-18 12:06                       ` [PATCH net 11/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_ENABLE_STREAM_RESET socko Xin Long
2019-03-18 12:06                       ` [PATCH net 12/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_EVENT sockopt Xin Long
2019-03-18 12:06                         ` Xin Long
2019-03-18 12:06                         ` [PATCH net 13/13] sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_STREAM_SCHEDULER sockopt Xin Long
2019-03-18 12:06                           ` Xin Long
2019-03-19  1:31 ` [PATCH net 00/13] sctp: fix ignoring asoc_id for tcp-style sockets on some setsockopts David Miller
2019-03-19  1:31   ` David Miller

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=a866141aba7511710929fffd71b0b911ddda28f4.1552910681.git.lucien.xin@gmail.com \
    --to=lucien.xin@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-sctp@vger.kernel.org \
    --cc=marcelo.leitner@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.