示例#1
0
static noinline void do_fault_error(struct pt_regs *regs, int access, int fault)
{
	int si_code;

	switch (fault) {
	case VM_FAULT_BADACCESS:
		if (access == VM_EXEC && signal_return(regs) == 0)
			break;
	case VM_FAULT_BADMAP:
		/* Bad memory access. Check if it is kernel or user space. */
		if (user_mode(regs)) {
			/* User mode accesses just cause a SIGSEGV */
			si_code = (fault == VM_FAULT_BADMAP) ?
				SEGV_MAPERR : SEGV_ACCERR;
			do_sigsegv(regs, si_code);
			break;
		}
	case VM_FAULT_BADCONTEXT:
	case VM_FAULT_PFAULT:
		do_no_context(regs);
		break;
	case VM_FAULT_SIGNAL:
		if (!user_mode(regs))
			do_no_context(regs);
		break;
	default: /* fault & VM_FAULT_ERROR */
		if (fault & VM_FAULT_OOM) {
			if (!user_mode(regs))
				do_no_context(regs);
			else
				pagefault_out_of_memory();
		} else if (fault & VM_FAULT_SIGSEGV) {
			/* Kernel mode? Handle exceptions or die */
			if (!user_mode(regs))
				do_no_context(regs);
			else
				do_sigsegv(regs, SEGV_MAPERR);
		} else if (fault & VM_FAULT_SIGBUS) {
			/* Kernel mode? Handle exceptions or die */
			if (!user_mode(regs))
				do_no_context(regs);
			else
				do_sigbus(regs);
		} else
			BUG();
		break;
	}
}
示例#2
0
Music_Frame::Music_Frame(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Music_Frame)
{
    ui->setupUi(this);
    QString qss;
    QFile qssFile(":/qss/music_frame");
    qssFile.open(QFile::ReadOnly);
    if(qssFile.isOpen())
    {
   //     qDebug() << "---\n";
        qss = QLatin1String(qssFile.readAll());
  //      qDebug() << qss;
        this->setStyleSheet(qss);
        qssFile.close();
    }
    PaihangBang_Init();
    translations();
    connect(ui->return_Btn,SIGNAL(clicked()),this,SIGNAL(signal_return()));
}
int main(int argc, char *argv[])
{
	struct stream_data	stream;
	struct stream_header	hdr;
	char const		*program = "/bin/false";
	struct signature_options sigopts = {
		.min_strength	=  0,
	};
	char			build_time[8*3 + 2];
	char			revision[8*3 + 2];
	int			notify_port = -1;

	while (1) {
		int         c = getopt_long(argc, argv, "vx:S:",
					    CMDLINE_OPTIONS, NULL);

		if (c==-1)
			break;

		switch (c) {
		case CMD_HELP     :  show_help();
		case CMD_VERSION  :  show_version();
		case 'x' :  program = optarg; break;
		case 'v' :  sigopts.min_strength = 1; break;
		case 'S':   sigopts.min_strength = atoi(optarg); break;

		case CMD_CAFILE:
			if (!add_filename(&sigopts.ca_files, optarg))
				return EX_OSERR;
			break;

		case CMD_CRLFILE:
			if (!add_filename(&sigopts.crl_files, optarg))
				return EX_OSERR;
			break;

		case CMD_NOTIFY_PORT:
			notify_port = atoi(optarg);
			break;

		default:
			fprintf(stderr, "Try --help for more information\n");
			return EX_USAGE;
		}
	}

	if (!notification_init(&stream.notify, notify_port))
		return EX_OSERR;

	if (!stream_data_open(&stream, 0))
		signal_return(&stream, EX_OSERR);

	if (!stream_data_read_params(&stream))
		signal_return(&stream, EX_DATAERR);

	if (!stream_data_read(&stream, &hdr, sizeof hdr, false))
		signal_return(&stream, EX_DATAERR);

	if (be32toh(hdr.magic) != STREAM_HEADER_MAGIC) {
		fprintf(stderr, "bad stream magic\n");
		signal_return(&stream, EX_DATAERR);
	}

	if (!read_hdr_ext(&stream, be32toh(hdr.version),
			  be32toh(hdr.extra_header)))
		signal_return(&stream, EX_DATAERR);

	sprintf(build_time, "%" PRIu64, be64toh(hdr.build_time));
	setenv("STREAM_BUILD_TIME", build_time, 1);

	sprintf(revision, "%" PRIx64, be64toh(stream.revision));
	setenv("STREAM_REVISION", revision, 1);

	notification_send_length(&stream.notify, stream.total_len);

	if (!stage_transaction(program, "start"))
		signal_return(&stream, EX_OSERR);

	for (;;) {
		struct stream_hunk_header	hhdr;
		struct memory_block_data	payload;
		struct memory_block_signature	signature;

		if (!stream_data_read(&stream, &hhdr, sizeof hhdr, true))
			signal_return(&stream, EX_DATAERR);

		if (stream.is_eos)
			break;

		payload.mem.stream   = &stream;
		payload.mem.len      = be32toh(hhdr.hunk_len);
		payload.mem.data     = NULL;
		payload.type         = be32toh(hhdr.type);
		payload.compression  = hhdr.compress_type;
		payload.len          = be32toh(hhdr.decompress_len);

		signature.opts       = &sigopts;
		signature.pre.stream = &stream;
		signature.pre.len    = be32toh(hhdr.prefix_len);
		signature.pre.data   = NULL;
		signature.mem.stream = &stream;
		signature.mem.len    = be32toh(hhdr.fixed_sign_len);
		signature.mem.data   = NULL;
		signature.type       = hhdr.sign_type;
		signature.shdr       = &hdr;
		signature.hhdr       = &hhdr;

		if (!process_hunk(program, &stream.notify, &payload, &signature))
			signal_return(&stream, EX_DATAERR);
	}

	stream_data_close(&stream);

	free(sigopts.ca_files.names);
	free(sigopts.crl_files.names);

	if (!stage_transaction(program, "end"))
		signal_return(&stream, EX_OSERR);

	signal_return(&stream, EX_OK);
}
示例#4
0
文件: fault.c 项目: mobilipia/iods
/*
 * This routine handles page faults.  It determines the address,
 * and the problem, and then passes it off to one of the appropriate
 * routines.
 *
 * error_code:
 *   04       Protection           ->  Write-Protection  (suprression)
 *   10       Segment translation  ->  Not present       (nullification)
 *   11       Page translation     ->  Not present       (nullification)
 *   3b       Region third trans.  ->  Not present       (nullification)
 */
static inline void
do_exception(struct pt_regs *regs, unsigned long error_code, int write)
{
	struct task_struct *tsk;
	struct mm_struct *mm;
	struct vm_area_struct *vma;
	unsigned long address;
	int space;
	int si_code;
	int fault;

	if (notify_page_fault(regs, error_code))
		return;

	tsk = current;
	mm = tsk->mm;

	/* get the failing address and the affected space */
	address = S390_lowcore.trans_exc_code & __FAIL_ADDR_MASK;
	space = check_space(tsk);

	/*
	 * Verify that the fault happened in user space, that
	 * we are not in an interrupt and that there is a 
	 * user context.
	 */
	if (unlikely(space == 0 || in_atomic() || !mm))
		goto no_context;

	/*
	 * When we get here, the fault happened in the current
	 * task's user address space, so we can switch on the
	 * interrupts again and then search the VMAs
	 */
	local_irq_enable();

	down_read(&mm->mmap_sem);

	si_code = SEGV_MAPERR;
	vma = find_vma(mm, address);
	if (!vma)
		goto bad_area;

#ifdef CONFIG_S390_EXEC_PROTECT
	if (unlikely((space == 2) && !(vma->vm_flags & VM_EXEC)))
		if (!signal_return(mm, regs, address, error_code))
			/*
			 * signal_return() has done an up_read(&mm->mmap_sem)
			 * if it returns 0.
			 */
			return;
#endif

	if (vma->vm_start <= address)
		goto good_area;
	if (!(vma->vm_flags & VM_GROWSDOWN))
		goto bad_area;
	if (expand_stack(vma, address))
		goto bad_area;
/*
 * Ok, we have a good vm_area for this memory access, so
 * we can handle it..
 */
good_area:
	si_code = SEGV_ACCERR;
	if (!write) {
		/* page not present, check vm flags */
		if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))
			goto bad_area;
	} else {
		if (!(vma->vm_flags & VM_WRITE))
			goto bad_area;
	}

survive:
	/*
	 * If for any reason at all we couldn't handle the fault,
	 * make sure we exit gracefully rather than endlessly redo
	 * the fault.
	 */
	fault = handle_mm_fault(mm, vma, address, write);
	if (unlikely(fault & VM_FAULT_ERROR)) {
		if (fault & VM_FAULT_OOM) {
			if (do_out_of_memory(regs, error_code, address))
				goto survive;
			return;
		} else if (fault & VM_FAULT_SIGBUS) {
			do_sigbus(regs, error_code, address);
			return;
		}
		BUG();
	}
	if (fault & VM_FAULT_MAJOR)
		tsk->maj_flt++;
	else
		tsk->min_flt++;

        up_read(&mm->mmap_sem);
	/*
	 * The instruction that caused the program check will
	 * be repeated. Don't signal single step via SIGTRAP.
	 */
	clear_tsk_thread_flag(tsk, TIF_SINGLE_STEP);
        return;

/*
 * Something tried to access memory that isn't in our memory map..
 * Fix it, but check if it's kernel or user first..
 */
bad_area:
	up_read(&mm->mmap_sem);

	/* User mode accesses just cause a SIGSEGV */
	if (regs->psw.mask & PSW_MASK_PSTATE) {
		tsk->thread.prot_addr = address;
		tsk->thread.trap_no = error_code;
		do_sigsegv(regs, error_code, si_code, address);
		return;
	}

no_context:
	do_no_context(regs, error_code, address);
}