From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-08 11:27:55
A helper sctp_ulpevent_nofity_peer_addr_change() will be extracted
to make peer_addr_change event and enqueue it, and the helper will
be called in sctp_assoc_add_peer() to send SCTP_ADDR_ADDED event.
This event is described in rfc6458#section-6.1.2:
SCTP_ADDR_ADDED: The address is now part of the association.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
include/net/sctp/ulpevent.h | 9 ++-------
net/sctp/associola.c | 19 ++++++-------------
net/sctp/ulpevent.c | 18 +++++++++++++++++-
3 files changed, 25 insertions(+), 21 deletions(-)
@@ -707,6 +707,8 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,list_add_tail_rcu(&peer->transports,&asoc->peer.transport_addr_list);asoc->peer.transport_count++;+sctp_ulpevent_nofity_peer_addr_change(peer,SCTP_ADDR_ADDED,0);+/* If we do not yet have a primary path, set one. */if(!asoc->peer.primary_path){sctp_assoc_set_primary(asoc,peer);
@@ -781,10 +783,8 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,enumsctp_transport_cmdcommand,sctp_sn_error_terror){-structsctp_ulpevent*event;-structsockaddr_storageaddr;-intspc_state=0;boolulp_notify=true;+intspc_state=0;/* Record the transition on the transport. */switch(command){
@@ -836,16 +836,9 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,/* Generate and send a SCTP_PEER_ADDR_CHANGE notification*totheuser.*/-if(ulp_notify){-memset(&addr,0,sizeof(structsockaddr_storage));-memcpy(&addr,&transport->ipaddr,-transport->af_specific->sockaddr_len);--event=sctp_ulpevent_make_peer_addr_change(asoc,&addr,-0,spc_state,error,GFP_ATOMIC);-if(event)-asoc->stream.si->enqueue_event(&asoc->ulpq,event);-}+if(ulp_notify)+sctp_ulpevent_nofity_peer_addr_change(transport,+spc_state,error);/* Select new active and retran paths. */sctp_select_active_and_retran_path(asoc);
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-08 11:28:03
sctp_ulpevent_nofity_peer_addr_change() is called in
sctp_assoc_rm_peer() to send SCTP_ADDR_REMOVED event
when this transport is removed from the asoc.
This event is described in rfc6458#section-6.1.2:
SCTP_ADDR_REMOVED: The address is no longer part of the
association.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/sctp/associola.c | 1 +
1 file changed, 1 insertion(+)
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-08 11:28:11
sctp_ulpevent_nofity_peer_addr_change() would be called in
sctp_assoc_set_primary() to send SCTP_ADDR_MADE_PRIM event
when this transport is set to the primary path of the asoc.
This event is described in rfc6458#section-6.1.2:
SCTP_ADDR_MADE_PRIM: This address has now been made the primary
destination address. This notification is provided whenever an
address is made primary.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/sctp/associola.c | 2 ++
1 file changed, 2 insertions(+)
@@ -429,6 +429,8 @@ void sctp_assoc_set_primary(struct sctp_association *asoc,changeover=1;asoc->peer.primary_path=transport;+sctp_ulpevent_nofity_peer_addr_change(transport,+SCTP_ADDR_MADE_PRIM,0);/* Set a default msg_name for events. */memcpy(&asoc->peer.primary_addr,&transport->ipaddr,
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-08 11:28:18
This patch is to add a new event SCTP_SEND_FAILED_EVENT described in
rfc6458#section-6.1.11. It's a update of SCTP_SEND_FAILED event:
struct sctp_sndrcvinfo ssf_info is replaced with
struct sctp_sndinfo ssfe_info in struct sctp_send_failed_event.
SCTP_SEND_FAILED is being deprecated, but we don't remove it in this
patch. Both are being processed in sctp_datamsg_destroy() when the
corresp event flag is set.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
include/net/sctp/ulpevent.h | 7 +++++++
include/uapi/linux/sctp.h | 16 +++++++++++++++-
net/sctp/chunk.c | 40 +++++++++++++++++++---------------------
net/sctp/ulpevent.c | 39 +++++++++++++++++++++++++++++++++++++++
4 files changed, 80 insertions(+), 22 deletions(-)
@@ -75,41 +75,39 @@ static void sctp_datamsg_destroy(struct sctp_datamsg *msg)structlist_head*pos,*temp;structsctp_chunk*chunk;structsctp_ulpevent*ev;-interror=0,notify;--/* If we failed, we may need to notify. */-notify=msg->send_failed?-1:0;+interror,sent;/* Release all references. */list_for_each_safe(pos,temp,&msg->chunks){list_del_init(pos);chunk=list_entry(pos,structsctp_chunk,frag_list);-/* Check whether we _really_ need to notify. */-if(notify<0){-asoc=chunk->asoc;-if(msg->send_error)-error=msg->send_error;-else-error=asoc->outqueue.error;--notify=sctp_ulpevent_type_enabled(asoc->subscribe,-SCTP_SEND_FAILED);++if(!msg->send_failed){+sctp_chunk_put(chunk);+continue;}-/* Generate a SEND FAILED event only if enabled. */-if(notify>0){-intsent;-if(chunk->has_tsn)-sent=SCTP_DATA_SENT;-else-sent=SCTP_DATA_UNSENT;+asoc=chunk->asoc;+error=msg->send_error?:asoc->outqueue.error;+sent=chunk->has_tsn?SCTP_DATA_SENT:SCTP_DATA_UNSENT;+if(sctp_ulpevent_type_enabled(asoc->subscribe,+SCTP_SEND_FAILED)){ev=sctp_ulpevent_make_send_failed(asoc,chunk,sent,error,GFP_ATOMIC);if(ev)asoc->stream.si->enqueue_event(&asoc->ulpq,ev);}+if(sctp_ulpevent_type_enabled(asoc->subscribe,+SCTP_SEND_FAILED_EVENT)){+ev=sctp_ulpevent_make_send_failed_event(asoc,chunk,+sent,error,+GFP_ATOMIC);+if(ev)+asoc->stream.si->enqueue_event(&asoc->ulpq,ev);+}+sctp_chunk_put(chunk);}
From: Jakub Kicinski <hidden> Date: 2019-10-10 00:13:38
On Tue, 8 Oct 2019 19:27:32 +0800, Xin Long wrote:
There are 4 events defined in rfc5061 missed in linux sctp:
SCTP_ADDR_ADDED, SCTP_ADDR_REMOVED, SCTP_ADDR_MADE_PRIM and
SCTP_SEND_FAILED_EVENT.
This patchset is to add them up.
From: Harald Welte <laforge@gnumonks.org> Date: 2020-04-19 10:43:38
Dear Linux SCTP developers,
this patchset (merged back in Q4/2019) has broken ABI compatibility, more
or less exactly as it was discussed/predicted in Message-Id
[off-list ref]
"[PATCH net] sctp: make sctp_setsockopt_events() less strict about the option length"
on this very list in February 2019.
The process to reproduce this is quite simple:
* upgrade your kernel / uapi headers to a later version (happens
automatically on most distributions as linux-libc-dev is upgraded)
* rebuild any application using SCTP_EVENTS which was working perfectly
fine before
* fail to execute on any older kernels
This can be a severe issue in production systems where you may not
upgrade the kernel until/unless a severe security issue actually makes
you do so.
Those steps above can very well happen on different machines, i.e. your
build server having a more recent linux-libc-dev package (and hence
linux/sctp.h) than some of the users in the field are running kernels.
I think this is a severe problem that affects portability of binaries
between differnt Linux versions and hence the kind of ABI breakage that
the kernel exactly doesn't want to have.
The point here is that there is no check if any of those newly-added
events at the end are actually used. I can accept that programs using
those new options will not run on older kernels - obviously. But old
programs that have no interest in new events being added should run just
fine, even if rebuilt against modern headers.
In the kernel setsockopt handling coee: Why not simply check if any of
the newly-added events are actually set to non-zero? If those are all
zero, we can assume that the code doesn't use them.
Yes, for all the existing kernels out there it's too late as they simply
only have the size based check. But I'm worried history will repeat
itself...
Thanks for your consideration.
--
- Harald Welte [off-list ref] http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)
From: Harald Welte <laforge@gnumonks.org> Date: 2020-05-01 13:16:27
Dear Linux SCTP developers,
On Sun, Apr 19, 2020 at 12:25:36PM +0200, Harald Welte wrote:
this patchset (merged back in Q4/2019) has broken ABI compatibility, more
or less exactly as it was discussed/predicted in Message-Id
[off-list ref]
"[PATCH net] sctp: make sctp_setsockopt_events() less strict about the option length"
on this very list in February 2019.
does the lack of any follow-up so far seems to indicate nobody considers
this a problem? Even without any feedback from the Linux kernel
developers, I would be curious to hear What do other SCTP users say.
So far I have a somewhat difficult time understanding that I would be
the only one worried about ABI breakage? If that's the case, I guess
it would be best to get the word out that people using Linux SCTP should
better make sure to not use binary packages but always build on the
system they run it on, to ensure kernel headers are identical.
I don't mean this in any cynical way. The point is either the ABI is
stable and people can move binaries between different OS/kernel
versions, or they cannot. So far the general assumption on Linux is you
can, but with SCTP you can not, so this needs to be clarified.
Regards,
Harald
--
- Harald Welte [off-list ref] http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)
On Fri, May 01, 2020 at 03:16:07PM +0200, Harald Welte wrote:
Dear Linux SCTP developers,
On Sun, Apr 19, 2020 at 12:25:36PM +0200, Harald Welte wrote:
quoted
this patchset (merged back in Q4/2019) has broken ABI compatibility, more
or less exactly as it was discussed/predicted in Message-Id
[off-list ref]
"[PATCH net] sctp: make sctp_setsockopt_events() less strict about the option length"
on this very list in February 2019.
does the lack of any follow-up so far seems to indicate nobody considers
this a problem? Even without any feedback from the Linux kernel
developers, I would be curious to hear What do other SCTP users say.
No. Speaking for myself only, I just didn't have the time to check
your report yet. I'm a developer but it's not on my main priorities.
So far I have a somewhat difficult time understanding that I would be
the only one worried about ABI breakage? If that's the case, I guess
it would be best to get the word out that people using Linux SCTP should
better make sure to not use binary packages but always build on the
system they run it on, to ensure kernel headers are identical.
I don't mean this in any cynical way. The point is either the ABI is
stable and people can move binaries between different OS/kernel
versions, or they cannot. So far the general assumption on Linux is you
can, but with SCTP you can not, so this needs to be clarified.
That's what we want as well. Some breakage happened, yes, by mistake,
and fixing that properly now, without breaking anything else, may be
just impossible, unfortunatelly. But you can be sure that we are
engaged on not doing it again.
Thanks,
Marcelo
From: Harald Welte <laforge@gnumonks.org> Date: 2020-06-01 10:46:46
Dear SCTP developers,
I have to get back to this bug. It is slowly turning into a nightmare.
Not only affected it forwards/backwards compatibility of application binaries
during upgrades of a distribution, but it also affects the ability to run
containerized workloads with SCTP. It's sort-of obvious but I didn't
realize it until now.
We are observing this problem now when we operate CentOS 8 based containers
on a Debian 9 based (docker) host. Apparently the CentOS userland has a different
definition of the event structure (larger) than the Debian kernel has (smaller) -> boom.
From my point of view, this bug is making it virtually impossible to run
containerized telecom workloads. I guess most users are very
conservative and still running rather ancient kernels and/or
distributions, but as soon as they start upgrading their kernel to
anything that includes that patch to the SCTP events structure, the
nightmare starts.
To my knowledge, there is no infrastructure at all for a situation like this - neither
in the Docker universe nor in k8s.. You cannot build separate container
images depending on what the host OS/kernel is going to be.
And particularly, if you are not self-hosting your container runtimes
but running your containers on some kind of cloud infrastructure
provider, you have no control over what exact kernel version might be in
use there - and it also may change at any time at the discretion of the
cloud service provider.
On Fri, May 01, 2020 at 11:20:08AM -0300, Marcelo Ricardo Leitner wrote:
That's what we want as well. Some breakage happened, yes, by mistake,
and fixing that properly now, without breaking anything else, may be
just impossible, unfortunatelly. But you can be sure that we are
engaged on not doing it again.
I would actually seriously consider to roll that change back - not only
in the next kernel release but also in all stable kernel releases. At least
the breakage then is constrained to a limited set of kernel versions.
Alternatively, I suggest to at least apply a patch to all supported
stable kernel series (picked up hopefully distributions) that makes those
older kernels accept a larger-length sctp_event_subscribe structure from
userspace, *if* any of the additional members are 0 (memcmp the
difference between old and new).
Regards,
Harald
--
- Harald Welte [off-list ref] http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)
From: Neil Horman <nhorman@tuxdriver.com> Date: 2020-06-01 12:15:21
On Sun, Apr 19, 2020 at 12:25:36PM +0200, Harald Welte wrote:
Dear Linux SCTP developers,
this patchset (merged back in Q4/2019) has broken ABI compatibility, more
or less exactly as it was discussed/predicted in Message-Id
[off-list ref]
"[PATCH net] sctp: make sctp_setsockopt_events() less strict about the option length"
on this very list in February 2019.
The process to reproduce this is quite simple:
* upgrade your kernel / uapi headers to a later version (happens
automatically on most distributions as linux-libc-dev is upgraded)
* rebuild any application using SCTP_EVENTS which was working perfectly
fine before
* fail to execute on any older kernels
This can be a severe issue in production systems where you may not
upgrade the kernel until/unless a severe security issue actually makes
you do so.
Those steps above can very well happen on different machines, i.e. your
build server having a more recent linux-libc-dev package (and hence
linux/sctp.h) than some of the users in the field are running kernels.
I think this is a severe problem that affects portability of binaries
between differnt Linux versions and hence the kind of ABI breakage that
the kernel exactly doesn't want to have.
The point here is that there is no check if any of those newly-added
events at the end are actually used. I can accept that programs using
those new options will not run on older kernels - obviously. But old
programs that have no interest in new events being added should run just
fine, even if rebuilt against modern headers.
In the kernel setsockopt handling coee: Why not simply check if any of
the newly-added events are actually set to non-zero? If those are all
zero, we can assume that the code doesn't use them.
Yes, for all the existing kernels out there it's too late as they simply
only have the size based check. But I'm worried history will repeat
itself...
Thanks for your consideration.
As Marcello noted, I don't think theres anything we can do here. We screwed
this up, but reverting the change is just going to create a second breakage
point through which users are going to have to deal with this. The best way
forward is to document the need to run a newer userspace uapi header set on a
correspondingly new kernel, and be sure in the future that any extension to the
uapi structures are codified as separate structures with separate socket options
(or some simmilar approach to allow for fixed size api structures)
Neil
--
- Harald Welte [off-list ref] http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)