From owner-svn-src-stable@freebsd.org Tue Dec 4 16:53:29 2018 Return-Path: Delivered-To: svn-src-stable@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 692761312BF1; Tue, 4 Dec 2018 16:53:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0B5FD82B3E; Tue, 4 Dec 2018 16:53:29 +0000 (UTC) (envelope-from kib@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 E1C0227FFC; Tue, 4 Dec 2018 16:53:28 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wB4GrSwG031004; Tue, 4 Dec 2018 16:53:28 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wB4GrSm8031003; Tue, 4 Dec 2018 16:53:28 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201812041653.wB4GrSm8031003@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 4 Dec 2018 16:53:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r341476 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 341476 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0B5FD82B3E X-Spamd-Result: default: False [-0.45 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.50)[-0.502,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_SPAM_SHORT(0.14)[0.135,0]; NEURAL_HAM_LONG(-0.09)[-0.087,0] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Dec 2018 16:53:29 -0000 Author: kib Date: Tue Dec 4 16:53:28 2018 New Revision: 341476 URL: https://svnweb.freebsd.org/changeset/base/341476 Log: MFC r341094: Improve sigonstack(). Modified: stable/11/sys/kern/kern_sig.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_sig.c ============================================================================== --- stable/11/sys/kern/kern_sig.c Tue Dec 4 16:49:14 2018 (r341475) +++ stable/11/sys/kern/kern_sig.c Tue Dec 4 16:53:28 2018 (r341476) @@ -617,20 +617,25 @@ signotify(struct thread *td) } } +/* + * Returns 1 (true) if altstack is configured for the thread, and the + * passed stack bottom address falls into the altstack range. Handles + * the 43 compat special case where the alt stack size is zero. + */ int sigonstack(size_t sp) { - struct thread *td = curthread; + struct thread *td; - return ((td->td_pflags & TDP_ALTSTACK) ? + td = curthread; + if ((td->td_pflags & TDP_ALTSTACK) == 0) + return (0); #if defined(COMPAT_43) - ((td->td_sigstk.ss_size == 0) ? - (td->td_sigstk.ss_flags & SS_ONSTACK) : - ((sp - (size_t)td->td_sigstk.ss_sp) < td->td_sigstk.ss_size)) -#else - ((sp - (size_t)td->td_sigstk.ss_sp) < td->td_sigstk.ss_size) + if (td->td_sigstk.ss_size == 0) + return ((td->td_sigstk.ss_flags & SS_ONSTACK) != 0); #endif - : 0); + return (sp >= (size_t)td->td_sigstk.ss_sp && + sp < td->td_sigstk.ss_size + (size_t)td->td_sigstk.ss_sp); } static __inline int