summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2011-10-07 01:37:58 +0000
committerdelphij <delphij@FreeBSD.org>2011-10-07 01:37:58 +0000
commit3774d9943004c15ab6f526c00ada0d87b57901d8 (patch)
tree04bfe7142ef0499b8abf10e424c76a3effcda412 /sys/kern
parent7adae26f0ff7104dea297cfdfb4ef600e60cc78b (diff)
downloadFreeBSD-src-3774d9943004c15ab6f526c00ada0d87b57901d8.zip
FreeBSD-src-3774d9943004c15ab6f526c00ada0d87b57901d8.tar.gz
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
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_ctf.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/sys/kern/kern_ctf.c b/sys/kern/kern_ctf.c
index 758ad81..bdff96e 100644
--- a/sys/kern/kern_ctf.c
+++ b/sys/kern/kern_ctf.c
@@ -164,8 +164,13 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
* 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, linker_ctf_t *lc)
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, linker_ctf_t *lc)
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) {
OpenPOWER on IntegriCloud