From owner-svn-src-stable@freebsd.org Thu Aug 15 17:40:49 2019 Return-Path: Delivered-To: svn-src-stable@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 03D9FB08AF; Thu, 15 Aug 2019 17:40:49 +0000 (UTC) (envelope-from kevans@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 468YdX6P54z49sq; Thu, 15 Aug 2019 17:40:48 +0000 (UTC) (envelope-from kevans@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 BCE621C0A8; Thu, 15 Aug 2019 17:40:48 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7FHemal051608; Thu, 15 Aug 2019 17:40:48 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7FHemAi051607; Thu, 15 Aug 2019 17:40:48 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201908151740.x7FHemAi051607@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 15 Aug 2019 17:40:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r351094 - in stable: 11/sbin/ipfw 12/sbin/ipfw X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sbin/ipfw 12/sbin/ipfw X-SVN-Commit-Revision: 351094 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Aug 2019 17:40:49 -0000 Author: kevans Date: Thu Aug 15 17:40:48 2019 New Revision: 351094 URL: https://svnweb.freebsd.org/changeset/base/351094 Log: MFC r350576: ipfw: fix jail option after r348215 r348215 changed jail_getid(3) to validate passed-in jids as active jails (as the function is documented to return -1 if the jail does not exist). This broke the jail option (in some cases?) as the jail historically hasn't needed to exist at the time of rule parsing; jids will get stored and later applied. Fix this caller to attempt to parse *av as a number first and just use it as-is to match historical behavior. jail_getid(3) must still be used in order for name arguments to work, but it's strictly a fallback in case we weren't given a number. Modified: stable/11/sbin/ipfw/ipfw2.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sbin/ipfw/ipfw2.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sbin/ipfw/ipfw2.c ============================================================================== --- stable/11/sbin/ipfw/ipfw2.c Thu Aug 15 17:35:24 2019 (r351093) +++ stable/11/sbin/ipfw/ipfw2.c Thu Aug 15 17:40:48 2019 (r351094) @@ -4674,12 +4674,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++;