From owner-svn-src-all@freebsd.org Tue Aug 20 17:46:41 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 784E5D6E81; Tue, 20 Aug 2019 17:46:41 +0000 (UTC) (envelope-from gordon@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46CdX12dP8z4bYs; Tue, 20 Aug 2019 17:46:41 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C0496D87; Tue, 20 Aug 2019 17:46:41 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7KHkffE060848; Tue, 20 Aug 2019 17:46:41 GMT (envelope-from gordon@FreeBSD.org) Received: (from gordon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7KHkf4r060847; Tue, 20 Aug 2019 17:46:41 GMT (envelope-from gordon@FreeBSD.org) Message-Id: <201908201746.x7KHkf4r060847@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gordon set sender to gordon@FreeBSD.org using -f From: Gordon Tetlow Date: Tue, 20 Aug 2019 17:46:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r351258 - releng/11.3/sbin/ipfw X-SVN-Group: releng X-SVN-Commit-Author: gordon X-SVN-Commit-Paths: releng/11.3/sbin/ipfw X-SVN-Commit-Revision: 351258 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Aug 2019 17:46:41 -0000 Author: gordon Date: Tue Aug 20 17:46:40 2019 New Revision: 351258 URL: https://svnweb.freebsd.org/changeset/base/351258 Log: Fix ipfw(8) jail keyword prior to jail startup. Approved by: so Security: FreeBSD-EN-19:17.ipfw Modified: releng/11.3/sbin/ipfw/ipfw2.c Modified: releng/11.3/sbin/ipfw/ipfw2.c ============================================================================== --- releng/11.3/sbin/ipfw/ipfw2.c Tue Aug 20 17:46:22 2019 (r351257) +++ releng/11.3/sbin/ipfw/ipfw2.c Tue Aug 20 17:46:40 2019 (r351258) @@ -4662,12 +4662,27 @@ read_options: case TOK_JAIL: NEED1("jail requires argument"); { + char *end; int jid; cmd->opcode = O_JAIL; - jid = jail_getid(*av); - if (jid < 0) - errx(EX_DATAERR, "%s", jail_errmsg); + /* + * If av is a number, then we'll just pass it as-is. If + * it's a name, try to resolve that to a jid. + * + * We save the jail_getid(3) call for a fallback because + * it entails an unconditional trip to the kernel to + * either validate a jid or resolve a name to a jid. + * This specific token doesn't currently require a + * jid to be an active jail, so we save a transition + * by simply using a number that we're given. + */ + jid = strtoul(*av, &end, 10); + if (*end != '\0') { + jid = jail_getid(*av); + if (jid < 0) + errx(EX_DATAERR, "%s", jail_errmsg); + } cmd32->d[0] = (uint32_t)jid; cmd->len |= F_INSN_SIZE(ipfw_insn_u32); av++;