From nobody Wed Nov 11 10:18:25 2026 X-Original-To: dev-commits-src-main@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 4jPfcN4V5tz700TM; Wed, 11 Nov 2026 10:18:28 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jPfcN2THXz4qwW; Wed, 11 Nov 2026 10:18:28 +0000 (UTC) (envelope-from brooks@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794392308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=C7QPSGctRlU5MuT3mpBHMTnJH0qJ93g1ICbbwQtmNXI=; b=d7vf8uWEnjKpNBdAFJhN8gY75LcU+Hi2YbsQnbMik3Kt/6XV64lmnYzzN9u4G8tgwKa0uT xFPAy/K3ZZeP7XekNL23VYsX0q4+Pdl45Xy9iScexXlny2qgcI4Yd2xH7ejvB7uRZiDGxb jcRt0eaNn5Ju70lYbHGOQtgPzu5mPSmpoIba8POLlvO6Sn245zdqTLuxfjCrlNl9r9x672 DDYKRZgGTcb81audQi47CQEkSsXiiyT7XFJRKiUB7W4ZWH5Jeb9uKq+COQVZaKMnnayX7e QBkHskbJM6uQfQlmc1w7r40Yemo6mJtF1PdBA8DEvqzhZCjLFAlp0GdJJPe+SQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794392308; b=A44tLIFWUFTgiJEdJpYwVRCX9w9UbwaWAxQdCKwg4tL7tn+xeBQDnU02a87zPzlvjD7rGi w9ZHoMlm8oX9BB0q+8rPp7fiFi+J5hTK+rZ8EXW8pCg7b7gepI6kWR0xRXZcWfWlFgqjjU aui0D1wnsyOiJ02AZKkoQM1YYvWHSsQPovPOzu+IGc9hFTTFGYL6tTPS01776V4cTF2YET F+VanXOUvk8ve86TsM6CcgOfrdpaIPD7yDO5G13B8l/b9asrts32mwrMFcICkYliMVPzpc RaIPOit1xB8SkXxHE6qWRv/V3KBGl+EA3BOHVChLU8paGX/ouRTjtGX9Rs1kfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794392308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=C7QPSGctRlU5MuT3mpBHMTnJH0qJ93g1ICbbwQtmNXI=; b=hDwXi7StwoIMTjSSiUGwlN+f06e4hL2z7YSrOMR2XtthB569Eg6eftLmEZ5Jb1XzgCqzMi 6zi/GloVs+ZXYvCaTJ4+l3cASeby1aPhrAJXXofJBBDnKcGc8R4/6MbjktrxvL9+tQWdhH Bvnwr+CfgHxfRtWgFmLJDtmgonKv96sXB49JtnHeyMsSoGf7eIKVcqGJMMYuCyVyqvDvrn 9XFY4rmTvcrrsogDxgViXdykrKwRZx/T87jnbycJdO+93AFViB84nvaDaEKe+3ypQWa7uU R930HA/pMONrOBWSn6nQ419ngXxVMoFcA4UWUABJY9+w9bdZxGGAWfvtpHbfeA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (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) (Authenticated sender: brooks/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4jPfcN1hKKz1LWd; Wed, 11 Nov 2026 10:18:28 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id DDAFC3C01A0; Wed, 11 Nov 2026 10:18:25 +0000 (UTC) Date: Wed, 11 Nov 2026 10:18:25 +0000 From: Brooks Davis To: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 7f8c2056db1e - main - modstat: avoid copying from freed memory Message-ID: References: <6af43c34.10b36.62ec09f3@gitrepo.freebsd.org> List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org List-Id: Commit messages for the main branch of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6af43c34.10b36.62ec09f3@gitrepo.freebsd.org> On Wed, Nov 11, 2026 at 09:58:12AM +0000, Brooks Davis wrote: > The branch main has been updated by brooks: > > URL: https://cgit.FreeBSD.org/src/commit/?id=7f8c2056db1e39e44c3eda15aa4e53f7fc971cd8 > > commit 7f8c2056db1e39e44c3eda15aa4e53f7fc971cd8 > Author: Brooks Davis > AuthorDate: 2026-11-11 09:40:40 +0000 > Commit: Brooks Davis > CommitDate: 2026-11-11 09:40:40 +0000 > > modstat: avoid copying from freed memory > > If a module is unloaded after the module is looked up in kern_modstat, > but before one of the copyout's occurs, then the memory being copied > might be freed and reused leading to an information disclosure. > > The LLM was particularly concerned about a TOCTOU issue in the length > of the name, but it seems likely that there are issues with all the > copyout's. As such, hold the shared lock throughout. As noted in the review, this change is suboptimal in that it holds the module lock too long, potenially over a page fault, but it's a minor performance issue in an administrative command. If kern_modstat only handled one version of struct module_stat I'd probably have done a more agressive refactor, but the compat bits make it more complicated than I wanted to deal with. This is an excellent example of why we should not version structures and instead add new system calls. I'd have had to edit more functions, but they would have been simple, linear things not this mess of ifs. -- Brooks