From nobody Mon Dec 26 06:20:05 2022 X-Original-To: standards@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 4NgSLs6r3yz1Lk9T for ; Mon, 26 Dec 2022 06:20:05 +0000 (UTC) (envelope-from bugzilla-noreply@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NgSLs5qDcz4C8w for ; Mon, 26 Dec 2022 06:20:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672035605; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ia+jZgB1CYIIbDqMwLbGzQsJDvOQuUoGCXgOZa1/O5A=; b=TnhD1tm8VOS35CB5lfsAKsiLHC2o9bn8UA8I5H3VzIJ0UfkSBHbblCPTAVyzXsVelmhU1d KJHqvMXTlHvjkPPq0RGFAkTxcAxA5VA3V+82HkqZS9MlW+3iNiS8O/f9rjI40OUtXySigB w7UwhXSr3ZGTWX7pSGfvkWGzXvJAekoM6PmSDvQawDlmLxD0jK+NxQRh8ZzU1+flytoq0P DHqeKrXhW5Aqd+iBVejb5gUccvw7Y8IGx/bNctnj0nHAZQGFJ6sg8SYoLdeF0DtN4+15U+ EEJ+BtkNsSRYLxzcM9jdFSW+P6B86uNnc8JzBpmO/kbmPss7f2XJU0NE5UIzng== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672035605; a=rsa-sha256; cv=none; b=XaYLVXI15FM5EYLHgZKzubbSGBNZmfkcGCA6qIDnUPmAIenE2EbYf+6ggng3jFFIozg/8+ GB0xoi0GfAP2h3LXcApLb6hnqM+y+X8lK4JIHTHSaOdP3P8cYyidBwYsvCnSAkAThvruDG TnaOVEvcNyxZ+M2U0p0oV6vkbmZw/dcfJxJUVQoQkVopoYYFk+qHMUu4+cMZdVrQClmnN+ XYbX5fKYsuDR39RNcfCa8ACVxYVEYpnLxJ1W2vDP61ywf/R4BITMD5ADnsvaASvepu2Jpx Ybax1jePKn4ZmvrwD8j+5iCeGHXVAO+1/brdGLJ8XZYM2JCplHvGy2hF7JmcAA== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NgSLs4mwszM55 for ; Mon, 26 Dec 2022 06:20:05 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 2BQ6K500016785 for ; Mon, 26 Dec 2022 06:20:05 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 2BQ6K5Yf016784 for standards@FreeBSD.org; Mon, 26 Dec 2022 06:20:05 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: standards@FreeBSD.org Subject: [Bug 268479] lib/libc/stdlib/getenv.c may have a problem with putenv() Date: Mon, 26 Dec 2022 06:20:05 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: standards X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: dclarke@blastwave.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: standards@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Standards compliance List-Archive: https://lists.freebsd.org/archives/freebsd-standards List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-standards@freebsd.org X-BeenThere: freebsd-standards@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D268479 --- Comment #12 from Dennis Clarke --- (In reply to Mark Millard from comment #11) Firstly, thank you for looking at this "thing" which may not be any sort of a bug at all. However it is surely very strange behavior! Only on a FreeBSD system can I entirely override the data from uname as a user. See :=20 callisto$=20 callisto$ uname -apKU=20 FreeBSD callisto 13.1-RELEASE-p3 WAT_THE_FUCK amd64 amd64 1301000 1301000 callisto$=20 callisto$ UNAME_s=3D UNAME_n=3D UNAME_r=3D UNAME_v=3D UNAME_m=3D UNAME_p= =3D UNAME_i=3D UNAME_K=3D UNAME_U=3D UNAME_b=3D uname -apKU | od -Ax -t x1 -v=20 0000000 20 20 20 20 20 20 20 0a=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 0000008 callisto$=20 Well that is a real surprise. Looking in ./usr.bin/uname/uname.c where I see the wild macro : 000156 000157 #define CHECK_ENV(opt,var) \ 000158 do { \ 000159 if ((var =3D getenv("UNAME_" opt)) =3D=3D NULL) { \ 000160 get_##var =3D native_##var; \ 000161 } else { \ 000162 get_##var =3D (get_t)NULL; \ 000163 } \ 000164 } while (0) 000165 000166 static void 000167 setup_get(void) 000168 { 000169 CHECK_ENV("s", sysname); 000170 CHECK_ENV("n", hostname); 000171 CHECK_ENV("r", release); 000172 CHECK_ENV("v", version); 000173 CHECK_ENV("m", platform); 000174 CHECK_ENV("p", arch); 000175 CHECK_ENV("i", ident); 000176 CHECK_ENV("K", kernvers); 000177 CHECK_ENV("U", uservers); 000178 CHECK_ENV("b", buildid); 000179 } 000180 So therefore the man page for UNAME(3) barely touches the true state of affairs for a user process! We can entirely hide the system data with a few env vars. So, to me, this seems like a great thing to "undo" where I the user can actually know the system we are running on. That means we need to walk around in **environ and hope the memory is contiguous? To me the environ pointer is somewhere mystical and not at all on the stack or even someplace I should mess with. I have to go digging into the core code on this and see if I can wreck havok with that array of pointers?=20 In any case this is interesting as I never expected to run a process and not know the actual system description. Very curious and also fun.=20 Dennis Clarke RISC-V/SPARC/PPC/ARM/CISC UNIX and Linux spoken GreyBeard and suspenders optional --=20 You are receiving this mail because: You are the assignee for the bug.=