From nobody Tue May 21 13:41:07 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VkFvT3gGdz5LND5; Tue, 21 May 2024 13:41:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VkFvS4yysz4HWk; Tue, 21 May 2024 13:41:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716298868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ngt/fW5tRLRiX6gG+wPpKzlVQDL/uOUGtqMLAx3eDzI=; b=egSc3XKIYiPfbZ+iGZpYV2KJgqvtzzXm4eMn5zBjH9JaGck7p1cSCzBZUMigiG17ua2IKI SE0hThzzU30ce/9cfN9AfLluxeyRodmvo8LA0K3V34w+rfAdJOmNcBleBA2o7fwlLlw7DA robZNROfVc4DyR3BOdwe2gMYbmzqbltNoI3hXjUcY50D8jnj6NWK/P1y9j7Vf5YtON+rMX Ba8u/4xGcNF/6zZB+0eZy5h0ODUIL6QAgtXllRZ9+JX8OHPlUOZEfA0VHuwBZsi1Y49INi f6Nn4jzDKI1JmW7BaUnlsUEyUD1YS/5tMkMeTrdcd/IiAwurz+xHWh9M8cONmg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716298868; a=rsa-sha256; cv=none; b=Z6fxagEaEJsIzkc1mE/U00CAaa31r6hCgw5ZuqyjeX4EXURJ3RvAD6DWVEdizvthwJN8Kl rueAnwqBaoz0JwPNVgtkmlHyA7l8DkiXSFxPAet0kbnUuWdqGX2DPfKjRlnxu84fpIPwYe Oo/MQkb3sDmaIJacvgltVg992B6MTRf5r6xJAjb/tpbOlZp6fvL+LldWYA1wtYhwpcitbk mGwwcQXpq07p4gcbcxCWSl2MIuf+UlPdOoKZBfzUlLCLjywsUSrgS8ZBnd+cyNJpjG6Er2 ZIcbeIpwOsLi6QRimzgWWbKJIk3pE1bAlprACih5Ejn7YmVncM2oOFWunsnOOw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716298868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ngt/fW5tRLRiX6gG+wPpKzlVQDL/uOUGtqMLAx3eDzI=; b=cisBA886sxAILY/xw3yeiypJrAj07D0l+ZdWBc6dGRdRXW5rv8k3neH/srRGR53cohlMAz Ms6QzypR5tqrYac1tCbZc+ZJfsQZJGCsCFFzWsTgWkkXwRNqGlEsEV8xoFkmmnxnkMmhB6 ZXmdnQg3fzlsJwRdF1UJUMNaSTEp7sT5WchG7TXizh2wxsUnK1fG+QChZU7Bm0daoeeX1U N+5RmeovdslOMGTTQBr7wJlpK3ilQyGtvCqdxIUlQ0/T+HNuip0sxL9XU5lI3H9ICpEaCw 2SdGSE7bvc8HL7D2LBTdJUaCSstN5oKEVRaHrzUIGsy1DNQ0Tnvq88dSovzLXw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VkFvR4WC7zP4c; Tue, 21 May 2024 13:41:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44LDf77C091745; Tue, 21 May 2024 13:41:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44LDf7E2091742; Tue, 21 May 2024 13:41:07 GMT (envelope-from git) Date: Tue, 21 May 2024 13:41:07 GMT Message-Id: <202405211341.44LDf7E2091742@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 7975f57b7e14 - main - uipc_shm: Fix double check for shmfd->shm_path List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7975f57b7e14b146ca730421ef9e2094c242e9c0 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=7975f57b7e14b146ca730421ef9e2094c242e9c0 commit 7975f57b7e14b146ca730421ef9e2094c242e9c0 Author: Ricardo Branco AuthorDate: 2024-05-20 13:09:08 +0000 Commit: Ed Maste CommitDate: 2024-05-21 13:39:53 +0000 uipc_shm: Fix double check for shmfd->shm_path Reviewed by: emaste, zlei Pull Request: https://github.com/freebsd/freebsd-src/pull/1250 --- sys/kern/uipc_shm.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 1136f34a6f85..c83455d1e70b 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1910,21 +1910,19 @@ shm_fill_kinfo_locked(struct shmfd *shmfd, struct kinfo_file *kif, bool list) kif->kf_un.kf_file.kf_file_mode = S_IFREG | shmfd->shm_mode; kif->kf_un.kf_file.kf_file_size = shmfd->shm_size; if (shmfd->shm_path != NULL) { - if (shmfd->shm_path != NULL) { - path = shmfd->shm_path; - pr_path = curthread->td_ucred->cr_prison->pr_path; - if (strcmp(pr_path, "/") != 0) { - /* Return the jail-rooted pathname. */ - pr_pathlen = strlen(pr_path); - visible = strncmp(path, pr_path, pr_pathlen) - == 0 && path[pr_pathlen] == '/'; - if (list && !visible) - return (EPERM); - if (visible) - path += pr_pathlen; - } - strlcpy(kif->kf_path, path, sizeof(kif->kf_path)); + path = shmfd->shm_path; + pr_path = curthread->td_ucred->cr_prison->pr_path; + if (strcmp(pr_path, "/") != 0) { + /* Return the jail-rooted pathname. */ + pr_pathlen = strlen(pr_path); + visible = strncmp(path, pr_path, pr_pathlen) == 0 && + path[pr_pathlen] == '/'; + if (list && !visible) + return (EPERM); + if (visible) + path += pr_pathlen; } + strlcpy(kif->kf_path, path, sizeof(kif->kf_path)); } return (0); }