View | Details | Raw Unified
Collapse All | Expand All

(-) linux-2.6.7-hardened-r10/fs/binfmt_elf.c (-8 / +28 lines)
 Lines 347-355    Link Here 
		goto out;
		goto out;
	retval = kernel_read(interpreter,interp_elf_ex->e_phoff,(char *)elf_phdata,size);
	retval = kernel_read(interpreter,interp_elf_ex->e_phoff,(char *)elf_phdata,size);
	error = retval;
	error = -EIO;
	if (retval < 0)
	if (retval != size) {
		if (retval < 0)
			error = retval;
		goto out_close;
		goto out_close;
	}
#ifdef CONFIG_PAX_SEGMEXEC
#ifdef CONFIG_PAX_SEGMEXEC
	if (current->flags & PF_PAX_SEGMEXEC)
	if (current->flags & PF_PAX_SEGMEXEC)
 Lines 767-774    Link Here 
		goto out;
		goto out;
	retval = kernel_read(bprm->file, elf_ex.e_phoff, (char *) elf_phdata, size);
	retval = kernel_read(bprm->file, elf_ex.e_phoff, (char *) elf_phdata, size);
	if (retval < 0)
	if (retval != size) {
		if (retval >= 0)
			retval = -EIO;
		goto out_free_ph;
		goto out_free_ph;
	}
	files = current->files;		/* Refcounted so ok */
	files = current->files;		/* Refcounted so ok */
	retval = unshare_files();
	retval = unshare_files();
 Lines 805-811    Link Here 
			 */
			 */
			retval = -ENOMEM;
			retval = -ENOMEM;
			if (elf_ppnt->p_filesz > PATH_MAX)
			if (elf_ppnt->p_filesz > PATH_MAX || 
			    elf_ppnt->p_filesz == 0)
				goto out_free_file;
				goto out_free_file;
			elf_interpreter = (char *) kmalloc(elf_ppnt->p_filesz,
			elf_interpreter = (char *) kmalloc(elf_ppnt->p_filesz,
							   GFP_KERNEL);
							   GFP_KERNEL);
 Lines 815-822    Link Here 
			retval = kernel_read(bprm->file, elf_ppnt->p_offset,
			retval = kernel_read(bprm->file, elf_ppnt->p_offset,
					   elf_interpreter,
					   elf_interpreter,
					   elf_ppnt->p_filesz);
					   elf_ppnt->p_filesz);
			if (retval < 0)
			if (retval != elf_ppnt->p_filesz) {
				if (retval >= 0)
					retval = -EIO;
				goto out_free_interp;
			}
			/* make sure path is NULL terminated */
			retval = -EINVAL;
			if (elf_interpreter[elf_ppnt->p_filesz - 1] != '\0')
				goto out_free_interp;
				goto out_free_interp;
			
			/* If the program interpreter is one of these two,
			/* If the program interpreter is one of these two,
			 * then assume an iBCS2 image. Otherwise assume
			 * then assume an iBCS2 image. Otherwise assume
			 * a native linux image.
			 * a native linux image.
 Lines 851-858    Link Here 
			if (IS_ERR(interpreter))
			if (IS_ERR(interpreter))
				goto out_free_interp;
				goto out_free_interp;
			retval = kernel_read(interpreter, 0, bprm->buf, BINPRM_BUF_SIZE);
			retval = kernel_read(interpreter, 0, bprm->buf, BINPRM_BUF_SIZE);
			if (retval < 0)
			if (retval != BINPRM_BUF_SIZE) {
				if (retval >= 0)
					retval = -EIO;
				goto out_free_dentry;
				goto out_free_dentry;
			}
			/* Get the exec headers */
			/* Get the exec headers */
			interp_ex = *((struct exec *) bprm->buf);
			interp_ex = *((struct exec *) bprm->buf);
 Lines 1105-1112    Link Here 
			}
			}
#endif
#endif
			if (BAD_ADDR(error))
			if (BAD_ADDR(error)) {
				continue;
				send_sig(SIGKILL, current, 0);
				goto out_free_dentry;
			}
			/* PaX: mirror at a randomized base */
			/* PaX: mirror at a randomized base */
			down_write(&current->mm->mmap_sem);
			down_write(&current->mm->mmap_sem);