From nobody Thu Aug 01 17:35:58 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 4WZbjC0Dmvz5T6M6; Thu, 01 Aug 2024 17:35:59 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WZbjB4K3jz4tXy; Thu, 1 Aug 2024 17:35:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722533758; 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=zZttNOnFtI0o6f2wvh+HLVQdwyXBnC5PabCKmP/wC8M=; b=VbjTe+Z88QMiqfSEtSLcH5o7dRtHDY/5ITSUnTf7urfMcjemMlSYx0+TSwGAiy8W4ikce4 tP9laYy/AqmC4wYod9XJYx8FJ3e2bAyolMZTZ3u6rAkeiiS1RSXwAgxAzFT2JCki8W3oCH 5l4nA6gptD1N4urSvNMxPaov3Q54YN0oXu8ej2+XHiiqTLqbSO2wjhwg0StDzxDYKAbnyo yMgdHh1YtrWLZyAiEyDR140gWFSDdCEXWYBMOxPrJjWNXUu3cbe5A1VFamB6/qUhVmjEun 13eHzQAidnMm96++R1pDqP41JvWPqCetxuQ68wPxG/gjrYqjHbz+OPj7bMh+1g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722533758; a=rsa-sha256; cv=none; b=y4r2mog6wljiedX9PLdCP9JMtm+p/5jdFuAK4dvGC4xv1GwWxv5hGW0jisov0WUChn7bd8 rbCr93cvJ18NDsdQs1Dx+GvaKuBpD6gzainDSQt9k1p9Q1plgcxmG5KDB9SF8QBfy4tTXq L+QI+c+ncOpUJOVpVQTXysv4ojgEid9G/a19wbBrKoO5gj9coZjJEnvdMsqxOnIkmoc84c i2roY4n/2PyDkRe/Ght6e3VWFKQoqGdJuErPhTL5LmU9u69VtZ1U3ji/9n3XIF8k9/UPqs c1+pdXRDqh5YISlNksV+K8mdhCrXO0EGav/HJPSM/bs9GcnJsPQY8xQkpr8+Tg== 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=1722533758; 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=zZttNOnFtI0o6f2wvh+HLVQdwyXBnC5PabCKmP/wC8M=; b=TUDrVay6WUyREUwe5571CVgKeZ4eOmTVQStEu4ogXCE3j/c5c+LP6+dFmg5A/oG53GPb2M m4fiKudx3xORFCZiUkqRmwO7dLn9W6GvqYiHShi+GkkPjufyll5CuJbxKCAtWb0lUdDxIy 7BL9j9rG2Tkv/6eicd8y15edDuKIdF09QEXg3qUisijNkdA7F/QlwR3TQ2dfu187XDexIA OcgbeZitbIF23zGEl75RYikCwAofcD1cdrGo4XrMiVYqhl1yjdkKVzCDu8Rmx4TO5tpAAh 133NH00vsHLreHEesqkB9mdg8jSXNGBP0UpXP8ZovtOTNtGIUropnllSMZcBkQ== 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 4WZbjB3k33ztnw; Thu, 1 Aug 2024 17:35:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 471HZwEf031787; Thu, 1 Aug 2024 17:35:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471HZwi2031784; Thu, 1 Aug 2024 17:35:58 GMT (envelope-from git) Date: Thu, 1 Aug 2024 17:35:58 GMT Message-Id: <202408011735.471HZwi2031784@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: bd208ed0ab94 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: bd208ed0ab94d92443feff6eea2240f498deed65 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=bd208ed0ab94d92443feff6eea2240f498deed65 commit bd208ed0ab94d92443feff6eea2240f498deed65 Author: Ricardo Branco AuthorDate: 2024-05-20 13:09:08 +0000 Commit: Ed Maste CommitDate: 2024-08-01 17:34:50 +0000 uipc_shm: Fix double check for shmfd->shm_path Reviewed by: emaste, zlei Pull Request: https://github.com/freebsd/freebsd-src/pull/1250 (cherry picked from commit 7975f57b7e14b146ca730421ef9e2094c242e9c0) --- 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 0bfbc636e405..20dbe59e2a96 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1909,21 +1909,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); }