From nobody Mon Nov 16 10:45:51 2026 X-Original-To: dev-commits-src-all@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 4jSkzg48cvz702wk for ; Mon, 16 Nov 2026 10:45:51 +0000 (UTC) (envelope-from git@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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jSkzg3FF5z4lBR for ; Mon, 16 Nov 2026 10:45:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794825951; 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; bh=JOTIApNx1QrXaUzE6hESGpPfLFADZKvLiiNoQCOU6ao=; b=t7Ote609XKFMXOHTyE6KjdWzCX3uFpQ063/qhdDNJqNc7TWyA4Ee5XbbdwwCM1yz78fAHa UCcSNb3WHj5xVZhqGF+1qI1VwP+F1MmDF9vxUcwd9+JTKEeCrcNdayBB32qN2ajpgiCoGh CJQCFMBYLNYKZ0LBqIrs4bKB1X8sSiiewj2Wtuz/CkFIEkXD9NNVMJUr4rNHdPxx6q1Uac qCmowYLqqFUnvaRwxAtFvNPOsYRxKg9ujRNktttdj7S7P/8+6CoEzxfmclea7I1qXczfv9 GlAynNMUSusIol8OeCkCpKjL+zZVPsvKhIFYm7pqMfa9QsX3xioas0iVfHvPNQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794825951; b=W3Pt/O4JxdL0m3GNMWoyudJHA45iLocFfcaYLQE8HSROHQbxxUhmUsJFJc0QunM9bjVv2j OaRglUxgVCB4yHmpfPT2IMMuRTTWOLu1f/H5BR6AOcjWk11+WS5lSibwC0u/LCYsZdmnON VzJ+bqkcaUf9c5ztUDpedyDUA++xYa1oQNdvIg9nXcnoqhAhxXmIliP0V47Vf7/hThqP4z 19Q5ry9ufqUyO2lhssSAvw/1rOvVpN8b5AVJjIHxNbaZf4fOArzrihCx4HWS3ukQCiG1dH Jt9GEU1/x1Yvl6gEULBu8NyJHLejzBSIq1Gu+Y6MkYpZtP4fFUlFHs5JC3Kjlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794825951; 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; bh=JOTIApNx1QrXaUzE6hESGpPfLFADZKvLiiNoQCOU6ao=; b=wpl9cPW2qcFk94e+4hdRo0Cy9vZoy8oK26Axp3Y7HkKnN5wyTzz2IDuITsQohLl7HBZl56 WWwo2/xOB8Q7xK1BO2ez+0NNnyKUvIakD2bLQ303jt0Ca7z8Pjiv+4zmr5noitxmCJ4PAc Nb27RrGLkhK5B8QL20BrHtkauYz8WHdswd7gaPRlyVic3okrMwxnVj8R6/6xuBh/v1aV1r HhTD9mVX/nRGlJgE6O2SxT/712DjZ5ZPE4tyNh4wVIp7aGKfiG7iMY0agQzD/ic0RWPr9x pYi4GHGEqOejopy4ap5lxuvVg/09kbiM1DzwBG0Erm/C5LFnwfd3vPFwPfD1vA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jSkzg2cg4zrHj for ; Mon, 16 Nov 2026 10:45:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 10401 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Nov 2026 10:45:51 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Brooks Davis Subject: git: 5c7d799c53cc - stable/15 - kern_module.c: add kern_ implementations List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches 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=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 5c7d799c53ccb2f0a886566750f8226ea0c7f02f Auto-Submitted: auto-generated Date: Mon, 16 Nov 2026 10:45:51 +0000 Message-Id: <6afadedf.10401.32183965@gitrepo.freebsd.org> The branch stable/15 has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=5c7d799c53ccb2f0a886566750f8226ea0c7f02f commit 5c7d799c53ccb2f0a886566750f8226ea0c7f02f Author: Brooks Davis AuthorDate: 2026-11-10 11:49:20 +0000 Commit: Brooks Davis CommitDate: 2026-11-16 10:45:15 +0000 kern_module.c: add kern_ implementations In the case of modstat(2) use a cast to access the name member of the old struct version so the compiler see the right array size. This addresses a sub-object bounds bug. Effort: CHERI upstreaming Sponsored by: DARPA, AFRL, Innovate UK Pull Request: https://github.com/freebsd/freebsd-src/pull/2284 (cherry picked from commit b96dc2c04fb4f504ad0c752c5d4b074c5bfbf7e0) --- sys/kern/kern_module.c | 29 ++++++++++++++++++++++------- sys/sys/syscallsubr.h | 3 +++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c index 6298f06fdba7..de2df96bdbf8 100644 --- a/sys/kern/kern_module.c +++ b/sys/kern/kern_module.c @@ -31,8 +31,9 @@ #include #include #include -#include +#include #include +#include #include #include #include @@ -373,18 +374,23 @@ struct module_stat_v2 { int sys_modstat(struct thread *td, struct modstat_args *uap) +{ + return (kern_modstat(td, uap->modid, uap->stat)); +} + +int +kern_modstat(struct thread *td, int modid, struct module_stat *stat) { module_t mod; modspecific_t data; int error = 0; int id, namelen, refs, version; - struct module_stat *stat; struct module_stat_v2 *stat_v2; - char *name; + char *name, *user_namep; bool is_v1v2; MOD_SLOCK; - mod = module_lookupbyid(uap->modid); + mod = module_lookupbyid(modid); if (mod == NULL) { MOD_SUNLOCK; return (ENOENT); @@ -394,7 +400,6 @@ sys_modstat(struct thread *td, struct modstat_args *uap) name = mod->name; data = mod->data; MOD_SUNLOCK; - stat = uap->stat; /* * Check the version of the user's structure. @@ -405,12 +410,16 @@ sys_modstat(struct thread *td, struct modstat_args *uap) version == sizeof(struct module_stat_v2)); if (!is_v1v2 && version != sizeof(struct module_stat)) return (EINVAL); + if (is_v1v2) + user_namep = ((struct module_stat_v1 *)stat)->name; + else + user_namep = stat->name; namelen = strlen(mod->name) + 1; if (is_v1v2 && namelen > MAXMODNAMEV1V2) namelen = MAXMODNAMEV1V2; else if (namelen > MAXMODNAMEV3) namelen = MAXMODNAMEV3; - if ((error = copyout(name, &stat->name[0], namelen)) != 0) + if ((error = copyout(name, user_namep, namelen)) != 0) return (error); /* Extending MAXMODNAME gives an offset change for v3. */ @@ -445,12 +454,18 @@ sys_modstat(struct thread *td, struct modstat_args *uap) int sys_modfind(struct thread *td, struct modfind_args *uap) +{ + return (kern_modfind(td, uap->name)); +} + +int +kern_modfind(struct thread *td, const char *uname) { int error = 0; char name[MAXMODNAMEV3]; module_t mod; - if ((error = copyinstr(uap->name, name, sizeof name, 0)) != 0) + if ((error = copyinstr(uname, name, sizeof name, 0)) != 0) return (error); MOD_SLOCK; diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h index 8061ea65e978..36538eda5034 100644 --- a/sys/sys/syscallsubr.h +++ b/sys/sys/syscallsubr.h @@ -50,6 +50,7 @@ struct kevent_copyops; struct kld_file_stat; struct ksiginfo; struct mbuf; +struct module_stat; struct mq_attr; struct msghdr; struct msqid_ds; @@ -252,6 +253,8 @@ int kern_mmap(struct thread *td, const struct mmap_req *mrp); int kern_mmap_racct_check(struct thread *td, struct vm_map *map, vm_size_t size); int kern_mmap_maxprot(struct proc *p, int prot); +int kern_modfind(struct thread *td, const char *uname); +int kern_modstat(struct thread *td, int modid, struct module_stat *stat); int kern_mprotect(struct thread *td, uintptr_t addr, size_t size, int prot, int flags); int kern_msgctl(struct thread *, int, int, struct msqid_ds *);