Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2882912rwb; Mon, 15 Aug 2022 13:15:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR4wfoEWsDOA58EOwG9I24aNobAaeG0BMADpclSsxgUYNVjP/pwa2g5HS0ARXhm3rPbOEG1i X-Received: by 2002:a17:907:7e9b:b0:731:5df7:2fe7 with SMTP id qb27-20020a1709077e9b00b007315df72fe7mr11247519ejc.409.1660594508059; Mon, 15 Aug 2022 13:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594508; cv=none; d=google.com; s=arc-20160816; b=fZrThjLw6fjMBJInw66Q+YefzBAZPhJT3jUPPVmihgWzpl0i3z9Tg9VLJ4AivXbouX DudRjtVY6YldV56cNohHUjKMfmDhiFiEzMPhiHGbmRUCwlT4UoFzaTEV4CL0g5af0jn3 fbouRTbZ1UTdKdYwAVftqJ96woyxxZgkfZ+J8O/Gn4wdj0u5YQA+NcOKHflIgbz2tbkp 7JQo4vq0W/PkqtoG92nsMM6j1B7+eT6CTlPfNvL4hfIjJiN3J//Ncf1qfWoGhEEUBuw7 /zyvlPzpyMree3ANzzVvK62Ty+hH7wMy41P6af//AidV3uNxpGZ2eIZpz8XaTpj5nnWT IRng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PjtRz8ekiZpCuXzgJZLBWivGXFly7wV+cU9xhRhGT5s=; b=PYNh6vJYT9y3CStc4xaW9d4h1xys0usPFLSsaes/WpiCcm+XNUKpHG3hx6JMEBvqJT Fsb7NClKZW6xagwFPjLDqfg6QB4l0y2U67fO2zPkj9wng8+oBqli62sfRC1K+SSvK++D HdptoVuFMpBZ8mpCZnRnq1kqVwG8Z3SQUfDUM1DTiQYD3+N9TRFvCEAGlR7DGwa1vThn 9+PX9JQqze43rwQlmKGnS040wvqV1rM3IoNjlPGDo6TVAWd9KNkymkUtbhrwMiv1fZlO +2Ocb02jdounXVMJ72QSJBcbMts52kEGPppGZGVzzdbqZuIDhpEi2fxKbJ+U7PR0zZGt USbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qhE7xj1q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l4-20020a170906794400b00711f4c750basi9204232ejo.940.2022.08.15.13.14.41; Mon, 15 Aug 2022 13:15:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qhE7xj1q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344491AbiHOTVP (ORCPT + 99 others); Mon, 15 Aug 2022 15:21:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345013AbiHOTR6 (ORCPT ); Mon, 15 Aug 2022 15:17:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D45683CBC9; Mon, 15 Aug 2022 11:39:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 27AAE60EEB; Mon, 15 Aug 2022 18:39:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22703C433C1; Mon, 15 Aug 2022 18:39:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588758; bh=me+uVPTFhaXSsPHbDKu2J3u0dmD1ACILvwldhii9Rro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qhE7xj1qrckUzp6/JtwZgYKh6SxpPZhx/Eh4phWtNg5c9fc8MOzVwuXjnJnvd5rrA RiJepeE0X6sZkievcn/wLxrZ0L2r0Hr0mjwULVgYSssGuJv3IFKaZeo1MKEYtEt9WG 0ChAJqrEvnKM4kVSWlSO3T2qwHPSrUGOSt1pJGWA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Md Haris Iqbal , Gioh Kim , Aleksei Marov , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.15 506/779] RDMA/rtrs: Do not allow sessname to contain special symbols / and . Date: Mon, 15 Aug 2022 20:02:30 +0200 Message-Id: <20220815180358.892721182@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Md Haris Iqbal [ Upstream commit dea7bb3ad3e08f96815330f88a62c24d7a9dacae ] 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 Reviewed-by: Gioh Kim Reviewed-by: Aleksei Marov Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 6 ++++++ drivers/infiniband/ulp/rtrs/rtrs-srv.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index a23438bacf12..be96701cf281 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -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, diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 078a1cbac90c..7df71f8cf149 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -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); -- 2.35.1