From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796541046; b=jcreUNrGbAxeuLf9S5OeQc3LLkdzMCLd5w3b2yzGgCU5vRRJ+0wIQsiJ/zsDozhMmben eRiwrMIjpTpWqPCof/3rdkO3+ObjYDfpUsfAoGlU1cygpNjNPFydiZPyk3h34iDxAI9fj 8rwoeRviE4260qZo2Y+WTd6Ms/PxP8oplK0wiXlw87GlvHaSwXP0IIQ653JIAw0hx54Iu 492VmP/ivhYwn30BA1INwdIR7M8rkGmGfWM9bQgQ8MVKtdQQX9fv4uPN2qajj81xVCPm3 9ihtwipO10KSy9hUjs85cJK2+zPpyfh6ffNz5gVrrQNu7086kVba4TPns91dETmbREA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796541046; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=DF3hMY4rqk2onfJpCrUJhc2kDTdhyI2KKKATss526BM=; b=3QUjLYggzpobpJxB1fZ54JsF//xx8L5Tni7cJlmaJJdra8b29Q64vxkdvGfVqi0+8OQ8 c960UgpBIHeO0vaCqnvSLPepkF2dMPFTW8cctlwU07f5gZJ/bFciHYxYB2XE+UUIE/VFe 0uQi9xSsqD3KF0bd5tG9cN7G1a+maIC78gCtpagSN2uHSCB/hwou/XmHzzv8YjFRWqScP F0EtyYP9bG/zdbEYt2SC4FYpHhki1AJql2Lv6CFM7Z4Cw9f+d05fgKMcRWNOv65gy98gJ qV/z2CwXdKJJIJuFTpfKEPSmzYFlmN8dKWuY7H/6V4+b13dLH4gIFZLkcOuZ/JLnt+w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dvaZcVFU; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CEC5606A332 for ; Sun, 6 Dec 2026 07:10:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dvaZcVFU Received: by smtp.kernel.org (Postfix) with ESMTPSA id 862C21F0093B; Sun, 6 Dec 2026 07:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796541045; bh=DF3hMY4rqk2onfJpCrUJhc2kDTdhyI2KKKATss526BM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=dvaZcVFUjW2eP37Yf7pq9zPv62w3LtdIyMUvQec/RZEuCWEbT2RVvE9DS4iT9xoh5 yO+sxt03xR9IXiWNPHsjZRuT/k7G6EufSL8HZyud+78EMhzrYHidQVE9w2wbt7elJW M6/BnhSDDEM1no0Jp1JwyrGWlsZlvRCWezgMZoRH2+3gybG8NVKQCn2W3ecIsNl6Ri tHcJefF0wrqr9m3GGYPMc4Lqks5V/ITi/+USFT4dxvjB9cQZq1R1QQ8To6RjVbz59r L4CK259HCPm0oIN09n2Fq3B3kRzvk6p50xQCrIntro9PJx9sC872Ttm+2XBhrjKdt1 Vryg1EKvNuLzA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 3/3] RDMA/iwpm: keep the port-mapper request data inside the request Reply-To: sashiko-reviews@lists.linux.dev To: "Daniel Wade" Cc: linux-rdma@vger.kernel.org In-Reply-To: <20261206065723.147-4-danjwade95@gmail.com> References: <20261206065723.147-1-danjwade95@gmail.com> <20261206065723.147-4-danjwade95@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 07:10:45 +0000 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] RDMA/iwpm: data race on nlmsg_request->data.sa during post-wait copy-out - [Medium] RDMA/iwpm: nlmsg_request published before nlmsg_request->data is initialized - [Low] RDMA/iwpm: whole-struct copy reads uninitialized stack fields from pm_msg -- commit 5384e5afb7f8b54dc9f77b2c25ecb5a44fd3f7e4 Author: Daniel Wade RDMA/iwpm: keep the port-mapper request data inside the request This commit embeds the port-mapper request data inside struct iwpm_nlmsg_request instead of storing a pointer to the caller's stack buffer in req_buffer, and moves the caller's kref_put() out of iwpm_wait_complete_req() so the response can be copied back before the request is freed. > diff --git a/drivers/infiniband/core/iwpm_msg.c b/drivers/infiniband/core= /iwpm_msg.c > index 1d77349db51e5..ecf7e12674732 100644 > --- a/drivers/infiniband/core/iwpm_msg.c > +++ b/drivers/infiniband/core/iwpm_msg.c > @@ -106,6 +106,7 @@ int iwpm_register_pid(struct iwpm_dev_data *pm_msg, u= 8 nl_client) > goto pid_query_error; > =20 > nlmsg_end(skb, nlh); > + nlmsg_request->data.dev =3D *pm_msg; [Severity: Medium] Can an early netlink reply race with this initialization of nlmsg_request->data? CPU0 CPU1 iwpm_register_pid() iwpm_get_nlmsg_request() list_add_tail(..., &iwpm_nlmsg_req_list) iwpm_register_pid_cb() iwpm_find_nlmsg_request() strcmp(pm_msg->dev_name, dev_name) <-- reads all-zero dev_name nlmsg_request->data.dev =3D *pm_msg iwpm_get_nlmsg_request() publishes the zero-allocated request on iwpm_nlmsg_req_list before the caller populates nlmsg_request->data. A privileged netlink reply with the next sequence number can match an empty dev_name and register iwpm_user_pid without verifying the device. The same window exists in iwpm_add_mapping() and iwpm_add_and_query_mapping(), where a concurrent callback's write to mapped_loc_addr can be overwritten by nlmsg_request->data.sa =3D *pm_msg. Populating nlmsg_request->data before inserting the request onto iwpm_nlmsg_req_list would close this window. [ ... ] > @@ -195,7 +196,7 @@ int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 = nl_client) > } > =20 > nlmsg_end(skb, nlh); > - nlmsg_request->req_buffer =3D pm_msg; > + nlmsg_request->data.sa =3D *pm_msg; [Severity: Low] Does this whole-struct assignment copy uninitialized stack bytes from pm_msg into nlmsg_request->data.sa? iw_cm_map() leaves mapped_loc_addr and mapped_rem_addr uninitialized in its stack pm_msg. Assigning *pm_msg here and in iwpm_add_and_query_mapping() clobbers the zeroed heap fields with uninitialized stack bytes. Any completion path that skips writing those fields will then propagate uninitialized stack memory instead of zeroes, and iwpm_add_mapping() always copies the unwritten mapped_rem_addr back out. Copying only the input fields in and output fields out, or zero-initializing pm_msg in iw_cm_map(), would avoid this. > @@ -205,6 +206,9 @@ int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 = nl_client) > goto add_mapping_error; > } > ret =3D iwpm_wait_complete_req(nlmsg_request); > + if (!ret) > + *pm_msg =3D nlmsg_request->data.sa; > + kref_put(&nlmsg_request->kref, iwpm_free_nlmsg_request); > return ret; [Severity: Medium] Can a second netlink reply race with this copy of nlmsg_request->data.sa? CPU0 CPU1 iwpm_add_mapping() iwpm_wait_complete_req() ... iwpm_add_mapping_cb() [reply 1] memcpy(&pm_msg->mapped_loc_addr, ...) up(&nlmsg_request->sem) kref_put() /* kref 2 -> 1 */ *pm_msg =3D nlmsg_request->data.sa iwpm_add_mapping_cb() [reply 2] <-- data race / torn read iwpm_find_nlmsg_request() memcpy(&pm_msg->mapped_loc_addr, ...) kref_put() /* unlinks here */ nlmsg_request is only unlinked from iwpm_nlmsg_req_list inside iwpm_free_nlmsg_request() when kref reaches zero, and iwpm_find_nlmsg_request() neither unlinks it nor checks request_done. Because rdma_nl_rcv_msg() takes a shared read lock on rdma_nl_types[index].sem, a second privileged reply on another netlink socket can find the request and overwrite data.sa (or err_code) while this function or iwpm_add_and_query_mapping() copies it out. This causes a data race and can produce torn mapped_loc_addr or mapped_rem_addr values. Unlinking or claiming the request under iwpm_nlmsg_req_lock on the first reply or timeout would give the caller exclusive access during copy-out. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261206065723.147-= 1-danjwade95@gmail.com?part=3D3