Commit Graph

94676 Commits

Author SHA1 Message Date
Sage Weil
91a888ecb4 msg/async/ProtocolV2: include entity_name, features in reconnect
- A connects to B
- A sends client_ident
- fault before A gets server_ident, so A doesn't know B's features or name
- B reconnects to A
- connection established

A thinks B is unknown.0 and has not idea what the featurs are.

Fix this by including id and featurs in reconnect.  We don't know the type, but that is
included in TAG_HELLO in another branch, which will be merged separately; add a

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
5d84f11934 msg/async/ProtocolV2: fix write_lock usage around AckFrame
If we are calling _try_send or touching outcoming_bl we must be holding
write_lock.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
65e81e6eb4 qa/suites/rados/verify/validator/valgrind: debug refs = 5
If we detect a leak, let's include logging so we can find it.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
dcdca44aa4 qa/standalone/ceph-helpers: fix health_ok test
Stopping the osd daemon won't reliably get you HEALTH_WARN or ERR; you have
to make sure it is also marked down.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
eb4af28be4 auth/AuthRegistry: only complain about disabling cephx if cephx was enabled
This gets rid of some warnings when auth_supported=none.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
7ba8ee2e04 auth/AuthRegistry: fix locking for get_supported_methods()
The other read-side accessors all consume this method and don't
need their own locking.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
028f1af996 auth: remove AUTH_UNKNOWN weirdness, hardcoded defaults.
This is what the old code does so I kept it but I don't think it makes any sense.
Same with the defaults; let's just set the config option to something valid.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
ecf41b1a3c msg/async/ProtocolV2: remove unused get_auth_allowed_methods
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
fa44155acc osd: set up messener auth_* before setting dispatcher (and going 'ready')
The messenger doesn't activate until you set the dispatcher.  Set up the auth_client
and auth_server values before that.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
524f26d7a9 mon/AuthMonitor: request max_global_id increase from peon in tick
For authv2, we only increase max_global_id from tick, not via prep_auth(), so we
need to ask the leader for more IDs here as we do there.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
869d43d982 mon: prime MgrClient only after messengers are initialized
If we do it earlier we may crash due to an uninitialised messenger
auth_client.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
ee59743a1a qa/suites/rados/workloads/rados_api_tests.yaml: debug mgrc = 20 on mon
Seeing some hangs when the mon is forwarding mgr commands (pg deep-scrub)
to the mgr.  This is a buggy test (it should send it to the mgr directly)
but it is helpful to verify the mon forwarding behavior works.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
e1f6eb8a7a auth: document Auth{Client,Server} interfaces
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
771682aad0 auth: future-proof AUTH_MODE_* a bit in case we need to change the encoding byte
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
e48301c5cf mon/MonClient: request monmap on open instead of ping
The ping is useless.  The MMonGetMap ensures we get a monmap (and finish
authenticate()) before we get any other maps/messages, like mgr_map.
Getting other maps sooner rather than later can be confuse to MonClient
users because they will get dispatched MMgrMap before the authenticate()
call has returned.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
4a7aca7737 mgr/PyModuleRegistry: add details for MGR_MODULE_{DEPENDENCY,ERROR}
We want to know what modules failed and why.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
09b1c44f27 crimson: fix build
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
42b5c4dd8f mon/MonClient: finsih authenticate() only after we get monmap; fix 'tell mgr'
We used to get a valid monmap before we finished the MAuth exchange and
returned from authenticate().  Now, we finish authenticating before we even
send or receive a message, so authenticate() returns quickly.  This
confuses many callers, and is probably a bad idea.  So, rejigger the
_finish_auth and _finish_hunting callers so that we finish hunting as soon
as we have picked a mon but don't finish_auth if we have not gotten our
first monmap.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
574e6bf6ad mon: add auth_lock to protect auth_meta manipulation
In particular, we could be handling a get_auth_request() on a reconnect
while also running handle_auth_request() on a racing connection between
monitors.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
766df9f740 ceph-mon: set up auth before binding
Otherwise initial connections will fail because they lack the auth_server.


Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
f1b917c2cc mon: defer initial connection auth attempts until initial quorum is formed
Otherwise e.g. a client.admin connectin will fail because the mon doesn't
have the key in the database yet.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
d532e1ef1a mon/MonClient: make MonClientPinger an AuthCleint
Reuse MonConnection to do the authentication.

Note this is a change in behavior: ceph ping mon* now requires
authentication.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
07b00a06e6 ceph_test_msgr: use DummyAuth
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
396e10fe79 auth/DummyAuth: dummy auth server and client for test code
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
b3defafb41 mon/Monitor: fix leak of auth_handler if we error out
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
5e4df2a509 doc/dev/cephx: re-wordwrap
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:34 -06:00
Sage Weil
c1102f043e doc/dev/cephx: document nautilus change to cephx
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:33 -06:00
Sage Weil
d3f0d0968a vstart.sh: fix --msgr2 option
Should be v2 only and turn of v1.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:33 -06:00
Sage Weil
87a991cc28 msg/async/ProtocolV2: use shared_ptr to manage auth_meta
When we reconnect a session, we need to move the new connection's auth_meta
over to the existing connection.  However, the existing connection may
have a thread that is unlocked and calling into an AuthClient or AuthServer
method making good use of the old auth_meta.

Resolved this by making auth_meta a shared_ptr and taking a local ref
before dropping the connection lock.  This way we are free to move the
auth_meta over to the new connection as long as we are holding the lock,
and at the same time the existing connection can fiddle with the old
auth_meta without being disturbed.  (That old auth_meta is about to get
discarded, but we still need to prevent the two threads from stomping on
each other.)

This also cleans up the reset_recv_state() a bit since we can simply
replace the old auth_meta with a totally fresh one without worrying about
what kind of state might be lurking in there.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:33 -06:00
Sage Weil
160b54da80 auth/Auth{Client,Server}: pass auth_meta in explicitly
This removes the wonky accessor on Connection, and most importantly
allows the caller to control the lifecycle of the AuthConnectionMeta.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:33 -06:00
Sage Weil
a948c0d0de mon/MonClient: behave if authorizer can't be built (yet)
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:33 -06:00
Sage Weil
26a8bb65a7 osd: set_auth_server on client_messenger
monc sets up the AuthClient, not the AuthServer.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:33 -06:00
Sage Weil
c1b5794a5a common/ceph_context: get_moduel_type() for seastar cct
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:33 -06:00
Sage Weil
951da2fbfa auth: make connection_secret a std::string
Move connection mode decision to initial auth_request point so that it
can inform auth implementation how big the connection secret should be.
Pass that value through where appropriate.

The connection_secret is now a std::string filled with random bytes.

For now the v2 protocol just uses the session_key CryptoKey to encrypt,
but this is about to change.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:33 -06:00
Sage Weil
c7ee66c3e5 auth,msg/async/ProtocolV2: negotiate connection modes
The modes are:

- crc: crc32c checksums to protect against bit errors.  No secrecy or
  authenticity guarantees, so a MITM could alter traffic in flight.
- secure: cryptographic secrecy and authenticity proection (i.e, encrypted
  and signed).

We do not include a 'signed' mode that provides authenticity without
secrecy because the cryptographic protocols appear to be faster than
SHA-2.

New settings:

- ms_cluster_mode  : mode(s list) for intra-cluster connections
- ms_service_mode  : mode(s list) for daemons to allow
- ms_client_mode   : mode(s list) for clients to allow

Also,

- ms_mon_cluster_mode  : mon <-> mon connections
- ms_mon_service_mode  : mon <-> daemon or client connections

The msgr2 protocol is expanded slightly to negotiate a mode.  Client
shares it's allowed/preferred modes, and server picks one as auth finishes.
Negotiation is independent of the authentication, except that the
authentiction mode may precluse certain choices. Specifically, AUTH_NONE
does not support 'secure', only 'crc'.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:33 -06:00
Sage Weil
9c3dd336b7 auth/AuthRegistry: refactor handling of auth_*_requred options
- simplify/consolidate my type and peer type effects on auth method
- watch for runtime config changes

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:33 -06:00
Sage Weil
fa7c83f6dc osd,mgr,mds: remove unused authorize registries
These are handled by AuthClient and AuthServer now.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:33 -06:00
Sage Weil
1d29722f80 switch monc, daemons to use new msgr2 auth frame exchange
- MonClient implements AuthClient to authenticate as a client
- MonClient implements AuthServer to allow daemons to verify authorizers
- Monitor implements AuthServer to allow clients to authenticate with
  an exchange of msgr2 frames
- Monitor implements AuthClient to authenticate with other monitors

After this change ProtocolV1 and SimpleMessenger still use all of the
old Dispatcher-based callbacks, but ProtocolV2 doesn't need them at
all (except for ms_handle_authentication when we finish).

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 12:10:33 -06:00
Sage Weil
c1a2d1be52 doc/dev/msgr2: update docs to match implementation for auth frames
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 06:53:03 -06:00
Sage Weil
ee2e31b244 auth/AuthClientHandler: add build_initial_request hook
With msgr2 the initial kickoff of an authentication handshake is client ->
server, while with msgr1 it was server -> client.  So existing
implementations have an empty initial message (outside of the messenger's
envelope).  Future auth implementations that are msgr2 only (e.g., krb)
may want to make use of this initial payload.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 06:53:03 -06:00
Sage Weil
d0dc20ed9a msg/Messenger: attach auth_client and/or auth_server to each Messenger
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 06:53:03 -06:00
Sage Weil
cfe7f4992b auth: introduce AuthClient and AuthServer handlers
These will be the primary interfaces consumed by the messenger and
implemented by either MonClient (regular client, or service daemon) or
Monitor for doing authentication.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 06:53:03 -06:00
Sage Weil
f152b4aae1 auth: codify AUTH_MODE_AUTHORIZER
The AuthAuthorizer encoding always begins with byte 0x01.  Codify that
as AUTH_MODE_AUTHORIZER so that we can distinguish an authorizer from
something else (e.g., an attempt to authenticate and get an initial auth
ticket with the mon).

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 06:53:03 -06:00
Sage Weil
5bd92c29d9 msg/Connection: track peer_id (id portion of entity_name_t) for msgr2
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 06:53:03 -06:00
Sage Weil
a7d6a54f73 auth/AuthAuthorizeHandler: add get_supported_methods()
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 06:53:03 -06:00
Sage Weil
0267fb04ff auth/AuthAuthorizeHandler: fix args for verify_authorizer()
const bufferlists in, pointers for output args.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 06:53:03 -06:00
Sage Weil
4f78af7d69 auth: constify bufferlist arg to AuthAuthorizer::add_challenge()
Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 06:53:03 -06:00
Sage Weil
1adf313ef9 auth/cephx: share all tickets and connection_secret in initial reply
Previously, we would give the client the auth ticket, like a rbd TGT
(ticket granting ticket), and the client would then ask for all of the
other tickets it wants in a separate message.

Instead, have the client specify which tickets it wants up front and pass
them all at the same time.

Also, generate and share the connection_secret, which will be used for
encryption.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 06:53:03 -06:00
Sage Weil
7dd93be90a msg/async,auth: add AuthConnectionMeta to Protocol
This will hold all of the authentication-related state in an easy-to-find
section that can be accessed via a Connection* or by the protocol stack
(as needed).

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 06:53:03 -06:00
Sage Weil
fc90a084c4 auth/AuthClientHandler: pass in session_key, connection_secret pointers
No functional change.

Signed-off-by: Sage Weil <sage@redhat.com>
2019-02-07 06:53:03 -06:00