From nobody Thu Sep 4 23:43:24 2025 X-Original-To: dev-commits-src-main@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 4cHwzG5SYzz66k0x; Thu, 04 Sep 2025 23:43:38 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4cHwzG1sGxz44TY; Thu, 04 Sep 2025 23:43:38 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 584NhO06067037; Fri, 5 Sep 2025 02:43:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 584NhO06067037 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 584NhOmh067036; Fri, 5 Sep 2025 02:43:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 5 Sep 2025 02:43:24 +0300 From: Konstantin Belousov To: Jamie Gritton Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 851dc7f859c2 - main - jail: add jail descriptors Message-ID: References: <202509042031.584KVpxY000408@gitrepo.freebsd.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202509042031.584KVpxY000408@gitrepo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on tom.home X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: 4cHwzG1sGxz44TY On Thu, Sep 04, 2025 at 08:31:51PM +0000, Jamie Gritton wrote: > The branch main has been updated by jamie: > > URL: https://cgit.FreeBSD.org/src/commit/?id=851dc7f859c23cab09a348bca03ab655534fb7e0 > > commit 851dc7f859c23cab09a348bca03ab655534fb7e0 > Author: Jamie Gritton > AuthorDate: 2025-09-04 20:27:47 +0000 > Commit: Jamie Gritton > CommitDate: 2025-09-04 20:27:47 +0000 > > jail: add jail descriptors > > Similar to process descriptors, jail desriptors are allow jail > administration using the file descriptor interface instead of JIDs. > They come from and can be used by jail_set(2) and jail_get(2), > and there are two new system calls, jail_attach_jd(2) and > jail_remove_jd(2). > > Reviewed by: bz, brooks The code is from jaildesc_alloc(): jd = malloc(sizeof(*jd), M_JAILDESC, M_WAITOK | M_ZERO); error = falloc_caps(td, &fp, fdp, 0, NULL); finit(fp, priv_check_cred(fp->f_cred, PRIV_JAIL_SET) == 0 ? FREAD | FWRITE : FREAD, DTYPE_JAILDESC, jd, &jaildesc_ops); ^^^^^^^^^^^ '?' should be placed on the previous line if (error != 0) { free(jd, M_JAILDESC); return (error); } If falloc_caps() returned error, fp does not point to a valid file. Then finit() operates on random memory. Generated files should have been committed as a follow-up, not in the same commit as written code. jaildesc_find() returns EBADF when passed file type is not DTYPE_JAIL. Normally EBADF means that the object underlying the file is invalidated, like vnode is reclaimed, tty is revoked, etc. For the wrong type, EINVAL should be returned. jaildesc_close() does finit(fp, 0, DTYPE_NONE, NULL, &badfileops); that is not needed, same as cleaning f_data. There are fo_chown/fo_chmod methods that are semantically applied to the jail files, instead of the underlying object. This is quite strange, files do not have concept of owner.