From owner-svn-src-all@freebsd.org Tue Jul 9 23:58:13 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D6BE15E938D; Tue, 9 Jul 2019 23:58:13 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E4D3E8CF3F; Tue, 9 Jul 2019 23:58:12 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BA51A7156; Tue, 9 Jul 2019 23:58:12 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x69NwCQd061167; Tue, 9 Jul 2019 23:58:12 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x69NwC7C061166; Tue, 9 Jul 2019 23:58:12 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201907092358.x69NwC7C061166@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 9 Jul 2019 23:58:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r349871 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 349871 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E4D3E8CF3F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.91 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.91)[-0.908,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2019 23:58:13 -0000 Author: jhb Date: Tue Jul 9 23:58:12 2019 New Revision: 349871 URL: https://svnweb.freebsd.org/changeset/base/349871 Log: Use 'retval' label for first error in syscallenter(). This is more consistent with the rest of the function and lets us unindent most of the function. Reviewed by: kib MFC after: 1 month Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D20897 Modified: head/sys/kern/subr_syscall.c Modified: head/sys/kern/subr_syscall.c ============================================================================== --- head/sys/kern/subr_syscall.c Tue Jul 9 22:24:22 2019 (r349870) +++ head/sys/kern/subr_syscall.c Tue Jul 9 23:58:12 2019 (r349871) @@ -85,69 +85,68 @@ syscallenter(struct thread *td) (uintptr_t)td, "pid:%d", td->td_proc->p_pid, "arg0:%p", sa->args[0], "arg1:%p", sa->args[1], "arg2:%p", sa->args[2]); - if (error == 0) { + if (error != 0) + goto retval; - STOPEVENT(p, S_SCE, sa->narg); - if (p->p_flag & P_TRACED) { - PROC_LOCK(p); - if (p->p_ptevents & PTRACE_SCE) - ptracestop((td), SIGTRAP, NULL); - PROC_UNLOCK(p); - } - if (td->td_dbgflags & TDB_USERWR) { - /* - * Reread syscall number and arguments if - * debugger modified registers or memory. - */ - error = (p->p_sysent->sv_fetch_syscall_args)(td); + STOPEVENT(p, S_SCE, sa->narg); + if ((p->p_flag & P_TRACED) != 0) { + PROC_LOCK(p); + if (p->p_ptevents & PTRACE_SCE) + ptracestop((td), SIGTRAP, NULL); + PROC_UNLOCK(p); + } + if ((td->td_dbgflags & TDB_USERWR) != 0) { + /* + * Reread syscall number and arguments if debugger + * modified registers or memory. + */ + error = (p->p_sysent->sv_fetch_syscall_args)(td); #ifdef KTRACE - if (KTRPOINT(td, KTR_SYSCALL)) - ktrsyscall(sa->code, sa->narg, sa->args); + if (KTRPOINT(td, KTR_SYSCALL)) + ktrsyscall(sa->code, sa->narg, sa->args); #endif - if (error != 0) - goto retval; - } + if (error != 0) + goto retval; + } #ifdef CAPABILITY_MODE - /* - * In capability mode, we only allow access to system calls - * flagged with SYF_CAPENABLED. - */ - if (IN_CAPABILITY_MODE(td) && - !(sa->callp->sy_flags & SYF_CAPENABLED)) { - error = ECAPMODE; - goto retval; - } + /* + * In capability mode, we only allow access to system calls + * flagged with SYF_CAPENABLED. + */ + if (IN_CAPABILITY_MODE(td) && + !(sa->callp->sy_flags & SYF_CAPENABLED)) { + error = ECAPMODE; + goto retval; + } #endif - error = syscall_thread_enter(td, sa->callp); - if (error != 0) - goto retval; + error = syscall_thread_enter(td, sa->callp); + if (error != 0) + goto retval; #ifdef KDTRACE_HOOKS - /* Give the syscall:::entry DTrace probe a chance to fire. */ - if (__predict_false(systrace_enabled && - sa->callp->sy_entry != 0)) - (*systrace_probe_func)(sa, SYSTRACE_ENTRY, 0); + /* Give the syscall:::entry DTrace probe a chance to fire. */ + if (__predict_false(systrace_enabled && sa->callp->sy_entry != 0)) + (*systrace_probe_func)(sa, SYSTRACE_ENTRY, 0); #endif - AUDIT_SYSCALL_ENTER(sa->code, td); - error = (sa->callp->sy_call)(td, sa->args); - AUDIT_SYSCALL_EXIT(error, td); + AUDIT_SYSCALL_ENTER(sa->code, td); + error = (sa->callp->sy_call)(td, sa->args); + AUDIT_SYSCALL_EXIT(error, td); - /* Save the latest error return value. */ - if ((td->td_pflags & TDP_NERRNO) == 0) - td->td_errno = error; + /* Save the latest error return value. */ + if ((td->td_pflags & TDP_NERRNO) == 0) + td->td_errno = error; #ifdef KDTRACE_HOOKS - /* Give the syscall:::return DTrace probe a chance to fire. */ - if (__predict_false(systrace_enabled && - sa->callp->sy_return != 0)) - (*systrace_probe_func)(sa, SYSTRACE_RETURN, - error ? -1 : td->td_retval[0]); + /* Give the syscall:::return DTrace probe a chance to fire. */ + if (__predict_false(systrace_enabled && sa->callp->sy_return != 0)) + (*systrace_probe_func)(sa, SYSTRACE_RETURN, + error ? -1 : td->td_retval[0]); #endif - syscall_thread_exit(td, sa->callp); - } + syscall_thread_exit(td, sa->callp); + retval: KTR_STOP4(KTR_SYSC, "syscall", syscallname(p, sa->code), (uintptr_t)td, "pid:%d", td->td_proc->p_pid, "error:%d", error,