libceph: nocephx_sign_messages option + misc
Subsystems (2)
Ilya Dryomov
maintainercover libceph: nocephx_sign_messages option + misc
Hello,
This adds nocephx_sign_messages libceph option (a lack of which is something people are running into, see [1]), plus a couple of related cleanups.
[1] https://forum.proxmox.com/threads/24116-new-krbd-option-on-pve4-don-t-work
Thanks,
Ilya
Ilya Dryomov (4):
libceph: msg signing callouts don't need con argument
libceph: drop authorizer check from cephx msg signing routines
libceph: stop duplicating client fields in messenger
libceph: add nocephx_sign_messages option
fs/ceph/mds_client.c | 14 ++++++++------ include/linux/ceph/libceph.h | 4 +++- include/linux/ceph/messenger.h | 16 +++------------- net/ceph/auth_x.c | 8 ++++++-- net/ceph/ceph_common.c | 18 +++++++++++++----- net/ceph/messenger.c | 32 ++++++++++++-------------------- net/ceph/osd_client.c | 14 ++++++++------ 7 files changed, 53 insertions(+), 53 deletions(-)
Signature · 1 line
2.4.3
Ilya Dryomov
maintainerPATCH 1/4 libceph: msg signing callouts don't need con argument
We can use msg->con instead - at the point we sign an outgoing message or check the signature on the incoming one, msg->con is always set. We wouldn't know how to sign a message without an associated session (i.e. msg->con == NULL) and being able to sign a message using an explicitly provided authorizer is of no use.
--- fs/ceph/mds_client.c | 14 ++++++++------ include/linux/ceph/messenger.h | 5 ++--- net/ceph/messenger.c | 4 ++-- net/ceph/osd_client.c | 14 ++++++++------ 4 files changed, 20 insertions(+), 17 deletions(-)
fs/ceph/mds_client.c +8 -6
@@ -3942,17 +3942,19 @@ static struct ceph_msg *mds_alloc_msg(struct ceph_connection *con,return msg; } -static int sign_message (struct ceph_connection *con,struct ceph_msg *msg) +static int mds_sign_message (struct ceph_msg *msg) { -struct ceph_mds_session *s = con->private; +struct ceph_mds_session *s = msg->con->private;struct ceph_auth_handshake *auth = &s->s_auth; +return ceph_auth_sign_message (auth, msg); } -static int check_message_signature (struct ceph_connection *con,struct ceph_msg *msg) +static int mds_check_message_signature (struct ceph_msg *msg) { -struct ceph_mds_session *s = con->private; +struct ceph_mds_session *s = msg->con->private;struct ceph_auth_handshake *auth = &s->s_auth; +return ceph_auth_check_message_signature (auth, msg); }
@@ -3965,8 +3967,8 @@ static const struct ceph_connection_operations mds_con_ops = { .invalidate_authorizer = invalidate_authorizer, .peer_reset = peer_reset, .alloc_msg = mds_alloc_msg, - .sign_message = sign_message, - .check_message_signature = check_message_signature, + .sign_message = mds_sign_message, + .check_message_signature = mds_check_message_signature, };/* eof */
include/linux/ceph/messenger.h +2 -3
@@ -43,10 +43,9 @@ struct ceph_connection_operations {struct ceph_msg * (*alloc_msg) (struct ceph_connection *con,struct ceph_msg_header *hdr,int *skip); -int (*sign_message) (struct ceph_connection *con,struct ceph_msg *msg); -int (*check_message_signature) (struct ceph_connection *con, -struct ceph_msg *msg); +int (*sign_message) (struct ceph_msg *msg); +int (*check_message_signature) (struct ceph_msg *msg); };/* use format string %s%d */
net/ceph/messenger.c +2 -2
@@ -1205,7 +1205,7 @@ static void prepare_write_message_footer(struct ceph_connection *con) con->out_kvec[v].iov_base = &m->footer;if (con->peer_features &CEPH_FEATURE_MSG_AUTH ) {if (con->ops->sign_message) - con->ops->sign_message (con, m); + con->ops->sign_message (m);else m->footer.sig =0 ; con->out_kvec[v].iov_len =sizeof (m->footer);
@@ -2422,7 +2422,7 @@ static int read_partial_message(struct ceph_connection *con) }if (need_sign && con->ops->check_message_signature && - con->ops->check_message_signature (con, m)) { + con->ops->check_message_signature (m)) {pr_err ("read_partial_message %p signature check failed\n" , m);return -EBADMSG ; }
net/ceph/osd_client.c +8 -6
@@ -2979,17 +2979,19 @@ static int invalidate_authorizer(struct ceph_connection *con)return ceph_monc_validate_auth (&osdc->client->monc); } -static int sign_message (struct ceph_connection *con,struct ceph_msg *msg) +static int osd_sign_message (struct ceph_msg *msg) { -struct ceph_osd *o = con->private; +struct ceph_osd *o = msg->con->private;struct ceph_auth_handshake *auth = &o->o_auth; +return ceph_auth_sign_message (auth, msg); } -static int check_message_signature (struct ceph_connection *con,struct ceph_msg *msg) +static int osd_check_message_signature (struct ceph_msg *msg) { -struct ceph_osd *o = con->private; +struct ceph_osd *o = msg->con->private;struct ceph_auth_handshake *auth = &o->o_auth; +return ceph_auth_check_message_signature (auth, msg); }
@@ -3001,7 +3003,7 @@ static const struct ceph_connection_operations osd_con_ops = { .verify_authorizer_reply = verify_authorizer_reply, .invalidate_authorizer = invalidate_authorizer, .alloc_msg = alloc_msg, - .sign_message = sign_message, - .check_message_signature = check_message_signature, + .sign_message = osd_sign_message, + .check_message_signature = osd_check_message_signature, .fault = osd_reset, };
Signature · 1 line
2.4.3
Ilya Dryomov
maintainerPATCH 2/4 libceph: drop authorizer check from cephx msg signing routines
In reply to Ilya DryomovI don't see a way for auth->authorizer to be NULL in ceph_x_sign_message() or ceph_x_check_message_signature().
--- net/ceph/auth_x.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
net/ceph/auth_x.c +1 -4
@@ -697,8 +697,7 @@ static int ceph_x_sign_message(struct ceph_auth_handshake *auth, struct ceph_msg *msg) {int ret; -if (!auth->authorizer) -return 0 ; + ret =calcu_signature ((struct ceph_x_authorizer *)auth->authorizer, msg, &msg->footer.sig);if (ret <0 )
@@ -713,8 +712,6 @@ static int ceph_x_check_message_signature(struct ceph_auth_handshake *auth,__le64 sig_check;int ret; -if (!auth->authorizer) -return 0 ; ret =calcu_signature ((struct ceph_x_authorizer *)auth->authorizer, msg, &sig_check);if (ret <0 )
Signature · 1 line
2.4.3
Ilya Dryomov
maintainerPATCH 3/4 libceph: stop duplicating client fields in messenger
In reply to Ilya Dryomovsupported_features and required_features serve no purpose at all, while nocrc and tcp_nodelay belong to ceph_options::flags.
--- include/linux/ceph/libceph.h | 1 + include/linux/ceph/messenger.h | 11 +---------- net/ceph/ceph_common.c | 6 +----- net/ceph/messenger.c | 26 +++++++++----------------- 4 files changed, 12 insertions(+), 32 deletions(-)
include/linux/ceph/libceph.h +1 -0
@@ -137,6 +137,7 @@ struct ceph_client {#endif }; +#define from_msgr (ms) container_of(ms, struct ceph_client, msgr)/*
include/linux/ceph/messenger.h +1 -10
@@ -57,8 +57,6 @@ struct ceph_messenger {atomic_t stopping;possible_net_t net; -bool nocrc; -bool tcp_nodelay;/* * the global_seq counts connections i (attempt to) initiate
@@ -66,9 +64,6 @@ struct ceph_messenger {*/ u32 global_seq;spinlock_t global_seq_lock; - -u64 supported_features; -u64 required_features; };enum ceph_msg_data_type {
@@ -267,11 +262,7 @@ extern void ceph_msgr_exit(void);extern void ceph_msgr_flush (void );extern void ceph_messenger_init (struct ceph_messenger *msgr, -struct ceph_entity_addr *myaddr, -u64 supported_features, -u64 required_features, -bool nocrc, -bool tcp_nodelay); +struct ceph_entity_addr *myaddr);extern void ceph_messenger_fini (struct ceph_messenger *msgr); extern void ceph_con_init(struct ceph_connection *con, void *private,
net/ceph/ceph_common.c +1 -5
@@ -596,11 +596,7 @@ struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private,if (ceph_test_opt (client,MYIP )) myaddr = &client->options->my_addr; -ceph_messenger_init (&client->msgr, myaddr, - client->supported_features, - client->required_features, -ceph_test_opt (client,NOCRC ), -ceph_test_opt (client,TCP_NODELAY )); +ceph_messenger_init (&client->msgr, myaddr);/* subsystems */ err =ceph_monc_init (&client->monc, client);
net/ceph/messenger.c +9 -17
@@ -509,7 +509,7 @@ static int ceph_tcp_connect(struct ceph_connection *con)return ret; } -if (con->msgr->tcp_nodelay) { +if (ceph_test_opt (from_msgr (con->msgr),TCP_NODELAY )) {int optval =1 ; ret = kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY,
@@ -1432,7 +1432,8 @@ static int prepare_write_connect(struct ceph_connection *con)dout ("prepare_write_connect %p cseq=%d gseq=%d proto=%d\n" , con, con->connect_seq, global_seq, proto); - con->out_connect.features =cpu_to_le64 (con->msgr->supported_features); + con->out_connect.features = +cpu_to_le64 (from_msgr (con->msgr)->supported_features); con->out_connect.host_type =cpu_to_le32 (CEPH_ENTITY_TYPE_CLIENT ); con->out_connect.connect_seq =cpu_to_le32 (con->connect_seq); con->out_connect.global_seq =cpu_to_le32 (global_seq);
@@ -1527,7 +1528,7 @@ static int write_partial_message_data(struct ceph_connection *con) {struct ceph_msg *msg = con->out_msg;struct ceph_msg_data_cursor *cursor = &msg->cursor; -bool do_datacrc = !con->msgr->nocrc; +bool do_datacrc = !ceph_test_opt (from_msgr (con->msgr),NOCRC );u32 crc;dout ("%s %p msg %p\n" , __func__, con, msg);
@@ -2005,8 +2006,8 @@ static int process_banner(struct ceph_connection *con)static int process_connect (struct ceph_connection *con) { -u64 sup_feat = con->msgr->supported_features; -u64 req_feat = con->msgr->required_features; +u64 sup_feat =from_msgr (con->msgr)->supported_features; +u64 req_feat =from_msgr (con->msgr)->required_features;u64 server_feat =ceph_sanitize_features (le64_to_cpu (con->in_reply.features));int ret;
@@ -2232,7 +2233,7 @@ static int read_partial_msg_data(struct ceph_connection *con) {struct ceph_msg *msg = con->in_msg;struct ceph_msg_data_cursor *cursor = &msg->cursor; -const bool do_datacrc = !con->msgr->nocrc; +bool do_datacrc = !ceph_test_opt (from_msgr (con->msgr),NOCRC );struct page *page;size_t page_offset;size_t length;
@@ -2277,7 +2278,7 @@ static int read_partial_message(struct ceph_connection *con)int end;int ret;unsigned int front_len, middle_len, data_len; -bool do_datacrc = !con->msgr->nocrc; +bool do_datacrc = !ceph_test_opt (from_msgr (con->msgr),NOCRC );bool need_sign = (con->peer_features &CEPH_FEATURE_MSG_AUTH );u64 seq;u32 crc;
@@ -2951,15 +2952,8 @@ static void con_fault(struct ceph_connection *con)* initialize a new messenger instance */ void ceph_messenger_init (struct ceph_messenger *msgr, -struct ceph_entity_addr *myaddr, -u64 supported_features, -u64 required_features, -bool nocrc, -bool tcp_nodelay) +struct ceph_entity_addr *myaddr) { - msgr->supported_features = supported_features; - msgr->required_features = required_features; -spin_lock_init (&msgr->global_seq_lock);if (myaddr)
@@ -2969,8 +2963,6 @@ void ceph_messenger_init(struct ceph_messenger *msgr, msgr->inst.addr.type =0 ;get_random_bytes (&msgr->inst.addr.nonce,sizeof (msgr->inst.addr.nonce));encode_my_addr (msgr); - msgr->nocrc = nocrc; - msgr->tcp_nodelay = tcp_nodelay;atomic_set (&msgr->stopping,0 );write_pnet (&msgr->net,get_net (current->nsproxy->net_ns));
Signature · 1 line
2.4.3
Ilya Dryomov
maintainerPATCH 4/4 libceph: add nocephx_sign_messages option
In reply to Ilya DryomovSupport for message signing was merged into 3.19, along with nocephx_require_signatures option. But, all that option does is allow the kernel client to talk to clusters that don't support MSG_AUTH feature bit. That's pretty useless, given that it's been supported since bobtail.
Meanwhile, if one disables message signing on the server side with "cephx sign messages = false", it becomes impossible to use the kernel client since it expects messages to be signed if MSG_AUTH was negotiated. Add nocephx_sign_messages option to support this use case.
--- include/linux/ceph/libceph.h | 3 ++- net/ceph/auth_x.c | 7 +++++++ net/ceph/ceph_common.c | 12 ++++++++++++ net/ceph/messenger.c | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-)
include/linux/ceph/libceph.h +2 -1
@@ -29,8 +29,9 @@#define CEPH_OPT_NOSHARE (1<<1)/* don't share client with other sbs */ #define CEPH_OPT_MYIP (1<<2)/* specified my ip */ #define CEPH_OPT_NOCRC (1<<3)/* no data crc on writes */ -#define CEPH_OPT_NOMSGAUTH (1<<4)/* not require cephx message signature */ +#define CEPH_OPT_NOMSGAUTH (1<<4)/* don't require msg signing feat */ #define CEPH_OPT_TCP_NODELAY (1<<5)/* TCP_NODELAY on TCP sockets */ +#define CEPH_OPT_NOMSGSIGN (1<<6)/* don't sign msgs */ #define CEPH_OPT_DEFAULT (CEPH_OPT_TCP_NODELAY)
net/ceph/auth_x.c +7 -0
@@ -8,6 +8,7 @@#include <linux/ceph/decode.h> #include <linux/ceph/auth.h> +#include <linux/ceph/libceph.h> #include <linux/ceph/messenger.h> #include "crypto.h"
@@ -698,6 +699,9 @@ static int ceph_x_sign_message(struct ceph_auth_handshake *auth, {int ret; +if (ceph_test_opt (from_msgr (msg->con->msgr),NOMSGSIGN )) +return 0 ; + ret =calcu_signature ((struct ceph_x_authorizer *)auth->authorizer, msg, &msg->footer.sig);if (ret <0 )
@@ -712,6 +716,9 @@ static int ceph_x_check_message_signature(struct ceph_auth_handshake *auth,__le64 sig_check;int ret; +if (ceph_test_opt (from_msgr (msg->con->msgr),NOMSGSIGN )) +return 0 ; + ret =calcu_signature ((struct ceph_x_authorizer *)auth->authorizer, msg, &sig_check);if (ret <0 )
net/ceph/ceph_common.c +12 -0
@@ -245,6 +245,8 @@ enum { Opt_nocrc, Opt_cephx_require_signatures, Opt_nocephx_require_signatures, + Opt_cephx_sign_messages, + Opt_nocephx_sign_messages, Opt_tcp_nodelay, Opt_notcp_nodelay, };
@@ -267,6 +269,8 @@ static match_table_t opt_tokens = { {Opt_nocrc, "nocrc"}, {Opt_cephx_require_signatures, "cephx_require_signatures"}, {Opt_nocephx_require_signatures, "nocephx_require_signatures"}, + {Opt_cephx_sign_messages, "cephx_sign_messages"}, + {Opt_nocephx_sign_messages, "nocephx_sign_messages"}, {Opt_tcp_nodelay, "tcp_nodelay"}, {Opt_notcp_nodelay, "notcp_nodelay"}, {-1, NULL}
@@ -491,6 +495,12 @@ ceph_parse_options(char *options, const char *dev_name,case Opt_nocephx_require_signatures: opt->flags |=CEPH_OPT_NOMSGAUTH ;break ; +case Opt_cephx_sign_messages: + opt->flags &= ~CEPH_OPT_NOMSGSIGN ; +break ; +case Opt_nocephx_sign_messages: + opt->flags |=CEPH_OPT_NOMSGSIGN ; +break ;case Opt_tcp_nodelay: opt->flags |=CEPH_OPT_TCP_NODELAY ;
@@ -534,6 +544,8 @@ int ceph_print_client_options(struct seq_file *m, struct ceph_client *client)seq_puts (m,"nocrc," );if (opt->flags &CEPH_OPT_NOMSGAUTH )seq_puts (m,"nocephx_require_signatures," ); +if (opt->flags &CEPH_OPT_NOMSGSIGN ) +seq_puts (m,"nocephx_sign_messages," );if ((opt->flags &CEPH_OPT_TCP_NODELAY ) ==0 )seq_puts (m,"notcp_nodelay," );
net/ceph/messenger.c +1 -1
@@ -2677,7 +2677,7 @@ more:if (ret <=0 ) {switch (ret) {case -EBADMSG : - con->error_msg ="bad crc" ; + con->error_msg ="bad crc/signature" ;/* fall through */ case -EBADE : ret = -EIO ;
Signature · 1 line
2.4.3
Quoted 22 lines · Ilya Dryomov
Hello,
This adds
nocephx_sign_messageslibceph option (a lack of which is something people are running into, see [1]), plus a couple of related cleanups.[1] https://forum.proxmox.com/threads/24116-new-krbd-option-on-pve4-don-t-work
Thanks,
Ilya
Ilya Dryomov (4):
libceph: msg signing callouts don't need con argument
libceph: drop authorizer check from cephx msg signing routines
libceph: stop duplicating client fields in messenger
libceph: addnocephx_sign_messagesoption
Quoted 9 lines
fs/ceph/mds_client.c | 14 ++++++++------ include/linux/ceph/libceph.h | 4 +++- include/linux/ceph/messenger.h | 16 +++------------- net/ceph/auth_x.c | 8 ++++++-- net/ceph/ceph_common.c | 18 +++++++++++++----- net/ceph/messenger.c | 32 ++++++++++++-------------------- net/ceph/osd_client.c | 14 ++++++++------ 7 files changed, 53 insertions(+), 53 deletions(-)