Verify that log tree commit is for sending rid

We were trusting the rid in the log trees struct that the client sent.
Compare it to our recorded rid on the connection and fail if the client
sent the wrong rid.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2021-08-04 10:05:11 -07:00
parent 7cf9cd8c20
commit 89b5865a4c

View File

@@ -882,6 +882,7 @@ static int server_commit_log_trees(struct super_block *sb,
u8 cmd, u64 id, void *arg, u16 arg_len)
{
struct scoutfs_super_block *super = &SCOUTFS_SB(sb)->super;
const u64 rid = scoutfs_net_client_rid(conn);
DECLARE_SERVER_INFO(sb, server);
SCOUTFS_BTREE_ITEM_REF(iref);
struct scoutfs_log_trees lt;
@@ -896,6 +897,11 @@ static int server_commit_log_trees(struct super_block *sb,
/* don't modify the caller's log_trees */
memcpy(&lt, arg, sizeof(struct scoutfs_log_trees));
if (le64_to_cpu(lt.rid) != rid) {
ret = -EIO;
goto out;
}
scoutfs_server_hold_commit(sb);
mutex_lock(&server->logs_mutex);