From nobody Tue Dec 13 22:25:27 2022 X-Original-To: freebsd-current@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 4NWtP20FTFz4jjH8 for ; Tue, 13 Dec 2022 22:25:42 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-vs1-f48.google.com (mail-vs1-f48.google.com [209.85.217.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NWtP12XJgz3q3W for ; Tue, 13 Dec 2022 22:25:41 +0000 (UTC) (envelope-from asomers@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=none; spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.217.48 as permitted sender) smtp.mailfrom=asomers@gmail.com; dmarc=none Received: by mail-vs1-f48.google.com with SMTP id t5so16152160vsh.8 for ; Tue, 13 Dec 2022 14:25:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wJ2jqbIWlriHZJI0pOhklUW5lJSdWDCQsL3fMAA/rGo=; b=qh0JH1YE324p/hjzQpUIjkLJdOpbvgRmKEyzPhF1Zri2cllzRuFEQm/eB1T4bRp9mR 9XwEmjpoH56KsFMhZwpwFyuTMzJaF/04vVXeWzjkzKVmx/m2lbfgeM560F7uWHXDqL+u J+/PmlNqLx7bc9sLaokPJRo650IQHU3j1du4p4SZmpFW5/ijBL8yL7b9dMtYcbOsL7Bn hMyCpFX0pvqP37+tYOPwYsfMbqlxN9YPkFQ7+mTQvb+QcwT7hCxJFbfA+oSYQYCMfyip lFBQb8QfWr/195zdR7jmE826rCJNSrgYG2vmDwuZ2qVpABIQG2OUpn9cTa5C7xOlJeMQ TSlw== X-Gm-Message-State: ANoB5plzxVeT7+kKHJoa7+jHB9h1AvnBnVxdK/8Pr/47DQSfAzwsPcvS 7FeKXZ5wV5rxBemVprQx/sYujiDFfQ7+emTRpJ8z08p8 X-Google-Smtp-Source: AA0mqf4+nBzVVhMjwv+y5UTdBkMP7xVuxTVh+gAuA7FQl7jCcXWBvixU6+17/UdvGfvoCYuMUnLVvG5QGTvqn+BUUaE= X-Received: by 2002:a05:6102:c48:b0:3b0:9f5f:e25 with SMTP id y8-20020a0561020c4800b003b09f5f0e25mr28019919vss.74.1670970339267; Tue, 13 Dec 2022 14:25:39 -0800 (PST) List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: Alan Somers Date: Tue, 13 Dec 2022 15:25:27 -0700 Message-ID: Subject: Re: What to do about a few lines in vfs_domount() never executed? To: Rick Macklem Cc: FreeBSD CURRENT Content-Type: text/plain; charset="UTF-8" X-Spamd-Result: default: False [-0.15 / 15.00]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_LONG(-0.98)[-0.981]; NEURAL_HAM_SHORT(-0.96)[-0.962]; NEURAL_SPAM_MEDIUM(0.79)[0.791]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; TAGGED_RCPT(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DMARC_NA(0.00)[freebsd.org]; RCVD_IN_DNSWL_NONE(0.00)[209.85.217.48:from]; MLMMJ_DEST(0.00)[freebsd-current@freebsd.org]; FROM_HAS_DN(0.00)[]; FREEFALL_USER(0.00)[asomers]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_ALL(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.217.48:from]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; RCVD_COUNT_TWO(0.00)[2] X-Rspamd-Queue-Id: 4NWtP12XJgz3q3W X-Spamd-Bar: / X-ThisMailContainsUnwantedMimeParts: N If you're 100.0% percent sure that it will never be run, you can delete it. But if you're only 99.9%, then I suggest converting it into a KASSERT. On Tue, Dec 13, 2022 at 3:20 PM Rick Macklem wrote: > > Hi, > > While working on getting mountd/nfsd to run in a vnet > prison, I came across the following lines near the > beginning of vfs_domount() in sys/kern/vfs_mount.c: > > if (fsflags & MNT_EXPORTED) { > error = priv_check(td, PRIV_VFS_MOUNT_EXPORTED); > if (error) > return (error); > } > > #1 - Since MNT_EXPORTED is never set in fsflags, this code never > gets executed. > --> I am asking what to do with the above code, since that > changes for the patch that allows mountd to run in a vnet > prison. > #2 - priv_check(td, PRIV_VFS_MOUNT_EXPORTED) always returns 0 > because nothing in sys/kern/kern_priv.c checks > PRIV_VFS_MOUNT_EXPORTED. > > I don't know what the original author's thinking was w.r.t. this. > Setting exports already checks that the mount operation can be > done by the requestor. > > So, what do you think should be done with the above code snippet? > - Consider it cruft and delete it. > - Try and figure out what PRIV_VFS_MOUNT_EXPORTED should check? > - Leave it as is. After the patch that allows mountd to run in > a vnet prison, MNT_EXPORTED will be set in fsflags, but the > priv_check() call will just return 0. (A little overhead, > but otherwise no semantics change.) > > rick >