From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: linux-sctp@vger.kernel.org
Subject: Re: Ooops with SCTP
Date: Wed, 23 Jul 2014 17:22:14 +0000 [thread overview]
Message-ID: <20140723172214.GA11270@obsidianresearch.com> (raw)
In-Reply-To: <20140705001606.GA29369@obsidianresearch.com>
On Mon, Jul 21, 2014 at 07:15:45AM -0400, Neil Horman wrote:
> ok, I've looked at this over the weekend, and for the most part I think it looks
> ok. Regarding your questions, I think sctp_id2transport is ok as it is, since
> that path is used for both ipv4 and ipv6, making unconditional promotion a bad
> idea. Calling the addr_map method lets us choose the v4 mapping function
> (empty), or the v6 mapping function, which only does a map if a v4 address is
> passed in.
Well, v4mapped should only change the presentation of addresses being
returned by syscalls, it should never change the internal behavior of
SCTP.
Hrm.. So sctp_id2transport has this as a trailing call:
sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk),
(union sctp_addr
*)addr);
Thus it does not alter the operation of sctp_id2transport in any way,
it just changes the presentation of the address for the caller.. So
that is good.
Going through the callers:
sctp_getsockopt_peer_addr_params -
sctp_getsockopt_peer_addr_info -
sctp_getsockopt_peer_addr_params -
sctp_getsockopt_paddr_thresholds
The address is copied back to user space after the call
completes
sctp_setsockopt_peer_addr_params -
sctp_setsockopt_primary_addr -
sctp_setsockopt_paddr_thresholds -
The address is never used again
Basically, if you do a getsockopt with an address then the structure
return'd by the kernel will be passed through addr_v4map.
It is a bit odd that the kernel transforms an input argument when
copying to output, but that doesn't necessarily seem bad...
> And I don't think we need to do any demotion of addresses as sctp_v6_addr_v4map
> is only called if the socket is AF_INET6, and can handle v6 addresses
> transparently. If the socket was created as AF_INET, we're safe, because that
> will reject AF_INET6 addresses anyway.
sctp_v6_addr_v4map appears to be called on every sockaddr before
returning it to user space.
So the job of sctp_v6_addr_v4map is to enforce the v4mapped behavior:
- If v4mapped is set all returns from the kernel should be AF_INET6
- If v4mapped is unset, all IPv4 addresses should be AF_INET, a V6
mapped should never be returned.
Right now it only promotes AF_INET to AF_INET6, it doesn't demote
AF_INET6 v4mapped back to AF_INET.
So the question is if v4mapped AF_INET6 addresses can exist inside the
kernel. If yes, we need to demote them in sctp_v6_addr_v4map for
correct presentation to userspace.
Unless you know the design is to keep v4 as AF_INET, then I'm thinking
for robustness it should just demote. Then we know the user API is
going to work properly no matter what changes are made to the
internals.
> If you're testing in the interviening week hasn't shown any further problems,
> I'd say officially post this with my signed off please.
I'll try to get a few mins to verify the above for sctp_v6_addr_v4map
and post the result.
Thanks,
Jason
prev parent reply other threads:[~2014-07-23 17:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-05 0:16 Ooops with SCTP Jason Gunthorpe
2014-07-05 13:03 ` Neil Horman
2014-07-05 16:39 ` Jason Gunthorpe
2014-07-06 12:21 ` Neil Horman
2014-07-07 4:48 ` Jason Gunthorpe
2014-07-07 12:44 ` Neil Horman
2014-07-07 17:45 ` Jason Gunthorpe
2014-07-07 18:22 ` Neil Horman
2014-07-07 19:39 ` Jason Gunthorpe
2014-07-09 15:50 ` Neil Horman
2014-07-09 16:28 ` Jason Gunthorpe
2014-07-09 18:27 ` Neil Horman
2014-07-09 18:51 ` Jason Gunthorpe
2014-07-10 11:33 ` Neil Horman
2014-07-10 19:58 ` Jason Gunthorpe
2014-07-10 20:14 ` Neil Horman
2014-07-21 11:15 ` Neil Horman
2014-07-23 17:22 ` Jason Gunthorpe [this message]
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=20140723172214.GA11270@obsidianresearch.com \
--to=jgunthorpe@obsidianresearch.com \
--cc=linux-sctp@vger.kernel.org \
/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