Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33d07337 authored by Yan, Zheng's avatar Yan, Zheng Committed by Ilya Dryomov
Browse files

libceph: message signature support



Signed-off-by: default avatarYan, Zheng <zyan@redhat.com>
parent ae385eaf
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -3744,6 +3744,20 @@ 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)
{
       struct ceph_mds_session *s = 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)
{
       struct ceph_mds_session *s = con->private;
       struct ceph_auth_handshake *auth = &s->s_auth;
       return ceph_auth_check_message_signature(auth, msg);
}

static const struct ceph_connection_operations mds_con_ops = {
	.get = con_get,
	.put = con_put,
@@ -3753,6 +3767,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,
};

/* eof */
+26 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@

struct ceph_auth_client;
struct ceph_authorizer;
struct ceph_msg;

struct ceph_auth_handshake {
	struct ceph_authorizer *authorizer;
@@ -20,6 +21,10 @@ struct ceph_auth_handshake {
	size_t authorizer_buf_len;
	void *authorizer_reply_buf;
	size_t authorizer_reply_buf_len;
	int (*sign_message)(struct ceph_auth_handshake *auth,
			    struct ceph_msg *msg);
	int (*check_message_signature)(struct ceph_auth_handshake *auth,
				       struct ceph_msg *msg);
};

struct ceph_auth_client_ops {
@@ -66,6 +71,11 @@ struct ceph_auth_client_ops {
	void (*reset)(struct ceph_auth_client *ac);

	void (*destroy)(struct ceph_auth_client *ac);

	int (*sign_message)(struct ceph_auth_handshake *auth,
			    struct ceph_msg *msg);
	int (*check_message_signature)(struct ceph_auth_handshake *auth,
				       struct ceph_msg *msg);
};

struct ceph_auth_client {
@@ -113,4 +123,20 @@ extern int ceph_auth_verify_authorizer_reply(struct ceph_auth_client *ac,
extern void ceph_auth_invalidate_authorizer(struct ceph_auth_client *ac,
					    int peer_type);

static inline int ceph_auth_sign_message(struct ceph_auth_handshake *auth,
					 struct ceph_msg *msg)
{
	if (auth->sign_message)
		return auth->sign_message(auth, msg);
	return 0;
}

static inline
int ceph_auth_check_message_signature(struct ceph_auth_handshake *auth,
				      struct ceph_msg *msg)
{
	if (auth->check_message_signature)
		return auth->check_message_signature(auth, msg);
	return 0;
}
#endif
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ static inline u64 ceph_sanitize_features(u64 features)
	 CEPH_FEATURE_PGPOOL3 |			\
	 CEPH_FEATURE_OSDENC |			\
	 CEPH_FEATURE_CRUSH_TUNABLES |		\
	 CEPH_FEATURE_MSG_AUTH |		\
	 CEPH_FEATURE_CRUSH_TUNABLES2 |		\
	 CEPH_FEATURE_REPLY_CREATE_INODE |	\
	 CEPH_FEATURE_OSDHASHPSPOOL |		\
+8 −1
Original line number Diff line number Diff line
@@ -42,6 +42,10 @@ 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);
};

/* use format string %s%d */
@@ -142,7 +146,10 @@ struct ceph_msg_data_cursor {
 */
struct ceph_msg {
	struct ceph_msg_header hdr;	/* header */
	union {
		struct ceph_msg_footer footer;		/* footer */
		struct ceph_msg_footer_old old_footer;	/* old format footer */
	};
	struct kvec front;              /* unaligned blobs of message */
	struct ceph_buffer *middle;

+8 −0
Original line number Diff line number Diff line
@@ -164,13 +164,21 @@ struct ceph_msg_header {
/*
 * follows data payload
 */
struct ceph_msg_footer_old {
	__le32 front_crc, middle_crc, data_crc;
	__u8 flags;
} __attribute__ ((packed));

struct ceph_msg_footer {
	__le32 front_crc, middle_crc, data_crc;
	// sig holds the 64 bits of the digital signature for the message PLR
	__le64  sig;
	__u8 flags;
} __attribute__ ((packed));

#define CEPH_MSG_FOOTER_COMPLETE  (1<<0)   /* msg wasn't aborted */
#define CEPH_MSG_FOOTER_NOCRC     (1<<1)   /* no data crc */
#define CEPH_MSG_FOOTER_SIGNED	  (1<<2)   /* msg was signed */


#endif
Loading