From owner-svn-src-all@freebsd.org Tue Feb 5 17:17:41 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3E71714C04AE; Tue, 5 Feb 2019 17:17:41 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9BB4C844BA; Tue, 5 Feb 2019 17:17:40 +0000 (UTC) (envelope-from byond.lenox@gmail.com) Received: by mail-lj1-f171.google.com with SMTP id t18-v6so3596021ljd.4; Tue, 05 Feb 2019 09:17:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wlmwN9NjkGwftL0JZp1M+SrSaasE72fc+8/0HSWGENA=; b=ZkejYg0hfpuq/Est/GwQBdVkh/m4ysMY0KlczhvfGkvSn1Uu5yNR5f8Cd5uHVrbmdo hSiv/DmUUMyX86eTaGfgtUL1eyiTbZF9r0bh4LC31QhtPWpTLRBM8Qvs+CxU7XECi53V YzvL+XDt6LOVxn/gPT+l4jT0ZL7XqDwZO0lSTa7p1rE4sRJ52LLRRhPhYoTUt5quCznC d4/ulOt+InNUbi6OF0sFSinHHXhZWm8lPHRl4n9B3Ctdy6MZVk6WtKxzB9c8TC58Da4M 4giIa/QEuu4klsuSOlMmQtF7rIe/2PxK/2+a1iG4xaSM7A8HzeibbeBt0JmS/cd5f6n+ LySQ== X-Gm-Message-State: AHQUAuZOmPZj5CWiOtXLn7qMOPFA7524WTPU4ieYMWJ5XiKMA6mvTbp2 Eyx3CQYU9wykQC6aN//qhr3ch1NCieM= X-Google-Smtp-Source: AHgI3Ib96/iafZuvllM0AAD0TcKurHOTK89o5Re6XZFJDSnYe8ZWsAVLAWZ+YkOXeL3EgcEsjG2HNg== X-Received: by 2002:a2e:7316:: with SMTP id o22-v6mr19505ljc.82.1549383141342; Tue, 05 Feb 2019 08:12:21 -0800 (PST) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com. [209.85.167.47]) by smtp.gmail.com with ESMTPSA id c2-v6sm3273574ljj.41.2019.02.05.08.12.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Feb 2019 08:12:20 -0800 (PST) Received: by mail-lf1-f47.google.com with SMTP id n23so3080410lfl.4; Tue, 05 Feb 2019 08:12:20 -0800 (PST) X-Received: by 2002:a19:f249:: with SMTP id d9mr961798lfk.83.1549383140158; Tue, 05 Feb 2019 08:12:20 -0800 (PST) MIME-Version: 1.0 References: <201902051534.x15FYtZU066605@repo.freebsd.org> In-Reply-To: <201902051534.x15FYtZU066605@repo.freebsd.org> From: Kyle Evans Date: Tue, 5 Feb 2019 10:11:31 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r343777 - head/sys/kern To: Bruce Evans Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 9BB4C844BA X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.96 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.958,0]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] 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, 05 Feb 2019 17:17:41 -0000 On Tue, Feb 5, 2019 at 9:35 AM Bruce Evans wrote: > > Author: bde > Date: Tue Feb 5 15:34:55 2019 > New Revision: 343777 > URL: https://svnweb.freebsd.org/changeset/base/343777 > > Log: > Fix zapping of static hints and env in init_static_kenv(). Environments > are terminated by 2 NULs, but only 1 NUL was zapped. Zapping only 1 > NUL just splits the first string into an empty string and a corrupted > string. All other strings in static hints and env remained live early > in the boot when they were supposed to be disabled. > I think we need to go another step here. This stuff was functional in my testing because it was all late enough to happen after static_env and static_hints were merged into the dynamic kenv (which I've only now noticed after you fixed this). It looks like our logic for merging is broken, IMO. Before I touched it: - When static_hints did get merged (by toggling of sysctl) it would stop merging at the first empty string (strlen(cp) == 0) -- introduced in r240067 -- regardless of whether said empty string was followed by a second NUL terminator. - When static_env merged in at SU_SUB_KMEM, it wouldn't merge if *kern_envp == '\0' but it wouldn't stop at an empty string, instead carrying the empty string into the dynamic env if my reading is correct. I broke the former even further by not merging anything at all if *static_hints == '\0', and I maintained the latter breakage except added an additional warning if we ventured upon a malformed entry. Both of these are inconsistent with how the environments are observed by kern_getenv or hints consumers before the merging, which will simply skip over the malformed empty strings until it hits proper termination. I think the resulting environment should be consistent with what these consumers would've seen pre-merge, and I think this should be fixed, if we can. Thoughts? Thanks, Kyle Evans