From nobody Wed Oct 30 13:21:47 2024 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 4XdnpN0Ddkz5bMB4; Wed, 30 Oct 2024 13:21:48 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XdnpM62lsz4jhw; Wed, 30 Oct 2024 13:21:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730294507; 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=gIgD1dmmDliW+2ItvwZsEN7t9kdU9TZ7KBL0CdMr3Eo=; b=x2TWxGeJUpaNliXl7FnBfRaCwcsQpt/8R1+dQ6pfLTU5OmAD+fuTUwe67fVraEVODGOs6R nuxkpO7CTMcEx1gJ/6gowq0xIRrfgkw+UNv7cORsvDTIE8FiCvzsa6h/jQlH4MCAxj89JH T9EhN+gnnzlHzoW1e8IolkVcRAc3yzePZ1ADEZaTTbBIKmg6D0dhpJSRKbf2BO20jngkvt Y1p8Y3E6SZRAjpvmqiMy1Qag4NTYVlLAGiFu0z04H+55/EBof9s+8tbqTbwMMMltAf3sD9 kcesC9C9k+h4r5RnX2kxeZWc+pBq9YBkfjqREDHw7aYweE3c57EBkDwQVr2Zvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730294507; 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=gIgD1dmmDliW+2ItvwZsEN7t9kdU9TZ7KBL0CdMr3Eo=; b=EyNLrukAAFRUkqQUTqrT6lmIyoHYtVsFoanz9VdSepEzpft48cLDfcQBmJL5vSOkHHFXBX e+EeNg8rk3uKMdYm6wa5uLfNbxs8MyGtptuvM7QvuAuZaSK7g5WpOVmCZ0jFPV4ucxe/BD 2WrtHe6XQMLXkiOEmr28WJgAWMmEETh4ZiF5aCWBC+aXctOxw7CKWxbJ1EnRfMgnf0LS1r F/BkYceogAMDXNQor/uzpPMt/9yDwRy5/wVfyWUlVcrXI1hdsWHO97gZ/NstUdrmEvguUW A2EYnv1pG72cHr/diCqFMW2tYHiqv/paR9z8we1OaGDooyjan17/WI3lIi0avg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730294507; a=rsa-sha256; cv=none; b=rbuk2bhkDNJUYsrXJ3oWZhiDW8thq6SWPqfSKIlY/6kielRkMNH+LOdjbIYey7I6h9TYLd USrQHFbQ0zIcU01HUoAshzfDyQPwxOPKEdOdEs2ts3jU5+XSG4eifTtJlIybpfJ6lGN1hC pZbQ3/8mBbzS+HnaNYPhe/J0ko85fWOmAkORezEZ9nlf+PpNRcX3JxHr6k81Gao+7mvZXa CUZorJUG3wRcIRhGlgOiE1IGqwhxXWh9vhPbquBF36QjzId6wsMC1q34YMAxDUInCjrgrN Pm9y+tWDtvkfykAJlEgyk2G9Ze3HnyFIEkwZaR5YCqBL3+NrJb8gFudCa9BWWg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 4XdnpM5fCDz186J; Wed, 30 Oct 2024 13:21:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49UDLliD088861; Wed, 30 Oct 2024 13:21:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49UDLlea088858; Wed, 30 Oct 2024 13:21:47 GMT (envelope-from git) Date: Wed, 30 Oct 2024 13:21:47 GMT Message-Id: <202410301321.49UDLlea088858@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: d57d71423847 - stable/13 - linker: Handle a truncated hints file properly List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d57d714238471eaa44c20538df1488fae378665e Auto-Submitted: auto-generated The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d57d714238471eaa44c20538df1488fae378665e commit d57d714238471eaa44c20538df1488fae378665e Author: Mark Johnston AuthorDate: 2024-10-23 16:54:56 +0000 Commit: Mark Johnston CommitDate: 2024-10-30 13:21:39 +0000 linker: Handle a truncated hints file properly If vattr.va_size is 0, we will end up accessing invalid memory. This is mostly harmless (because malloc(0) still allocates some memory), but it triggers a KASAN report. PR: 282268 Reviewed by: christos, imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47240 (cherry picked from commit b5149b265346c55994c7ebaab2a6a6fd1bd6fe5e) --- sys/kern/kern_linker.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index 5271d002fba4..caee3aaedcd7 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -1931,6 +1931,10 @@ linker_hints_lookup(const char *path, int pathlen, const char *modname, printf("linker.hints file too large %ld\n", (long)vattr.va_size); goto bad; } + if (vattr.va_size < sizeof(ival)) { + printf("linker.hints file truncated\n"); + goto bad; + } hints = malloc(vattr.va_size, M_TEMP, M_WAITOK); error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)hints, vattr.va_size, 0, UIO_SYSSPACE, IO_NODELOCKED, cred, NOCRED, &reclen, td);