Skip to content
Snippets Groups Projects
exec.c 47.7 KiB
Newer Older
  • Learn to ignore specific revisions
  • Linus Torvalds's avatar
    Linus Torvalds committed
    
    
    	retval = binfmt->core_dump(&cprm);
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    	if (retval)
    		current->signal->group_exit_code |= 0x80;
    
    		wait_for_dump_helpers(cprm.file);
    
    close_fail:
    	if (cprm.file)
    		filp_close(cprm.file, NULL);
    
    	if (ispipe)
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    fail_unlock:
    
    	coredump_finish(mm);
    
    	revert_creds(old_cred);
    
    	put_cred(cred);
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    fail:
    
    	return;
    
    Linus Torvalds's avatar
    Linus Torvalds committed
    }
    
    
    /*
     * Core dumping helper functions.  These are the only things you should
     * do on a core-file: use only these functions to write out all the
     * necessary info.
     */
    int dump_write(struct file *file, const void *addr, int nr)
    {
    	return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
    }
    
    EXPORT_SYMBOL(dump_write);
    
    
    int dump_seek(struct file *file, loff_t off)
    {
    	int ret = 1;
    
    	if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
    		if (file->f_op->llseek(file, off, SEEK_CUR) < 0)
    			return 0;
    	} else {
    		char *buf = (char *)get_zeroed_page(GFP_KERNEL);
    
    		if (!buf)
    			return 0;
    		while (off > 0) {
    			unsigned long n = off;
    
    			if (n > PAGE_SIZE)
    				n = PAGE_SIZE;
    			if (!dump_write(file, buf, n)) {
    				ret = 0;
    				break;
    			}
    			off -= n;
    		}
    		free_page((unsigned long)buf);
    	}
    	return ret;
    }
    
    EXPORT_SYMBOL(dump_seek);