From nobody Wed Oct 23 22:13:20 2024 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 4XYjwx225kz5ZkHq; Wed, 23 Oct 2024 22:13:21 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XYjwx1TWYz4ccx; Wed, 23 Oct 2024 22:13:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729721601; 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=GDD/NSRRb/TscE2/O74Xl7SMSW+q4aqwNay6sKEpuRo=; b=mwYYFGu4Y0jCPW8AzzsqTUoxc7k6JPuFDTxjteTOaMMno4MvXIHNEWxBoLYjF42fa20ZdM w/CbcThETxKR16XeY2/fOIgGR4dKW+TCmpTjHNdwljYrJeUVCi9eKrsmhN7NEFEj8q7V3c uG/ShTbXp85uSTGkHW/Tk5na5UMNyMExhEjbvErE6ADLPl8kTP7hYdd5CcwctGBvEH/gl7 oYHnOkcgd/HwtmISxzKisqRMhrfiYxMAdfX3jB8RpJJyd+g6xmVt27nVoxxJMMJgOtUKfp YVqaZeT+2RCeuaKCdTDJCNSyR0DQ8aFCWPOpvG6RlOdicEHOrGZHzdfKxBJgLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729721601; 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=GDD/NSRRb/TscE2/O74Xl7SMSW+q4aqwNay6sKEpuRo=; b=Ny6ieQq3OOzi7im0V6zkFIEPE+FenLM4ZtTpc2oI7bL/kTHK8YBBFVlfIJBmdKNp74+qV4 SVOKlSYvnBcSTFG6yfcCer201cnsk0aHEXUJV8AgZyxK0Ud2bu/pD15x/JIgJaNSIojhYo Gf0cUBKG85drVpCZ+m8osgnqNcPTAt+Cq608ySVlia/eVLZdLYQygqECTWxmcvzlDMRj8k sI6ncifDOD9T1dWU7bicaKMYCRhadUTCeGY5DLyKhU/3bWTsarqRcNJmtsKobvleWbvO5J AF/UnCQoe3qVetw7UkX/u4qVQjNsK1NZMa+yX8kUMegDIuMB2RaiaJceLqnpWw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729721601; a=rsa-sha256; cv=none; b=HeHiHzh6S1wYYJLqNZpgmlnwIyqVQuRbP3CWG0/T/0TP0K2+ZsOAfWgyAfx+O/j7DZHLCt 7fH8pDRRozsJWwTeQetcpBTqfd0ZTxVDMkgWtCAXK2UpSJLZK5z8Hgb/IsBkQY8opD6k8J poCTFBHk6JCObp7QB3jKpNAQaZhabZb91P4bxNQRs6TE+3wbgtx4k5uiHpH/WzxZrEnf60 /QalZtz/eDC96nNvywZOaFfzq9kzkCISqUc3DImv5gkvOmLn2AeoHtcJ7mrZGDVEfE5e40 y4KUUd0afsFjxSdM4EAG1b+kdLtu3tsfTG7dOfUuOcpNvfaAWdogoYQLL/Fk9Q== 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 4XYjwx0z7YzGfg; Wed, 23 Oct 2024 22:13:21 +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 49NMDKdu085580; Wed, 23 Oct 2024 22:13:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49NMDKaG085577; Wed, 23 Oct 2024 22:13:20 GMT (envelope-from git) Date: Wed, 23 Oct 2024 22:13:20 GMT Message-Id: <202410232213.49NMDKaG085577@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: b5149b265346 - main - linker: Handle a truncated hints file properly List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: b5149b265346c55994c7ebaab2a6a6fd1bd6fe5e Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b5149b265346c55994c7ebaab2a6a6fd1bd6fe5e commit b5149b265346c55994c7ebaab2a6a6fd1bd6fe5e Author: Mark Johnston AuthorDate: 2024-10-23 16:54:56 +0000 Commit: Mark Johnston CommitDate: 2024-10-23 22:12:45 +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 --- 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 3f34bb12aeaa..f388ac8a583a 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -2030,6 +2030,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);