From owner-svn-src-head@FreeBSD.ORG Fri Oct 7 01:37:58 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E3297106564A; Fri, 7 Oct 2011 01:37:58 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B990F8FC14; Fri, 7 Oct 2011 01:37:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p971bwLH086236; Fri, 7 Oct 2011 01:37:58 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p971bwnn086234; Fri, 7 Oct 2011 01:37:58 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201110070137.p971bwnn086234@svn.freebsd.org> From: Xin LI Date: Fri, 7 Oct 2011 01:37:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226082 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2011 01:37:59 -0000 Author: delphij Date: Fri Oct 7 01:37:58 2011 New Revision: 226082 URL: http://svn.freebsd.org/changeset/base/226082 Log: Return proper errno when we hit error when doing sanity check. This fixes dtrace crashes when module is not compiled with CTF data. Submitted by: Paul Ambrose ambrosehua at gmail.com MFC after: 1 week Modified: head/sys/kern/kern_ctf.c Modified: head/sys/kern/kern_ctf.c ============================================================================== --- head/sys/kern/kern_ctf.c Fri Oct 7 01:15:04 2011 (r226081) +++ head/sys/kern/kern_ctf.c Fri Oct 7 01:37:58 2011 (r226082) @@ -164,8 +164,13 @@ link_elf_ctf_get(linker_file_t lf, linke * section names aren't present, then we can't locate the * .SUNW_ctf section containing the CTF data. */ - if (hdr->e_shstrndx == 0 || shdr[hdr->e_shstrndx].sh_type != SHT_STRTAB) + if (hdr->e_shstrndx == 0 || shdr[hdr->e_shstrndx].sh_type != SHT_STRTAB) { + printf("%s(%d): module %s e_shstrndx is %d, sh_type is %d\n", + __func__, __LINE__, lf->pathname, hdr->e_shstrndx, + shdr[hdr->e_shstrndx].sh_type); + error = EFTYPE; goto out; + } /* Allocate memory to buffer the section header strings. */ if ((shstrtab = malloc(shdr[hdr->e_shstrndx].sh_size, M_LINKER, @@ -187,8 +192,12 @@ link_elf_ctf_get(linker_file_t lf, linke break; /* Check if the CTF section wasn't found. */ - if (i >= hdr->e_shnum) + if (i >= hdr->e_shnum) { + printf("%s(%d): module %s has no .SUNW_ctf section\n", + __func__, __LINE__, lf->pathname); + error = EFTYPE; goto out; + } /* Read the CTF header. */ if ((error = vn_rdwr(UIO_READ, nd.ni_vp, ctf_hdr, sizeof(ctf_hdr), @@ -197,12 +206,21 @@ link_elf_ctf_get(linker_file_t lf, linke goto out; /* Check the CTF magic number. (XXX check for big endian!) */ - if (ctf_hdr[0] != 0xf1 || ctf_hdr[1] != 0xcf) + if (ctf_hdr[0] != 0xf1 || ctf_hdr[1] != 0xcf) { + printf("%s(%d): module %s has invalid format\n", + __func__, __LINE__, lf->pathname); + error = EFTYPE; goto out; + } /* Check if version 2. */ - if (ctf_hdr[2] != 2) + if (ctf_hdr[2] != 2) { + printf("%s(%d): module %s CTF format version is %d " + "(2 expected)\n", + __func__, __LINE__, lf->pathname, ctf_hdr[2]); + error = EFTYPE; goto out; + } /* Check if the data is compressed. */ if ((ctf_hdr[3] & 0x1) != 0) {