From nobody Sat Sep 6 02:29:05 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 4cJcc10gFVz66nF9; Sat, 06 Sep 2025 02:29:21 +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 4cJcc04bV4z3P35; Sat, 06 Sep 2025 02:29:20 +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 5862T6u1019878; Sat, 6 Sep 2025 05:29:09 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 5862T6u1019878 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 5862T6bA019877; Sat, 6 Sep 2025 05:29:06 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 6 Sep 2025 05:29:05 +0300 From: Konstantin Belousov To: James 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> <282327ee69d5c26f379961c12e19dfbe@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: <282327ee69d5c26f379961c12e19dfbe@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: 4cJcc04bV4z3P35 On Fri, Sep 05, 2025 at 10:24:16AM -0700, James Gritton wrote: > On 2025-09-04 22:14, Konstantin Belousov wrote: > > On Thu, Sep 04, 2025 at 09:43:13PM -0700, James Gritton wrote: > > > On 2025-09-04 16:43, Konstantin Belousov wrote: > > > > 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 > > > > > > I wasn't aware of this requirement; style(9) is silent on it. > > In fact style(9) contains the explicit requirement: > > If you have to wrap a long statement, put the operator at the end > > of the > > line. > > There are a lot more of this pattern repeated in the commit. > > Ah, yes it says that. I was scanning examples looking for the "?", > and missed the general statement. I don't think it's the best move > for the ?: operator in particular, but I appreciate consistency in > style. I can change that in kern_jaildesc.c, but it's a little > trickier in kern_jail.c since it's already replete with me having done > it wrong over the years. > > > > > Generated files should have been committed as a follow-up, not in the > > > > same commit as written code. > > > > > > The FreeBSD Wiki explicitly allows it in the same commit. > > I always objected against this practice. For instance, the commit > > message > > for this commit is even less useful because most of the limit was > > filled > > with the auto-generated stuff, instead of the code. Same for reading > > the > > commits with log. > > > > Could you please point me to the wiki page? > > https://wiki.freebsd.org/AddingSyscalls#Committing > > > > > 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. > > > > > > That's part of the code that I lifted from process descriptors, nearly > > > identical to procdesc_find. A check of other c_type checks shows > > > EBADF isn't uncommon. > > So procdesc is wrong as well, I think. > > The existing code base is quite inconsistent. I some EINVAL, some > EBADF (procdesc, kqueue, fcntl), also EPERM, ENODEV, ENOTSUPP, EPIPE, > and ENOTSOCK. EINVAL is the most common, but there are enough EBADF > that I feel I can keep it. kern_event.c is relatively consistent to report EBADF when kqueue(2) is called on closing kqueue, which essentially means that it is reclaimed under it. kern_descrip.c' EBADFs are right: mostly EBADF is returned when fget() failed. The only incorrect use EBADF are two places in sys_procdesc.c, and I will fix them. So no, I do not agree with the frivolous use of EBADF in new code.