From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Xin Long <lucien.xin@gmail.com>
Cc: network dev <netdev@vger.kernel.org>,
linux-sctp@vger.kernel.org, davem@davemloft.net,
Neil Horman <nhorman@tuxdriver.com>
Subject: Re: [PATCH net] sctp: not allow to set asoc prsctp_enable by sockopt
Date: Thu, 15 Nov 2018 15:22:21 -0200 [thread overview]
Message-ID: <20181115172221.GA3601@localhost.localdomain> (raw)
In-Reply-To: <7417f2d10de933afb69b832d9a30a210f42a16bb.1542280468.git.lucien.xin@gmail.com>
On Thu, Nov 15, 2018 at 07:14:28PM +0800, Xin Long wrote:
> As rfc7496#section4.5 says about SCTP_PR_SUPPORTED:
>
> This socket option allows the enabling or disabling of the
> negotiation of PR-SCTP support for future associations. For existing
> associations, it allows one to query whether or not PR-SCTP support
> was negotiated on a particular association.
>
> It means only sctp sock's prsctp_enable can be set.
>
> Note that for the limitation of SCTP_{CURRENT|ALL}_ASSOC, we will
> add it when introducing SCTP_{FUTURE|CURRENT|ALL}_ASSOC for linux
> sctp in another patchset.
>
> Fixes: 28aa4c26fce2 ("sctp: add SCTP_PR_SUPPORTED on sctp sockopt")
> Reported-by: Ying Xu <yinxu@redhat.com>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
> net/sctp/socket.c | 13 +++----------
> 1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 739f3e5..e9b8232 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -3940,7 +3940,6 @@ static int sctp_setsockopt_pr_supported(struct sock *sk,
> unsigned int optlen)
> {
> struct sctp_assoc_value params;
> - struct sctp_association *asoc;
> int retval = -EINVAL;
>
> if (optlen != sizeof(params))
> @@ -3951,16 +3950,10 @@ static int sctp_setsockopt_pr_supported(struct sock *sk,
> goto out;
> }
>
> - asoc = sctp_id2assoc(sk, params.assoc_id);
> - if (asoc) {
> - asoc->prsctp_enable = !!params.assoc_value;
> - } else if (!params.assoc_id) {
> - struct sctp_sock *sp = sctp_sk(sk);
> -
> - sp->ep->prsctp_enable = !!params.assoc_value;
> - } else {
> + if (sctp_style(sk, UDP) && sctp_id2assoc(sk, params.assoc_id))
This would allow using a non-existent assoc id on UDP-style sockets to
set it at the socket, which is not expected. It should be more like:
+ if (sctp_style(sk, UDP) && params.assoc_id)
> goto out;
> - }
> +
> + sctp_sk(sk)->ep->prsctp_enable = !!params.assoc_value;
>
> retval = 0;
>
> --
> 2.1.0
>
next prev parent reply other threads:[~2018-11-16 3:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 11:14 [PATCH net] sctp: not allow to set asoc prsctp_enable by sockopt Xin Long
2018-11-15 17:22 ` Marcelo Ricardo Leitner [this message]
2018-11-15 21:43 ` Neil Horman
2018-11-15 22:25 ` Marcelo Ricardo Leitner
2018-11-15 23:25 ` Neil Horman
[not found] ` <20181115234101.GC31918@localhost.localdomain>
2018-11-16 15:12 ` Neil Horman
2018-11-18 7:02 ` Xin Long
2018-11-19 4:14 ` Marcelo Ricardo Leitner
2018-11-19 17:26 ` Neil Horman
2018-11-16 6:42 ` Xin Long
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=20181115172221.GA3601@localhost.localdomain \
--to=marcelo.leitner@gmail.com \
--cc=davem@davemloft.net \
--cc=linux-sctp@vger.kernel.org \
--cc=lucien.xin@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).