Skip to content

Commit

Permalink
RDMA/rtrs: Do not allow sessname to contain special symbols / and .
Browse files Browse the repository at this point in the history
[ Upstream commit dea7bb3 ]

Allowing these characters in sessname can lead to unexpected results,
particularly because / is used as a separator between files in a path, and
. points to the current directory.

Link: https://lore.kernel.org/r/20210922125333.351454-7-haris.iqbal@ionos.com
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Reviewed-by: Gioh Kim <gi-oh.kim@ionos.com>
Reviewed-by: Aleksei Marov <aleksei.marov@ionos.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
hiqbal-ionos authored and gregkh committed Aug 17, 2022
1 parent 8b6dba7 commit e44928f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/infiniband/ulp/rtrs/rtrs-clt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2790,6 +2790,12 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops,
struct rtrs_clt *clt;
int err, i;

if (strchr(sessname, '/') || strchr(sessname, '.')) {
pr_err("sessname cannot contain / and .\n");
err = -EINVAL;
goto out;
}

clt = alloc_clt(sessname, paths_num, port, pdu_sz, ops->priv,
ops->link_ev,
reconnect_delay_sec,
Expand Down
5 changes: 5 additions & 0 deletions drivers/infiniband/ulp/rtrs/rtrs-srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,11 @@ static int process_info_req(struct rtrs_srv_con *con,
return err;
}

if (strchr(msg->sessname, '/') || strchr(msg->sessname, '.')) {
rtrs_err(s, "sessname cannot contain / and .\n");
return -EINVAL;
}

if (exist_sessname(sess->srv->ctx,
msg->sessname, &sess->srv->paths_uuid)) {
rtrs_err(s, "sessname is duplicated: %s\n", msg->sessname);
Expand Down

0 comments on commit e44928f

Please sign in to comment.