From owner-svn-src-stable-12@freebsd.org Sun Mar 10 00:56:39 2019 Return-Path: Delivered-To: svn-src-stable-12@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 3B27B153E977; Sun, 10 Mar 2019 00:56:39 +0000 (UTC) (envelope-from kp@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 C6C7B83450; Sun, 10 Mar 2019 00:56:38 +0000 (UTC) (envelope-from kp@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 B78651B468; Sun, 10 Mar 2019 00:56:38 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2A0ucDh013393; Sun, 10 Mar 2019 00:56:38 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2A0ucCT013392; Sun, 10 Mar 2019 00:56:38 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201903100056.x2A0ucCT013392@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sun, 10 Mar 2019 00:56:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344974 - stable/12/sys/netpfil/pf X-SVN-Group: stable-12 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/12/sys/netpfil/pf X-SVN-Commit-Revision: 344974 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C6C7B83450 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 00:56:39 -0000 Author: kp Date: Sun Mar 10 00:56:38 2019 New Revision: 344974 URL: https://svnweb.freebsd.org/changeset/base/344974 Log: pf: Small performance tweak Because fetching a counter is a rather expansive function we should use counter_u64_fetch() in pf_state_expires() only when necessary. A "rdr pass" rule should not cause more effort than separate "rdr" and "pass" rules. For rules with adaptive timeout values the call of counter_u64_fetch() should be accepted, but otherwise not. From the man page: The adaptive timeout values can be defined both globally and for each rule. When used on a per-rule basis, the values relate to the number of states created by the rule, otherwise to the total number of states. This handling of adaptive timeouts is done in pf_state_expires(). The calculation needs three values: start, end and states. 1. Normal rules "pass .." without adaptive setting meaning "start = 0" runs in the else-section and therefore takes "start" and "end" from the global default settings and sets "states" to pf_status.states (= total number of states). 2. Special rules like "pass .. keep state (adaptive.start 500 adaptive.end 1000)" have start != 0, run in the if-section and take "start" and "end" from the rule and set "states" to the number of states created by their rule using counter_u64_fetch(). Thats all ok, but there is a third case without special handling in the above code snippet: 3. All "rdr/nat pass .." statements use together the pf_default_rule. Therefore we have "start != 0" in this case and we run the if-section but we better should run the else-section in this case and do not fetch the counter of the pf_default_rule but take the total number of states. Submitted by: Andreas Longwitz Modified: stable/12/sys/netpfil/pf/pf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netpfil/pf/pf.c ============================================================================== --- stable/12/sys/netpfil/pf/pf.c Sat Mar 9 21:09:44 2019 (r344973) +++ stable/12/sys/netpfil/pf/pf.c Sun Mar 10 00:56:38 2019 (r344974) @@ -1564,7 +1564,7 @@ pf_state_expires(const struct pf_state *state) if (!timeout) timeout = V_pf_default_rule.timeout[state->timeout]; start = state->rule.ptr->timeout[PFTM_ADAPTIVE_START]; - if (start) { + if (start && state->rule.ptr != &V_pf_default_rule) { end = state->rule.ptr->timeout[PFTM_ADAPTIVE_END]; states = counter_u64_fetch(state->rule.ptr->states_cur); } else { From owner-svn-src-stable-12@freebsd.org Sun Mar 10 04:41:31 2019 Return-Path: Delivered-To: svn-src-stable-12@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 9F44215236BB; Sun, 10 Mar 2019 04:41:31 +0000 (UTC) (envelope-from ae@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 39C758B9CA; Sun, 10 Mar 2019 04:41:31 +0000 (UTC) (envelope-from ae@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 2F1341DFC9; Sun, 10 Mar 2019 04:41:31 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2A4fVIY029770; Sun, 10 Mar 2019 04:41:31 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2A4fVGk029769; Sun, 10 Mar 2019 04:41:31 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201903100441.x2A4fVGk029769@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Sun, 10 Mar 2019 04:41:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344976 - stable/12/sys/netpfil/ipfw X-SVN-Group: stable-12 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/12/sys/netpfil/ipfw X-SVN-Commit-Revision: 344976 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 39C758B9CA X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.92 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.92)[-0.921,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 04:41:31 -0000 Author: ae Date: Sun Mar 10 04:41:30 2019 New Revision: 344976 URL: https://svnweb.freebsd.org/changeset/base/344976 Log: MFC r344870: Fix the problem with O_LIMIT states introduced in r344018. dyn_install_state() uses `rule` pointer when it creates state. For O_LIMIT states this pointer actually is not struct ip_fw, it is pointer to O_LIMIT_PARENT state, that keeps actual pointer to ip_fw parent rule. Thus we need to cache rule id and number before calling dyn_get_parent_state(), so we can use them later when the `rule` pointer is overrided. PR: 236292 Modified: stable/12/sys/netpfil/ipfw/ip_fw_dynamic.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netpfil/ipfw/ip_fw_dynamic.c ============================================================================== --- stable/12/sys/netpfil/ipfw/ip_fw_dynamic.c Sun Mar 10 00:56:39 2019 (r344975) +++ stable/12/sys/netpfil/ipfw/ip_fw_dynamic.c Sun Mar 10 04:41:30 2019 (r344976) @@ -1869,11 +1869,13 @@ dyn_install_state(const struct ipfw_flow_id *pkt, uint uint16_t kidx, uint8_t type) { struct ipfw_flow_id id; - uint32_t hashval, parent_hashval; + uint32_t hashval, parent_hashval, ruleid, rulenum; int ret; MPASS(type == O_LIMIT || type == O_KEEP_STATE); + ruleid = rule->id; + rulenum = rule->rulenum; if (type == O_LIMIT) { /* Create masked flow id and calculate bucket */ id.addr_type = pkt->addr_type; @@ -1928,11 +1930,11 @@ dyn_install_state(const struct ipfw_flow_id *pkt, uint hashval = hash_packet(pkt); if (IS_IP4_FLOW_ID(pkt)) - ret = dyn_add_ipv4_state(rule, rule->id, rule->rulenum, pkt, + ret = dyn_add_ipv4_state(rule, ruleid, rulenum, pkt, ulp, pktlen, hashval, info, fibnum, kidx, type); #ifdef INET6 else if (IS_IP6_FLOW_ID(pkt)) - ret = dyn_add_ipv6_state(rule, rule->id, rule->rulenum, pkt, + ret = dyn_add_ipv6_state(rule, ruleid, rulenum, pkt, zoneid, ulp, pktlen, hashval, info, fibnum, kidx, type); #endif /* INET6 */ else From owner-svn-src-stable-12@freebsd.org Sun Mar 10 09:34:38 2019 Return-Path: Delivered-To: svn-src-stable-12@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 5FF18152D256; Sun, 10 Mar 2019 09:34:38 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F3B2D6DA47; Sun, 10 Mar 2019 09:34:37 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.codepro.be", Issuer "Let's Encrypt Authority X3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id CE277942B; Sun, 10 Mar 2019 09:34:37 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from [10.0.2.193] (ptr-8rh08jyp2rmld95bwel.18120a2.ip6.access.telenet.be [IPv6:2a02:1811:240e:402:2980:fc78:46a9:71cd]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id A47FC1B4D1; Sun, 10 Mar 2019 10:34:35 +0100 (CET) From: "Kristof Provost" To: "Harry Schmalzbauer" Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: Re: svn commit: r344974 - stable/12/sys/netpfil/pf Date: Sun, 10 Mar 2019 10:34:34 +0100 X-Mailer: MailMate (2.0BETAr6135) Message-ID: <8C805FB7-AE8B-4FF9-82E6-EA406C3B07BE@FreeBSD.org> In-Reply-To: <7bdf4d3c-61b3-4319-d5b7-5234991fad78@omnilan.de> References: <201903100056.x2A0ucCT013392@repo.freebsd.org> <7bdf4d3c-61b3-4319-d5b7-5234991fad78@omnilan.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: F3B2D6DA47 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.961,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] Content-Type: text/plain; charset=utf-8; format=flowed; markup=markdown Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 09:34:38 -0000 On 10 Mar 2019, at 10:16, Harry Schmalzbauer wrote: > Am 10.03.2019 um 01:56 schrieb Kristof Provost: >> Author: kp >> Date: Sun Mar 10 00:56:38 2019 >> New Revision: 344974 >> URL: https://svnweb.freebsd.org/changeset/base/344974 >> >> Log: >> pf: Small performance tweak > > Seems to be the MFC of 344493. > Indeed, apologies for missing out the MFC tag here. That’ll teach me to sleep before I commit, rather than after. > Out of curiosity, do you have to manually write these log messages > each time?  > Yes. I should see about scripting these MFCs someday, to avoid silly mistakes like this. Regards, Kristof From owner-svn-src-stable-12@freebsd.org Sun Mar 10 16:57:37 2019 Return-Path: Delivered-To: svn-src-stable-12@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 09F491539817; Sun, 10 Mar 2019 16:57:37 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A2DEA84B44; Sun, 10 Mar 2019 16:57:36 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from venus.codepro.be (venus.codepro.be [5.9.86.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.codepro.be", Issuer "Let's Encrypt Authority X3" (verified OK)) (Authenticated sender: kp) by smtp.freebsd.org (Postfix) with ESMTPSA id 71A24C43A; Sun, 10 Mar 2019 16:57:36 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from [10.0.2.193] (ptr-8rh08k0c8y7tidee3xm.18120a2.ip6.access.telenet.be [IPv6:2a02:1811:240e:402:9596:89f9:e3f6:8d6a]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id 143C91B760; Sun, 10 Mar 2019 17:57:35 +0100 (CET) From: "Kristof Provost" To: "Ian Lepore" Cc: "Harry Schmalzbauer" , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: Re: svn commit: r344974 - stable/12/sys/netpfil/pf Date: Sun, 10 Mar 2019 17:57:34 +0100 X-Mailer: MailMate (2.0BETAr6135) Message-ID: <93666CE2-959E-425D-80F9-71858D6B6B85@FreeBSD.org> In-Reply-To: References: <201903100056.x2A0ucCT013392@repo.freebsd.org> <7bdf4d3c-61b3-4319-d5b7-5234991fad78@omnilan.de> <8C805FB7-AE8B-4FF9-82E6-EA406C3B07BE@FreeBSD.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: A2DEA84B44 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.93 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.93)[-0.927,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] Content-Type: text/plain; markup=markdown X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 16:57:37 -0000 On 10 Mar 2019, at 17:54, Ian Lepore wrote: > On Sun, 2019-03-10 at 10:34 +0100, Kristof Provost wrote: >> Yes. I should see about scripting these MFCs someday, to avoid silly >> mistakes like this. >> > > Or looking into using gonzo's mfc helper website at > > https://mfc.kernelnomicon.org/6/ > > It will let you select one or more of your (or somebody else's) prior > commits and it'll generate the commands to do the mfc, and the text you > can paste into the commit message. > Oooh! I did not know it could do that. Shiny! Kristof From owner-svn-src-stable-12@freebsd.org Sun Mar 10 16:14:44 2019 Return-Path: Delivered-To: svn-src-stable-12@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 EFC6915387BE; Sun, 10 Mar 2019 16:14:43 +0000 (UTC) (envelope-from ngie@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 9716983600; Sun, 10 Mar 2019 16:14:43 +0000 (UTC) (envelope-from ngie@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 8A4D5258F2; Sun, 10 Mar 2019 16:14:43 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2AGEhKn002153; Sun, 10 Mar 2019 16:14:43 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2AGEhZ7002151; Sun, 10 Mar 2019 16:14:43 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903101614.x2AGEhZ7002151@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Sun, 10 Mar 2019 16:14:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344978 - stable/12/lib/libc/tests/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/12/lib/libc/tests/sys X-SVN-Commit-Revision: 344978 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9716983600 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 16:14:44 -0000 Author: ngie Date: Sun Mar 10 16:14:42 2019 New Revision: 344978 URL: https://svnweb.freebsd.org/changeset/base/344978 Log: MFC r343362,r343365,r343367,r343368,r343461,r343751,r344310: r343362: Add [initial] functional tests for sendfile(2) as lib/libc/sys/sendfile These testcases exercise a number of functional requirements for sendfile(2). The testcases use IPv4 and IPv6 domain sockets with TCP, and were confirmed functional on UFS and ZFS. UDP address family sockets cannot be used per the sendfile(2) contract, thus using UDP sockets is outside the scope of testing the syscall in positive cases. As seen in `:s_negative_udp_socket_test`, UDP is used to test the sendfile(2) contract to ensure that EINVAL is returned by sendfile(2). The testcases added explicitly avoid testing out `SF_SYNC` due to the complexity of verifying that support. However, this is a good next logical item to verify. The `hdtr_positive*` testcases work to a certain degree (the header testcases pass), but the trailer testcases do not work (it is an expected failure). In particular, the value received by the mock server doesn't match the expected value, and instead looks something like the following (using python array notation): `trailer[:]message[1:]` instead of: `message[:]trailer[:]` This makes me think there's a buffer overrun issue or problem with the offset somewhere in the sendfile(2) system call, but I need to do some other testing first to verify that the code is indeed sane, and my assumptions/code isn't buggy. The `sbytes_negative` testcases that check `sbytes` being set to an invalid value resulting in `EFAULT` fails today as the other change (which checks `copyout(9)`) has not been committed [1]. Thus, it should remain an expected failure (see bug 232210 for more details on this item). Next steps for testing sendfile(2): 1. Fix the header/trailer testcases so that they pass. 2. Setup if_tap interface and test with it, instead of using "localhost", per @asomers's suggestion. 3. Handle short recv(2)'s in `server_cat(..)`. 4. Add `SF_SYNC` support. 5. Add some more negative tests outside the scope of the functional contract. PR: 232210 r343365: Unbreak the gcc build with sendfile_test after r343362 gcc 8.x is more pedantic than clang 7.x with format strings and the tests passed `void*` variables while supplying `%s` (which is technically incorrect). Make the affected `void*` variables use `char*` storage instead to address this issue, as the compiler will upcast the values to `char*`. MFC with: r343362 r343367: Unbreak the build on architectures where size_t isn't synonymous with uintmax_t I should have used `%zu` instead of `%ju` with `size_t` types. MFC with: r343362, r343365 Pointyhat to: ngie r343368: Fix up r343367 I should have only changed the format qualifier with the `size_t` value, `length`, not the other [`off_t`] value, `dest_file_size`. MFC with: r343362, r343365, r343367 r343461: Fix reporting errors with `gai_strerror(..)` The return value (`err`) should be checked; not the `errno` value. PR: 235200 MFC with: r343362, r343365, r343367-r343368 r343751: Avoid the DNS lookup for "localhost" ci.FreeBSD.org does not have access to a DNS resolver/network (unlike my test VM), so in order for the test to pass on the host, it needs to avoid the DNS lookup by using the numeric host address representation. PR: 235200 MFC with: r343362, r343365, r343367-r343368, r343461 r344310: Make `server_cat(..)` handle short receives In short, the prior code was far too simplistic when it came to calling recv(2) and failed intermittently (or in the case of Jenkins, deterministically). Handle short recv(2)s by checking the return code and incrementing the window into the buffer by the number of received bytes. If the number of received bytes <= 0, then bail out of the loop, and test the total number of received bytes vs the expected number of bytes sent for equality, and base whether or not the test passes/fails on that fact. Remove the expected failure, now that the hdtr testcases deterministically pass on my host after this change [1]. PR: 234809 [1], 235200 Approved by: emaste (mentor, implicit: MFC to ^/stable/11 in r344977) Differential Revision: https://reviews.freebsd.org/D19523 Added: stable/12/lib/libc/tests/sys/sendfile_test.c - copied, changed from r343362, head/lib/libc/tests/sys/sendfile_test.c Modified: stable/12/lib/libc/tests/sys/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/tests/sys/Makefile ============================================================================== --- stable/12/lib/libc/tests/sys/Makefile Sun Mar 10 16:13:00 2019 (r344977) +++ stable/12/lib/libc/tests/sys/Makefile Sun Mar 10 16:14:42 2019 (r344978) @@ -8,6 +8,7 @@ PACKAGE= tests ATF_TESTS_C+= brk_test .endif ATF_TESTS_C+= queue_test +ATF_TESTS_C+= sendfile_test # TODO: clone, lwp_create, lwp_ctl, posix_fadvise, recvmmsg, # swapcontext Copied and modified: stable/12/lib/libc/tests/sys/sendfile_test.c (from r343362, head/lib/libc/tests/sys/sendfile_test.c) ============================================================================== --- head/lib/libc/tests/sys/sendfile_test.c Wed Jan 23 22:00:17 2019 (r343362, copy source) +++ stable/12/lib/libc/tests/sys/sendfile_test.c Sun Mar 10 16:14:42 2019 (r344978) @@ -97,24 +97,33 @@ generate_random_port(int seed) static void resolve_localhost(struct addrinfo **res, int domain, int type, int port) { + const char *host; char *serv; struct addrinfo hints; int error; - ATF_REQUIRE_MSG(domain == AF_INET || domain == AF_INET6, - "unhandled domain: %d", domain); + switch (domain) { + case AF_INET: + host = "127.0.0.1"; + break; + case AF_INET6: + host = "::1"; + break; + default: + atf_tc_fail("unhandled domain: %d", domain); + } ATF_REQUIRE_MSG(asprintf(&serv, "%d", port) >= 0, "asprintf failed: %s", strerror(errno)); memset(&hints, 0, sizeof(hints)); hints.ai_family = domain; - hints.ai_flags = AI_ADDRCONFIG|AI_NUMERICSERV; + hints.ai_flags = AI_ADDRCONFIG|AI_NUMERICSERV|AI_NUMERICHOST; hints.ai_socktype = type; - error = getaddrinfo("localhost", serv, &hints, res); + error = getaddrinfo(host, serv, &hints, res); ATF_REQUIRE_EQ_MSG(error, 0, - "getaddrinfo failed: %s", gai_strerror(errno)); + "getaddrinfo failed: %s", gai_strerror(error)); free(serv); } @@ -147,6 +156,8 @@ setup_client(int domain, int type, int port) "Will try to connect to host='%s', address_family=%d, " "socket_type=%d\n", host, res->ai_family, res->ai_socktype); + /* Avoid a double print when forked by flushing. */ + fflush(stdout); sock = make_socket(res->ai_family, res->ai_socktype, res->ai_protocol); error = connect(sock, (struct sockaddr*)res->ai_addr, res->ai_addrlen); freeaddrinfo(res); @@ -178,6 +189,8 @@ setup_server(int domain, int type, int port) "Will try to bind socket to host='%s', address_family=%d, " "socket_type=%d\n", host, res->ai_family, res->ai_socktype); + /* Avoid a double print when forked by flushing. */ + fflush(stdout); error = bind(sock, res->ai_addr, res->ai_addrlen); freeaddrinfo(res); ATF_REQUIRE_EQ_MSG(error, 0, "bind failed: %s", strerror(errno)); @@ -195,11 +208,17 @@ setup_server(int domain, int type, int port) static void server_cat(const char *dest_filename, int server_sock, size_t len) { - void *buffer; + char *buffer, *buf_window_ptr; int recv_sock; - ssize_t received_bytes; + size_t buffer_size; + ssize_t received_bytes, recv_ret; - buffer = calloc(len + 1, sizeof(char)); + /* + * Ensure that there isn't excess data sent across the wire by + * capturing 10 extra bytes (plus 1 for nul). + */ + buffer_size = len + 10 + 1; + buffer = calloc(buffer_size, sizeof(char)); if (buffer == NULL) err(1, "malloc failed"); @@ -207,32 +226,26 @@ server_cat(const char *dest_filename, int server_sock, if (recv_sock == -1) err(1, "accept failed"); - /* - * XXX: this assumes the simplest case where all data is received in a - * single recv(2) call. - */ - if (recv(recv_sock, buffer, len, 0) == -1) - err(1, "recv failed"); + buf_window_ptr = buffer; + received_bytes = 0; + do { + recv_ret = recv(recv_sock, buf_window_ptr, + buffer_size - received_bytes, 0); + if (recv_ret <= 0) + break; + buf_window_ptr += recv_ret; + received_bytes += recv_ret; + } while (received_bytes < buffer_size); atf_utils_create_file(dest_filename, "%s", buffer); - /* - * This recv(2) call helps ensure the amount of sent data is exactly - * what was specified by `len`. - */ - received_bytes = recv(recv_sock, buffer, len, 0); - switch (received_bytes) { - case -1: - err(1, "recv failed"); - case 0: - break; - default: - errx(1, "received unexpected data: %s", buffer); - } - (void)close(recv_sock); (void)close(server_sock); free(buffer); + + if (received_bytes != len) + errx(1, "received unexpected data: %zd != %zd", received_bytes, + len); } static int @@ -268,7 +281,7 @@ static void verify_source_and_dest(const char* dest_filename, int src_fd, off_t offset, size_t nbytes) { - void *dest_pointer, *src_pointer; + char *dest_pointer, *src_pointer; off_t dest_file_size, src_file_size; size_t length; int dest_fd; @@ -290,7 +303,7 @@ verify_source_and_dest(const char* dest_filename, int ATF_REQUIRE_EQ_MSG(dest_file_size, length, "number of bytes written out to %s (%ju) doesn't match the " - "expected number of bytes (%ju)", dest_filename, dest_file_size, + "expected number of bytes (%zu)", dest_filename, dest_file_size, length); ATF_REQUIRE_EQ_MSG(0, lseek(src_fd, offset, SEEK_SET), @@ -384,7 +397,7 @@ ATF_TC_BODY(fd_positive_file_v6, tc) static void fd_positive_shm_test(int domain) { - void *shm_pointer; + char *shm_pointer; off_t offset; size_t nbytes, pattern_size; pid_t server_pid; @@ -658,10 +671,6 @@ hdtr_positive_test(int domain) offset = 0; nbytes = 0; - atf_tc_expect_fail( - "The header/trailer testcases fail today with a data mismatch; " - "bug # 234809"); - for (i = 0; i < nitems(testcases); i++) { struct sf_hdtr hdtr; char *pattern; @@ -687,9 +696,9 @@ hdtr_positive_test(int domain) client_sock = setup_tcp_client(domain, port); rc = asprintf(&pattern, "%s%s%s", - testcases[i].include_headers ? headers[0].iov_base : "", + testcases[i].include_headers ? (char *)headers[0].iov_base : "", DETERMINISTIC_PATTERN, - testcases[i].include_trailers ? trailers[0].iov_base : ""); + testcases[i].include_trailers ? (char *)trailers[0].iov_base : ""); ATF_REQUIRE_MSG(rc != -1, "asprintf failed: %s", strerror(errno)); atf_utils_create_file(SOURCE_FILE ".full", "%s", pattern); From owner-svn-src-stable-12@freebsd.org Sun Mar 10 09:16:22 2019 Return-Path: Delivered-To: svn-src-stable-12@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 4FF10152CB59; Sun, 10 Mar 2019 09:16:22 +0000 (UTC) (envelope-from freebsd@omnilan.de) Received: from mx0.gentlemail.de (mx0.gentlemail.de [IPv6:2a00:e10:2800::a130]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C30EE6D070; Sun, 10 Mar 2019 09:16:21 +0000 (UTC) (envelope-from freebsd@omnilan.de) Received: from mh0.gentlemail.de (ezra.dcm1.omnilan.net [78.138.80.135]) by mx0.gentlemail.de (8.14.5/8.14.5) with ESMTP id x2A9GIe1030440; Sun, 10 Mar 2019 10:16:18 +0100 (CET) (envelope-from freebsd@omnilan.de) Received: from titan.inop.mo1.omnilan.net (s1.omnilan.de [217.91.127.234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mh0.gentlemail.de (Postfix) with ESMTPSA id 1BB54DA0; Sun, 10 Mar 2019 10:16:18 +0100 (CET) Subject: Re: svn commit: r344974 - stable/12/sys/netpfil/pf To: Kristof Provost , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org References: <201903100056.x2A0ucCT013392@repo.freebsd.org> From: Harry Schmalzbauer Organization: OmniLAN Message-ID: <7bdf4d3c-61b3-4319-d5b7-5234991fad78@omnilan.de> Date: Sun, 10 Mar 2019 10:16:17 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <201903100056.x2A0ucCT013392@repo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Greylist: ACL 130 matched, not delayed by milter-greylist-4.2.7 (mx0.gentlemail.de [78.138.80.130]); Sun, 10 Mar 2019 10:16:18 +0100 (CET) X-Milter: Spamilter (Reciever: mx0.gentlemail.de; Sender-ip: 78.138.80.135; Sender-helo: mh0.gentlemail.de; ) X-Rspamd-Queue-Id: C30EE6D070 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.95 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.95)[-0.951,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 09:16:22 -0000 Am 10.03.2019 um 01:56 schrieb Kristof Provost: > Author: kp > Date: Sun Mar 10 00:56:38 2019 > New Revision: 344974 > URL: https://svnweb.freebsd.org/changeset/base/344974 > > Log: > pf: Small performance tweak Seems to be the MFC of 344493. Out of curiosity, do you have to manually write these log messages each time?  I do my local svn commits with ' -m "A one liner since svn and me never beacem good friends, especailly if it's about log view/search"...  I saw the FreeBSD provided templates, but since my skills and time won't allow me to advance to commiting anything, I haven't had a closer look. Thanks, -harry From owner-svn-src-stable-12@freebsd.org Sun Mar 10 20:43:09 2019 Return-Path: Delivered-To: svn-src-stable-12@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 7D41F1541517; Sun, 10 Mar 2019 20:43:09 +0000 (UTC) (envelope-from wulf@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 2395D8D8EC; Sun, 10 Mar 2019 20:43:09 +0000 (UTC) (envelope-from wulf@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 17FDD7D9; Sun, 10 Mar 2019 20:43:09 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2AKh8OD044748; Sun, 10 Mar 2019 20:43:08 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2AKh87N044745; Sun, 10 Mar 2019 20:43:08 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <201903102043.x2AKh87N044745@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Sun, 10 Mar 2019 20:43:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344983 - in stable/12: sbin/sysctl sys/dev/evdev X-SVN-Group: stable-12 X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: in stable/12: sbin/sysctl sys/dev/evdev X-SVN-Commit-Revision: 344983 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2395D8D8EC X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 20:43:09 -0000 Author: wulf Date: Sun Mar 10 20:43:08 2019 New Revision: 344983 URL: https://svnweb.freebsd.org/changeset/base/344983 Log: MFC r344494,r344495: evdev: export event device properties through sysctl interface A big security advantage of Wayland is not allowing applications to read input devices all the time. Having /dev/input/* accessible to the user account subverts this advantage. libudev-devd was opening the evdev devices to detect their types (mouse, keyboard, touchpad, etc). This don't work if /dev/input/* is inaccessible. With the kernel exposing this information as sysctls (kern.evdev.input.*), we can work w/o /dev/input/* access, preserving the Wayland security model. Submitted by: Greg V Reviewed by: wulf, imp Differential Revision: https://reviews.freebsd.org/D18694 Modified: stable/12/sbin/sysctl/sysctl.c stable/12/sys/dev/evdev/evdev.c stable/12/sys/dev/evdev/evdev_private.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/sysctl/sysctl.c ============================================================================== --- stable/12/sbin/sysctl/sysctl.c Sun Mar 10 20:19:43 2019 (r344982) +++ stable/12/sbin/sysctl/sysctl.c Sun Mar 10 20:43:08 2019 (r344983) @@ -49,6 +49,7 @@ static const char rcsid[] = #include #include #include +#include #ifdef __amd64__ #include @@ -680,6 +681,22 @@ S_vmtotal(size_t l2, void *p) return (0); } +static int +S_input_id(size_t l2, void *p) +{ + struct input_id *id = p; + + if (l2 != sizeof(*id)) { + warnx("S_input_id %zu != %zu", l2, sizeof(*id)); + return (1); + } + + printf("{ bustype = 0x%04x, vendor = 0x%04x, " + "product = 0x%04x, version = 0x%04x }", + id->bustype, id->vendor, id->product, id->version); + return (0); +} + #ifdef __amd64__ static int S_efi_map(size_t l2, void *p) @@ -983,6 +1000,8 @@ show_var(int *oid, int nlen) func = S_loadavg; else if (strcmp(fmt, "S,vmtotal") == 0) func = S_vmtotal; + else if (strcmp(fmt, "S,input_id") == 0) + func = S_input_id; #ifdef __amd64__ else if (strcmp(fmt, "S,efi_map_header") == 0) func = S_efi_map; Modified: stable/12/sys/dev/evdev/evdev.c ============================================================================== --- stable/12/sys/dev/evdev/evdev.c Sun Mar 10 20:19:43 2019 (r344982) +++ stable/12/sys/dev/evdev/evdev.c Sun Mar 10 20:43:08 2019 (r344983) @@ -69,14 +69,16 @@ MALLOC_DEFINE(M_EVDEV, "evdev", "evdev memory"); int evdev_rcpt_mask = EVDEV_RCPT_SYSMOUSE | EVDEV_RCPT_KBDMUX; int evdev_sysmouse_t_axis = 0; -#ifdef EVDEV_SUPPORT SYSCTL_NODE(_kern, OID_AUTO, evdev, CTLFLAG_RW, 0, "Evdev args"); +#ifdef EVDEV_SUPPORT SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_RW, &evdev_rcpt_mask, 0, "Who is receiving events: bit0 - sysmouse, bit1 - kbdmux, " "bit2 - mouse hardware, bit3 - keyboard hardware"); SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RW, &evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm"); #endif +SYSCTL_NODE(_kern_evdev, OID_AUTO, input, CTLFLAG_RD, 0, + "Evdev input devices"); static void evdev_start_repeat(struct evdev_dev *, uint16_t); static void evdev_stop_repeat(struct evdev_dev *); @@ -196,6 +198,87 @@ evdev_estimate_report_size(struct evdev_dev *evdev) return (size); } +static void +evdev_sysctl_create(struct evdev_dev *evdev) +{ + struct sysctl_oid *ev_sysctl_tree; + char ev_unit_str[8]; + + snprintf(ev_unit_str, sizeof(ev_unit_str), "%d", evdev->ev_unit); + sysctl_ctx_init(&evdev->ev_sysctl_ctx); + + ev_sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&evdev->ev_sysctl_ctx, + SYSCTL_STATIC_CHILDREN(_kern_evdev_input), OID_AUTO, + ev_unit_str, CTLFLAG_RD, NULL, "", "device index"); + + SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "name", CTLFLAG_RD, + evdev->ev_name, 0, + "Input device name"); + + SYSCTL_ADD_STRUCT(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "id", CTLFLAG_RD, + &evdev->ev_id, input_id, + "Input device identification"); + + /* ioctl returns ENOENT if phys is not set. sysctl returns "" here */ + SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "phys", CTLFLAG_RD, + evdev->ev_shortname, 0, + "Input device short name"); + + /* ioctl returns ENOENT if uniq is not set. sysctl returns "" here */ + SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "uniq", CTLFLAG_RD, + evdev->ev_serial, 0, + "Input device unique number"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "props", CTLFLAG_RD, + evdev->ev_prop_flags, sizeof(evdev->ev_prop_flags), "", + "Input device properties"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "type_bits", CTLFLAG_RD, + evdev->ev_type_flags, sizeof(evdev->ev_type_flags), "", + "Input device supported events types"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "key_bits", CTLFLAG_RD, + evdev->ev_key_flags, sizeof(evdev->ev_key_flags), + "", "Input device supported keys"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "rel_bits", CTLFLAG_RD, + evdev->ev_rel_flags, sizeof(evdev->ev_rel_flags), "", + "Input device supported relative events"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "abs_bits", CTLFLAG_RD, + evdev->ev_abs_flags, sizeof(evdev->ev_abs_flags), "", + "Input device supported absolute events"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "msc_bits", CTLFLAG_RD, + evdev->ev_msc_flags, sizeof(evdev->ev_msc_flags), "", + "Input device supported miscellaneous events"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "led_bits", CTLFLAG_RD, + evdev->ev_led_flags, sizeof(evdev->ev_led_flags), "", + "Input device supported LED events"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "snd_bits", CTLFLAG_RD, + evdev->ev_snd_flags, sizeof(evdev->ev_snd_flags), "", + "Input device supported sound events"); + + SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, + SYSCTL_CHILDREN(ev_sysctl_tree), OID_AUTO, "sw_bits", CTLFLAG_RD, + evdev->ev_sw_flags, sizeof(evdev->ev_sw_flags), "", + "Input device supported switch events"); +} + static int evdev_register_common(struct evdev_dev *evdev) { @@ -235,6 +318,12 @@ evdev_register_common(struct evdev_dev *evdev) /* Create char device node */ ret = evdev_cdev_create(evdev); + if (ret != 0) + goto bail_out; + + /* Create sysctls (for device enumeration without /dev/input access rights) */ + evdev_sysctl_create(evdev); + bail_out: return (ret); } @@ -271,6 +360,8 @@ evdev_unregister(struct evdev_dev *evdev) int ret; debugf(evdev, "%s: unregistered evdev provider: %s\n", evdev->ev_shortname, evdev->ev_name); + + sysctl_ctx_free(&evdev->ev_sysctl_ctx); EVDEV_LOCK(evdev); evdev->ev_cdev->si_drv1 = NULL; Modified: stable/12/sys/dev/evdev/evdev_private.h ============================================================================== --- stable/12/sys/dev/evdev/evdev_private.h Sun Mar 10 20:19:43 2019 (r344982) +++ stable/12/sys/dev/evdev/evdev_private.h Sun Mar 10 20:43:08 2019 (r344983) @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -131,6 +132,9 @@ struct evdev_dev /* Parent driver callbacks: */ const struct evdev_methods * ev_methods; void * ev_softc; + + /* Sysctl: */ + struct sysctl_ctx_list ev_sysctl_ctx; LIST_ENTRY(evdev_dev) ev_link; LIST_HEAD(, evdev_client) ev_clients; From owner-svn-src-stable-12@freebsd.org Sun Mar 10 16:54:50 2019 Return-Path: Delivered-To: svn-src-stable-12@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 BF8A8153973D for ; Sun, 10 Mar 2019 16:54:50 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1.eu.mailhop.org (outbound1.eu.mailhop.org [52.28.251.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 39F17849BA for ; Sun, 10 Mar 2019 16:54:50 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1552236880; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=EGe2kVneqY6qSDt0U4JEeAnrK1bft4IXmYH5hDvjZsMoVrgeAkireTtieUFwaw+wsl9HLZFko9Oh+ Wb03APCqdoLJUKWBNRVK1Qw3MpzGqGlczltKkW7h+2fxxfSQKt4MUokqdJNQRTr6jCMqnTBlil68uS MYpvKrlPaUOAbEdwkhAXw0UOQzE+pnceG6br7c12Zd64hOtiF7HUtEFZPGUQo4Ke3uSmt+O72s6Yd2 h8L+3bG/uAnXamVLN3AmMh/Gs+jZuxRGTnjCvfGbaeu5C1lbwbDW6o2RiAwladj1lJpfYmgjZuixva rVBAik5Ba+4SwpZ7NQ73ABYgDF8ynLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:cc:to:from:subject:message-id:dkim-signature:from; bh=n6lH6/FamoF/uluarbPO/lm5V540v40hxw54ayupNUM=; b=jmMflR5nZUap+HRdV+6VJRz/dwWqmiuS3l0co4CRVZCoeZWzoabU4TQ29Lp9jJFSsarMSwGBp/TCN 5SVTixVWnO7iEG+/5dPyzOk3GnE+gaQOX17bGSSsbbCsE6ttnU8lkxlC48TzuAr+AE8k4fYXuMnRVA 9uQ6G1NVeIoRO1gJFzElNr/ocQy4RMzBqszTmECu1FIx80A8Zxtf1Yh0EiaSz+7wzJqNSrm5hR0Kwe I8qb5fDVlALgttrCZgoRLgWTu67FkOtWGBW9bnRqItUlEtZvVkzzYJIUGMAuDEe85WV7qn+qRqj/s+ taYTHhWXckGvR+GYUVyKSfKjra6QF7Q== ARC-Authentication-Results: i=1; outbound3.eu.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:cc:to:from:subject:message-id:from; bh=n6lH6/FamoF/uluarbPO/lm5V540v40hxw54ayupNUM=; b=WCF1SSo+O+chjbPc/SyMHXojJL7av1FSXKBFlpqmmeHuWNrT13XAKx7FFEzQAipzw3eeM06feKdXQ id3PZCVueusn9c4eFoN9aW1/vQMM0lvGjoiAF5GKpKveDv7GwhjpJtlDEX/03czNN9c8f5t8/VMMib o5y90pt7wXo9ZsGmFF6n718Y4r99oUiqu/AVbZ3N64DpY3KYhEImgbfnrAWdVz42kIZL72rPz4Jee/ L9AYq0jfGPgmhnlamL9SdiYyJkDD84VhGCdoRvzLL9sH+U5iGp+FHH/JsGAHBEcScU+7fqkTeh3wsW /VNWiAB0HuM/NsxoFEPljtEpCFnj9Jg== X-MHO-RoutePath: aGlwcGll X-MHO-User: 2fde6095-4355-11e9-908b-352056dbf2de X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound3.eu.mailhop.org (Halon) with ESMTPSA id 2fde6095-4355-11e9-908b-352056dbf2de; Sun, 10 Mar 2019 16:54:38 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id x2AGsauC040553; Sun, 10 Mar 2019 10:54:36 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: Subject: Re: svn commit: r344974 - stable/12/sys/netpfil/pf From: Ian Lepore To: Kristof Provost , Harry Schmalzbauer Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Date: Sun, 10 Mar 2019 10:54:36 -0600 In-Reply-To: <8C805FB7-AE8B-4FF9-82E6-EA406C3B07BE@FreeBSD.org> References: <201903100056.x2A0ucCT013392@repo.freebsd.org> <7bdf4d3c-61b3-4319-d5b7-5234991fad78@omnilan.de> <8C805FB7-AE8B-4FF9-82E6-EA406C3B07BE@FreeBSD.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 39F17849BA X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.975,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Mar 2019 16:54:51 -0000 On Sun, 2019-03-10 at 10:34 +0100, Kristof Provost wrote: > On 10 Mar 2019, at 10:16, Harry Schmalzbauer wrote: > > Am 10.03.2019 um 01:56 schrieb Kristof Provost: > > > Author: kp > > > Date: Sun Mar 10 00:56:38 2019 > > > New Revision: 344974 > > > URL: https://svnweb.freebsd.org/changeset/base/344974 > > > > > > Log: > > > pf: Small performance tweak > > > > Seems to be the MFC of 344493. > > > > Indeed, apologies for missing out the MFC tag here. That’ll teach me > to sleep before I commit, rather than after. > > > Out of curiosity, do you have to manually write these log messages > > each time? > > > > Yes. I should see about scripting these MFCs someday, to avoid silly > mistakes like this. > Or looking into using gonzo's mfc helper website at https://mfc.kernelnomicon.org/6/ It will let you select one or more of your (or somebody else's) prior commits and it'll generate the commands to do the mfc, and the text you can paste into the commit message. -- Ian From owner-svn-src-stable-12@freebsd.org Mon Mar 11 01:45:27 2019 Return-Path: Delivered-To: svn-src-stable-12@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 7A9591527A1C; Mon, 11 Mar 2019 01:45:27 +0000 (UTC) (envelope-from mav@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 1C91172093; Mon, 11 Mar 2019 01:45:27 +0000 (UTC) (envelope-from mav@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 083A53D8C; Mon, 11 Mar 2019 01:45:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2B1jQVl001851; Mon, 11 Mar 2019 01:45:26 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2B1jQux001850; Mon, 11 Mar 2019 01:45:26 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903110145.x2B1jQux001850@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 11 Mar 2019 01:45:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344993 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 344993 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1C91172093 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 01:45:27 -0000 Author: mav Date: Mon Mar 11 01:45:26 2019 New Revision: 344993 URL: https://svnweb.freebsd.org/changeset/base/344993 Log: MFC r344782: bridge: Fix spurious warnings about capabilities Mask off the bits we don't care about when checking that capabilities of the member interfaces have been disabled as intended. Modified: stable/12/sys/net/if_bridge.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/if_bridge.c ============================================================================== --- stable/12/sys/net/if_bridge.c Mon Mar 11 01:44:37 2019 (r344992) +++ stable/12/sys/net/if_bridge.c Mon Mar 11 01:45:26 2019 (r344993) @@ -925,7 +925,7 @@ bridge_set_ifcap(struct bridge_softc *sc, struct bridg { struct ifnet *ifp = bif->bif_ifp; struct ifreq ifr; - int error; + int error, mask, stuck; BRIDGE_UNLOCK_ASSERT(sc); @@ -938,10 +938,12 @@ bridge_set_ifcap(struct bridge_softc *sc, struct bridg if_printf(sc->sc_ifp, "error setting capabilities on %s: %d\n", ifp->if_xname, error); - if ((ifp->if_capenable & ~set) != 0) + mask = BRIDGE_IFCAPS_MASK | BRIDGE_IFCAPS_STRIP; + stuck = ifp->if_capenable & mask & ~set; + if (stuck != 0) if_printf(sc->sc_ifp, "can't disable some capabilities on %s: 0x%x\n", - ifp->if_xname, ifp->if_capenable & ~set); + ifp->if_xname, stuck); } } From owner-svn-src-stable-12@freebsd.org Mon Mar 11 01:44:19 2019 Return-Path: Delivered-To: svn-src-stable-12@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 7332915279F6; Mon, 11 Mar 2019 01:44:19 +0000 (UTC) (envelope-from mav@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 162C971ECA; Mon, 11 Mar 2019 01:44:19 +0000 (UTC) (envelope-from mav@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 033F53D8A; Mon, 11 Mar 2019 01:44:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2B1iI1L001680; Mon, 11 Mar 2019 01:44:18 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2B1iIM1001678; Mon, 11 Mar 2019 01:44:18 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903110144.x2B1iIM1001678@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 11 Mar 2019 01:44:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344991 - stable/12/sys/cam/ctl X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cam/ctl X-SVN-Commit-Revision: 344991 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 162C971ECA X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.96)[-0.964,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 01:44:19 -0000 Author: mav Date: Mon Mar 11 01:44:18 2019 New Revision: 344991 URL: https://svnweb.freebsd.org/changeset/base/344991 Log: MFC r344489: Free some space in struct ctl_io_hdr for better use. - Collapse original_sc and serializing_sc fields into one, since they are never used simultanously, we have only one local I/O and one remote. - Move remote_sglist and local_sglist fields into CTL_PRIV_BACKEND, since they are used only on Originating SC in XFER mode, where requests don't ever reach backends, so we can reuse backend's private storage. Modified: stable/12/sys/cam/ctl/ctl.c stable/12/sys/cam/ctl/ctl_io.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/ctl/ctl.c ============================================================================== --- stable/12/sys/cam/ctl/ctl.c Mon Mar 11 01:27:01 2019 (r344990) +++ stable/12/sys/cam/ctl/ctl.c Mon Mar 11 01:44:18 2019 (r344991) @@ -651,7 +651,7 @@ ctl_ha_datamove(union ctl_io *io) memset(&msg.dt, 0, sizeof(msg.dt)); msg.hdr.msg_type = CTL_MSG_DATAMOVE; - msg.hdr.original_sc = io->io_hdr.original_sc; + msg.hdr.original_sc = io->io_hdr.remote_io; msg.hdr.serializing_sc = io; msg.hdr.nexus = io->io_hdr.nexus; msg.hdr.status = io->io_hdr.status; @@ -766,7 +766,7 @@ ctl_ha_done(union ctl_io *io) if (io->io_hdr.io_type == CTL_IO_SCSI) { memset(&msg, 0, sizeof(msg)); msg.hdr.msg_type = CTL_MSG_FINISH_IO; - msg.hdr.original_sc = io->io_hdr.original_sc; + msg.hdr.original_sc = io->io_hdr.remote_io; msg.hdr.nexus = io->io_hdr.nexus; msg.hdr.status = io->io_hdr.status; msg.scsi.scsi_status = io->scsiio.scsi_status; @@ -1439,7 +1439,7 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e // populate ctsio from msg io->io_hdr.io_type = CTL_IO_SCSI; io->io_hdr.msg_type = CTL_MSG_SERIALIZE; - io->io_hdr.original_sc = msg->hdr.original_sc; + io->io_hdr.remote_io = msg->hdr.original_sc; io->io_hdr.flags |= CTL_FLAG_FROM_OTHER_SC | CTL_FLAG_IO_ACTIVE; /* @@ -1495,7 +1495,7 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e * Keep track of this, we need to send it back over * when the datamove is complete. */ - io->io_hdr.serializing_sc = msg->hdr.serializing_sc; + io->io_hdr.remote_io = msg->hdr.serializing_sc; if (msg->hdr.status == CTL_SUCCESS) io->io_hdr.status = msg->hdr.status; @@ -1508,9 +1508,8 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e CTL_HA_DATAMOVE_SEGMENT + 1; sgl = malloc(sizeof(*sgl) * i, M_CTL, M_WAITOK | M_ZERO); - io->io_hdr.remote_sglist = sgl; - io->io_hdr.local_sglist = - &sgl[msg->dt.kern_sg_entries]; + CTL_RSGL(io) = sgl; + CTL_LSGL(io) = &sgl[msg->dt.kern_sg_entries]; io->scsiio.kern_data_ptr = (uint8_t *)sgl; @@ -1597,7 +1596,7 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e } io->io_hdr.flags |= CTL_FLAG_IO_ACTIVE; io->io_hdr.msg_type = CTL_MSG_R2R; - io->io_hdr.serializing_sc = msg->hdr.serializing_sc; + io->io_hdr.remote_io = msg->hdr.serializing_sc; ctl_enqueue_isc(io); break; @@ -2369,7 +2368,7 @@ ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio) mtx_unlock(&lun->lun_lock); /* send msg back to other side */ - msg_info.hdr.original_sc = ctsio->io_hdr.original_sc; + msg_info.hdr.original_sc = ctsio->io_hdr.remote_io; msg_info.hdr.serializing_sc = (union ctl_io *)ctsio; msg_info.hdr.msg_type = CTL_MSG_R2R; ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, @@ -2395,7 +2394,7 @@ ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio) /*retry_count*/ 0); badjuju: ctl_copy_sense_data_back((union ctl_io *)ctsio, &msg_info); - msg_info.hdr.original_sc = ctsio->io_hdr.original_sc; + msg_info.hdr.original_sc = ctsio->io_hdr.remote_io; msg_info.hdr.serializing_sc = NULL; msg_info.hdr.msg_type = CTL_MSG_BAD_JUJU; ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, @@ -11043,7 +11042,7 @@ ctl_check_blocked(struct ctl_lun *lun) cur_blocked->io_hdr.flags &= ~CTL_FLAG_IO_ACTIVE; msg_info.hdr.original_sc = - cur_blocked->io_hdr.original_sc; + cur_blocked->io_hdr.remote_io; msg_info.hdr.serializing_sc = cur_blocked; msg_info.hdr.msg_type = CTL_MSG_R2R; ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, @@ -12480,7 +12479,7 @@ ctl_send_datamove_done(union ctl_io *io, int have_lock memset(&msg, 0, sizeof(msg)); msg.hdr.msg_type = CTL_MSG_DATAMOVE_DONE; msg.hdr.original_sc = io; - msg.hdr.serializing_sc = io->io_hdr.serializing_sc; + msg.hdr.serializing_sc = io->io_hdr.remote_io; msg.hdr.nexus = io->io_hdr.nexus; msg.hdr.status = io->io_hdr.status; msg.scsi.kern_data_resid = io->scsiio.kern_data_resid; @@ -12531,10 +12530,10 @@ ctl_datamove_remote_write_cb(struct ctl_ha_dt_req *rq) ctl_dt_req_free(rq); for (i = 0; i < io->scsiio.kern_sg_entries; i++) - free(io->io_hdr.local_sglist[i].addr, M_CTL); - free(io->io_hdr.remote_sglist, M_CTL); - io->io_hdr.remote_sglist = NULL; - io->io_hdr.local_sglist = NULL; + free(CTL_LSGLT(io)[i].addr, M_CTL); + free(CTL_RSGL(io), M_CTL); + CTL_RSGL(io) = NULL; + CTL_LSGL(io) = NULL; /* * The data is in local and remote memory, so now we need to send @@ -12574,7 +12573,7 @@ ctl_datamove_remote_write(union ctl_io *io) return; /* Switch the pointer over so the FETD knows what to do */ - io->scsiio.kern_data_ptr = (uint8_t *)io->io_hdr.local_sglist; + io->scsiio.kern_data_ptr = (uint8_t *)CTL_LSGL(io); /* * Use a custom move done callback, since we need to send completion @@ -12597,10 +12596,10 @@ ctl_datamove_remote_dm_read_cb(union ctl_io *io) uint32_t i; for (i = 0; i < io->scsiio.kern_sg_entries; i++) - free(io->io_hdr.local_sglist[i].addr, M_CTL); - free(io->io_hdr.remote_sglist, M_CTL); - io->io_hdr.remote_sglist = NULL; - io->io_hdr.local_sglist = NULL; + free(CTL_LSGLT(io)[i].addr, M_CTL); + free(CTL_RSGL(io), M_CTL); + CTL_RSGL(io) = NULL; + CTL_LSGL(io) = NULL; #if 0 scsi_path_string(io, path_str, sizeof(path_str)); @@ -12647,7 +12646,7 @@ ctl_datamove_remote_read_cb(struct ctl_ha_dt_req *rq) ctl_dt_req_free(rq); /* Switch the pointer over so the FETD knows what to do */ - io->scsiio.kern_data_ptr = (uint8_t *)io->io_hdr.local_sglist; + io->scsiio.kern_data_ptr = (uint8_t *)CTL_LSGL(io); /* * Use a custom move done callback, since we need to send completion @@ -12670,7 +12669,7 @@ ctl_datamove_remote_sgl_setup(union ctl_io *io) int i; retval = 0; - local_sglist = io->io_hdr.local_sglist; + local_sglist = CTL_LSGL(io); len_to_go = io->scsiio.kern_data_len; /* @@ -12741,8 +12740,8 @@ ctl_datamove_remote_xfer(union ctl_io *io, unsigned co return (1); } - local_sglist = io->io_hdr.local_sglist; - remote_sglist = io->io_hdr.remote_sglist; + local_sglist = CTL_LSGL(io); + remote_sglist = CTL_RSGL(io); local_used = 0; remote_used = 0; total_used = 0; @@ -12855,10 +12854,10 @@ ctl_datamove_remote_read(union ctl_io *io) * error if there is a problem. */ for (i = 0; i < io->scsiio.kern_sg_entries; i++) - free(io->io_hdr.local_sglist[i].addr, M_CTL); - free(io->io_hdr.remote_sglist, M_CTL); - io->io_hdr.remote_sglist = NULL; - io->io_hdr.local_sglist = NULL; + free(CTL_LSGLT(io)[i].addr, M_CTL); + free(CTL_RSGL(io), M_CTL); + CTL_RSGL(io) = NULL; + CTL_LSGL(io) = NULL; } } @@ -13106,7 +13105,7 @@ bailout: (io->io_hdr.flags & CTL_FLAG_SENT_2OTHER_SC)) { memset(&msg, 0, sizeof(msg)); msg.hdr.msg_type = CTL_MSG_FINISH_IO; - msg.hdr.serializing_sc = io->io_hdr.serializing_sc; + msg.hdr.serializing_sc = io->io_hdr.remote_io; msg.hdr.nexus = io->io_hdr.nexus; ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg, sizeof(msg.scsi) - sizeof(msg.scsi.sense_data), Modified: stable/12/sys/cam/ctl/ctl_io.h ============================================================================== --- stable/12/sys/cam/ctl/ctl_io.h Mon Mar 11 01:27:01 2019 (r344990) +++ stable/12/sys/cam/ctl/ctl_io.h Mon Mar 11 01:44:18 2019 (r344991) @@ -167,6 +167,15 @@ union ctl_priv { #define CTL_PORT(io) (((struct ctl_softc *)CTL_SOFTC(io))-> \ ctl_ports[(io)->io_hdr.nexus.targ_port]) +/* + * These are used only on Originating SC in XFER mode, where requests don't + * ever reach backends, so we can reuse backend's private storage. + */ +#define CTL_RSGL(io) ((io)->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptrs[0]) +#define CTL_LSGL(io) ((io)->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptrs[1]) +#define CTL_RSGLT(io) ((struct ctl_sg_entry *)CTL_RSGL(io)) +#define CTL_LSGLT(io) ((struct ctl_sg_entry *)CTL_LSGL(io)) + #define CTL_INVALID_PORTNAME 0xFF #define CTL_UNMAPPED_IID 0xFF @@ -229,12 +238,12 @@ struct ctl_io_hdr { struct bintime dma_bt; /* DMA total ticks */ #endif /* CTL_TIME_IO */ uint32_t num_dmas; /* Number of DMAs */ - union ctl_io *original_sc; - union ctl_io *serializing_sc; + union ctl_io *remote_io; /* I/O counterpart on remote HA side */ + void *pad1; void *pool; /* I/O pool */ union ctl_priv ctl_private[CTL_NUM_PRIV];/* CTL private area */ - struct ctl_sg_entry *remote_sglist; - struct ctl_sg_entry *local_sglist; + void *pad2; + void *pad3; STAILQ_ENTRY(ctl_io_hdr) links; /* linked list pointer */ TAILQ_ENTRY(ctl_io_hdr) ooa_links; TAILQ_ENTRY(ctl_io_hdr) blocked_links; From owner-svn-src-stable-12@freebsd.org Mon Mar 11 00:52:56 2019 Return-Path: Delivered-To: svn-src-stable-12@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 A2CE01525779; Mon, 11 Mar 2019 00:52:56 +0000 (UTC) (envelope-from markj@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 452C26FB98; Mon, 11 Mar 2019 00:52:56 +0000 (UTC) (envelope-from markj@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 3AD9F32A6; Mon, 11 Mar 2019 00:52:56 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2B0qutB074349; Mon, 11 Mar 2019 00:52:56 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2B0qtaf074348; Mon, 11 Mar 2019 00:52:55 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201903110052.x2B0qtaf074348@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 11 Mar 2019 00:52:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344988 - in stable/12/sys: kern vm X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/12/sys: kern vm X-SVN-Commit-Revision: 344988 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 452C26FB98 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.92 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_SHORT(-0.93)[-0.929,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 00:52:56 -0000 Author: markj Date: Mon Mar 11 00:52:55 2019 New Revision: 344988 URL: https://svnweb.freebsd.org/changeset/base/344988 Log: MFC r344550: Improve vmem tuning for platforms without a direct map. Modified: stable/12/sys/kern/subr_vmem.c stable/12/sys/vm/vm_kern.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/subr_vmem.c ============================================================================== --- stable/12/sys/kern/subr_vmem.c Sun Mar 10 23:05:38 2019 (r344987) +++ stable/12/sys/kern/subr_vmem.c Mon Mar 11 00:52:55 2019 (r344988) @@ -689,9 +689,11 @@ vmem_startup(void) /* * Reserve enough tags to allocate new tags. We allow multiple * CPUs to attempt to allocate new tags concurrently to limit - * false restarts in UMA. + * false restarts in UMA. vmem_bt_alloc() allocates from a per-domain + * arena, which may involve importing a range from the kernel arena, + * so we need to keep at least 2 * BT_MAXALLOC tags reserved. */ - uma_zone_reserve(vmem_bt_zone, BT_MAXALLOC * (mp_ncpus + 1) / 2); + uma_zone_reserve(vmem_bt_zone, 2 * BT_MAXALLOC * mp_ncpus); uma_zone_set_allocf(vmem_bt_zone, vmem_bt_alloc); #endif } Modified: stable/12/sys/vm/vm_kern.c ============================================================================== --- stable/12/sys/vm/vm_kern.c Sun Mar 10 23:05:38 2019 (r344987) +++ stable/12/sys/vm/vm_kern.c Mon Mar 11 00:52:55 2019 (r344988) @@ -124,8 +124,8 @@ SYSCTL_ULONG(_vm, OID_AUTO, max_kernel_address, CTLFLA #if VM_NRESERVLEVEL > 0 #define KVA_QUANTUM_SHIFT (VM_LEVEL_0_ORDER + PAGE_SHIFT) #else -/* On non-superpage architectures want large import sizes. */ -#define KVA_QUANTUM_SHIFT (10 + PAGE_SHIFT) +/* On non-superpage architectures we want large import sizes. */ +#define KVA_QUANTUM_SHIFT (8 + PAGE_SHIFT) #endif #define KVA_QUANTUM (1 << KVA_QUANTUM_SHIFT) From owner-svn-src-stable-12@freebsd.org Mon Mar 11 02:42:50 2019 Return-Path: Delivered-To: svn-src-stable-12@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 9BBD31529801; Mon, 11 Mar 2019 02:42:50 +0000 (UTC) (envelope-from sef@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 4202D7480B; Mon, 11 Mar 2019 02:42:50 +0000 (UTC) (envelope-from sef@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 346A047E8; Mon, 11 Mar 2019 02:42:50 +0000 (UTC) (envelope-from sef@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2B2goSi032897; Mon, 11 Mar 2019 02:42:50 GMT (envelope-from sef@FreeBSD.org) Received: (from sef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2B2gnNE032896; Mon, 11 Mar 2019 02:42:49 GMT (envelope-from sef@FreeBSD.org) Message-Id: <201903110242.x2B2gnNE032896@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sef set sender to sef@FreeBSD.org using -f From: Sean Eric Fagan Date: Mon, 11 Mar 2019 02:42:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344995 - in stable/12: sys/kgssapi usr.sbin/gssd X-SVN-Group: stable-12 X-SVN-Commit-Author: sef X-SVN-Commit-Paths: in stable/12: sys/kgssapi usr.sbin/gssd X-SVN-Commit-Revision: 344995 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4202D7480B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.93 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.936,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 02:42:50 -0000 Author: sef Date: Mon Mar 11 02:42:49 2019 New Revision: 344995 URL: https://svnweb.freebsd.org/changeset/base/344995 Log: MFC r344402 * Handle SIGPIPE in gssd We've got some cases where the other end of gssd's AF_LOCAL socket gets closed, resulting in an error (and SIGPIPE) when it tries to do I/O to it. Closing without cleaning up means the next time nfsd starts up, it hangs, unkillably; this allows gssd to handle that particular error. * Limit the retry cound in gssd_syscall to 5. The default is INT_MAX, which effectively means forever. And it's an uninterruptable RPC call, so it will never stop. The two changes mitigate the problem. Modified: stable/12/sys/kgssapi/gss_impl.c stable/12/usr.sbin/gssd/gssd.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kgssapi/gss_impl.c ============================================================================== --- stable/12/sys/kgssapi/gss_impl.c Mon Mar 11 02:02:04 2019 (r344994) +++ stable/12/sys/kgssapi/gss_impl.c Mon Mar 11 02:42:49 2019 (r344995) @@ -112,6 +112,15 @@ sys_gssd_syscall(struct thread *td, struct gssd_syscal cl = clnt_reconnect_create(nconf, (struct sockaddr *) &sun, GSSD, GSSDVERS, RPC_MAXDATASIZE, RPC_MAXDATASIZE); + /* + * The number of retries defaults to INT_MAX, which effectively + * means an infinite, uninterruptable loop. Limiting it to + * five retries keeps it from running forever. + */ + if (cl != NULL) { + int retry_count = 5; + CLNT_CONTROL(cl, CLSET_RETRIES, &retry_count); + } } else cl = NULL; Modified: stable/12/usr.sbin/gssd/gssd.c ============================================================================== --- stable/12/usr.sbin/gssd/gssd.c Mon Mar 11 02:02:04 2019 (r344994) +++ stable/12/usr.sbin/gssd/gssd.c Mon Mar 11 02:42:49 2019 (r344995) @@ -202,6 +202,7 @@ main(int argc, char **argv) signal(SIGHUP, SIG_IGN); } signal(SIGTERM, gssd_terminate); + signal(SIGPIPE, gssd_terminate); memset(&sun, 0, sizeof sun); sun.sun_family = AF_LOCAL; From owner-svn-src-stable-12@freebsd.org Mon Mar 11 03:00:34 2019 Return-Path: Delivered-To: svn-src-stable-12@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 69A06152A35B; Mon, 11 Mar 2019 03:00:34 +0000 (UTC) (envelope-from sef@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 08C5975173; Mon, 11 Mar 2019 03:00:34 +0000 (UTC) (envelope-from sef@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 F24DA4999; Mon, 11 Mar 2019 03:00:33 +0000 (UTC) (envelope-from sef@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2B30XNt038462; Mon, 11 Mar 2019 03:00:33 GMT (envelope-from sef@FreeBSD.org) Received: (from sef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2B30XnL038461; Mon, 11 Mar 2019 03:00:33 GMT (envelope-from sef@FreeBSD.org) Message-Id: <201903110300.x2B30XnL038461@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sef set sender to sef@FreeBSD.org using -f From: Sean Eric Fagan Date: Mon, 11 Mar 2019 03:00:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344997 - stable/12/lib/libutil X-SVN-Group: stable-12 X-SVN-Commit-Author: sef X-SVN-Commit-Paths: stable/12/lib/libutil X-SVN-Commit-Revision: 344997 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 08C5975173 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.93 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_SHORT(-0.94)[-0.936,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 03:00:34 -0000 Author: sef Date: Mon Mar 11 03:00:33 2019 New Revision: 344997 URL: https://svnweb.freebsd.org/changeset/base/344997 Log: MFC r343881 r339008 broke repquota for UFS. This rectifies that. Refactor the function calls and tests so that, on UFS, the proper fields are filled out. PR: 233849 Modified: stable/12/lib/libutil/quotafile.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libutil/quotafile.c ============================================================================== --- stable/12/lib/libutil/quotafile.c Mon Mar 11 02:57:00 2019 (r344996) +++ stable/12/lib/libutil/quotafile.c Mon Mar 11 03:00:33 2019 (r344997) @@ -119,6 +119,7 @@ quota_open(struct fstab *fs, int quotatype, int openfl struct group *grp; struct stat st; int qcmd, serrno; + int ufs; if ((qf = calloc(1, sizeof(*qf))) == NULL) return (NULL); @@ -129,15 +130,21 @@ quota_open(struct fstab *fs, int quotatype, int openfl goto error; qf->dev = st.st_dev; qcmd = QCMD(Q_GETQUOTASIZE, quotatype); + ufs = strcmp(fs->fs_vfstype, "ufs") == 0; + /* + * On UFS, hasquota() fills in qf->qfname. But we only care about + * this for UFS. So we need to call hasquota() for UFS, first. + */ + if (ufs) { + serrno = hasquota(fs, quotatype, qf->qfname, + sizeof(qf->qfname)); + } if (quotactl(qf->fsname, qcmd, 0, &qf->wordsize) == 0) return (qf); - /* We only check the quota file for ufs */ - if (strcmp(fs->fs_vfstype, "ufs")) { + if (!ufs) { errno = 0; goto error; - } - serrno = hasquota(fs, quotatype, qf->qfname, sizeof(qf->qfname)); - if (serrno == 0) { + } else if (serrno == 0) { errno = EOPNOTSUPP; goto error; } From owner-svn-src-stable-12@freebsd.org Mon Mar 11 03:02:02 2019 Return-Path: Delivered-To: svn-src-stable-12@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 C4777152A543; Mon, 11 Mar 2019 03:02:02 +0000 (UTC) (envelope-from sef@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 5DBED75685; Mon, 11 Mar 2019 03:02:02 +0000 (UTC) (envelope-from sef@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 ABCE44B42; Mon, 11 Mar 2019 03:01:58 +0000 (UTC) (envelope-from sef@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2B31wVZ041415; Mon, 11 Mar 2019 03:01:58 GMT (envelope-from sef@FreeBSD.org) Received: (from sef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2B31waS041414; Mon, 11 Mar 2019 03:01:58 GMT (envelope-from sef@FreeBSD.org) Message-Id: <201903110301.x2B31waS041414@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sef set sender to sef@FreeBSD.org using -f From: Sean Eric Fagan Date: Mon, 11 Mar 2019 03:01:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r344998 - stable/12/lib/libutil X-SVN-Group: stable-12 X-SVN-Commit-Author: sef X-SVN-Commit-Paths: stable/12/lib/libutil X-SVN-Commit-Revision: 344998 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5DBED75685 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.93 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_SHORT(-0.94)[-0.936,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 03:02:02 -0000 Author: sef Date: Mon Mar 11 03:01:58 2019 New Revision: 344998 URL: https://svnweb.freebsd.org/changeset/base/344998 Log: MFC r343882 r343881 had an uninitialized error. This fixes that. PR: 233849 Modified: stable/12/lib/libutil/quotafile.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libutil/quotafile.c ============================================================================== --- stable/12/lib/libutil/quotafile.c Mon Mar 11 03:00:33 2019 (r344997) +++ stable/12/lib/libutil/quotafile.c Mon Mar 11 03:01:58 2019 (r344998) @@ -118,7 +118,7 @@ quota_open(struct fstab *fs, int quotatype, int openfl struct dqhdr64 dqh; struct group *grp; struct stat st; - int qcmd, serrno; + int qcmd, serrno = 0; int ufs; if ((qf = calloc(1, sizeof(*qf))) == NULL) From owner-svn-src-stable-12@freebsd.org Mon Mar 11 07:18:41 2019 Return-Path: Delivered-To: svn-src-stable-12@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 DC61A1534581; Mon, 11 Mar 2019 07:18:40 +0000 (UTC) (envelope-from ygy@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 8103786E70; Mon, 11 Mar 2019 07:18:40 +0000 (UTC) (envelope-from ygy@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 756877623; Mon, 11 Mar 2019 07:18:40 +0000 (UTC) (envelope-from ygy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2B7Ievv073392; Mon, 11 Mar 2019 07:18:40 GMT (envelope-from ygy@FreeBSD.org) Received: (from ygy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2B7Ieun073391; Mon, 11 Mar 2019 07:18:40 GMT (envelope-from ygy@FreeBSD.org) Message-Id: <201903110718.x2B7Ieun073391@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ygy set sender to ygy@FreeBSD.org using -f From: Guangyuan Yang Date: Mon, 11 Mar 2019 07:18:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345001 - stable/12/sbin/ipfw X-SVN-Group: stable-12 X-SVN-Commit-Author: ygy X-SVN-Commit-Paths: stable/12/sbin/ipfw X-SVN-Commit-Revision: 345001 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8103786E70 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.994,0]; NEURAL_HAM_SHORT(-0.96)[-0.958,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 07:18:41 -0000 Author: ygy (doc committer) Date: Mon Mar 11 07:18:40 2019 New Revision: 345001 URL: https://svnweb.freebsd.org/changeset/base/345001 Log: MFC r344709: Fix typos and caps for ipfw(8) man page. PR: 236030 Submitted by: olgeni Modified: stable/12/sbin/ipfw/ipfw.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/ipfw/ipfw.8 ============================================================================== --- stable/12/sbin/ipfw/ipfw.8 Mon Mar 11 03:07:05 2019 (r345000) +++ stable/12/sbin/ipfw/ipfw.8 Mon Mar 11 07:18:40 2019 (r345001) @@ -1,7 +1,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 4, 2018 +.Dd March 1, 2019 .Dt IPFW 8 .Os .Sh NAME @@ -1329,11 +1329,11 @@ its use is discouraged. .Brc .Bl -tag -width indent .It Cm any -matches any IP address. +Matches any IP address. .It Cm me -matches any IP address configured on an interface in the system. +Matches any IP address configured on an interface in the system. .It Cm me6 -matches any IPv6 address configured on an interface in the system. +Matches any IPv6 address configured on an interface in the system. The address list is evaluated at the time the packet is analysed. .It Cm table Ns Pq Ar name Ns Op , Ns Ar value @@ -2083,7 +2083,7 @@ The following table types are supported: .It Ar flow-spec : Ar flow-field Ns Op , Ns Ar flow-spec .It Ar flow-field : src-ip | proto | src-port | dst-ip | dst-port .It Cm addr -matches IPv4 or IPv6 address. +Matches IPv4 or IPv6 address. Each entry is represented by an .Ar addr Ns Op / Ns Ar masklen and will match all addresses with base @@ -2097,11 +2097,11 @@ is not specified, it defaults to 32 for IPv4 and 128 f When looking up an IP address in a table, the most specific entry will match. .It Cm iface -matches interface names. +Matches interface names. Each entry is represented by string treated as interface name. Wildcards are not supported. .It Cm number -maches protocol ports, uids/gids or jail IDs. +Matches protocol ports, uids/gids or jail IDs. Each entry is represented by 32-bit unsigned integer. Ranges are not supported. .It Cm flow @@ -2792,7 +2792,7 @@ specifies the quantum (credit) of the scheduler. .Ar m is the number of bytes a queue can serve before being moved to the tail of old queues list. -The default is 1514 bytes, and the maximum accepable value +The default is 1514 bytes, and the maximum acceptable value is 9000 bytes. .It Cm limit .Ar m @@ -2800,14 +2800,14 @@ specifies the hard size limit (in unit of packets) of instance of the scheduler. The default value of .Ar m -is 10240 packets, and the maximum accepable value is 20480 packets. +is 10240 packets, and the maximum acceptable value is 20480 packets. .It Cm flows .Ar m specifies the total number of flow queues (sub-queues) that fq_* creates and manages. By default, 1024 sub-queues are created when an instance of the fq_{codel/pie} scheduler is created. -The maximum accepable value is +The maximum acceptable value is 65536. .El .Pp @@ -2906,7 +2906,7 @@ is the typical queue size for Ethernet devices. Note that for slow speed links you should keep the queue size short or your traffic might be affected by a significant queueing delay. -E.g., 50 max-sized ethernet packets (1500 bytes) mean 600Kbit +E.g., 50 max-sized Ethernet packets (1500 bytes) mean 600Kbit or 20s of queue on a 30Kbit/s pipe. Even worse effects can result if you get packets from an interface with a much larger MTU, e.g.\& the loopback interface @@ -3053,7 +3053,7 @@ De-randomisation is enabled by default. .It Cm onoff enable turning PIE on and off depending on queue load. If this option is enabled, -PIE turnes on when over 1/3 of queue becomes full. +PIE turns on when over 1/3 of queue becomes full. This option is disabled by default. .It Cm dre | ts @@ -4089,7 +4089,7 @@ by adding the following to the appropriate place in ru If your network has network traffic analyzer connected to your host directly via dedicated interface or remotely via RSPAN vlan, you can selectively mirror -some ethernet layer2 frames to the analyzer. +some Ethernet layer2 frames to the analyzer. .Pp First, make sure your firewall is already configured and runs. Then, enable layer2 processing if not already enabled: @@ -4434,7 +4434,7 @@ or it could be split in: .Dl "ipfw nat 5 config redirect_port tcp" .Dl " 192.168.0.1:80,192.168.0.10:22,192.168.0.20:25 500" .Pp -Sometimes you may want to mix NAT and dynamic rules. It could be achived with +Sometimes you may want to mix NAT and dynamic rules. It could be achieved with .Cm record-state and .Cm defer-action @@ -4447,8 +4447,8 @@ rule will be performed as soon as rule is matched. In .Cm allow rule packet need to be passed to NAT, not allowed as soon is possible. .Pp -There is example of set of rules to achive this. Bear in mind that this -is exmaple only and it is not very usefult by itself. +There is example of set of rules to achieve this. Bear in mind that this +is exmaple only and it is not very useful by itself. .Pp On way out, after all checks place this rules: .Pp From owner-svn-src-stable-12@freebsd.org Mon Mar 11 13:55:49 2019 Return-Path: Delivered-To: svn-src-stable-12@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 D809D1543E7C; Mon, 11 Mar 2019 13:55:48 +0000 (UTC) (envelope-from mav@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 7E5B99700A; Mon, 11 Mar 2019 13:55:48 +0000 (UTC) (envelope-from mav@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 6FB95BA7A; Mon, 11 Mar 2019 13:55:48 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2BDtmWK088018; Mon, 11 Mar 2019 13:55:48 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2BDtl7x088015; Mon, 11 Mar 2019 13:55:47 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903111355.x2BDtl7x088015@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 11 Mar 2019 13:55:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345006 - stable/12/sys/cam/ctl X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cam/ctl X-SVN-Commit-Revision: 345006 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7E5B99700A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.995,0]; NEURAL_HAM_SHORT(-0.96)[-0.958,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 13:55:49 -0000 Author: mav Date: Mon Mar 11 13:55:47 2019 New Revision: 345006 URL: https://svnweb.freebsd.org/changeset/base/345006 Log: MFC r344743: Reduce CTL threads priority to about PUSER. Since in most configurations CTL serves as network service, we found that this change improves local system interactivity under heavy load. Priority of main threads is set slightly higher then worker taskqueues to make them quickly sort incoming requests not creating bottlenecks, while plenty of worker taskqueues should be less sensitive to latency. Modified: stable/12/sys/cam/ctl/ctl.c stable/12/sys/cam/ctl/ctl_backend_block.c stable/12/sys/cam/ctl/ctl_backend_ramdisk.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/ctl/ctl.c ============================================================================== --- stable/12/sys/cam/ctl/ctl.c Mon Mar 11 13:33:03 2019 (r345005) +++ stable/12/sys/cam/ctl/ctl.c Mon Mar 11 13:55:47 2019 (r345006) @@ -66,6 +66,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include @@ -13296,6 +13298,9 @@ ctl_work_thread(void *arg) int retval; CTL_DEBUG_PRINT(("ctl_work_thread starting\n")); + thread_lock(curthread); + sched_prio(curthread, PUSER - 1); + thread_unlock(curthread); while (!softc->shutdown) { /* @@ -13345,7 +13350,7 @@ ctl_work_thread(void *arg) } /* Sleep until we have something to do. */ - mtx_sleep(thr, &thr->queue_lock, PDROP | PRIBIO, "-", 0); + mtx_sleep(thr, &thr->queue_lock, PDROP, "-", 0); } thr->thread = NULL; kthread_exit(); @@ -13358,6 +13363,9 @@ ctl_lun_thread(void *arg) struct ctl_be_lun *be_lun; CTL_DEBUG_PRINT(("ctl_lun_thread starting\n")); + thread_lock(curthread); + sched_prio(curthread, PUSER - 1); + thread_unlock(curthread); while (!softc->shutdown) { mtx_lock(&softc->ctl_lock); @@ -13371,7 +13379,7 @@ ctl_lun_thread(void *arg) /* Sleep until we have something to do. */ mtx_sleep(&softc->pending_lun_queue, &softc->ctl_lock, - PDROP | PRIBIO, "-", 0); + PDROP, "-", 0); } softc->lun_thread = NULL; kthread_exit(); @@ -13389,6 +13397,9 @@ ctl_thresh_thread(void *arg) int i, e, set; CTL_DEBUG_PRINT(("ctl_thresh_thread starting\n")); + thread_lock(curthread); + sched_prio(curthread, PUSER - 1); + thread_unlock(curthread); while (!softc->shutdown) { mtx_lock(&softc->ctl_lock); @@ -13476,7 +13487,7 @@ ctl_thresh_thread(void *arg) } } mtx_sleep(&softc->thresh_thread, &softc->ctl_lock, - PDROP | PRIBIO, "-", CTL_LBP_PERIOD * hz); + PDROP, "-", CTL_LBP_PERIOD * hz); } softc->thresh_thread = NULL; kthread_exit(); Modified: stable/12/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- stable/12/sys/cam/ctl/ctl_backend_block.c Mon Mar 11 13:33:03 2019 (r345005) +++ stable/12/sys/cam/ctl/ctl_backend_block.c Mon Mar 11 13:55:47 2019 (r345006) @@ -2381,7 +2381,7 @@ ctl_be_block_create(struct ctl_be_block_softc *softc, */ retval = taskqueue_start_threads(&be_lun->io_taskqueue, /*num threads*/num_threads, - /*priority*/PWAIT, + /*priority*/PUSER, /*thread name*/ "%s taskq", be_lun->lunname); Modified: stable/12/sys/cam/ctl/ctl_backend_ramdisk.c ============================================================================== --- stable/12/sys/cam/ctl/ctl_backend_ramdisk.c Mon Mar 11 13:33:03 2019 (r345005) +++ stable/12/sys/cam/ctl/ctl_backend_ramdisk.c Mon Mar 11 13:55:47 2019 (r345006) @@ -1149,7 +1149,7 @@ ctl_backend_ramdisk_create(struct ctl_be_ramdisk_softc retval = taskqueue_start_threads(&be_lun->io_taskqueue, /*num threads*/1, - /*priority*/PWAIT, + /*priority*/PUSER, /*thread name*/ "%s taskq", be_lun->lunname); if (retval != 0) From owner-svn-src-stable-12@freebsd.org Mon Mar 11 18:17:27 2019 Return-Path: Delivered-To: svn-src-stable-12@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 1F55A1528A40; Mon, 11 Mar 2019 18:17:27 +0000 (UTC) (envelope-from ngie@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 BAB847434E; Mon, 11 Mar 2019 18:17:26 +0000 (UTC) (envelope-from ngie@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 90F8CE820; Mon, 11 Mar 2019 18:17:26 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2BIHQS4027244; Mon, 11 Mar 2019 18:17:26 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2BIHQEI027243; Mon, 11 Mar 2019 18:17:26 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201903111817.x2BIHQEI027243@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Mon, 11 Mar 2019 18:17:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345016 - stable/12/usr.bin/getconf X-SVN-Group: stable-12 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/12/usr.bin/getconf X-SVN-Commit-Revision: 345016 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: BAB847434E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.995,0]; NEURAL_HAM_SHORT(-0.95)[-0.952,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 18:17:27 -0000 Author: ngie Date: Mon Mar 11 18:17:26 2019 New Revision: 345016 URL: https://svnweb.freebsd.org/changeset/base/345016 Log: MFC r342952: Add Linux compatibility support for `SC_NPROCESSORS_{CONF,ONLN}` as `_SC_NPROCESSORS_{CONF,ONLN}` The goal of this change is to make it easier to use getconf to query the number of available processors. Sadly it's unclear per POSIX, which form (with a preceding _ or lacking it) is correct. I will bring this up on the Austin Group list so this point is clarified for implementors that might rely on this getconf variable in future POSIX spec versions. This is something I noticed when trying to import GoogleTest to FreeBSD as one of the CI scripts uses this variable on Linux. Approved by: emaste (mentor; implicit: https://reviews.freebsd.org/D19527) Differential Revision: https://reviews.freebsd.org/D19528 Modified: stable/12/usr.bin/getconf/sysconf.gperf Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/getconf/sysconf.gperf ============================================================================== --- stable/12/usr.bin/getconf/sysconf.gperf Mon Mar 11 18:17:12 2019 (r345015) +++ stable/12/usr.bin/getconf/sysconf.gperf Mon Mar 11 18:17:26 2019 (r345016) @@ -63,6 +63,8 @@ SYMLOOP_MAX, _SC_SYMLOOP_MAX TIMER_MAX, _SC_TIMER_MAX TTY_NAME_MAX, _SC_TTY_NAME_MAX TZNAME_MAX, _SC_TZNAME_MAX +_NPROCESSORS_CONF, _SC_NPROCESSORS_CONF +_NPROCESSORS_ONLN, _SC_NPROCESSORS_ONLN _POSIX2_CHAR_TERM, _SC_2_CHAR_TERM _POSIX2_C_BIND, _SC_2_C_BIND _POSIX2_C_DEV, _SC_2_C_DEV From owner-svn-src-stable-12@freebsd.org Tue Mar 12 16:33:50 2019 Return-Path: Delivered-To: svn-src-stable-12@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 65C5D1535B72; Tue, 12 Mar 2019 16:33:50 +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.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 EDF956FAF9; Tue, 12 Mar 2019 16:33:49 +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 D9092255FE; Tue, 12 Mar 2019 16:33:49 +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 x2CGXn7Q043807; Tue, 12 Mar 2019 16:33:49 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2CGXjll043779; Tue, 12 Mar 2019 16:33:45 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201903121633.x2CGXjll043779@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 12 Mar 2019 16:33:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345067 - in stable/12: lib/libc/sys sys/amd64/amd64 sys/arm/arm sys/arm64/arm64 sys/compat/freebsd32 sys/compat/ia32 sys/i386/i386 sys/kern sys/mips/mips sys/powerpc/powerpc sys/riscv/... X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12: lib/libc/sys sys/amd64/amd64 sys/arm/arm sys/arm64/arm64 sys/compat/freebsd32 sys/compat/ia32 sys/i386/i386 sys/kern sys/mips/mips sys/powerpc/powerpc sys/riscv/riscv sys/sparc64/sparc64... X-SVN-Commit-Revision: 345067 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EDF956FAF9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.943,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Mar 2019 16:33:50 -0000 Author: kib Date: Tue Mar 12 16:33:44 2019 New Revision: 345067 URL: https://svnweb.freebsd.org/changeset/base/345067 Log: MFC r343964, r344121, r344128, r344593, r344594: ASLR. Added: stable/12/usr.bin/proccontrol/proccontrol.1 - copied unchanged from r344594, head/usr.bin/proccontrol/proccontrol.1 Modified: stable/12/lib/libc/sys/procctl.2 stable/12/sys/amd64/amd64/elf_machdep.c stable/12/sys/arm/arm/elf_machdep.c stable/12/sys/arm64/arm64/elf_machdep.c stable/12/sys/compat/freebsd32/freebsd32_misc.c stable/12/sys/compat/ia32/ia32_sysvec.c stable/12/sys/i386/i386/elf_machdep.c stable/12/sys/kern/imgact_elf.c stable/12/sys/kern/kern_exec.c stable/12/sys/kern/kern_fork.c stable/12/sys/kern/kern_procctl.c stable/12/sys/mips/mips/elf_machdep.c stable/12/sys/powerpc/powerpc/elf32_machdep.c stable/12/sys/powerpc/powerpc/elf64_machdep.c stable/12/sys/riscv/riscv/elf_machdep.c stable/12/sys/sparc64/sparc64/elf_machdep.c stable/12/sys/sys/imgact.h stable/12/sys/sys/proc.h stable/12/sys/sys/procctl.h stable/12/sys/sys/sysent.h stable/12/sys/vm/vm_map.c stable/12/sys/vm/vm_map.h stable/12/usr.bin/proccontrol/Makefile stable/12/usr.bin/proccontrol/proccontrol.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/sys/procctl.2 ============================================================================== --- stable/12/lib/libc/sys/procctl.2 Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/lib/libc/sys/procctl.2 Tue Mar 12 16:33:44 2019 (r345067) @@ -72,6 +72,46 @@ The control request to perform is specified by the argument. The following commands are supported: .Bl -tag -width PROC_TRAPCAP_STATUS +.It Dv PROC_ASLR_CTL +Controls the Address Space Layout Randomization (ASLR) in the program +images created +by +.Xr execve 2 +in the specified process or its descendants that did not changed +the control nor modified it by other means. +The +.Va arg +parameter must point to the integer variable holding one of the following +values: +.Bl -tag -width PROC_ASLR_FORCE_DISABLE +.It Dv PROC_ASLR_FORCE_ENABLE +Request that ASLR is enabled after execution, even if it is disabled +system-wide. +The image flag and set-uid might prevent ASLR enablement still. +.It Dv PROC_ASLR_FORCE_DISABLE +Request that ASLR is disabled after execution. +Same notes as for +.Dv PROC_ASKR_FORCE_ENABLE +apply. +.It Dv PROC_ASLR_NOFORCE +Use system-wide configured policy for ASLR. +.El +.It Dv PROC_ASLR_STATUS +Returns the current status of ASLR enablement for the target process. +The +.Va arg +parameter must point to the integer variable, where one of the +following values is written: +.Bl -tag -width PROC_ASLR_FORCE_DISABLE +.It Dv PROC_ASLR_FORCE_ENABLE +.It Dv PROC_ASLR_FORCE_DISABLE +.It Dv PROC_ASLR_NOFORCE +.El +.Pp +If the currently executed image in the process itself has ASLR enabled, +the +.Dv PROC_ASLR_ACTIVE +flag is or-ed with the value listed above. .It Dv PROC_SPROTECT Set process protection state. This is used to mark a process as protected from being killed if the system @@ -543,11 +583,16 @@ The .Fn procctl function appeared in .Fx 10.0 . +.Pp The reaper facility is based on a similar feature of Linux and DragonflyBSD, and first appeared in .Fx 10.2 . +.Pp The .Dv PROC_PDEATHSIG_CTL facility is based on the prctl(PR_SET_PDEATHSIG, ...) feature of Linux, and first appeared in .Fx 11.2 . +.Pp +The ASLR support was added to system for the checklists compliance in +.Fx 13.0 . Modified: stable/12/sys/amd64/amd64/elf_machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/elf_machdep.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/amd64/amd64/elf_machdep.c Tue Mar 12 16:33:44 2019 (r345067) @@ -74,7 +74,8 @@ struct sysentvec elf64_freebsd_sysvec = { .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_LP64 | SV_SHP | SV_TIMEKEEP, + .sv_flags = SV_ABI_FREEBSD | SV_ASLR | SV_LP64 | SV_SHP | + SV_TIMEKEEP, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, Modified: stable/12/sys/arm/arm/elf_machdep.c ============================================================================== --- stable/12/sys/arm/arm/elf_machdep.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/arm/arm/elf_machdep.c Tue Mar 12 16:33:44 2019 (r345067) @@ -83,9 +83,9 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_maxssiz = NULL, .sv_flags = #if __ARM_ARCH >= 6 - SV_SHP | SV_TIMEKEEP | + SV_ASLR | SV_SHP | SV_TIMEKEEP | #endif - SV_ABI_FREEBSD | SV_ILP32, + SV_ABI_FREEBSD | SV_ILP32 | SV_ASLR, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, Modified: stable/12/sys/arm64/arm64/elf_machdep.c ============================================================================== --- stable/12/sys/arm64/arm64/elf_machdep.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/arm64/arm64/elf_machdep.c Tue Mar 12 16:33:44 2019 (r345067) @@ -80,7 +80,8 @@ static struct sysentvec elf64_freebsd_sysvec = { .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_SHP | SV_TIMEKEEP | SV_ABI_FREEBSD | SV_LP64, + .sv_flags = SV_SHP | SV_TIMEKEEP | SV_ABI_FREEBSD | SV_LP64 | + SV_ASLR, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, Modified: stable/12/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/12/sys/compat/freebsd32/freebsd32_misc.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/compat/freebsd32/freebsd32_misc.c Tue Mar 12 16:33:44 2019 (r345067) @@ -3351,6 +3351,7 @@ freebsd32_procctl(struct thread *td, struct freebsd32_ int error, error1, flags, signum; switch (uap->com) { + case PROC_ASLR_CTL: case PROC_SPROTECT: case PROC_TRACE_CTL: case PROC_TRAPCAP_CTL: @@ -3382,6 +3383,7 @@ freebsd32_procctl(struct thread *td, struct freebsd32_ return (error); data = &x.rk; break; + case PROC_ASLR_STATUS: case PROC_TRACE_STATUS: case PROC_TRAPCAP_STATUS: data = &flags; @@ -3410,6 +3412,7 @@ freebsd32_procctl(struct thread *td, struct freebsd32_ if (error == 0) error = error1; break; + case PROC_ASLR_STATUS: case PROC_TRACE_STATUS: case PROC_TRAPCAP_STATUS: if (error == 0) Modified: stable/12/sys/compat/ia32/ia32_sysvec.c ============================================================================== --- stable/12/sys/compat/ia32/ia32_sysvec.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/compat/ia32/ia32_sysvec.c Tue Mar 12 16:33:44 2019 (r345067) @@ -120,7 +120,7 @@ struct sysentvec ia32_freebsd_sysvec = { .sv_setregs = ia32_setregs, .sv_fixlimit = ia32_fixlimit, .sv_maxssiz = &ia32_maxssiz, - .sv_flags = SV_ABI_FREEBSD | SV_IA32 | SV_ILP32 | + .sv_flags = SV_ABI_FREEBSD | SV_ASLR | SV_IA32 | SV_ILP32 | SV_SHP | SV_TIMEKEEP, .sv_set_syscall_retval = ia32_set_syscall_retval, .sv_fetch_syscall_args = ia32_fetch_syscall_args, Modified: stable/12/sys/i386/i386/elf_machdep.c ============================================================================== --- stable/12/sys/i386/i386/elf_machdep.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/i386/i386/elf_machdep.c Tue Mar 12 16:33:44 2019 (r345067) @@ -76,8 +76,8 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_IA32 | SV_ILP32 | SV_SHP | - SV_TIMEKEEP, + .sv_flags = SV_ABI_FREEBSD | SV_ASLR | SV_IA32 | SV_ILP32 | + SV_SHP | SV_TIMEKEEP, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/kern/imgact_elf.c Tue Mar 12 16:33:44 2019 (r345067) @@ -137,6 +137,27 @@ SYSCTL_INT(_kern_elf32, OID_AUTO, read_exec, CTLFLAG_R #endif #endif +SYSCTL_NODE(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, aslr, CTLFLAG_RW, 0, + ""); +#define ASLR_NODE_OID __CONCAT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), _aslr) + +static int __elfN(aslr_enabled) = 0; +SYSCTL_INT(ASLR_NODE_OID, OID_AUTO, enable, CTLFLAG_RWTUN, + &__elfN(aslr_enabled), 0, + __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) + ": enable address map randomization"); + +static int __elfN(pie_aslr_enabled) = 0; +SYSCTL_INT(ASLR_NODE_OID, OID_AUTO, pie_enable, CTLFLAG_RWTUN, + &__elfN(pie_aslr_enabled), 0, + __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) + ": enable address map randomization for PIE binaries"); + +static int __elfN(aslr_honor_sbrk) = 1; +SYSCTL_INT(ASLR_NODE_OID, OID_AUTO, honor_sbrk, CTLFLAG_RW, + &__elfN(aslr_honor_sbrk), 0, + __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) ": assume sbrk is used"); + static Elf_Brandinfo *elf_brand_list[MAX_BRANDS]; #define trunc_page_ps(va, ps) rounddown2(va, ps) @@ -774,6 +795,36 @@ fail: return (error); } +static u_long +__CONCAT(rnd_, __elfN(base))(vm_map_t map __unused, u_long minv, u_long maxv, + u_int align) +{ + u_long rbase, res; + + MPASS(vm_map_min(map) <= minv); + MPASS(maxv <= vm_map_max(map)); + MPASS(minv < maxv); + MPASS(minv + align < maxv); + arc4rand(&rbase, sizeof(rbase), 0); + res = roundup(minv, (u_long)align) + rbase % (maxv - minv); + res &= ~((u_long)align - 1); + if (res >= maxv) + res -= align; + KASSERT(res >= minv, + ("res %#lx < minv %#lx, maxv %#lx rbase %#lx", + res, minv, maxv, rbase)); + KASSERT(res < maxv, + ("res %#lx > maxv %#lx, minv %#lx rbase %#lx", + res, maxv, minv, rbase)); + return (res); +} + +/* + * Impossible et_dyn_addr initial value indicating that the real base + * must be calculated later with some randomization applied. + */ +#define ET_DYN_ADDR_RAND 1 + static int __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) { @@ -782,6 +833,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i const Elf_Phdr *phdr; Elf_Auxargs *elf_auxargs; struct vmspace *vmspace; + vm_map_t map; const char *err_str, *newinterp; char *interp, *interp_buf, *path; Elf_Brandinfo *brand_info; @@ -789,6 +841,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i vm_prot_t prot; u_long text_size, data_size, total_size, text_addr, data_addr; u_long seg_size, seg_addr, addr, baddr, et_dyn_addr, entry, proghdr; + u_long maxalign, mapsz, maxv, maxv1; uint32_t fctl0; int32_t osrel; int error, i, n, interp_name_len, have_interp; @@ -832,12 +885,17 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i err_str = newinterp = NULL; interp = interp_buf = NULL; td = curthread; + maxalign = PAGE_SIZE; + mapsz = 0; for (i = 0; i < hdr->e_phnum; i++) { switch (phdr[i].p_type) { case PT_LOAD: if (n == 0) baddr = phdr[i].p_vaddr; + if (phdr[i].p_align > maxalign) + maxalign = phdr[i].p_align; + mapsz += phdr[i].p_memsz; n++; break; case PT_INTERP: @@ -898,6 +956,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i error = ENOEXEC; goto ret; } + sv = brand_info->sysvec; et_dyn_addr = 0; if (hdr->e_type == ET_DYN) { if ((brand_info->flags & BI_CAN_EXEC_DYN) == 0) { @@ -909,10 +968,18 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i * Honour the base load address from the dso if it is * non-zero for some reason. */ - if (baddr == 0) - et_dyn_addr = ET_DYN_LOAD_ADDR; + if (baddr == 0) { + if ((sv->sv_flags & SV_ASLR) == 0 || + (fctl0 & NT_FREEBSD_FCTL_ASLR_DISABLE) != 0) + et_dyn_addr = ET_DYN_LOAD_ADDR; + else if ((__elfN(pie_aslr_enabled) && + (imgp->proc->p_flag2 & P2_ASLR_DISABLE) == 0) || + (imgp->proc->p_flag2 & P2_ASLR_ENABLE) != 0) + et_dyn_addr = ET_DYN_ADDR_RAND; + else + et_dyn_addr = ET_DYN_LOAD_ADDR; + } } - sv = brand_info->sysvec; if (interp != NULL && brand_info->interp_newpath != NULL) newinterp = brand_info->interp_newpath; @@ -929,9 +996,54 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i */ VOP_UNLOCK(imgp->vp, 0); + /* + * Decide whether to enable randomization of user mappings. + * First, reset user preferences for the setid binaries. + * Then, account for the support of the randomization by the + * ABI, by user preferences, and make special treatment for + * PIE binaries. + */ + if (imgp->credential_setid) { + PROC_LOCK(imgp->proc); + imgp->proc->p_flag2 &= ~(P2_ASLR_ENABLE | P2_ASLR_DISABLE); + PROC_UNLOCK(imgp->proc); + } + if ((sv->sv_flags & SV_ASLR) == 0 || + (imgp->proc->p_flag2 & P2_ASLR_DISABLE) != 0 || + (fctl0 & NT_FREEBSD_FCTL_ASLR_DISABLE) != 0) { + KASSERT(et_dyn_addr != ET_DYN_ADDR_RAND, + ("et_dyn_addr == RAND and !ASLR")); + } else if ((imgp->proc->p_flag2 & P2_ASLR_ENABLE) != 0 || + (__elfN(aslr_enabled) && hdr->e_type == ET_EXEC) || + et_dyn_addr == ET_DYN_ADDR_RAND) { + imgp->map_flags |= MAP_ASLR; + /* + * If user does not care about sbrk, utilize the bss + * grow region for mappings as well. We can select + * the base for the image anywere and still not suffer + * from the fragmentation. + */ + if (!__elfN(aslr_honor_sbrk) || + (imgp->proc->p_flag2 & P2_ASLR_IGNSTART) != 0) + imgp->map_flags |= MAP_ASLR_IGNSTART; + } + error = exec_new_vmspace(imgp, sv); + vmspace = imgp->proc->p_vmspace; + map = &vmspace->vm_map; + imgp->proc->p_sysent = sv; + maxv = vm_map_max(map) - lim_max(td, RLIMIT_STACK); + if (et_dyn_addr == ET_DYN_ADDR_RAND) { + KASSERT((map->flags & MAP_ASLR) != 0, + ("ET_DYN_ADDR_RAND but !MAP_ASLR")); + et_dyn_addr = __CONCAT(rnd_, __elfN(base))(map, + vm_map_min(map) + mapsz + lim_max(td, RLIMIT_DATA), + /* reserve half of the address space to interpreter */ + maxv / 2, 1UL << flsl(maxalign)); + } + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); if (error != 0) goto ret; @@ -1023,7 +1135,6 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i goto ret; } - vmspace = imgp->proc->p_vmspace; vmspace->vm_tsize = text_size >> PAGE_SHIFT; vmspace->vm_taddr = (caddr_t)(uintptr_t)text_addr; vmspace->vm_dsize = data_size >> PAGE_SHIFT; @@ -1037,6 +1148,14 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i */ addr = round_page((vm_offset_t)vmspace->vm_daddr + lim_max(td, RLIMIT_DATA)); + if ((map->flags & MAP_ASLR) != 0) { + maxv1 = maxv / 2 + addr / 2; + MPASS(maxv1 >= addr); /* No overflow */ + map->anon_loc = __CONCAT(rnd_, __elfN(base))(map, addr, maxv1, + MAXPAGESIZES > 1 ? pagesizes[1] : pagesizes[0]); + } else { + map->anon_loc = addr; + } PROC_UNLOCK(imgp->proc); imgp->entry_addr = entry; @@ -1044,6 +1163,13 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i if (interp != NULL) { have_interp = FALSE; VOP_UNLOCK(imgp->vp, 0); + if ((map->flags & MAP_ASLR) != 0) { + /* Assume that interpeter fits into 1/4 of AS */ + maxv1 = maxv / 2 + addr / 2; + MPASS(maxv1 >= addr); /* No overflow */ + addr = __CONCAT(rnd_, __elfN(base))(map, addr, + maxv1, PAGE_SIZE); + } if (brand_info->emul_path != NULL && brand_info->emul_path[0] != '\0') { path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); Modified: stable/12/sys/kern/kern_exec.c ============================================================================== --- stable/12/sys/kern/kern_exec.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/kern/kern_exec.c Tue Mar 12 16:33:44 2019 (r345067) @@ -1104,9 +1104,13 @@ exec_new_vmspace(struct image_params *imgp, struct sys shmexit(vmspace); pmap_remove_pages(vmspace_pmap(vmspace)); vm_map_remove(map, vm_map_min(map), vm_map_max(map)); - /* An exec terminates mlockall(MCL_FUTURE). */ + /* + * An exec terminates mlockall(MCL_FUTURE), ASLR state + * must be re-evaluated. + */ vm_map_lock(map); - vm_map_modflags(map, 0, MAP_WIREFUTURE); + vm_map_modflags(map, 0, MAP_WIREFUTURE | MAP_ASLR | + MAP_ASLR_IGNSTART); vm_map_unlock(map); } else { error = vmspace_exec(p, sv_minuser, sv->sv_maxuser); @@ -1115,6 +1119,7 @@ exec_new_vmspace(struct image_params *imgp, struct sys vmspace = p->p_vmspace; map = &vmspace->vm_map; } + map->flags |= imgp->map_flags; /* Map a shared page */ obj = sv->sv_shared_page_obj; Modified: stable/12/sys/kern/kern_fork.c ============================================================================== --- stable/12/sys/kern/kern_fork.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/kern/kern_fork.c Tue Mar 12 16:33:44 2019 (r345067) @@ -507,7 +507,8 @@ do_fork(struct thread *td, struct fork_req *fr, struct * Increase reference counts on shared objects. */ p2->p_flag = P_INMEM; - p2->p_flag2 = p1->p_flag2 & (P2_NOTRACE | P2_NOTRACE_EXEC | P2_TRAPCAP); + p2->p_flag2 = p1->p_flag2 & (P2_ASLR_DISABLE | P2_ASLR_ENABLE | + P2_ASLR_IGNSTART | P2_NOTRACE | P2_NOTRACE_EXEC | P2_TRAPCAP); p2->p_swtick = ticks; if (p1->p_flag & P_PROFIL) startprofclock(p2); Modified: stable/12/sys/kern/kern_procctl.c ============================================================================== --- stable/12/sys/kern/kern_procctl.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/kern/kern_procctl.c Tue Mar 12 16:33:44 2019 (r345067) @@ -43,6 +43,11 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include +#include +#include + static int protect_setchild(struct thread *td, struct proc *p, int flags) { @@ -413,6 +418,62 @@ trapcap_status(struct thread *td, struct proc *p, int return (0); } +static int +aslr_ctl(struct thread *td, struct proc *p, int state) +{ + + PROC_LOCK_ASSERT(p, MA_OWNED); + + switch (state) { + case PROC_ASLR_FORCE_ENABLE: + p->p_flag2 &= ~P2_ASLR_DISABLE; + p->p_flag2 |= P2_ASLR_ENABLE; + break; + case PROC_ASLR_FORCE_DISABLE: + p->p_flag2 |= P2_ASLR_DISABLE; + p->p_flag2 &= ~P2_ASLR_ENABLE; + break; + case PROC_ASLR_NOFORCE: + p->p_flag2 &= ~(P2_ASLR_ENABLE | P2_ASLR_DISABLE); + break; + default: + return (EINVAL); + } + return (0); +} + +static int +aslr_status(struct thread *td, struct proc *p, int *data) +{ + struct vmspace *vm; + int d; + + switch (p->p_flag2 & (P2_ASLR_ENABLE | P2_ASLR_DISABLE)) { + case 0: + d = PROC_ASLR_NOFORCE; + break; + case P2_ASLR_ENABLE: + d = PROC_ASLR_FORCE_ENABLE; + break; + case P2_ASLR_DISABLE: + d = PROC_ASLR_FORCE_DISABLE; + break; + } + if ((p->p_flag & P_WEXIT) == 0) { + _PHOLD(p); + PROC_UNLOCK(p); + vm = vmspace_acquire_ref(p); + if (vm != NULL && (vm->vm_map.flags & MAP_ASLR) != 0) { + d |= PROC_ASLR_ACTIVE; + vmspace_free(vm); + } + PROC_LOCK(p); + _PRELE(p); + } + *data = d; + return (0); +} + #ifndef _SYS_SYSPROTO_H_ struct procctl_args { idtype_t idtype; @@ -434,6 +495,7 @@ sys_procctl(struct thread *td, struct procctl_args *ua int error, error1, flags, signum; switch (uap->com) { + case PROC_ASLR_CTL: case PROC_SPROTECT: case PROC_TRACE_CTL: case PROC_TRAPCAP_CTL: @@ -463,6 +525,7 @@ sys_procctl(struct thread *td, struct procctl_args *ua return (error); data = &x.rk; break; + case PROC_ASLR_STATUS: case PROC_TRACE_STATUS: case PROC_TRAPCAP_STATUS: data = &flags; @@ -490,6 +553,7 @@ sys_procctl(struct thread *td, struct procctl_args *ua if (error == 0) error = error1; break; + case PROC_ASLR_STATUS: case PROC_TRACE_STATUS: case PROC_TRAPCAP_STATUS: if (error == 0) @@ -509,6 +573,10 @@ kern_procctl_single(struct thread *td, struct proc *p, PROC_LOCK_ASSERT(p, MA_OWNED); switch (com) { + case PROC_ASLR_CTL: + return (aslr_ctl(td, p, *(int *)data)); + case PROC_ASLR_STATUS: + return (aslr_status(td, p, data)); case PROC_SPROTECT: return (protect_set(td, p, *(int *)data)); case PROC_REAP_ACQUIRE: @@ -544,6 +612,8 @@ kern_procctl(struct thread *td, idtype_t idtype, id_t bool tree_locked; switch (com) { + case PROC_ASLR_CTL: + case PROC_ASLR_STATUS: case PROC_REAP_ACQUIRE: case PROC_REAP_RELEASE: case PROC_REAP_STATUS: @@ -593,6 +663,8 @@ kern_procctl(struct thread *td, idtype_t idtype, id_t sx_xlock(&proctree_lock); tree_locked = true; break; + case PROC_ASLR_CTL: + case PROC_ASLR_STATUS: case PROC_TRACE_STATUS: case PROC_TRAPCAP_STATUS: tree_locked = false; Modified: stable/12/sys/mips/mips/elf_machdep.c ============================================================================== --- stable/12/sys/mips/mips/elf_machdep.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/mips/mips/elf_machdep.c Tue Mar 12 16:33:44 2019 (r345067) @@ -77,7 +77,7 @@ struct sysentvec elf64_freebsd_sysvec = { .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_LP64, + .sv_flags = SV_ABI_FREEBSD | SV_LP64 | SV_ASLR, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, @@ -133,7 +133,7 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_ILP32, + .sv_flags = SV_ABI_FREEBSD | SV_ILP32 | SV_ASLR, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, Modified: stable/12/sys/powerpc/powerpc/elf32_machdep.c ============================================================================== --- stable/12/sys/powerpc/powerpc/elf32_machdep.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/powerpc/powerpc/elf32_machdep.c Tue Mar 12 16:33:44 2019 (r345067) @@ -116,7 +116,7 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_fixlimit = NULL, #endif .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_ILP32 | SV_SHP, + .sv_flags = SV_ABI_FREEBSD | SV_ILP32 | SV_SHP | SV_ASLR, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_shared_page_base = FREEBSD32_SHAREDPAGE, Modified: stable/12/sys/powerpc/powerpc/elf64_machdep.c ============================================================================== --- stable/12/sys/powerpc/powerpc/elf64_machdep.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/powerpc/powerpc/elf64_machdep.c Tue Mar 12 16:33:44 2019 (r345067) @@ -80,7 +80,7 @@ struct sysentvec elf64_freebsd_sysvec_v1 = { .sv_setregs = exec_setregs_funcdesc, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_LP64 | SV_SHP, + .sv_flags = SV_ABI_FREEBSD | SV_LP64 | SV_SHP | SV_ASLR, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, Modified: stable/12/sys/riscv/riscv/elf_machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/elf_machdep.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/riscv/riscv/elf_machdep.c Tue Mar 12 16:33:44 2019 (r345067) @@ -83,7 +83,7 @@ struct sysentvec elf64_freebsd_sysvec = { .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_LP64, + .sv_flags = SV_ABI_FREEBSD | SV_LP64 | SV_ASLR, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, Modified: stable/12/sys/sparc64/sparc64/elf_machdep.c ============================================================================== --- stable/12/sys/sparc64/sparc64/elf_machdep.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/sparc64/sparc64/elf_machdep.c Tue Mar 12 16:33:44 2019 (r345067) @@ -81,7 +81,7 @@ static struct sysentvec elf64_freebsd_sysvec = { .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_LP64, + .sv_flags = SV_ABI_FREEBSD | SV_LP64 | SV_ASLR, .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, Modified: stable/12/sys/sys/imgact.h ============================================================================== --- stable/12/sys/sys/imgact.h Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/sys/imgact.h Tue Mar 12 16:33:44 2019 (r345067) @@ -88,6 +88,7 @@ struct image_params { u_long stack_sz; struct ucred *newcred; /* new credentials if changing */ bool credential_setid; /* true if becoming setid */ + u_int map_flags; }; #ifdef _KERNEL Modified: stable/12/sys/sys/proc.h ============================================================================== --- stable/12/sys/sys/proc.h Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/sys/proc.h Tue Mar 12 16:33:44 2019 (r345067) @@ -752,6 +752,9 @@ struct proc { #define P2_AST_SU 0x00000008 /* Handles SU ast for kthreads. */ #define P2_PTRACE_FSTP 0x00000010 /* SIGSTOP from PT_ATTACH not yet handled. */ #define P2_TRAPCAP 0x00000020 /* SIGTRAP on ENOTCAPABLE */ +#define P2_ASLR_ENABLE 0x00000040 /* Force enable ASLR. */ +#define P2_ASLR_DISABLE 0x00000080 /* Force disable ASLR. */ +#define P2_ASLR_IGNSTART 0x00000100 /* Enable ASLR to consume sbrk area. */ /* Flags protected by proctree_lock, kept in p_treeflags. */ #define P_TREE_ORPHANED 0x00000001 /* Reparented, on orphan list */ Modified: stable/12/sys/sys/procctl.h ============================================================================== --- stable/12/sys/sys/procctl.h Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/sys/procctl.h Tue Mar 12 16:33:44 2019 (r345067) @@ -53,6 +53,8 @@ #define PROC_TRAPCAP_STATUS 10 /* query trap capability status */ #define PROC_PDEATHSIG_CTL 11 /* set parent death signal */ #define PROC_PDEATHSIG_STATUS 12 /* get parent death signal */ +#define PROC_ASLR_CTL 13 /* en/dis ASLR */ +#define PROC_ASLR_STATUS 14 /* query ASLR status */ /* Operations for PROC_SPROTECT (passed in integer arg). */ #define PPROT_OP(x) ((x) & 0xf) @@ -115,6 +117,11 @@ struct procctl_reaper_kill { #define PROC_TRAPCAP_CTL_ENABLE 1 #define PROC_TRAPCAP_CTL_DISABLE 2 + +#define PROC_ASLR_FORCE_ENABLE 1 +#define PROC_ASLR_FORCE_DISABLE 2 +#define PROC_ASLR_NOFORCE 3 +#define PROC_ASLR_ACTIVE 0x80000000 #ifndef _KERNEL __BEGIN_DECLS Modified: stable/12/sys/sys/sysent.h ============================================================================== --- stable/12/sys/sys/sysent.h Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/sys/sysent.h Tue Mar 12 16:33:44 2019 (r345067) @@ -145,6 +145,7 @@ struct sysentvec { #define SV_SHP 0x010000 /* Shared page. */ #define SV_CAPSICUM 0x020000 /* Force cap_enter() on startup. */ #define SV_TIMEKEEP 0x040000 /* Shared page timehands. */ +#define SV_ASLR 0x080000 /* ASLR allowed. */ #define SV_ABI_MASK 0xff #define SV_ABI_ERRNO(p, e) ((p)->p_sysent->sv_errsize <= 0 ? e : \ Modified: stable/12/sys/vm/vm_map.c ============================================================================== --- stable/12/sys/vm/vm_map.c Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/vm/vm_map.c Tue Mar 12 16:33:44 2019 (r345067) @@ -801,6 +801,7 @@ _vm_map_init(vm_map_t map, pmap_t pmap, vm_offset_t mi map->root = NULL; map->timestamp = 0; map->busy = 0; + map->anon_loc = 0; } void @@ -1480,6 +1481,36 @@ vm_map_fixed(vm_map_t map, vm_object_t object, vm_ooff return (result); } +static const int aslr_pages_rnd_64[2] = {0x1000, 0x10}; +static const int aslr_pages_rnd_32[2] = {0x100, 0x4}; + +static int cluster_anon = 1; +SYSCTL_INT(_vm, OID_AUTO, cluster_anon, CTLFLAG_RW, + &cluster_anon, 0, + "Cluster anonymous mappings: 0 = no, 1 = yes if no hint, 2 = always"); + +static bool +clustering_anon_allowed(vm_offset_t addr) +{ + + switch (cluster_anon) { + case 0: + return (false); + case 1: + return (addr == 0); + case 2: + default: + return (true); + } +} + +static long aslr_restarts; +SYSCTL_LONG(_vm, OID_AUTO, aslr_restarts, CTLFLAG_RD, + &aslr_restarts, 0, + "Number of aslr failures"); + +#define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31) + /* * Searches for the specified amount of free space in the given map with the * specified alignment. Performs an address-ordered, first-fit search from @@ -1559,8 +1590,9 @@ vm_map_find(vm_map_t map, vm_object_t object, vm_ooffs vm_size_t length, vm_offset_t max_addr, int find_space, vm_prot_t prot, vm_prot_t max, int cow) { - vm_offset_t alignment, min_addr; - int rv; + vm_offset_t alignment, curr_min_addr, min_addr; + int gap, pidx, rv, try; + bool cluster, en_aslr, update_anon; KASSERT((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) == 0 || object == NULL, @@ -1575,24 +1607,96 @@ vm_map_find(vm_map_t map, vm_object_t object, vm_ooffs alignment = (vm_offset_t)1 << (find_space >> 8); } else alignment = 0; + en_aslr = (map->flags & MAP_ASLR) != 0; + update_anon = cluster = clustering_anon_allowed(*addr) && + (map->flags & MAP_IS_SUB_MAP) == 0 && max_addr == 0 && + find_space != VMFS_NO_SPACE && object == NULL && + (cow & (MAP_INHERIT_SHARE | MAP_STACK_GROWS_UP | + MAP_STACK_GROWS_DOWN)) == 0 && prot != PROT_NONE; + curr_min_addr = min_addr = *addr; + if (en_aslr && min_addr == 0 && !cluster && + find_space != VMFS_NO_SPACE && + (map->flags & MAP_ASLR_IGNSTART) != 0) + curr_min_addr = min_addr = vm_map_min(map); + try = 0; vm_map_lock(map); + if (cluster) { + curr_min_addr = map->anon_loc; + if (curr_min_addr == 0) + cluster = false; + } if (find_space != VMFS_NO_SPACE) { KASSERT(find_space == VMFS_ANY_SPACE || find_space == VMFS_OPTIMAL_SPACE || find_space == VMFS_SUPER_SPACE || alignment != 0, ("unexpected VMFS flag")); - min_addr = *addr; again: - if (vm_map_findspace(map, min_addr, length, addr) || + /* + * When creating an anonymous mapping, try clustering + * with an existing anonymous mapping first. + * + * We make up to two attempts to find address space + * for a given find_space value. The first attempt may + * apply randomization or may cluster with an existing + * anonymous mapping. If this first attempt fails, + * perform a first-fit search of the available address + * space. + * + * If all tries failed, and find_space is + * VMFS_OPTIMAL_SPACE, fallback to VMFS_ANY_SPACE. + * Again enable clustering and randomization. + */ + try++; + MPASS(try <= 2); + + if (try == 2) { + /* + * Second try: we failed either to find a + * suitable region for randomizing the + * allocation, or to cluster with an existing + * mapping. Retry with free run. + */ + curr_min_addr = (map->flags & MAP_ASLR_IGNSTART) != 0 ? + vm_map_min(map) : min_addr; + atomic_add_long(&aslr_restarts, 1); + } + + if (try == 1 && en_aslr && !cluster) { + /* + * Find space for allocation, including + * gap needed for later randomization. + */ + pidx = MAXPAGESIZES > 1 && pagesizes[1] != 0 && + (find_space == VMFS_SUPER_SPACE || find_space == + VMFS_OPTIMAL_SPACE) ? 1 : 0; + gap = vm_map_max(map) > MAP_32BIT_MAX_ADDR && + (max_addr == 0 || max_addr > MAP_32BIT_MAX_ADDR) ? + aslr_pages_rnd_64[pidx] : aslr_pages_rnd_32[pidx]; + if (vm_map_findspace(map, curr_min_addr, length + + gap * pagesizes[pidx], addr) || + (max_addr != 0 && *addr + length > max_addr)) + goto again; + /* And randomize the start address. */ + *addr += (arc4random() % gap) * pagesizes[pidx]; + } else if (vm_map_findspace(map, curr_min_addr, length, addr) || (max_addr != 0 && *addr + length > max_addr)) { + if (cluster) { + cluster = false; + MPASS(try == 1); + goto again; + } rv = KERN_NO_SPACE; goto done; } + if (find_space != VMFS_ANY_SPACE && (rv = vm_map_alignspace(map, object, offset, addr, length, max_addr, alignment)) != KERN_SUCCESS) { if (find_space == VMFS_OPTIMAL_SPACE) { find_space = VMFS_ANY_SPACE; + curr_min_addr = min_addr; + cluster = update_anon; + try = 0; goto again; } goto done; @@ -1613,6 +1717,8 @@ again: rv = vm_map_insert(map, object, offset, *addr, *addr + length, prot, max, cow); } + if (rv == KERN_SUCCESS && update_anon) + map->anon_loc = *addr + length; done: vm_map_unlock(map); return (rv); @@ -1922,8 +2028,14 @@ vm_map_submap( vm_map_t submap) { vm_map_entry_t entry; - int result = KERN_INVALID_ARGUMENT; + int result; + result = KERN_INVALID_ARGUMENT; + + vm_map_lock(submap); + submap->flags |= MAP_IS_SUB_MAP; + vm_map_unlock(submap); + vm_map_lock(map); VM_MAP_RANGE_CHECK(map, start, end); @@ -1944,6 +2056,11 @@ vm_map_submap( } vm_map_unlock(map); + if (result != KERN_SUCCESS) { + vm_map_lock(submap); + submap->flags &= ~MAP_IS_SUB_MAP; + vm_map_unlock(submap); + } return (result); } @@ -3170,6 +3287,9 @@ vm_map_delete(vm_map_t map, vm_offset_t start, vm_offs entry->object.vm_object != NULL) pmap_remove(map->pmap, entry->start, entry->end); + if (entry->end == map->anon_loc) + map->anon_loc = entry->start; + /* * Delete the entry only after removing all pmap * entries pointing to its pages. (Otherwise, its @@ -3452,6 +3572,8 @@ vmspace_fork(struct vmspace *vm1, vm_ooffset_t *fork_c vmspace_free(vm2); return (NULL); } + + new_map->anon_loc = old_map->anon_loc; old_entry = old_map->header.next; Modified: stable/12/sys/vm/vm_map.h ============================================================================== --- stable/12/sys/vm/vm_map.h Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/sys/vm/vm_map.h Tue Mar 12 16:33:44 2019 (r345067) @@ -202,6 +202,7 @@ struct vm_map { vm_flags_t flags; /* flags for this vm_map */ vm_map_entry_t root; /* Root of a binary search tree */ pmap_t pmap; /* (c) Physical map */ + vm_offset_t anon_loc; int busy; }; @@ -210,6 +211,9 @@ struct vm_map { */ #define MAP_WIREFUTURE 0x01 /* wire all future pages */ #define MAP_BUSY_WAKEUP 0x02 +#define MAP_IS_SUB_MAP 0x04 /* has parent */ +#define MAP_ASLR 0x08 /* enabled ASLR */ +#define MAP_ASLR_IGNSTART 0x10 #ifdef _KERNEL #if defined(KLD_MODULE) && !defined(KLD_TIED) Modified: stable/12/usr.bin/proccontrol/Makefile ============================================================================== --- stable/12/usr.bin/proccontrol/Makefile Tue Mar 12 16:21:39 2019 (r345066) +++ stable/12/usr.bin/proccontrol/Makefile Tue Mar 12 16:33:44 2019 (r345067) @@ -2,6 +2,5 @@ PROG= proccontrol WARNS?= 6 -MAN= .include Copied: stable/12/usr.bin/proccontrol/proccontrol.1 (from r344594, head/usr.bin/proccontrol/proccontrol.1) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/usr.bin/proccontrol/proccontrol.1 Tue Mar 12 16:33:44 2019 (r345067, copy of r344594, head/usr.bin/proccontrol/proccontrol.1) @@ -0,0 +1,123 @@ +.\" Copyright (c) 2019 The FreeBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This documentation was written by +.\" Konstantin Belousov under sponsorship +.\" from the FreeBSD Foundation. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd February 22, 2019 +.Dt PROCCONTROL 1 +.Os +.Sh NAME +.Nm proccontrol +.Nd Control some process execution aspects +.Sh SYNOPSIS +.Nm +.Fl m Ar mode +.Op Fl s Ar control +.Op Fl q +.Fl p Ar pid | command +.Sh DESCRIPTION +The +.Nm +command modifies the execution parameter of existing process +specified by the +.Ar pid +argument, or starts execution of the new program +.Ar command +with the execution parameter set for it. +.Pp +Which execution parameter is changed, selected by the mandatory +parameter +.Ar mode . +Possible values for +.Ar mode +are: +.Bl -tag -width trapcap +.It Ar aslr +Control the Address Space Layout Randomization. +Only applicable to the new process spawned. +.It Ar trace +Control the permission for debuggers to attach. +.It Ar trapcap +Controls the signalling of capability mode access violations. +.El +.Pp +The +Ar control +specifies if the selected +.Ar mode +should be enabled or disabled. +Possible values are +.Ar enable +and +.Ar disable , +with the default value being +.Ar enable +if not specified. +See +.Xr procctl 2 +for detailed description of each mode effects and interaction with other +process control facilities. +.Pp +The +.Op Fl q +switch makes the utility query and print the current setting for +the selected mode. +.Sh EXIT STATUS *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Tue Mar 12 17:03:59 2019 Return-Path: Delivered-To: svn-src-stable-12@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 87A661536DE2; Tue, 12 Mar 2019 17:03:59 +0000 (UTC) (envelope-from emaste@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 29BE3717A9; Tue, 12 Mar 2019 17:03:59 +0000 (UTC) (envelope-from emaste@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 1DDF725B14; Tue, 12 Mar 2019 17:03:59 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2CH3wqQ059652; Tue, 12 Mar 2019 17:03:58 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2CH3wix059651; Tue, 12 Mar 2019 17:03:58 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201903121703.x2CH3wix059651@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 12 Mar 2019 17:03:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345071 - stable/12/usr.sbin/freebsd-update X-SVN-Group: stable-12 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/12/usr.sbin/freebsd-update X-SVN-Commit-Revision: 345071 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 29BE3717A9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Mar 2019 17:03:59 -0000 Author: emaste Date: Tue Mar 12 17:03:58 2019 New Revision: 345071 URL: https://svnweb.freebsd.org/changeset/base/345071 Log: MFC r344818: freebsd-update.8: update example to contemporary versions PR: 235761 Reported by: linimon Modified: stable/12/usr.sbin/freebsd-update/freebsd-update.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/freebsd-update/freebsd-update.8 ============================================================================== --- stable/12/usr.sbin/freebsd-update/freebsd-update.8 Tue Mar 12 16:49:08 2019 (r345070) +++ stable/12/usr.sbin/freebsd-update/freebsd-update.8 Tue Mar 12 17:03:58 2019 (r345071) @@ -59,13 +59,13 @@ by the .Fx Release Engineering Team, e.g., .Fx -10.3-RELEASE and +11.2-RELEASE and .Fx -11.0-RELEASE, but not +12.0-RELEASE, but not .Fx -10.3-STABLE or +11.2-STABLE or .Fx -12-CURRENT. +13.0-CURRENT. .Sh OPTIONS The following options are supported: .Bl -tag -width "-r newrelease" From owner-svn-src-stable-12@freebsd.org Tue Mar 12 19:03:48 2019 Return-Path: Delivered-To: svn-src-stable-12@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 8874F153B516; Tue, 12 Mar 2019 19:03:48 +0000 (UTC) (envelope-from kp@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 2BFA781404; Tue, 12 Mar 2019 19:03:48 +0000 (UTC) (envelope-from kp@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 1B3E526FE9; Tue, 12 Mar 2019 19:03:48 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2CJ3lgr028287; Tue, 12 Mar 2019 19:03:47 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2CJ3lj1028286; Tue, 12 Mar 2019 19:03:47 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201903121903.x2CJ3lj1028286@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Tue, 12 Mar 2019 19:03:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345076 - stable/12/tests/sys/netpfil/pf X-SVN-Group: stable-12 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/12/tests/sys/netpfil/pf X-SVN-Commit-Revision: 345076 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2BFA781404 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Mar 2019 19:03:48 -0000 Author: kp Date: Tue Mar 12 19:03:47 2019 New Revision: 345076 URL: https://svnweb.freebsd.org/changeset/base/345076 Log: pf tests: Disable noalias test Direct commit to stable/12 to disable the noalias test. The noalias feature has not been merged to stable/12 as it is a (small) behaviour change. This means this test will fail. Disable it. Modified: stable/12/tests/sys/netpfil/pf/pass_block.sh Modified: stable/12/tests/sys/netpfil/pf/pass_block.sh ============================================================================== --- stable/12/tests/sys/netpfil/pf/pass_block.sh Tue Mar 12 18:59:01 2019 (r345075) +++ stable/12/tests/sys/netpfil/pf/pass_block.sh Tue Mar 12 19:03:47 2019 (r345076) @@ -168,6 +168,6 @@ atf_init_test_cases() { atf_add_test_case "v4" atf_add_test_case "v6" - atf_add_test_case "noalias" + #atf_add_test_case "noalias" atf_add_test_case "nested_inline" } From owner-svn-src-stable-12@freebsd.org Wed Mar 13 20:26:33 2019 Return-Path: Delivered-To: svn-src-stable-12@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 2DFC61540F11; Wed, 13 Mar 2019 20:26:33 +0000 (UTC) (envelope-from mav@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 BDDF36EA0F; Wed, 13 Mar 2019 20:26:32 +0000 (UTC) (envelope-from mav@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 6EDDFFAEE; Wed, 13 Mar 2019 20:26:28 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2DKQS51040053; Wed, 13 Mar 2019 20:26:28 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2DKQSa6040052; Wed, 13 Mar 2019 20:26:28 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903132026.x2DKQSa6040052@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 13 Mar 2019 20:26:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345111 - stable/12/sys/cam/ctl X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cam/ctl X-SVN-Commit-Revision: 345111 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: BDDF36EA0F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.98)[-0.979,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 20:26:33 -0000 Author: mav Date: Wed Mar 13 20:26:27 2019 New Revision: 345111 URL: https://svnweb.freebsd.org/changeset/base/345111 Log: MFC r344586: Scrap some debug printf's, unused for years. Modified: stable/12/sys/cam/ctl/ctl.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/ctl/ctl.c ============================================================================== --- stable/12/sys/cam/ctl/ctl.c Wed Mar 13 19:53:20 2019 (r345110) +++ stable/12/sys/cam/ctl/ctl.c Wed Mar 13 20:26:27 2019 (r345111) @@ -1454,12 +1454,6 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e if (softc->ha_mode != CTL_HA_MODE_XFER) io->io_hdr.flags |= CTL_FLAG_INT_COPY; io->io_hdr.nexus = msg->hdr.nexus; -#if 0 - printf("port %u, iid %u, lun %u\n", - io->io_hdr.nexus.targ_port, - io->io_hdr.nexus.initid, - io->io_hdr.nexus.targ_lun); -#endif io->scsiio.tag_num = msg->scsi.tag_num; io->scsiio.tag_type = msg->scsi.tag_type; #ifdef CTL_TIME_IO @@ -1539,11 +1533,6 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e msg->dt.cur_sg_entries); i++, j++) { sgl[i].addr = msg->dt.sg_list[j].addr; sgl[i].len = msg->dt.sg_list[j].len; - -#if 0 - printf("%s: DATAMOVE: %p,%lu j=%d, i=%d\n", - __func__, sgl[i].addr, sgl[i].len, j, i); -#endif } /* @@ -6468,11 +6457,6 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) && (subpage == SMS_SUBPAGE_PAGE_0)) continue; -#if 0 - printf("found page %#x len %d\n", - page_index->page_code & SMPH_PC_MASK, - page_index->page_len); -#endif page_len += page_index->page_len; } break; @@ -6505,12 +6489,6 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) && (subpage != SMS_SUBPAGE_ALL)) continue; -#if 0 - printf("found page %#x len %d\n", - page_index->page_code & SMPH_PC_MASK, - page_index->page_len); -#endif - page_len += page_index->page_len; } @@ -6529,10 +6507,6 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) } total_len = header_len + page_len; -#if 0 - printf("header_len = %d, page_len = %d, total_len = %d\n", - header_len, page_len, total_len); -#endif ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO); ctsio->kern_sg_entries = 0; @@ -8220,10 +8194,6 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) case SPRO_REGISTER: case SPRO_REG_IGNO: { -#if 0 - printf("Registration received\n"); -#endif - /* * We don't support any of these options, as we report in * the read capabilities request (see @@ -8336,9 +8306,6 @@ ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) break; } case SPRO_RESERVE: -#if 0 - printf("Reserve executed type %d\n", type); -#endif mtx_lock(&lun->lun_lock); if (lun->flags & CTL_LUN_PR_RESERVED) { /* @@ -11900,15 +11867,8 @@ ctl_abort_task(union ctl_io *io) struct ctl_softc *softc = CTL_SOFTC(io); union ctl_io *xio; struct ctl_lun *lun; -#if 0 - struct sbuf sb; - char printbuf[128]; -#endif - int found; uint32_t targ_lun; - found = 0; - /* * Look up the LUN. */ @@ -11921,11 +11881,6 @@ ctl_abort_task(union ctl_io *io) return (1); } -#if 0 - printf("ctl_abort_task: called for lun %lld, tag %d type %d\n", - lun->lun, io->taskio.tag_num, io->taskio.tag_type); -#endif - mtx_lock(&lun->lun_lock); mtx_unlock(&softc->ctl_lock); /* @@ -11937,25 +11892,7 @@ ctl_abort_task(union ctl_io *io) */ for (xio = (union ctl_io *)TAILQ_FIRST(&lun->ooa_queue); xio != NULL; xio = (union ctl_io *)TAILQ_NEXT(&xio->io_hdr, ooa_links)) { -#if 0 - sbuf_new(&sb, printbuf, sizeof(printbuf), SBUF_FIXEDLEN); - sbuf_printf(&sb, "LUN %lld tag %d type %d%s%s%s%s: ", - lun->lun, xio->scsiio.tag_num, - xio->scsiio.tag_type, - (xio->io_hdr.blocked_links.tqe_prev - == NULL) ? "" : " BLOCKED", - (xio->io_hdr.flags & - CTL_FLAG_DMA_INPROG) ? " DMA" : "", - (xio->io_hdr.flags & - CTL_FLAG_ABORT) ? " ABORT" : "", - (xio->io_hdr.flags & - CTL_FLAG_IS_WAS_ON_RTR ? " RTR" : "")); - ctl_scsi_command_string(&xio->scsiio, NULL, &sb); - sbuf_finish(&sb); - printf("%s\n", sbuf_data(&sb)); -#endif - if ((xio->io_hdr.nexus.targ_port != io->io_hdr.nexus.targ_port) || (xio->io_hdr.nexus.initid != io->io_hdr.nexus.initid) || (xio->io_hdr.flags & CTL_FLAG_ABORT)) @@ -11972,8 +11909,8 @@ ctl_abort_task(union ctl_io *io) #if 0 if (((xio->scsiio.tag_type == CTL_TAG_UNTAGGED) && (io->taskio.tag_type == CTL_TAG_UNTAGGED)) - || (xio->scsiio.tag_num == io->taskio.tag_num)) -#endif + || (xio->scsiio.tag_num == io->taskio.tag_num)) { +#else /* * XXX KDM we've got problems with FC, because it * doesn't send down a tag type with aborts. So we @@ -11982,8 +11919,8 @@ ctl_abort_task(union ctl_io *io) * Need to figure that out!! */ if (xio->scsiio.tag_num == io->taskio.tag_num) { +#endif xio->io_hdr.flags |= CTL_FLAG_ABORT; - found = 1; if ((io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC) == 0 && !(lun->flags & CTL_LUN_PRIMARY_SC)) { union ctl_ha_msg msg_info; @@ -11995,34 +11932,12 @@ ctl_abort_task(union ctl_io *io) msg_info.hdr.msg_type = CTL_MSG_MANAGE_TASKS; msg_info.hdr.original_sc = NULL; msg_info.hdr.serializing_sc = NULL; -#if 0 - printf("Sent Abort to other side\n"); -#endif ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, sizeof(msg_info.task), M_NOWAIT); } -#if 0 - printf("ctl_abort_task: found I/O to abort\n"); -#endif } } mtx_unlock(&lun->lun_lock); - - if (found == 0) { - /* - * This isn't really an error. It's entirely possible for - * the abort and command completion to cross on the wire. - * This is more of an informative/diagnostic error. - */ -#if 0 - printf("ctl_abort_task: ABORT sent for nonexistent I/O: " - "%u:%u:%u tag %d type %d\n", - io->io_hdr.nexus.initid, - io->io_hdr.nexus.targ_port, - io->io_hdr.nexus.targ_lun, io->taskio.tag_num, - io->taskio.tag_type); -#endif - } io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; return (0); } @@ -12590,11 +12505,6 @@ ctl_datamove_remote_write(union ctl_io *io) static int ctl_datamove_remote_dm_read_cb(union ctl_io *io) { -#if 0 - char str[256]; - char path_str[64]; - struct sbuf sb; -#endif uint32_t i; for (i = 0; i < io->scsiio.kern_sg_entries; i++) @@ -12603,23 +12513,6 @@ ctl_datamove_remote_dm_read_cb(union ctl_io *io) CTL_RSGL(io) = NULL; CTL_LSGL(io) = NULL; -#if 0 - scsi_path_string(io, path_str, sizeof(path_str)); - sbuf_new(&sb, str, sizeof(str), SBUF_FIXEDLEN); - sbuf_cat(&sb, path_str); - scsi_command_string(&io->scsiio, NULL, &sb); - sbuf_printf(&sb, "\n"); - sbuf_cat(&sb, path_str); - sbuf_printf(&sb, "Tag: 0x%04x, type %d\n", - io->scsiio.tag_num, io->scsiio.tag_type); - sbuf_cat(&sb, path_str); - sbuf_printf(&sb, "%s: flags %#x, status %#x\n", __func__, - io->io_hdr.flags, io->io_hdr.status); - sbuf_finish(&sb); - printk("%s", sbuf_data(&sb)); -#endif - - /* * The read is done, now we need to send status (good or bad) back * to the other side. @@ -12693,14 +12586,6 @@ ctl_datamove_remote_sgl_setup(union ctl_io *io) */ io->scsiio.kern_sg_entries = i; -#if 0 - printf("%s: kern_sg_entries = %d\n", __func__, - io->scsiio.kern_sg_entries); - for (i = 0; i < io->scsiio.kern_sg_entries; i++) - printf("%s: sg[%d] = %p, %lu\n", __func__, i, - local_sglist[i].addr, local_sglist[i].len); -#endif - return (retval); } @@ -12813,12 +12698,6 @@ ctl_datamove_remote_xfer(union ctl_io *io, unsigned co if (total_used >= io->scsiio.kern_data_len) rq->callback = callback; - -#if 0 - printf("%s: %s: local %p remote %p size %d\n", __func__, - (command == CTL_HA_DT_CMD_WRITE) ? "WRITE" : "READ", - rq->local, rq->remote, rq->size); -#endif isc_ret = ctl_dt_single(rq); if (isc_ret > CTL_HA_STATUS_SUCCESS) From owner-svn-src-stable-12@freebsd.org Wed Mar 13 20:27:50 2019 Return-Path: Delivered-To: svn-src-stable-12@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 F244A1541036; Wed, 13 Mar 2019 20:27:49 +0000 (UTC) (envelope-from mav@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 A41BD6ECDA; Wed, 13 Mar 2019 20:27:49 +0000 (UTC) (envelope-from mav@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 95698FAF2; Wed, 13 Mar 2019 20:27:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2DKRn6O040243; Wed, 13 Mar 2019 20:27:49 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2DKRmOM040239; Wed, 13 Mar 2019 20:27:48 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903132027.x2DKRmOM040239@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 13 Mar 2019 20:27:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345113 - stable/12/sys/cam/ctl X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cam/ctl X-SVN-Commit-Revision: 345113 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: A41BD6ECDA X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.981,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 20:27:50 -0000 Author: mav Date: Wed Mar 13 20:27:48 2019 New Revision: 345113 URL: https://svnweb.freebsd.org/changeset/base/345113 Log: MFC r344636: Refactor command ordering/blocking mechanism in CTL. Replace long per-LUN queue of blocked commands, scanned on each command completion and sometimes even twice, causing up to O(n^^2) processing cost, by much shorter per-command blocked queues, scanned only when respective command completes, and check only commands before the previous blocker, reducing cost to O(n). While there, unblock aborted commands to make them "complete" ASAP to be removed from the OOA queue and so not waste time ordering other commands against them. Aborted commands that were not sent to execution yet should have no visible side effects, so this is safe and easy optimization now, comparing to commands already in processing, which are a still pain. Together those two optimizations should fix quite pathological case, when due to backend slowness CTL accumulated many thousands of blocked requests, partially aborted by initiator and so supposedly not even existing, but still wasting CTL CPU time. Modified: stable/12/sys/cam/ctl/ctl.c stable/12/sys/cam/ctl/ctl_frontend_ioctl.c stable/12/sys/cam/ctl/ctl_io.h stable/12/sys/cam/ctl/ctl_private.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/ctl/ctl.c ============================================================================== --- stable/12/sys/cam/ctl/ctl.c Wed Mar 13 20:26:46 2019 (r345112) +++ stable/12/sys/cam/ctl/ctl.c Wed Mar 13 20:27:48 2019 (r345113) @@ -502,8 +502,11 @@ static ctl_action ctl_extent_check_seq(union ctl_io *i static ctl_action ctl_check_for_blockage(struct ctl_lun *lun, union ctl_io *pending_io, union ctl_io *ooa_io); static ctl_action ctl_check_ooa(struct ctl_lun *lun, union ctl_io *pending_io, - union ctl_io *starting_io); -static int ctl_check_blocked(struct ctl_lun *lun); + union ctl_io **starting_io); +static void ctl_try_unblock_io(struct ctl_lun *lun, union ctl_io *io, + bool skip); +static void ctl_try_unblock_others(struct ctl_lun *lun, union ctl_io *io, + bool skip); static int ctl_scsiio_lun_check(struct ctl_lun *lun, const struct ctl_cmd_entry *entry, struct ctl_scsiio *ctsio); @@ -2281,6 +2284,7 @@ ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio) union ctl_ha_msg msg_info; struct ctl_lun *lun; const struct ctl_cmd_entry *entry; + union ctl_io *bio; uint32_t targ_lun; targ_lun = ctsio->io_hdr.nexus.targ_mapped_lun; @@ -2339,12 +2343,11 @@ ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio) #endif TAILQ_INSERT_TAIL(&lun->ooa_queue, &ctsio->io_hdr, ooa_links); - switch (ctl_check_ooa(lun, (union ctl_io *)ctsio, - (union ctl_io *)TAILQ_PREV(&ctsio->io_hdr, ctl_ooaq, - ooa_links))) { + bio = (union ctl_io *)TAILQ_PREV(&ctsio->io_hdr, ctl_ooaq, ooa_links); + switch (ctl_check_ooa(lun, (union ctl_io *)ctsio, &bio)) { case CTL_ACTION_BLOCK: - ctsio->io_hdr.flags |= CTL_FLAG_BLOCKED; - TAILQ_INSERT_TAIL(&lun->blocked_queue, &ctsio->io_hdr, + ctsio->io_hdr.blocker = bio; + TAILQ_INSERT_TAIL(&bio->io_hdr.blocked_queue, &ctsio->io_hdr, blocked_links); mtx_unlock(&lun->lun_lock); break; @@ -2426,7 +2429,7 @@ ctl_ioctl_fill_ooa(struct ctl_lun *lun, uint32_t *cur_ #endif bcopy(io->scsiio.cdb, entry->cdb, io->scsiio.cdb_len); entry->cdb_len = io->scsiio.cdb_len; - if (io->io_hdr.flags & CTL_FLAG_BLOCKED) + if (io->io_hdr.blocker != NULL) entry->cmd_flags |= CTL_OOACMD_FLAG_BLOCKED; if (io->io_hdr.flags & CTL_FLAG_DMA_INPROG) @@ -3891,6 +3894,7 @@ ctl_alloc_io(void *pool_ref) if (io != NULL) { io->io_hdr.pool = pool_ref; CTL_SOFTC(io) = pool->ctl_softc; + TAILQ_INIT(&io->io_hdr.blocked_queue); } return (io); } @@ -3905,6 +3909,7 @@ ctl_alloc_io_nowait(void *pool_ref) if (io != NULL) { io->io_hdr.pool = pool_ref; CTL_SOFTC(io) = pool->ctl_softc; + TAILQ_INIT(&io->io_hdr.blocked_queue); } return (io); } @@ -3936,6 +3941,7 @@ ctl_zero_io(union ctl_io *io) memset(io, 0, sizeof(*io)); io->io_hdr.pool = pool; CTL_SOFTC(io) = pool->ctl_softc; + TAILQ_INIT(&io->io_hdr.blocked_queue); } int @@ -4698,7 +4704,6 @@ fail: lun->last_busy = getsbinuptime(); #endif TAILQ_INIT(&lun->ooa_queue); - TAILQ_INIT(&lun->blocked_queue); STAILQ_INIT(&lun->error_list); lun->ie_reported = 1; callout_init_mtx(&lun->ie_callout, &lun->lun_lock, 0); @@ -5872,7 +5877,7 @@ ctl_unmap(struct ctl_scsiio *ctsio) ptrlen->ptr = (void *)buf; ptrlen->len = len; ptrlen->flags = byte2; - ctl_check_blocked(lun); + ctl_try_unblock_others(lun, (union ctl_io *)ctsio, FALSE); mtx_unlock(&lun->lun_lock); retval = lun->backend->config_write((union ctl_io *)ctsio); @@ -10761,6 +10766,14 @@ ctl_check_for_blockage(struct ctl_lun *lun, union ctl_ const ctl_serialize_action *serialize_row; /* + * Aborted commands are not going to be executed and may even + * not report completion, so we don't care about their order. + * Let them complete ASAP to clean the OOA queue. + */ + if (pending_io->io_hdr.flags & CTL_FLAG_ABORT) + return (CTL_ACTION_SKIP); + + /* * The initiator attempted multiple untagged commands at the same * time. Can't do that. */ @@ -10890,7 +10903,7 @@ ctl_check_for_blockage(struct ctl_lun *lun, union ctl_ */ static ctl_action ctl_check_ooa(struct ctl_lun *lun, union ctl_io *pending_io, - union ctl_io *starting_io) + union ctl_io **starting_io) { union ctl_io *ooa_io; ctl_action action; @@ -10903,150 +10916,152 @@ ctl_check_ooa(struct ctl_lun *lun, union ctl_io *pendi * queue. If starting_io is NULL, we'll just end up returning * CTL_ACTION_PASS. */ - for (ooa_io = starting_io; ooa_io != NULL; + for (ooa_io = *starting_io; ooa_io != NULL; ooa_io = (union ctl_io *)TAILQ_PREV(&ooa_io->io_hdr, ctl_ooaq, ooa_links)){ - - /* - * This routine just checks to see whether - * cur_blocked is blocked by ooa_io, which is ahead - * of it in the queue. It doesn't queue/dequeue - * cur_blocked. - */ action = ctl_check_for_blockage(lun, pending_io, ooa_io); - switch (action) { - case CTL_ACTION_BLOCK: - case CTL_ACTION_OVERLAP: - case CTL_ACTION_OVERLAP_TAG: - case CTL_ACTION_SKIP: - case CTL_ACTION_ERROR: + if (action != CTL_ACTION_PASS) { + *starting_io = ooa_io; return (action); - break; /* NOTREACHED */ - case CTL_ACTION_PASS: - break; - default: - panic("%s: Invalid action %d\n", __func__, action); } } + *starting_io = NULL; return (CTL_ACTION_PASS); } /* - * Assumptions: - * - An I/O has just completed, and has been removed from the per-LUN OOA - * queue, so some items on the blocked queue may now be unblocked. + * Try to unblock the specified I/O. + * + * skip parameter allows explicitly skip present blocker of the I/O, + * starting from the previous one on OOA queue. It can be used when + * we know for sure that the blocker I/O does no longer count. */ -static int -ctl_check_blocked(struct ctl_lun *lun) +static void +ctl_try_unblock_io(struct ctl_lun *lun, union ctl_io *io, bool skip) { struct ctl_softc *softc = lun->ctl_softc; - union ctl_io *cur_blocked, *next_blocked; + union ctl_io *bio, *obio; + const struct ctl_cmd_entry *entry; + union ctl_ha_msg msg_info; + ctl_action action; mtx_assert(&lun->lun_lock, MA_OWNED); - /* - * Run forward from the head of the blocked queue, checking each - * entry against the I/Os prior to it on the OOA queue to see if - * there is still any blockage. - * - * We cannot use the TAILQ_FOREACH() macro, because it can't deal - * with our removing a variable on it while it is traversing the - * list. - */ - for (cur_blocked = (union ctl_io *)TAILQ_FIRST(&lun->blocked_queue); - cur_blocked != NULL; cur_blocked = next_blocked) { - union ctl_io *prev_ooa; - ctl_action action; + if (io->io_hdr.blocker == NULL) + return; - next_blocked = (union ctl_io *)TAILQ_NEXT(&cur_blocked->io_hdr, - blocked_links); + obio = bio = io->io_hdr.blocker; + if (skip) + bio = (union ctl_io *)TAILQ_PREV(&bio->io_hdr, ctl_ooaq, + ooa_links); + action = ctl_check_ooa(lun, io, &bio); + if (action == CTL_ACTION_BLOCK) { + /* Still blocked, but may be by different I/O now. */ + if (bio != obio) { + TAILQ_REMOVE(&obio->io_hdr.blocked_queue, + &io->io_hdr, blocked_links); + TAILQ_INSERT_TAIL(&bio->io_hdr.blocked_queue, + &io->io_hdr, blocked_links); + io->io_hdr.blocker = bio; + } + return; + } - prev_ooa = (union ctl_io *)TAILQ_PREV(&cur_blocked->io_hdr, - ctl_ooaq, ooa_links); + /* No longer blocked, one way or another. */ + TAILQ_REMOVE(&obio->io_hdr.blocked_queue, &io->io_hdr, blocked_links); + io->io_hdr.blocker = NULL; + switch (action) { + case CTL_ACTION_OVERLAP: + ctl_set_overlapped_cmd(&io->scsiio); + goto error; + case CTL_ACTION_OVERLAP_TAG: + ctl_set_overlapped_tag(&io->scsiio, + io->scsiio.tag_num & 0xff); + goto error; + case CTL_ACTION_PASS: + case CTL_ACTION_SKIP: + + /* Serializing commands from the other SC retire there. */ + if ((io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC) && + (softc->ha_mode != CTL_HA_MODE_XFER)) { + io->io_hdr.flags &= ~CTL_FLAG_IO_ACTIVE; + msg_info.hdr.original_sc = io->io_hdr.remote_io; + msg_info.hdr.serializing_sc = io; + msg_info.hdr.msg_type = CTL_MSG_R2R; + ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, + sizeof(msg_info.hdr), M_NOWAIT); + break; + } + /* - * If cur_blocked happens to be the first item in the OOA - * queue now, prev_ooa will be NULL, and the action - * returned will just be CTL_ACTION_PASS. + * Check this I/O for LUN state changes that may have happened + * while this command was blocked. The LUN state may have been + * changed by a command ahead of us in the queue. */ - action = ctl_check_ooa(lun, cur_blocked, prev_ooa); - - switch (action) { - case CTL_ACTION_BLOCK: - /* Nothing to do here, still blocked */ + entry = ctl_get_cmd_entry(&io->scsiio, NULL); + if (ctl_scsiio_lun_check(lun, entry, &io->scsiio) != 0) { + ctl_done(io); break; - case CTL_ACTION_OVERLAP: - case CTL_ACTION_OVERLAP_TAG: - /* - * This shouldn't happen! In theory we've already - * checked this command for overlap... - */ - break; - case CTL_ACTION_PASS: - case CTL_ACTION_SKIP: { - const struct ctl_cmd_entry *entry; + } - /* - * The skip case shouldn't happen, this transaction - * should have never made it onto the blocked queue. - */ - /* - * This I/O is no longer blocked, we can remove it - * from the blocked queue. Since this is a TAILQ - * (doubly linked list), we can do O(1) removals - * from any place on the list. - */ - TAILQ_REMOVE(&lun->blocked_queue, &cur_blocked->io_hdr, - blocked_links); - cur_blocked->io_hdr.flags &= ~CTL_FLAG_BLOCKED; + io->io_hdr.flags |= CTL_FLAG_IS_WAS_ON_RTR; + ctl_enqueue_rtr(io); + break; + case CTL_ACTION_ERROR: + default: + ctl_set_internal_failure(&io->scsiio, + /*sks_valid*/ 0, + /*retry_count*/ 0); - if ((softc->ha_mode != CTL_HA_MODE_XFER) && - (cur_blocked->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC)){ - /* - * Need to send IO back to original side to - * run - */ - union ctl_ha_msg msg_info; +error: + /* Serializing commands from the other SC are done here. */ + if ((io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC) && + (softc->ha_mode != CTL_HA_MODE_XFER)) { + ctl_try_unblock_others(lun, io, TRUE); + TAILQ_REMOVE(&lun->ooa_queue, &io->io_hdr, ooa_links); - cur_blocked->io_hdr.flags &= ~CTL_FLAG_IO_ACTIVE; - msg_info.hdr.original_sc = - cur_blocked->io_hdr.remote_io; - msg_info.hdr.serializing_sc = cur_blocked; - msg_info.hdr.msg_type = CTL_MSG_R2R; - ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, - sizeof(msg_info.hdr), M_NOWAIT); - break; - } - entry = ctl_get_cmd_entry(&cur_blocked->scsiio, NULL); - - /* - * Check this I/O for LUN state changes that may - * have happened while this command was blocked. - * The LUN state may have been changed by a command - * ahead of us in the queue, so we need to re-check - * for any states that can be caused by SCSI - * commands. - */ - if (ctl_scsiio_lun_check(lun, entry, - &cur_blocked->scsiio) == 0) { - cur_blocked->io_hdr.flags |= - CTL_FLAG_IS_WAS_ON_RTR; - ctl_enqueue_rtr(cur_blocked); - } else - ctl_done(cur_blocked); + ctl_copy_sense_data_back(io, &msg_info); + msg_info.hdr.original_sc = io->io_hdr.remote_io; + msg_info.hdr.serializing_sc = NULL; + msg_info.hdr.msg_type = CTL_MSG_BAD_JUJU; + ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, + sizeof(msg_info.scsi), M_WAITOK); + ctl_free_io(io); break; } - default: - /* - * This probably shouldn't happen -- we shouldn't - * get CTL_ACTION_ERROR, or anything else. - */ - break; - } + + ctl_done(io); + break; } +} - return (CTL_RETVAL_COMPLETE); +/* + * Try to unblock I/Os blocked by the specified I/O. + * + * skip parameter allows explicitly skip the specified I/O as blocker, + * starting from the previous one on the OOA queue. It can be used when + * we know for sure that the specified I/O does no longer count (done). + * It has to be still on OOA queue though so that we know where to start. + */ +static void +ctl_try_unblock_others(struct ctl_lun *lun, union ctl_io *bio, bool skip) +{ + union ctl_io *io, *next_io; + + mtx_assert(&lun->lun_lock, MA_OWNED); + + for (io = (union ctl_io *)TAILQ_FIRST(&bio->io_hdr.blocked_queue); + io != NULL; io = next_io) { + next_io = (union ctl_io *)TAILQ_NEXT(&io->io_hdr, blocked_links); + + KASSERT(io->io_hdr.blocker != NULL, + ("I/O %p on blocked list without blocker", io)); + ctl_try_unblock_io(lun, io, skip); + } + KASSERT(!skip || TAILQ_EMPTY(&bio->io_hdr.blocked_queue), + ("blocked_queue is not empty after skipping %p", bio)); } /* @@ -11214,6 +11229,8 @@ ctl_failover_lun(union ctl_io *rio) if (io->flags & CTL_FLAG_IO_ACTIVE) { io->flags |= CTL_FLAG_ABORT; io->flags |= CTL_FLAG_FAILOVER; + ctl_try_unblock_io(lun, + (union ctl_io *)io, FALSE); } else { /* This can be only due to DATAMOVE */ io->msg_type = CTL_MSG_DATAMOVE_DONE; io->flags &= ~CTL_FLAG_DMA_INPROG; @@ -11221,7 +11238,7 @@ ctl_failover_lun(union ctl_io *rio) io->port_status = 31340; ctl_enqueue_isc((union ctl_io *)io); } - } + } else /* We are slave */ if (io->flags & CTL_FLAG_SENT_2OTHER_SC) { io->flags &= ~CTL_FLAG_SENT_2OTHER_SC; @@ -11235,23 +11252,19 @@ ctl_failover_lun(union ctl_io *rio) } } } else { /* SERIALIZE modes */ - TAILQ_FOREACH_SAFE(io, &lun->blocked_queue, blocked_links, - next_io) { - /* We are master */ - if (io->flags & CTL_FLAG_FROM_OTHER_SC) { - TAILQ_REMOVE(&lun->blocked_queue, io, - blocked_links); - io->flags &= ~CTL_FLAG_BLOCKED; - TAILQ_REMOVE(&lun->ooa_queue, io, ooa_links); - ctl_free_io((union ctl_io *)io); - } - } TAILQ_FOREACH_SAFE(io, &lun->ooa_queue, ooa_links, next_io) { /* We are master */ if (io->flags & CTL_FLAG_FROM_OTHER_SC) { + if (io->blocker != NULL) { + TAILQ_REMOVE(&io->blocker->io_hdr.blocked_queue, + io, blocked_links); + io->blocker = NULL; + } + ctl_try_unblock_others(lun, (union ctl_io *)io, + TRUE); TAILQ_REMOVE(&lun->ooa_queue, io, ooa_links); ctl_free_io((union ctl_io *)io); - } + } else /* We are slave */ if (io->flags & CTL_FLAG_SENT_2OTHER_SC) { io->flags &= ~CTL_FLAG_SENT_2OTHER_SC; @@ -11262,7 +11275,6 @@ ctl_failover_lun(union ctl_io *rio) } } } - ctl_check_blocked(lun); } mtx_unlock(&lun->lun_lock); } @@ -11272,6 +11284,7 @@ ctl_scsiio_precheck(struct ctl_softc *softc, struct ct { struct ctl_lun *lun; const struct ctl_cmd_entry *entry; + union ctl_io *bio; uint32_t initidx, targ_lun; int retval = 0; @@ -11447,12 +11460,11 @@ ctl_scsiio_precheck(struct ctl_softc *softc, struct ct return (retval); } - switch (ctl_check_ooa(lun, (union ctl_io *)ctsio, - (union ctl_io *)TAILQ_PREV(&ctsio->io_hdr, - ctl_ooaq, ooa_links))) { + bio = (union ctl_io *)TAILQ_PREV(&ctsio->io_hdr, ctl_ooaq, ooa_links); + switch (ctl_check_ooa(lun, (union ctl_io *)ctsio, &bio)) { case CTL_ACTION_BLOCK: - ctsio->io_hdr.flags |= CTL_FLAG_BLOCKED; - TAILQ_INSERT_TAIL(&lun->blocked_queue, &ctsio->io_hdr, + ctsio->io_hdr.blocker = bio; + TAILQ_INSERT_TAIL(&bio->io_hdr.blocked_queue, &ctsio->io_hdr, blocked_links); mtx_unlock(&lun->lun_lock); return (retval); @@ -11665,6 +11677,7 @@ ctl_do_lun_reset(struct ctl_lun *lun, uint32_t initidx for (xio = (union ctl_io *)TAILQ_FIRST(&lun->ooa_queue); xio != NULL; xio = (union ctl_io *)TAILQ_NEXT(&xio->io_hdr, ooa_links)) { xio->io_hdr.flags |= CTL_FLAG_ABORT | CTL_FLAG_ABORT_STATUS; + ctl_try_unblock_io(lun, xio, FALSE); } /* Clear CA. */ for (i = 0; i < ctl_max_ports; i++) { @@ -11763,6 +11776,7 @@ ctl_abort_tasks_lun(struct ctl_lun *lun, uint32_t targ ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, sizeof(msg_info.task), M_NOWAIT); } + ctl_try_unblock_io(lun, xio, FALSE); } } } @@ -11935,6 +11949,7 @@ ctl_abort_task(union ctl_io *io) ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, sizeof(msg_info.task), M_NOWAIT); } + ctl_try_unblock_io(lun, xio, FALSE); } } mtx_unlock(&lun->lun_lock); @@ -12110,8 +12125,8 @@ ctl_handle_isc(union ctl_io *io) break; } mtx_lock(&lun->lun_lock); + ctl_try_unblock_others(lun, io, TRUE); TAILQ_REMOVE(&lun->ooa_queue, &io->io_hdr, ooa_links); - ctl_check_blocked(lun); mtx_unlock(&lun->lun_lock); ctl_free_io(io); break; @@ -12935,6 +12950,13 @@ ctl_process_done(union ctl_io *io) } /* + * Run through the blocked queue of this I/O and see if anything + * can be unblocked, now that this I/O is done and will be removed. + * We need to do it before removal to have OOA position to start. + */ + ctl_try_unblock_others(lun, io, TRUE); + + /* * Remove this from the OOA queue. */ TAILQ_REMOVE(&lun->ooa_queue, &io->io_hdr, ooa_links); @@ -12944,12 +12966,6 @@ ctl_process_done(union ctl_io *io) #endif /* - * Run through the blocked queue on this LUN and see if anything - * has become unblocked, now that this transaction is done. - */ - ctl_check_blocked(lun); - - /* * If the LUN has been invalidated, free it if there is nothing * left on its OOA queue. */ @@ -13104,7 +13120,7 @@ ctl_serseq_done(union ctl_io *io) return; mtx_lock(&lun->lun_lock); io->io_hdr.flags |= CTL_FLAG_SERSEQ_DONE; - ctl_check_blocked(lun); + ctl_try_unblock_others(lun, io, FALSE); mtx_unlock(&lun->lun_lock); } Modified: stable/12/sys/cam/ctl/ctl_frontend_ioctl.c ============================================================================== --- stable/12/sys/cam/ctl/ctl_frontend_ioctl.c Wed Mar 13 20:26:46 2019 (r345112) +++ stable/12/sys/cam/ctl/ctl_frontend_ioctl.c Wed Mar 13 20:27:48 2019 (r345113) @@ -620,6 +620,7 @@ ctl_ioctl_io(struct cdev *dev, u_long cmd, caddr_t add memcpy(io, (void *)addr, sizeof(*io)); io->io_hdr.pool = pool_tmp; CTL_SOFTC(io) = sc_tmp; + TAILQ_INIT(&io->io_hdr.blocked_queue); /* * No status yet, so make sure the status is set properly. Modified: stable/12/sys/cam/ctl/ctl_io.h ============================================================================== --- stable/12/sys/cam/ctl/ctl_io.h Wed Mar 13 20:26:46 2019 (r345112) +++ stable/12/sys/cam/ctl/ctl_io.h Wed Mar 13 20:27:48 2019 (r345113) @@ -87,7 +87,6 @@ typedef enum { CTL_FLAG_DO_AUTOSENSE = 0x00000020, /* grab sense info */ CTL_FLAG_USER_REQ = 0x00000040, /* request came from userland */ CTL_FLAG_ALLOCATED = 0x00000100, /* data space allocated */ - CTL_FLAG_BLOCKED = 0x00000200, /* on the blocked queue */ CTL_FLAG_ABORT_STATUS = 0x00000400, /* return TASK ABORTED status */ CTL_FLAG_ABORT = 0x00000800, /* this I/O should be aborted */ CTL_FLAG_DMA_INPROG = 0x00001000, /* DMA in progress */ @@ -239,14 +238,13 @@ struct ctl_io_hdr { #endif /* CTL_TIME_IO */ uint32_t num_dmas; /* Number of DMAs */ union ctl_io *remote_io; /* I/O counterpart on remote HA side */ - void *pad1; + union ctl_io *blocker; /* I/O blocking this one */ void *pool; /* I/O pool */ union ctl_priv ctl_private[CTL_NUM_PRIV];/* CTL private area */ - void *pad2; - void *pad3; + TAILQ_HEAD(, ctl_io_hdr) blocked_queue; /* I/Os blocked by this one */ STAILQ_ENTRY(ctl_io_hdr) links; /* linked list pointer */ - TAILQ_ENTRY(ctl_io_hdr) ooa_links; - TAILQ_ENTRY(ctl_io_hdr) blocked_links; + TAILQ_ENTRY(ctl_io_hdr) ooa_links; /* ooa_queue links */ + TAILQ_ENTRY(ctl_io_hdr) blocked_links; /* blocked_queue links */ }; typedef enum { Modified: stable/12/sys/cam/ctl/ctl_private.h ============================================================================== --- stable/12/sys/cam/ctl/ctl_private.h Wed Mar 13 20:26:46 2019 (r345112) +++ stable/12/sys/cam/ctl/ctl_private.h Wed Mar 13 20:27:48 2019 (r345113) @@ -390,7 +390,6 @@ struct ctl_lun { sbintime_t last_busy; #endif TAILQ_HEAD(ctl_ooaq, ctl_io_hdr) ooa_queue; - TAILQ_HEAD(ctl_blockq,ctl_io_hdr) blocked_queue; STAILQ_ENTRY(ctl_lun) links; struct scsi_sense_data **pending_sense; ctl_ua_type **pending_ua; From owner-svn-src-stable-12@freebsd.org Wed Mar 13 20:28:49 2019 Return-Path: Delivered-To: svn-src-stable-12@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 CB0A415410F3; Wed, 13 Mar 2019 20:28:49 +0000 (UTC) (envelope-from mav@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 6D20E6EF04; Wed, 13 Mar 2019 20:28:49 +0000 (UTC) (envelope-from mav@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 5B691FAF4; Wed, 13 Mar 2019 20:28:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2DKSntv040398; Wed, 13 Mar 2019 20:28:49 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2DKSnVp040397; Wed, 13 Mar 2019 20:28:49 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903132028.x2DKSnVp040397@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 13 Mar 2019 20:28:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345115 - stable/12/usr.bin/ctlstat X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/usr.bin/ctlstat X-SVN-Commit-Revision: 345115 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6D20E6EF04 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 20:28:50 -0000 Author: mav Date: Wed Mar 13 20:28:48 2019 New Revision: 345115 URL: https://svnweb.freebsd.org/changeset/base/345115 Log: MFC r344844: Flush stdout after each iteration. Without this, if output is redirected from the console, it is buffered for too long, making tool quite unusable. Modified: stable/12/usr.bin/ctlstat/ctlstat.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/ctlstat/ctlstat.c ============================================================================== --- stable/12/usr.bin/ctlstat/ctlstat.c Wed Mar 13 20:28:07 2019 (r345114) +++ stable/12/usr.bin/ctlstat/ctlstat.c Wed Mar 13 20:28:48 2019 (r345115) @@ -717,6 +717,7 @@ main(int argc, char **argv) } fprintf(stdout, "\n"); + fflush(stdout); ctx.flags &= ~CTLSTAT_FLAG_FIRST_RUN; if (count != 1) sleep(waittime); From owner-svn-src-stable-12@freebsd.org Wed Mar 13 21:53:13 2019 Return-Path: Delivered-To: svn-src-stable-12@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 6FAC31543042; Wed, 13 Mar 2019 21:53:13 +0000 (UTC) (envelope-from jilles@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 1084C72248; Wed, 13 Mar 2019 21:53:13 +0000 (UTC) (envelope-from jilles@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 DFB8B18A61; Wed, 13 Mar 2019 21:53:12 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2DLrCqf087288; Wed, 13 Mar 2019 21:53:12 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2DLrB2N087278; Wed, 13 Mar 2019 21:53:11 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201903132153.x2DLrB2N087278@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Wed, 13 Mar 2019 21:53:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345117 - in stable/12/bin/sh: . tests/expansion X-SVN-Group: stable-12 X-SVN-Commit-Author: jilles X-SVN-Commit-Paths: in stable/12/bin/sh: . tests/expansion X-SVN-Commit-Revision: 345117 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1084C72248 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2019 21:53:13 -0000 Author: jilles Date: Wed Mar 13 21:53:10 2019 New Revision: 345117 URL: https://svnweb.freebsd.org/changeset/base/345117 Log: MFC r342880,r343981,r344902: sh: Fix $((-9223372036854775808)) Since $((9223372036854775808)) overflows, $((-9223372036854775808)) was not parsed correctly (with x=-9223372036854775808, $((x)) already worked, since that parses the value with the minus sign in one step). Values further from zero are still clamped to 9223372036854775807. Also, allow the full 64 bits in octal and hexadecimal. Added: stable/12/bin/sh/tests/expansion/arith15.0 - copied, changed from r342880, head/bin/sh/tests/expansion/arith15.0 stable/12/bin/sh/tests/expansion/arith16.0 - copied unchanged from r343981, head/bin/sh/tests/expansion/arith16.0 stable/12/bin/sh/tests/expansion/arith17.0 - copied unchanged from r343981, head/bin/sh/tests/expansion/arith17.0 Modified: stable/12/bin/sh/arith_yacc.c stable/12/bin/sh/arith_yacc.h stable/12/bin/sh/arith_yylex.c stable/12/bin/sh/shell.h stable/12/bin/sh/tests/expansion/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/bin/sh/arith_yacc.c ============================================================================== --- stable/12/bin/sh/arith_yacc.c Wed Mar 13 20:29:10 2019 (r345116) +++ stable/12/bin/sh/arith_yacc.c Wed Mar 13 21:53:10 2019 (r345117) @@ -104,7 +104,7 @@ static arith_t arith_lookupvarint(char *varname) if (str == NULL || *str == '\0') str = "0"; errno = 0; - result = strtoarith_t(str, &p, 0); + result = strtoarith_t(str, &p); if (errno != 0 || *p != '\0') yyerror("variable conversion error"); return result; Modified: stable/12/bin/sh/arith_yacc.h ============================================================================== --- stable/12/bin/sh/arith_yacc.h Wed Mar 13 20:29:10 2019 (r345116) +++ stable/12/bin/sh/arith_yacc.h Wed Mar 13 21:53:10 2019 (r345117) @@ -90,4 +90,5 @@ union yystype { extern union yystype yylval; +arith_t strtoarith_t(const char *restrict nptr, char **restrict endptr); int yylex(void); Modified: stable/12/bin/sh/arith_yylex.c ============================================================================== --- stable/12/bin/sh/arith_yylex.c Wed Mar 13 20:29:10 2019 (r345116) +++ stable/12/bin/sh/arith_yylex.c Wed Mar 13 21:53:10 2019 (r345117) @@ -35,6 +35,8 @@ #include __FBSDID("$FreeBSD$"); +#include +#include #include #include #include @@ -50,6 +52,32 @@ __FBSDID("$FreeBSD$"); #error Arithmetic tokens are out of order. #endif +arith_t +strtoarith_t(const char *restrict nptr, char **restrict endptr) +{ + arith_t val; + + while (isspace((unsigned char)*nptr)) + nptr++; + switch (*nptr) { + case '-': + return strtoimax(nptr, endptr, 0); + case '0': + return (arith_t)strtoumax(nptr, endptr, 0); + default: + val = (arith_t)strtoumax(nptr, endptr, 0); + if (val >= 0) + return val; + else if (val == ARITH_MIN) { + errno = ERANGE; + return ARITH_MIN; + } else { + errno = ERANGE; + return ARITH_MAX; + } + } +} + int yylex(void) { @@ -78,7 +106,7 @@ yylex(void) case '7': case '8': case '9': - yylval.val = strtoarith_t(buf, &end, 0); + yylval.val = strtoarith_t(buf, &end); arith_buf = end; return ARITH_NUM; case 'A': Modified: stable/12/bin/sh/shell.h ============================================================================== --- stable/12/bin/sh/shell.h Wed Mar 13 20:29:10 2019 (r345116) +++ stable/12/bin/sh/shell.h Wed Mar 13 21:53:10 2019 (r345117) @@ -59,8 +59,6 @@ */ typedef intmax_t arith_t; #define ARITH_FORMAT_STR "%" PRIdMAX -#define atoarith_t(arg) strtoimax(arg, NULL, 0) -#define strtoarith_t(nptr, endptr, base) strtoimax(nptr, endptr, base) #define ARITH_MIN INTMAX_MIN #define ARITH_MAX INTMAX_MAX Modified: stable/12/bin/sh/tests/expansion/Makefile ============================================================================== --- stable/12/bin/sh/tests/expansion/Makefile Wed Mar 13 20:29:10 2019 (r345116) +++ stable/12/bin/sh/tests/expansion/Makefile Wed Mar 13 21:53:10 2019 (r345117) @@ -21,6 +21,9 @@ ${PACKAGE}FILES+= arith11.0 ${PACKAGE}FILES+= arith12.0 ${PACKAGE}FILES+= arith13.0 ${PACKAGE}FILES+= arith14.0 +${PACKAGE}FILES+= arith15.0 +${PACKAGE}FILES+= arith16.0 +${PACKAGE}FILES+= arith17.0 ${PACKAGE}FILES+= assign1.0 ${PACKAGE}FILES+= cmdsubst1.0 ${PACKAGE}FILES+= cmdsubst2.0 Copied and modified: stable/12/bin/sh/tests/expansion/arith15.0 (from r342880, head/bin/sh/tests/expansion/arith15.0) ============================================================================== --- head/bin/sh/tests/expansion/arith15.0 Wed Jan 9 09:36:54 2019 (r342880, copy source) +++ stable/12/bin/sh/tests/expansion/arith15.0 Wed Mar 13 21:53:10 2019 (r345117) @@ -12,9 +12,9 @@ check() { XXX=-9223372036854775808 check "XXX" -9223372036854775808 check "XXX - 1" 9223372036854775807 -check $(($XXX - 1)) 9223372036854775807 -check $(($XXX - 2)) 9223372036854775806 -check $((0x8000000000000000 == 0x7fffffffffffffff)) \ +check "$XXX - 1" 9223372036854775807 +check "$XXX - 2" 9223372036854775806 +check "0x8000000000000000 == 0x7fffffffffffffff" \ 0 exit $((failures != 0)) Copied: stable/12/bin/sh/tests/expansion/arith16.0 (from r343981, head/bin/sh/tests/expansion/arith16.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/bin/sh/tests/expansion/arith16.0 Wed Mar 13 21:53:10 2019 (r345117, copy of r343981, head/bin/sh/tests/expansion/arith16.0) @@ -0,0 +1,26 @@ +# $FreeBSD$ + +failures=0 + +for x in \ + 0x10000000000000000 \ + -0x8000000000000001 \ + 0xfffffffffffffffffffffffffffffffff \ + -0xfffffffffffffffffffffffffffffffff \ + 02000000000000000000000 \ + 9223372036854775808 \ + 9223372036854775809 \ + -9223372036854775809 \ + 9999999999999999999999999 \ + -9999999999999999999999999 +do + msg=$({ + v=$((x)) || : + } 3>&1 >&2 2>&3 3>&-) + r=$? + if [ "$r" = 0 ] || [ -z "$msg" ]; then + printf 'Failed: %s\n' "$x" + : $((failures += 1)) + fi +done +exit $((failures > 0)) Copied: stable/12/bin/sh/tests/expansion/arith17.0 (from r343981, head/bin/sh/tests/expansion/arith17.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/bin/sh/tests/expansion/arith17.0 Wed Mar 13 21:53:10 2019 (r345117, copy of r343981, head/bin/sh/tests/expansion/arith17.0) @@ -0,0 +1,3 @@ +# $FreeBSD$ + +[ $((9223372036854775809)) -gt 0 ] From owner-svn-src-stable-12@freebsd.org Thu Mar 14 00:57:36 2019 Return-Path: Delivered-To: svn-src-stable-12@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 57F511546968; Thu, 14 Mar 2019 00:57:36 +0000 (UTC) (envelope-from mav@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 EF6E6802F2; Thu, 14 Mar 2019 00:57:35 +0000 (UTC) (envelope-from mav@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 B82A81A8E1; Thu, 14 Mar 2019 00:57:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2E0vZSb082555; Thu, 14 Mar 2019 00:57:35 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2E0vZs5082554; Thu, 14 Mar 2019 00:57:35 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903140057.x2E0vZs5082554@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Mar 2019 00:57:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345120 - stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 345120 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EF6E6802F2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Mar 2019 00:57:36 -0000 Author: mav Date: Thu Mar 14 00:57:35 2019 New Revision: 345120 URL: https://svnweb.freebsd.org/changeset/base/345120 Log: MFC r344866: Add respective tunables to few ZFS sysctls. Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu Mar 14 00:12:59 2019 (r345119) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Thu Mar 14 00:57:35 2019 (r345120) @@ -1420,22 +1420,22 @@ boolean_t l2arc_noprefetch = B_TRUE; /* don't cache p boolean_t l2arc_feed_again = B_TRUE; /* turbo warmup */ boolean_t l2arc_norw = B_TRUE; /* no reads during writes */ -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, CTLFLAG_RW, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, CTLFLAG_RWTUN, &l2arc_write_max, 0, "max write size"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, CTLFLAG_RW, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, CTLFLAG_RWTUN, &l2arc_write_boost, 0, "extra write during warmup"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, CTLFLAG_RW, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, CTLFLAG_RWTUN, &l2arc_headroom, 0, "number of dev writes"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, CTLFLAG_RW, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, CTLFLAG_RWTUN, &l2arc_feed_secs, 0, "interval seconds"); -SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, CTLFLAG_RW, +SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, CTLFLAG_RWTUN, &l2arc_feed_min_ms, 0, "min interval milliseconds"); -SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_noprefetch, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_noprefetch, CTLFLAG_RWTUN, &l2arc_noprefetch, 0, "don't cache prefetch bufs"); -SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_feed_again, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_feed_again, CTLFLAG_RWTUN, &l2arc_feed_again, 0, "turbo warmup"); -SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_norw, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_norw, CTLFLAG_RWTUN, &l2arc_norw, 0, "no reads during writes"); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_size, CTLFLAG_RD, Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c Thu Mar 14 00:12:59 2019 (r345119) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c Thu Mar 14 00:57:35 2019 (r345120) @@ -152,7 +152,7 @@ static boolean_t vdev_trim_on_init = B_TRUE; SYSCTL_DECL(_vfs_zfs_vdev); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, trim_on_init, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, trim_on_init, CTLFLAG_RWTUN, &vdev_trim_on_init, 0, "Enable/disable full vdev trim on initialisation"); /* From owner-svn-src-stable-12@freebsd.org Thu Mar 14 00:58:40 2019 Return-Path: Delivered-To: svn-src-stable-12@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 BE8D61546A28; Thu, 14 Mar 2019 00:58:40 +0000 (UTC) (envelope-from mav@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 58F0980539; Thu, 14 Mar 2019 00:58:40 +0000 (UTC) (envelope-from mav@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 1B3901A8E4; Thu, 14 Mar 2019 00:58:40 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2E0wdVn082711; Thu, 14 Mar 2019 00:58:39 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2E0wdqD082710; Thu, 14 Mar 2019 00:58:39 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201903140058.x2E0wdqD082710@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 14 Mar 2019 00:58:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345122 - stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 345122 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 58F0980539 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Mar 2019 00:58:40 -0000 Author: mav Date: Thu Mar 14 00:58:39 2019 New Revision: 345122 URL: https://svnweb.freebsd.org/changeset/base/345122 Log: MFC r344903: Improve entropy for ZFS taskqueue selection. I just found that at least on Skylake CPUs cpu_ticks() never returns odd values, only even, and possibly has even bigger step (176/2?), that makes its lower bits very bad entropy source, leaving half of taskqueues unused. Switch to sbinuptime(), closer to upstreams, mitigates the problem by the rate conversion working as kind of hash function. In case that is somehow not enough (timer rate is too low or too divisible) mix in curcpu. Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Thu Mar 14 00:57:54 2019 (r345121) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Thu Mar 14 00:58:39 2019 (r345122) @@ -1070,7 +1070,8 @@ spa_taskq_dispatch_ent(spa_t *spa, zio_type_t t, zio_t tq = tqs->stqs_taskq[0]; } else { #ifdef _KERNEL - tq = tqs->stqs_taskq[cpu_ticks() % tqs->stqs_count]; + tq = tqs->stqs_taskq[(u_int)(sbinuptime() + curcpu) % + tqs->stqs_count]; #else tq = tqs->stqs_taskq[gethrtime() % tqs->stqs_count]; #endif From owner-svn-src-stable-12@freebsd.org Thu Mar 14 02:46:06 2019 Return-Path: Delivered-To: svn-src-stable-12@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 5FDFF15250E0; Thu, 14 Mar 2019 02:46:06 +0000 (UTC) (envelope-from sef@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 0E54384E6A; Thu, 14 Mar 2019 02:46:06 +0000 (UTC) (envelope-from sef@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 001A41BF30; Thu, 14 Mar 2019 02:46:05 +0000 (UTC) (envelope-from sef@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2E2k5U6039820; Thu, 14 Mar 2019 02:46:05 GMT (envelope-from sef@FreeBSD.org) Received: (from sef@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2E2k3wv039808; Thu, 14 Mar 2019 02:46:03 GMT (envelope-from sef@FreeBSD.org) Message-Id: <201903140246.x2E2k3wv039808@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sef set sender to sef@FreeBSD.org using -f From: Sean Eric Fagan Date: Thu, 14 Mar 2019 02:46:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345124 - in stable/12: sys/conf sys/modules/crypto sys/opencrypto tools/tools/crypto X-SVN-Group: stable-12 X-SVN-Commit-Author: sef X-SVN-Commit-Paths: in stable/12: sys/conf sys/modules/crypto sys/opencrypto tools/tools/crypto X-SVN-Commit-Revision: 345124 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0E54384E6A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.99)[-0.987,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Mar 2019 02:46:06 -0000 Author: sef Date: Thu Mar 14 02:46:03 2019 New Revision: 345124 URL: https://svnweb.freebsd.org/changeset/base/345124 Log: MFC r344140,r344141,r344142,r344143,r344388,r344547 r344140: Add CBC-MAC authentication. r344141: Add AES-CCM encryption, and plumb into OCF. r344142: Pasting in a source control line missed the last quote. Fixed. r344143: Fix another issue from r344141, having to do with size of a shift amount. This did not show up in my testing. r344388: It turns out that setting the IV length is necessary with CCM in OpenSSL. This adds that back. r344547: Fix another bug introduced during the review process of r344140: the tag wasn't being computed properly due to chaning a >= comparison to an == comparison. Added: stable/12/sys/opencrypto/cbc_mac.c - copied, changed from r344140, head/sys/opencrypto/cbc_mac.c stable/12/sys/opencrypto/cbc_mac.h - copied unchanged from r344140, head/sys/opencrypto/cbc_mac.h stable/12/sys/opencrypto/xform_cbc_mac.c - copied unchanged from r344140, head/sys/opencrypto/xform_cbc_mac.c Modified: stable/12/sys/conf/files stable/12/sys/modules/crypto/Makefile stable/12/sys/opencrypto/cryptodev.c stable/12/sys/opencrypto/cryptodev.h stable/12/sys/opencrypto/cryptosoft.c stable/12/sys/opencrypto/xform_aes_icm.c stable/12/sys/opencrypto/xform_auth.h stable/12/sys/opencrypto/xform_enc.h stable/12/tools/tools/crypto/cryptocheck.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/conf/files ============================================================================== --- stable/12/sys/conf/files Thu Mar 14 00:58:57 2019 (r345123) +++ stable/12/sys/conf/files Thu Mar 14 02:46:03 2019 (r345124) @@ -4856,6 +4856,8 @@ crypto/libsodium/randombytes.c optional crypto \ compile-with "${NORMAL_C} -I$S/contrib/libsodium/src/libsodium/include -I$S/crypto/libsodium" crypto/libsodium/utils.c optional crypto \ compile-with "${NORMAL_C} -I$S/contrib/libsodium/src/libsodium/include -I$S/crypto/libsodium" +opencrypto/cbc_mac.c optional crypto +opencrypto/xform_cbc_mac.c optional crypto rpc/auth_none.c optional krpc | nfslockd | nfscl | nfsd rpc/auth_unix.c optional krpc | nfslockd | nfscl | nfsd rpc/authunix_prot.c optional krpc | nfslockd | nfscl | nfsd Modified: stable/12/sys/modules/crypto/Makefile ============================================================================== --- stable/12/sys/modules/crypto/Makefile Thu Mar 14 00:58:57 2019 (r345123) +++ stable/12/sys/modules/crypto/Makefile Thu Mar 14 02:46:03 2019 (r345124) @@ -68,5 +68,7 @@ CFLAGS.utils.c += -I${LIBSODIUM_INC} -I${LIBSODIUM_C SRCS += opt_param.h cryptodev_if.h bus_if.h device_if.h SRCS += opt_ddb.h +SRCS += cbc_mac.c +SRCS += xform_cbc_mac.c .include Copied and modified: stable/12/sys/opencrypto/cbc_mac.c (from r344140, head/sys/opencrypto/cbc_mac.c) ============================================================================== --- head/sys/opencrypto/cbc_mac.c Fri Feb 15 03:46:39 2019 (r344140, copy source) +++ stable/12/sys/opencrypto/cbc_mac.c Thu Mar 14 02:46:03 2019 (r345124) @@ -23,7 +23,7 @@ */ #include -__FBSDID("$FreeBSD$); +__FBSDID("$FreeBSD$"); #include #include @@ -124,23 +124,31 @@ AES_CBC_MAC_Reinit(struct aes_cbc_mac_ctx *ctx, const rijndaelEncrypt(ctx->keysched, ctx->rounds, b0, ctx->block); /* If there is auth data, we need to set up the staging block */ if (ctx->authDataLength) { + size_t addLength; if (ctx->authDataLength < ((1<<16) - (1<<8))) { uint16_t sizeVal = htobe16(ctx->authDataLength); bcopy(&sizeVal, ctx->staging_block, sizeof(sizeVal)); - ctx->blockIndex = sizeof(sizeVal); - } else if (ctx->authDataLength < (1UL<<32)) { + addLength = sizeof(sizeVal); + } else if (ctx->authDataLength < (1ULL<<32)) { uint32_t sizeVal = htobe32(ctx->authDataLength); ctx->staging_block[0] = 0xff; ctx->staging_block[1] = 0xfe; bcopy(&sizeVal, ctx->staging_block+2, sizeof(sizeVal)); - ctx->blockIndex = 2 + sizeof(sizeVal); + addLength = 2 + sizeof(sizeVal); } else { uint64_t sizeVal = htobe64(ctx->authDataLength); ctx->staging_block[0] = 0xff; ctx->staging_block[1] = 0xff; bcopy(&sizeVal, ctx->staging_block+2, sizeof(sizeVal)); - ctx->blockIndex = 2 + sizeof(sizeVal); + addLength = 2 + sizeof(sizeVal); } + ctx->blockIndex = addLength; + /* + * The length descriptor goes into the AAD buffer, so we + * need to account for it. + */ + ctx->authDataLength += addLength; + ctx->authDataCount = addLength; } } @@ -181,10 +189,9 @@ AES_CBC_MAC_Update(struct aes_cbc_mac_ctx *ctx, const ctx->authDataCount += copy_amt; ctx->blockIndex += copy_amt; ctx->blockIndex %= sizeof(ctx->staging_block); - if (ctx->authDataCount == ctx->authDataLength) - length = 0; + if (ctx->blockIndex == 0 || - ctx->authDataCount >= ctx->authDataLength) { + ctx->authDataCount == ctx->authDataLength) { /* * We're done with this block, so we * xor staging_block with block, and then @@ -193,8 +200,17 @@ AES_CBC_MAC_Update(struct aes_cbc_mac_ctx *ctx, const xor_and_encrypt(ctx, ctx->staging_block, ctx->block); bzero(ctx->staging_block, sizeof(ctx->staging_block)); ctx->blockIndex = 0; + if (ctx->authDataCount >= ctx->authDataLength) + break; } } + /* + * We'd like to be able to check length == 0 and return + * here, but the way OCF calls us, length is always + * blksize (16, in this case). So we have to count on + * the fact that OCF calls us separately for the AAD and + * for the real data. + */ return (0); } /* Copied: stable/12/sys/opencrypto/cbc_mac.h (from r344140, head/sys/opencrypto/cbc_mac.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/opencrypto/cbc_mac.h Thu Mar 14 02:46:03 2019 (r345124, copy of r344140, head/sys/opencrypto/cbc_mac.h) @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014 The FreeBSD Foundation + * Copyright (c) 2018, iXsystems Inc. + * All rights reserved. + * + * This software was developed by Sean Eric Fagan, with lots of references + * to existing AES-CCM (gmac) code. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#ifndef _CBC_CCM_H +# define _CBC_CCM_H + +# include +# include + +# define CCM_CBC_BLOCK_LEN 16 /* 128 bits */ +# define CCM_CBC_MAX_DIGEST_LEN 16 +# define CCM_CBC_MIN_DIGEST_LEN 4 + +/* + * This is the authentication context structure; + * the encryption one is similar. + */ +struct aes_cbc_mac_ctx { + uint64_t authDataLength, authDataCount; + uint64_t cryptDataLength, cryptDataCount; + int blockIndex; + uint8_t staging_block[CCM_CBC_BLOCK_LEN]; + uint8_t block[CCM_CBC_BLOCK_LEN]; + const uint8_t *nonce; + int nonceLength; /* This one is in bytes, not bits! */ + /* AES state data */ + int rounds; + uint32_t keysched[4*(RIJNDAEL_MAXNR+1)]; +}; + +void AES_CBC_MAC_Init(struct aes_cbc_mac_ctx *); +void AES_CBC_MAC_Setkey(struct aes_cbc_mac_ctx *, const uint8_t *, uint16_t); +void AES_CBC_MAC_Reinit(struct aes_cbc_mac_ctx *, const uint8_t *, uint16_t); +int AES_CBC_MAC_Update(struct aes_cbc_mac_ctx *, const uint8_t *, uint16_t); +void AES_CBC_MAC_Final(uint8_t *, struct aes_cbc_mac_ctx *); + +#endif /* _CBC_CCM_H */ Modified: stable/12/sys/opencrypto/cryptodev.c ============================================================================== --- stable/12/sys/opencrypto/cryptodev.c Thu Mar 14 00:58:57 2019 (r345123) +++ stable/12/sys/opencrypto/cryptodev.c Thu Mar 14 02:46:03 2019 (r345124) @@ -444,6 +444,9 @@ cryptof_ioctl( case CRYPTO_CHACHA20: txform = &enc_xform_chacha20; break; + case CRYPTO_AES_CCM_16: + txform = &enc_xform_ccm; + break; default: CRYPTDEB("invalid cipher"); @@ -488,6 +491,25 @@ cryptof_ioctl( thash = &auth_hash_nist_gmac_aes_256; break; + case CRYPTO_AES_CCM_CBC_MAC: + switch (sop->keylen) { + case 16: + thash = &auth_hash_ccm_cbc_mac_128; + break; + case 24: + thash = &auth_hash_ccm_cbc_mac_192; + break; + case 32: + thash = &auth_hash_ccm_cbc_mac_256; + break; + default: + CRYPTDEB("Invalid CBC MAC key size %d", + sop->keylen); + SDT_PROBE1(opencrypto, dev, ioctl, + error, __LINE__); + return (EINVAL); + } + break; #ifdef notdef case CRYPTO_MD5: thash = &auth_hash_md5; @@ -1003,12 +1025,13 @@ cryptodev_aead( } /* - * For GCM, crd_len covers only the AAD. For other ciphers + * For GCM/CCM, crd_len covers only the AAD. For other ciphers * chained with an HMAC, crd_len covers both the AAD and the * cipher text. */ crda->crd_skip = 0; - if (cse->cipher == CRYPTO_AES_NIST_GCM_16) + if (cse->cipher == CRYPTO_AES_NIST_GCM_16 || + cse->cipher == CRYPTO_AES_CCM_16) crda->crd_len = caead->aadlen; else crda->crd_len = caead->aadlen + caead->len; Modified: stable/12/sys/opencrypto/cryptodev.h ============================================================================== --- stable/12/sys/opencrypto/cryptodev.h Thu Mar 14 00:58:57 2019 (r345123) +++ stable/12/sys/opencrypto/cryptodev.h Thu Mar 14 02:46:03 2019 (r345124) @@ -86,6 +86,7 @@ #define SHA1_KPDK_HASH_LEN 20 #define AES_GMAC_HASH_LEN 16 #define POLY1305_HASH_LEN 16 +#define AES_CBC_MAC_HASH_LEN 16 /* Maximum hash algorithm result length */ #define HASH_MAX_LEN SHA2_512_HASH_LEN /* Keep this updated */ @@ -107,6 +108,9 @@ #define AES_128_GMAC_KEY_LEN 16 #define AES_192_GMAC_KEY_LEN 24 #define AES_256_GMAC_KEY_LEN 32 +#define AES_128_CBC_MAC_KEY_LEN 16 +#define AES_192_CBC_MAC_KEY_LEN 24 +#define AES_256_CBC_MAC_KEY_LEN 32 #define POLY1305_KEY_LEN 32 @@ -129,6 +133,7 @@ #define ARC4_IV_LEN 1 #define AES_GCM_IV_LEN 12 +#define AES_CCM_IV_LEN 12 #define AES_XTS_IV_LEN 8 #define AES_XTS_ALPHA 0x87 /* GF(2^128) generator polynomial */ @@ -199,7 +204,9 @@ #define CRYPTO_SHA2_384 36 #define CRYPTO_SHA2_512 37 #define CRYPTO_POLY1305 38 -#define CRYPTO_ALGORITHM_MAX 38 /* Keep updated - see below */ +#define CRYPTO_AES_CCM_CBC_MAC 39 /* auth side */ +#define CRYPTO_AES_CCM_16 40 /* cipher side */ +#define CRYPTO_ALGORITHM_MAX 40 /* Keep updated - see below */ #define CRYPTO_ALGO_VALID(x) ((x) >= CRYPTO_ALGORITHM_MIN && \ (x) <= CRYPTO_ALGORITHM_MAX) Modified: stable/12/sys/opencrypto/cryptosoft.c ============================================================================== --- stable/12/sys/opencrypto/cryptosoft.c Thu Mar 14 00:58:57 2019 (r345123) +++ stable/12/sys/opencrypto/cryptosoft.c Thu Mar 14 02:46:03 2019 (r345124) @@ -62,6 +62,9 @@ __FBSDID("$FreeBSD$"); #include #include "cryptodev_if.h" +_Static_assert(AES_CCM_IV_LEN == AES_GCM_IV_LEN, + "AES_GCM_IV_LEN must currently be the same as AES_CCM_IV_LEN"); + static int32_t swcr_id; u_int8_t hmac_ipad_buffer[HMAC_MAX_BLOCK_LEN]; @@ -506,6 +509,7 @@ swcr_authenc(struct cryptop *crp) caddr_t buf = (caddr_t)crp->crp_buf; uint32_t *blkp; int aadlen, blksz, i, ivlen, len, iskip, oskip, r; + int isccm = 0; ivlen = blksz = iskip = oskip = 0; @@ -520,13 +524,18 @@ swcr_authenc(struct cryptop *crp) sw = &ses->swcr_algorithms[i]; switch (sw->sw_alg) { + case CRYPTO_AES_CCM_16: case CRYPTO_AES_NIST_GCM_16: case CRYPTO_AES_NIST_GMAC: swe = sw; crde = crd; exf = swe->sw_exf; - ivlen = 12; + /* AES_CCM_IV_LEN and AES_GCM_IV_LEN are both 12 */ + ivlen = AES_CCM_IV_LEN; break; + case CRYPTO_AES_CCM_CBC_MAC: + isccm = 1; + /* FALLTHROUGH */ case CRYPTO_AES_128_NIST_GMAC: case CRYPTO_AES_192_NIST_GMAC: case CRYPTO_AES_256_NIST_GMAC: @@ -544,8 +553,26 @@ swcr_authenc(struct cryptop *crp) } if (crde == NULL || crda == NULL) return (EINVAL); + /* + * We need to make sure that the auth algorithm matches the + * encr algorithm. Specifically, for AES-GCM must go with + * AES NIST GMAC, and AES-CCM must go with CBC-MAC. + */ + if (crde->crd_alg == CRYPTO_AES_NIST_GCM_16) { + switch (crda->crd_alg) { + case CRYPTO_AES_128_NIST_GMAC: + case CRYPTO_AES_192_NIST_GMAC: + case CRYPTO_AES_256_NIST_GMAC: + break; /* Good! */ + default: + return (EINVAL); /* Not good! */ + } + } else if (crde->crd_alg == CRYPTO_AES_CCM_16 && + crda->crd_alg != CRYPTO_AES_CCM_CBC_MAC) + return (EINVAL); - if (crde->crd_alg == CRYPTO_AES_NIST_GCM_16 && + if ((crde->crd_alg == CRYPTO_AES_NIST_GCM_16 || + crde->crd_alg == CRYPTO_AES_CCM_16) && (crde->crd_flags & CRD_F_IV_EXPLICIT) == 0) return (EINVAL); @@ -576,6 +603,15 @@ swcr_authenc(struct cryptop *crp) } } + if (swa->sw_alg == CRYPTO_AES_CCM_CBC_MAC) { + /* + * AES CCM-CBC needs to know the length of + * both the auth data, and payload data, before + * doing the auth computation. + */ + ctx.aes_cbc_mac_ctx.authDataLength = crda->crd_len; + ctx.aes_cbc_mac_ctx.cryptDataLength = crde->crd_len; + } /* Supply MAC with IV */ if (axf->Reinit) axf->Reinit(&ctx, iv, ivlen); @@ -610,16 +646,30 @@ swcr_authenc(struct cryptop *crp) bzero(blk, blksz); crypto_copydata(crp->crp_flags, buf, crde->crd_skip + i, len, blk); + /* + * One of the problems with CCM+CBC is that the authentication + * is done on the unecncrypted data. As a result, we have + * to do the authentication update at different times, + * depending on whether it's CCM or not. + */ if (crde->crd_flags & CRD_F_ENCRYPT) { + if (isccm) + axf->Update(&ctx, blk, len); if (exf->encrypt_multi != NULL) exf->encrypt_multi(swe->sw_kschedule, blk, len); else exf->encrypt(swe->sw_kschedule, blk); - axf->Update(&ctx, blk, len); + if (!isccm) + axf->Update(&ctx, blk, len); crypto_copyback(crp->crp_flags, buf, crde->crd_skip + i, len, blk); } else { + if (isccm) { + KASSERT(exf->encrypt_multi == NULL, + ("assume CCM is single-block only")); + exf->decrypt(swe->sw_kschedule, blk); + } axf->Update(&ctx, blk, len); } } @@ -650,6 +700,11 @@ swcr_authenc(struct cryptop *crp) r = timingsafe_bcmp(aalg, uaalg, axf->hashsize); if (r == 0) { /* tag matches, decrypt data */ + if (isccm) { + KASSERT(exf->reinit != NULL, + ("AES-CCM reinit function must be set")); + exf->reinit(swe->sw_kschedule, iv); + } for (i = 0; i < crde->crd_len; i += blksz) { len = MIN(crde->crd_len - i, blksz); if (len < blksz) @@ -799,6 +854,9 @@ swcr_newsession(device_t dev, crypto_session_t cses, s case CRYPTO_AES_NIST_GCM_16: txf = &enc_xform_aes_nist_gcm; goto enccommon; + case CRYPTO_AES_CCM_16: + txf = &enc_xform_ccm; + goto enccommon; case CRYPTO_AES_NIST_GMAC: txf = &enc_xform_aes_nist_gmac; swd->sw_exf = txf; @@ -943,6 +1001,22 @@ swcr_newsession(device_t dev, crypto_session_t cses, s swd->sw_axf = axf; break; + case CRYPTO_AES_CCM_CBC_MAC: + switch (cri->cri_klen) { + case 128: + axf = &auth_hash_ccm_cbc_mac_128; + break; + case 192: + axf = &auth_hash_ccm_cbc_mac_192; + break; + case 256: + axf = &auth_hash_ccm_cbc_mac_256; + break; + default: + swcr_freesession(dev, cses); + return EINVAL; + } + goto auth4common; case CRYPTO_AES_128_NIST_GMAC: axf = &auth_hash_nist_gmac_aes_128; goto auth4common; @@ -1042,6 +1116,7 @@ swcr_freesession(device_t dev, crypto_session_t cses) case CRYPTO_CAMELLIA_CBC: case CRYPTO_NULL_CBC: case CRYPTO_CHACHA20: + case CRYPTO_AES_CCM_16: txf = swd->sw_exf; if (swd->sw_kschedule) @@ -1056,6 +1131,7 @@ swcr_freesession(device_t dev, crypto_session_t cses) case CRYPTO_SHA2_512_HMAC: case CRYPTO_RIPEMD160_HMAC: case CRYPTO_NULL_HMAC: + case CRYPTO_AES_CCM_CBC_MAC: axf = swd->sw_axf; if (swd->sw_ictx) { @@ -1201,6 +1277,8 @@ swcr_process(device_t dev, struct cryptop *crp, int hi case CRYPTO_AES_128_NIST_GMAC: case CRYPTO_AES_192_NIST_GMAC: case CRYPTO_AES_256_NIST_GMAC: + case CRYPTO_AES_CCM_16: + case CRYPTO_AES_CCM_CBC_MAC: crp->crp_etype = swcr_authenc(crp); goto done; @@ -1291,6 +1369,8 @@ swcr_attach(device_t dev) REGISTER(CRYPTO_BLAKE2B); REGISTER(CRYPTO_BLAKE2S); REGISTER(CRYPTO_CHACHA20); + REGISTER(CRYPTO_AES_CCM_16); + REGISTER(CRYPTO_AES_CCM_CBC_MAC); REGISTER(CRYPTO_POLY1305); #undef REGISTER Modified: stable/12/sys/opencrypto/xform_aes_icm.c ============================================================================== --- stable/12/sys/opencrypto/xform_aes_icm.c Thu Mar 14 00:58:57 2019 (r345123) +++ stable/12/sys/opencrypto/xform_aes_icm.c Thu Mar 14 02:46:03 2019 (r345124) @@ -57,6 +57,7 @@ static void aes_icm_crypt(caddr_t, u_int8_t *); static void aes_icm_zerokey(u_int8_t **); static void aes_icm_reinit(caddr_t, u_int8_t *); static void aes_gcm_reinit(caddr_t, u_int8_t *); +static void aes_ccm_reinit(caddr_t, u_int8_t *); /* Encryption instances */ struct enc_xform enc_xform_aes_icm = { @@ -79,6 +80,18 @@ struct enc_xform enc_xform_aes_nist_gcm = { aes_gcm_reinit, }; +struct enc_xform enc_xform_ccm = { + .type = CRYPTO_AES_CCM_16, + .name = "AES-CCM", + .blocksize = AES_ICM_BLOCK_LEN, .ivsize = AES_CCM_IV_LEN, + .minkey = AES_MIN_KEY, .maxkey = AES_MAX_KEY, + .encrypt = aes_icm_crypt, + .decrypt = aes_icm_crypt, + .setkey = aes_icm_setkey, + .zerokey = aes_icm_zerokey, + .reinit = aes_ccm_reinit, +}; + /* * Encryption wrapper routines. */ @@ -102,6 +115,21 @@ aes_gcm_reinit(caddr_t key, u_int8_t *iv) /* GCM starts with 2 as counter 1 is used for final xor of tag. */ bzero(&ctx->ac_block[AESICM_BLOCKSIZE - 4], 4); ctx->ac_block[AESICM_BLOCKSIZE - 1] = 2; +} + +static void +aes_ccm_reinit(caddr_t key, u_int8_t *iv) +{ + struct aes_icm_ctx *ctx; + + ctx = (struct aes_icm_ctx*)key; + + /* CCM has flags, then the IV, then the counter, which starts at 1 */ + bzero(ctx->ac_block, sizeof(ctx->ac_block)); + /* 3 bytes for length field; this gives a nonce of 12 bytes */ + ctx->ac_block[0] = (15 - AES_CCM_IV_LEN) - 1; + bcopy(iv, ctx->ac_block+1, AES_CCM_IV_LEN); + ctx->ac_block[AESICM_BLOCKSIZE - 1] = 1; } static void Modified: stable/12/sys/opencrypto/xform_auth.h ============================================================================== --- stable/12/sys/opencrypto/xform_auth.h Thu Mar 14 00:58:57 2019 (r345123) +++ stable/12/sys/opencrypto/xform_auth.h Thu Mar 14 02:46:03 2019 (r345124) @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -85,6 +86,9 @@ extern struct auth_hash auth_hash_nist_gmac_aes_256; extern struct auth_hash auth_hash_blake2b; extern struct auth_hash auth_hash_blake2s; extern struct auth_hash auth_hash_poly1305; +extern struct auth_hash auth_hash_ccm_cbc_mac_128; +extern struct auth_hash auth_hash_ccm_cbc_mac_192; +extern struct auth_hash auth_hash_ccm_cbc_mac_256; union authctx { MD5_CTX md5ctx; @@ -95,6 +99,7 @@ union authctx { SHA384_CTX sha384ctx; SHA512_CTX sha512ctx; struct aes_gmac_ctx aes_gmac_ctx; + struct aes_cbc_mac_ctx aes_cbc_mac_ctx; }; #endif /* _CRYPTO_XFORM_AUTH_H_ */ Copied: stable/12/sys/opencrypto/xform_cbc_mac.c (from r344140, head/sys/opencrypto/xform_cbc_mac.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/opencrypto/xform_cbc_mac.c Thu Mar 14 02:46:03 2019 (r345124, copy of r344140, head/sys/opencrypto/xform_cbc_mac.c) @@ -0,0 +1,55 @@ +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +/* Authentication instances */ +struct auth_hash auth_hash_ccm_cbc_mac_128 = { + .type = CRYPTO_AES_CCM_CBC_MAC, + .name = "CBC-CCM-AES-128", + .keysize = AES_128_CBC_MAC_KEY_LEN, + .hashsize = AES_CBC_MAC_HASH_LEN, + .ctxsize = sizeof(struct aes_cbc_mac_ctx), + .blocksize = CCM_CBC_BLOCK_LEN, + .Init = (void (*)(void *)) AES_CBC_MAC_Init, + .Setkey = + (void (*)(void *, const u_int8_t *, u_int16_t))AES_CBC_MAC_Setkey, + .Reinit = + (void (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Reinit, + .Update = + (int (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Update, + .Final = (void (*)(u_int8_t *, void *)) AES_CBC_MAC_Final, +}; +struct auth_hash auth_hash_ccm_cbc_mac_192 = { + .type = CRYPTO_AES_CCM_CBC_MAC, + .name = "CBC-CCM-AES-192", + .keysize = AES_192_CBC_MAC_KEY_LEN, + .hashsize = AES_CBC_MAC_HASH_LEN, + .ctxsize = sizeof(struct aes_cbc_mac_ctx), + .blocksize = CCM_CBC_BLOCK_LEN, + .Init = (void (*)(void *)) AES_CBC_MAC_Init, + .Setkey = + (void (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Setkey, + .Reinit = + (void (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Reinit, + .Update = + (int (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Update, + .Final = (void (*)(u_int8_t *, void *)) AES_CBC_MAC_Final, +}; +struct auth_hash auth_hash_ccm_cbc_mac_256 = { + .type = CRYPTO_AES_CCM_CBC_MAC, + .name = "CBC-CCM-AES-256", + .keysize = AES_256_CBC_MAC_KEY_LEN, + .hashsize = AES_CBC_MAC_HASH_LEN, + .ctxsize = sizeof(struct aes_cbc_mac_ctx), + .blocksize = CCM_CBC_BLOCK_LEN, + .Init = (void (*)(void *)) AES_CBC_MAC_Init, + .Setkey = + (void (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Setkey, + .Reinit = + (void (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Reinit, + .Update = + (int (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Update, + .Final = (void (*)(u_int8_t *, void *)) AES_CBC_MAC_Final, +}; Modified: stable/12/sys/opencrypto/xform_enc.h ============================================================================== --- stable/12/sys/opencrypto/xform_enc.h Thu Mar 14 00:58:57 2019 (r345123) +++ stable/12/sys/opencrypto/xform_enc.h Thu Mar 14 02:46:03 2019 (r345124) @@ -84,6 +84,7 @@ extern struct enc_xform enc_xform_aes_xts; extern struct enc_xform enc_xform_arc4; extern struct enc_xform enc_xform_camellia; extern struct enc_xform enc_xform_chacha20; +extern struct enc_xform enc_xform_ccm; struct aes_icm_ctx { u_int32_t ac_ek[4*(RIJNDAEL_MAXNR + 1)]; Modified: stable/12/tools/tools/crypto/cryptocheck.c ============================================================================== --- stable/12/tools/tools/crypto/cryptocheck.c Thu Mar 14 00:58:57 2019 (r345123) +++ stable/12/tools/tools/crypto/cryptocheck.c Thu Mar 14 02:46:03 2019 (r345124) @@ -105,6 +105,9 @@ * aes-gcm 128-bit aes gcm * aes-gcm192 192-bit aes gcm * aes-gcm256 256-bit aes gcm + * aes-ccm 128-bit aes ccm + * aes-ccm192 192-bit aes ccm + * aes-ccm256 256-bit aes ccm */ #include @@ -131,7 +134,7 @@ struct alg { const char *name; int cipher; int mac; - enum { T_HASH, T_HMAC, T_BLKCIPHER, T_AUTHENC, T_GCM } type; + enum { T_HASH, T_HMAC, T_BLKCIPHER, T_AUTHENC, T_GCM, T_CCM } type; const EVP_CIPHER *(*evp_cipher)(void); const EVP_MD *(*evp_md)(void); } algs[] = { @@ -186,6 +189,15 @@ struct alg { { .name = "aes-gcm256", .cipher = CRYPTO_AES_NIST_GCM_16, .mac = CRYPTO_AES_256_NIST_GMAC, .type = T_GCM, .evp_cipher = EVP_aes_256_gcm }, + { .name = "aes-ccm", .cipher = CRYPTO_AES_CCM_16, + .mac = CRYPTO_AES_CCM_CBC_MAC, .type = T_CCM, + .evp_cipher = EVP_aes_128_ccm }, + { .name = "aes-ccm192", .cipher = CRYPTO_AES_CCM_16, + .mac = CRYPTO_AES_CCM_CBC_MAC, .type = T_CCM, + .evp_cipher = EVP_aes_192_ccm }, + { .name = "aes-ccm256", .cipher = CRYPTO_AES_CCM_16, + .mac = CRYPTO_AES_CCM_CBC_MAC, .type = T_CCM, + .evp_cipher = EVP_aes_256_ccm }, }; static bool verbose; @@ -1159,6 +1171,217 @@ out: } static void +openssl_ccm_encrypt(struct alg *alg, const EVP_CIPHER *cipher, const char *key, + const char *iv, size_t iv_len, const char *aad, size_t aad_len, + const char *input, char *output, size_t size, char *tag) +{ + EVP_CIPHER_CTX *ctx; + int outl, total; + + ctx = EVP_CIPHER_CTX_new(); + if (ctx == NULL) + errx(1, "OpenSSL %s (%zu) ctx new failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + if (EVP_EncryptInit_ex(ctx, cipher, NULL, NULL, NULL) != 1) + errx(1, "OpenSSL %s (%zu) ctx init failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_IVLEN, iv_len, NULL) != 1) + errx(1, "OpenSSL %s (%zu) setting iv length failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_TAG, AES_CBC_MAC_HASH_LEN, NULL) != 1) + errx(1, "OpenSSL %s (%zu) setting tag length failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + if (EVP_EncryptInit_ex(ctx, NULL, NULL, (const u_char *)key, + (const u_char *)iv) != 1) + errx(1, "OpenSSL %s (%zu) ctx init failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + if (EVP_EncryptUpdate(ctx, NULL, &outl, NULL, size) != 1) + errx(1, "OpenSSL %s (%zu) unable to set data length: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + + if (aad != NULL) { + if (EVP_EncryptUpdate(ctx, NULL, &outl, (const u_char *)aad, + aad_len) != 1) + errx(1, "OpenSSL %s (%zu) aad update failed: %s", + alg->name, size, + ERR_error_string(ERR_get_error(), NULL)); + } + if (EVP_EncryptUpdate(ctx, (u_char *)output, &outl, + (const u_char *)input, size) != 1) + errx(1, "OpenSSL %s (%zu) encrypt update failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + total = outl; + if (EVP_EncryptFinal_ex(ctx, (u_char *)output + outl, &outl) != 1) + errx(1, "OpenSSL %s (%zu) encrypt final failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + total += outl; + if (total != size) + errx(1, "OpenSSL %s (%zu) encrypt size mismatch: %d", alg->name, + size, total); + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_GET_TAG, AES_CBC_MAC_HASH_LEN, + tag) != 1) + errx(1, "OpenSSL %s (%zu) get tag failed: %s", alg->name, + size, ERR_error_string(ERR_get_error(), NULL)); + EVP_CIPHER_CTX_free(ctx); +} + +static bool +ocf_ccm(struct alg *alg, const char *key, size_t key_len, const char *iv, + size_t iv_len, const char *aad, size_t aad_len, const char *input, + char *output, size_t size, char *tag, int enc, int *cridp) +{ + struct session2_op sop; + struct crypt_aead caead; + int fd; + bool rv; + + memset(&sop, 0, sizeof(sop)); + memset(&caead, 0, sizeof(caead)); + sop.crid = crid; + sop.keylen = key_len; + sop.key = (char *)key; + sop.cipher = alg->cipher; + sop.mackeylen = key_len; + sop.mackey = (char *)key; + sop.mac = alg->mac; + fd = crget(); + if (ioctl(fd, CIOCGSESSION2, &sop) < 0) { + warn("cryptodev %s not supported for device %s", + alg->name, crfind(crid)); + close(fd); + return (false); + } + + caead.ses = sop.ses; + caead.op = enc ? COP_ENCRYPT : COP_DECRYPT; + caead.len = size; + caead.aadlen = aad_len; + caead.ivlen = iv_len; + caead.src = (char *)input; + caead.dst = output; + caead.aad = (char *)aad; + caead.tag = tag; + caead.iv = (char *)iv; + + if (ioctl(fd, CIOCCRYPTAEAD, &caead) < 0) { + warn("cryptodev %s (%zu) failed for device %s", + alg->name, size, crfind(crid)); + rv = false; + } else + rv = true; + + if (ioctl(fd, CIOCFSESSION, &sop.ses) < 0) + warn("ioctl(CIOCFSESSION)"); + + close(fd); + *cridp = sop.crid; + return (rv); +} + +static void +run_ccm_test(struct alg *alg, size_t size) +{ + const EVP_CIPHER *cipher; + char *aad, *buffer, *cleartext, *ciphertext; + char *iv, *key; + u_int iv_len, key_len; + int crid; + char control_tag[AES_CBC_MAC_HASH_LEN], test_tag[AES_CBC_MAC_HASH_LEN]; + + cipher = alg->evp_cipher(); + if (size % EVP_CIPHER_block_size(cipher) != 0) { + if (verbose) + printf( + "%s (%zu): invalid buffer size (block size %d)\n", + alg->name, size, EVP_CIPHER_block_size(cipher)); + return; + } + + memset(control_tag, 0x3c, sizeof(control_tag)); + memset(test_tag, 0x3c, sizeof(test_tag)); + + /* + * We only have one algorithm constant for CBC-MAC; however, the + * alg structure uses the different openssl types, which gives us + * the key length. We need that for the OCF code. + */ + key_len = EVP_CIPHER_key_length(cipher); + + /* + * AES-CCM can have varying IV lengths; however, for the moment + * we only support AES_CCM_IV_LEN (12). So if the sizes are + * different, we'll fail. + */ + iv_len = EVP_CIPHER_iv_length(cipher); + if (iv_len != AES_CCM_IV_LEN) { + if (verbose) + printf("OpenSSL CCM IV length (%d) != AES_CCM_IV_LEN", + iv_len); + return; + } + + key = alloc_buffer(key_len); + iv = generate_iv(iv_len, alg); + cleartext = alloc_buffer(size); + buffer = malloc(size); + ciphertext = malloc(size); + if (aad_len != 0) + aad = alloc_buffer(aad_len); + else + aad = NULL; + + /* OpenSSL encrypt */ + openssl_ccm_encrypt(alg, cipher, key, iv, iv_len, aad, aad_len, cleartext, + ciphertext, size, control_tag); + + /* OCF encrypt */ + if (!ocf_ccm(alg, key, key_len, iv, iv_len, aad, aad_len, cleartext, + buffer, size, test_tag, 1, &crid)) + goto out; + if (memcmp(ciphertext, buffer, size) != 0) { + printf("%s (%zu) encryption mismatch:\n", alg->name, size); + printf("control:\n"); + hexdump(ciphertext, size, NULL, 0); + printf("test (cryptodev device %s):\n", crfind(crid)); + hexdump(buffer, size, NULL, 0); + goto out; + } + if (memcmp(control_tag, test_tag, sizeof(control_tag)) != 0) { + printf("%s (%zu) enc tag mismatch:\n", alg->name, size); + printf("control:\n"); + hexdump(control_tag, sizeof(control_tag), NULL, 0); + printf("test (cryptodev device %s):\n", crfind(crid)); + hexdump(test_tag, sizeof(test_tag), NULL, 0); + goto out; + } + + /* OCF decrypt */ + if (!ocf_ccm(alg, key, key_len, iv, iv_len, aad, aad_len, ciphertext, + buffer, size, control_tag, 0, &crid)) + goto out; + if (memcmp(cleartext, buffer, size) != 0) { + printf("%s (%zu) decryption mismatch:\n", alg->name, size); + printf("control:\n"); + hexdump(cleartext, size, NULL, 0); + printf("test (cryptodev device %s):\n", crfind(crid)); + hexdump(buffer, size, NULL, 0); + goto out; + } + + if (verbose) + printf("%s (%zu) matched (cryptodev device %s)\n", + alg->name, size, crfind(crid)); + +out: + free(aad); + free(ciphertext); + free(buffer); + free(cleartext); + free(iv); + free(key); +} + +static void run_test(struct alg *alg, size_t size) { @@ -1178,6 +1401,9 @@ run_test(struct alg *alg, size_t size) case T_GCM: run_gcm_test(alg, size); break; + case T_CCM: + run_ccm_test(alg, size); + break; } } @@ -1247,7 +1473,8 @@ run_aead_tests(size_t *sizes, u_int nsizes) u_int i; for (i = 0; i < nitems(algs); i++) - if (algs[i].type == T_GCM) + if (algs[i].type == T_GCM || + algs[i].type == T_CCM) run_test_sizes(&algs[i], sizes, nsizes); } From owner-svn-src-stable-12@freebsd.org Thu Mar 14 08:25:29 2019 Return-Path: Delivered-To: svn-src-stable-12@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 59076153603D; Thu, 14 Mar 2019 08:25:29 +0000 (UTC) (envelope-from ae@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 EC22B6B261; Thu, 14 Mar 2019 08:25:28 +0000 (UTC) (envelope-from ae@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 DDE4D1FB6B; Thu, 14 Mar 2019 08:25:28 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2E8PS0R016587; Thu, 14 Mar 2019 08:25:28 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2E8PSCW016585; Thu, 14 Mar 2019 08:25:28 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201903140825.x2E8PSCW016585@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 14 Mar 2019 08:25:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345125 - in stable/12/sys: amd64/amd64 i386/i386 X-SVN-Group: stable-12 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: in stable/12/sys: amd64/amd64 i386/i386 X-SVN-Commit-Revision: 345125 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EC22B6B261 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Mar 2019 08:25:29 -0000 Author: ae Date: Thu Mar 14 08:25:28 2019 New Revision: 345125 URL: https://svnweb.freebsd.org/changeset/base/345125 Log: MFC r344873: Fix typo. Modified: stable/12/sys/amd64/amd64/vm_machdep.c stable/12/sys/i386/i386/vm_machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/vm_machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/vm_machdep.c Thu Mar 14 02:46:03 2019 (r345124) +++ stable/12/sys/amd64/amd64/vm_machdep.c Thu Mar 14 08:25:28 2019 (r345125) @@ -86,7 +86,7 @@ _Static_assert(OFFSETOF_CURTHREAD == offsetof(struct p _Static_assert(OFFSETOF_CURPCB == offsetof(struct pcpu, pc_curpcb), "OFFSETOF_CURPCB does not correspond with offset of pc_curpcb."); _Static_assert(OFFSETOF_MONITORBUF == offsetof(struct pcpu, pc_monitorbuf), - "OFFSETOF_MONINORBUF does not correspond with offset of pc_monitorbuf."); + "OFFSETOF_MONITORBUF does not correspond with offset of pc_monitorbuf."); struct savefpu * get_pcb_user_save_td(struct thread *td) Modified: stable/12/sys/i386/i386/vm_machdep.c ============================================================================== --- stable/12/sys/i386/i386/vm_machdep.c Thu Mar 14 02:46:03 2019 (r345124) +++ stable/12/sys/i386/i386/vm_machdep.c Thu Mar 14 08:25:28 2019 (r345125) @@ -95,7 +95,7 @@ _Static_assert(OFFSETOF_CURTHREAD == offsetof(struct p _Static_assert(OFFSETOF_CURPCB == offsetof(struct pcpu, pc_curpcb), "OFFSETOF_CURPCB does not correspond with offset of pc_curpcb."); _Static_assert(__OFFSETOF_MONITORBUF == offsetof(struct pcpu, pc_monitorbuf), - "__OFFSETOF_MONINORBUF does not correspond with offset of pc_monitorbuf."); + "__OFFSETOF_MONITORBUF does not correspond with offset of pc_monitorbuf."); union savefpu * get_pcb_user_save_td(struct thread *td) From owner-svn-src-stable-12@freebsd.org Thu Mar 14 10:03:05 2019 Return-Path: Delivered-To: svn-src-stable-12@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 B8C54153BA07; Thu, 14 Mar 2019 10:03:05 +0000 (UTC) (envelope-from smh@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 5B3D26FD9A; Thu, 14 Mar 2019 10:03:05 +0000 (UTC) (envelope-from smh@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 4DDC520E0E; Thu, 14 Mar 2019 10:03:05 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2EA35VD068952; Thu, 14 Mar 2019 10:03:05 GMT (envelope-from smh@FreeBSD.org) Received: (from smh@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2EA340p068950; Thu, 14 Mar 2019 10:03:04 GMT (envelope-from smh@FreeBSD.org) Message-Id: <201903141003.x2EA340p068950@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: smh set sender to smh@FreeBSD.org using -f From: Steven Hartland Date: Thu, 14 Mar 2019 10:03:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345128 - in stable/12: sbin/camcontrol stand/libsa/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: smh X-SVN-Commit-Paths: in stable/12: sbin/camcontrol stand/libsa/zfs X-SVN-Commit-Revision: 345128 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5B3D26FD9A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Mar 2019 10:03:06 -0000 Author: smh Date: Thu Mar 14 10:03:04 2019 New Revision: 345128 URL: https://svnweb.freebsd.org/changeset/base/345128 Log: MFC r344701: Fix incorrect / unused sector_count for identify requests Fix unused sector_count for identify requests from camcontrol by changing to zero which is a more appropriate value when the parameter is unused. Sponsored by: Multiplay Modified: stable/12/sbin/camcontrol/camcontrol.c stable/12/stand/libsa/zfs/zfsimpl.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/12/sbin/camcontrol/camcontrol.c Thu Mar 14 09:18:54 2019 (r345127) +++ stable/12/sbin/camcontrol/camcontrol.c Thu Mar 14 10:03:04 2019 (r345128) @@ -2292,7 +2292,7 @@ ata_do_identify(struct cam_device *device, int retry_c /*command*/command, /*features*/0, /*lba*/0, - /*sector_count*/(u_int8_t)sizeof(struct ata_params), + /*sector_count*/0, /*data_ptr*/(u_int8_t *)ptr, /*dxfer_len*/sizeof(struct ata_params), /*timeout*/timeout ? timeout : 30 * 1000, @@ -2312,8 +2312,7 @@ ata_do_identify(struct cam_device *device, int retry_c /*command*/retry_command, /*features*/0, /*lba*/0, - /*sector_count*/(u_int8_t) - sizeof(struct ata_params), + /*sector_count*/0, /*data_ptr*/(u_int8_t *)ptr, /*dxfer_len*/sizeof(struct ata_params), /*timeout*/timeout ? timeout : 30 * 1000, Modified: stable/12/stand/libsa/zfs/zfsimpl.c ============================================================================== --- stable/12/stand/libsa/zfs/zfsimpl.c Thu Mar 14 09:18:54 2019 (r345127) +++ stable/12/stand/libsa/zfs/zfsimpl.c Thu Mar 14 10:03:04 2019 (r345128) @@ -2076,6 +2076,7 @@ zfs_mount_dataset(const spa_t *spa, uint64_t objnum, o { dnode_phys_t dataset; dsl_dataset_phys_t *ds; + int err; if (objset_get_dnode(spa, &spa->spa_mos, objnum, &dataset)) { printf("ZFS: can't find dataset %ju\n", (uintmax_t)objnum); @@ -2083,9 +2084,9 @@ zfs_mount_dataset(const spa_t *spa, uint64_t objnum, o } ds = (dsl_dataset_phys_t *) &dataset.dn_bonus; - if (zio_read(spa, &ds->ds_bp, objset)) { - printf("ZFS: can't read object set for dataset %ju\n", - (uintmax_t)objnum); + if ((err = zio_read(spa, &ds->ds_bp, objset)) != 0) { + printf("ZFS: can't read object set for dataset %ju (error %d)\n", + (uintmax_t)objnum, err); return (EIO); } From owner-svn-src-stable-12@freebsd.org Thu Mar 14 10:06:47 2019 Return-Path: Delivered-To: svn-src-stable-12@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 31400153BD7C; Thu, 14 Mar 2019 10:06:47 +0000 (UTC) (envelope-from smh@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 C609270042; Thu, 14 Mar 2019 10:06:46 +0000 (UTC) (envelope-from smh@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 B617220E18; Thu, 14 Mar 2019 10:06:46 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2EA6kIX069176; Thu, 14 Mar 2019 10:06:46 GMT (envelope-from smh@FreeBSD.org) Received: (from smh@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2EA6kAd069175; Thu, 14 Mar 2019 10:06:46 GMT (envelope-from smh@FreeBSD.org) Message-Id: <201903141006.x2EA6kAd069175@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: smh set sender to smh@FreeBSD.org using -f From: Steven Hartland Date: Thu, 14 Mar 2019 10:06:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345129 - stable/12/stand/libsa/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: smh X-SVN-Commit-Paths: stable/12/stand/libsa/zfs X-SVN-Commit-Revision: 345129 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C609270042 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.945,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Mar 2019 10:06:47 -0000 Author: smh Date: Thu Mar 14 10:06:46 2019 New Revision: 345129 URL: https://svnweb.freebsd.org/changeset/base/345129 Log: Revert zfsimpl.c accidentally committed in r345128 Revert an unrelated change to zfsimpl.c accidentally committed in r345128. Sponsored by: Multiplay Modified: stable/12/stand/libsa/zfs/zfsimpl.c Modified: stable/12/stand/libsa/zfs/zfsimpl.c ============================================================================== --- stable/12/stand/libsa/zfs/zfsimpl.c Thu Mar 14 10:03:04 2019 (r345128) +++ stable/12/stand/libsa/zfs/zfsimpl.c Thu Mar 14 10:06:46 2019 (r345129) @@ -2076,7 +2076,6 @@ zfs_mount_dataset(const spa_t *spa, uint64_t objnum, o { dnode_phys_t dataset; dsl_dataset_phys_t *ds; - int err; if (objset_get_dnode(spa, &spa->spa_mos, objnum, &dataset)) { printf("ZFS: can't find dataset %ju\n", (uintmax_t)objnum); @@ -2084,9 +2083,9 @@ zfs_mount_dataset(const spa_t *spa, uint64_t objnum, o } ds = (dsl_dataset_phys_t *) &dataset.dn_bonus; - if ((err = zio_read(spa, &ds->ds_bp, objset)) != 0) { - printf("ZFS: can't read object set for dataset %ju (error %d)\n", - (uintmax_t)objnum, err); + if (zio_read(spa, &ds->ds_bp, objset)) { + printf("ZFS: can't read object set for dataset %ju\n", + (uintmax_t)objnum); return (EIO); } From owner-svn-src-stable-12@freebsd.org Fri Mar 15 01:26:11 2019 Return-Path: Delivered-To: svn-src-stable-12@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 77CEA15367B1; Fri, 15 Mar 2019 01:26:11 +0000 (UTC) (envelope-from mmacy@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 1A4DA7755D; Fri, 15 Mar 2019 01:26:11 +0000 (UTC) (envelope-from mmacy@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 0E2292D80; Fri, 15 Mar 2019 01:26:11 +0000 (UTC) (envelope-from mmacy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2F1QArQ055046; Fri, 15 Mar 2019 01:26:10 GMT (envelope-from mmacy@FreeBSD.org) Received: (from mmacy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2F1QAqX055045; Fri, 15 Mar 2019 01:26:10 GMT (envelope-from mmacy@FreeBSD.org) Message-Id: <201903150126.x2F1QAqX055045@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmacy set sender to mmacy@FreeBSD.org using -f From: Matt Macy Date: Fri, 15 Mar 2019 01:26:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345169 - stable/12/sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: mmacy X-SVN-Commit-Paths: stable/12/sys/sys X-SVN-Commit-Revision: 345169 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1A4DA7755D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 01:26:11 -0000 Author: mmacy Date: Fri Mar 15 01:26:10 2019 New Revision: 345169 URL: https://svnweb.freebsd.org/changeset/base/345169 Log: bump version to reflect MFC of CCM for the benefit of the ZoF port Sponsored by: iX Systems Modified: stable/12/sys/sys/param.h Modified: stable/12/sys/sys/param.h ============================================================================== --- stable/12/sys/sys/param.h Fri Mar 15 00:20:28 2019 (r345168) +++ stable/12/sys/sys/param.h Fri Mar 15 01:26:10 2019 (r345169) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1200503 /* Master, propagated to newvers */ +#define __FreeBSD_version 1200504 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable-12@freebsd.org Fri Mar 15 07:34:07 2019 Return-Path: Delivered-To: svn-src-stable-12@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 A43BB1540E8A; Fri, 15 Mar 2019 07:34:07 +0000 (UTC) (envelope-from avos@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 405BF8CB2F; Fri, 15 Mar 2019 07:34:07 +0000 (UTC) (envelope-from avos@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 2FD856F83; Fri, 15 Mar 2019 07:34:07 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2F7Y7dT051045; Fri, 15 Mar 2019 07:34:07 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2F7Y6Ov051042; Fri, 15 Mar 2019 07:34:06 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201903150734.x2F7Y6Ov051042@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Fri, 15 Mar 2019 07:34:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345172 - stable/12/sys/dev/iwm X-SVN-Group: stable-12 X-SVN-Commit-Author: avos X-SVN-Commit-Paths: stable/12/sys/dev/iwm X-SVN-Commit-Revision: 345172 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 405BF8CB2F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 07:34:07 -0000 Author: avos Date: Fri Mar 15 07:34:06 2019 New Revision: 345172 URL: https://svnweb.freebsd.org/changeset/base/345172 Log: MFC r345002: iwm(4): use correct channel list source for Intel 3168 Intel 3168 uses another EEPROM section to store channel flags; port missing bits from iwlwifi to make it work. PR: 230750, 236235 Tested by: Bert JW Regeer Modified: stable/12/sys/dev/iwm/if_iwm.c stable/12/sys/dev/iwm/if_iwm_7000.c stable/12/sys/dev/iwm/if_iwm_config.h stable/12/sys/dev/iwm/if_iwmreg.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iwm/if_iwm.c ============================================================================== --- stable/12/sys/dev/iwm/if_iwm.c Fri Mar 15 02:11:28 2019 (r345171) +++ stable/12/sys/dev/iwm/if_iwm.c Fri Mar 15 07:34:06 2019 (r345172) @@ -2237,7 +2237,8 @@ iwm_parse_nvm_data(struct iwm_softc *sc, } if (sc->cfg->device_family == IWM_DEVICE_FAMILY_7000) { - memcpy(data->nvm_ch_flags, &nvm_sw[IWM_NVM_CHANNELS], + memcpy(data->nvm_ch_flags, sc->cfg->nvm_type == IWM_NVM_SDP ? + ®ulatory[0] : &nvm_sw[IWM_NVM_CHANNELS], IWM_NUM_CHANNELS * sizeof(uint16_t)); } else { memcpy(data->nvm_ch_flags, ®ulatory[IWM_NVM_CHANNELS_8000], @@ -2297,8 +2298,9 @@ iwm_parse_nvm_sections(struct iwm_softc *sc, struct iw sw = (const uint16_t *)sections[IWM_NVM_SECTION_TYPE_SW].data; calib = (const uint16_t *) sections[IWM_NVM_SECTION_TYPE_CALIBRATION].data; - regulatory = (const uint16_t *) - sections[IWM_NVM_SECTION_TYPE_REGULATORY].data; + regulatory = sc->cfg->nvm_type == IWM_NVM_SDP ? + (const uint16_t *)sections[IWM_NVM_SECTION_TYPE_REGULATORY_SDP].data : + (const uint16_t *)sections[IWM_NVM_SECTION_TYPE_REGULATORY].data; mac_override = (const uint16_t *) sections[IWM_NVM_SECTION_TYPE_MAC_OVERRIDE].data; phy_sku = (const uint16_t *)sections[IWM_NVM_SECTION_TYPE_PHY_SKU].data; Modified: stable/12/sys/dev/iwm/if_iwm_7000.c ============================================================================== --- stable/12/sys/dev/iwm/if_iwm_7000.c Fri Mar 15 02:11:28 2019 (r345171) +++ stable/12/sys/dev/iwm/if_iwm_7000.c Fri Mar 15 07:34:06 2019 (r345172) @@ -119,6 +119,7 @@ const struct iwm_cfg iwm3168_cfg = { .fw_name = IWM3168_FW, IWM_DEVICE_7000_COMMON, .host_interrupt_operation_mode = 0, + .nvm_type = IWM_NVM_SDP, }; const struct iwm_cfg iwm7265_cfg = { Modified: stable/12/sys/dev/iwm/if_iwm_config.h ============================================================================== --- stable/12/sys/dev/iwm/if_iwm_config.h Fri Mar 15 02:11:28 2019 (r345171) +++ stable/12/sys/dev/iwm/if_iwm_config.h Fri Mar 15 07:34:06 2019 (r345172) @@ -102,7 +102,20 @@ static inline uint8_t num_of_ant(uint8_t mask) #define IWM_OTP_LOW_IMAGE_SIZE_FAMILY_8000 (32 * 512 * sizeof(uint16_t)) /* 32 KB */ #define IWM_OTP_LOW_IMAGE_SIZE_FAMILY_9000 IWM_OTP_LOW_IMAGE_SIZE_FAMILY_8000 + /** + * enum iwl_nvm_type - nvm formats + * @IWM_NVM: the regular format + * @IWM_NVM_EXT: extended NVM format + * @IWM_NVM_SDP: NVM format used by 3168 series + */ +enum iwm_nvm_type { + IWM_NVM, + IWM_NVM_EXT, + IWM_NVM_SDP, +}; + +/** * struct iwm_cfg * @name: Official name of the device * @fw_name: Firmware filename. @@ -111,6 +124,7 @@ static inline uint8_t num_of_ant(uint8_t mask) * @nvm_hw_section_num: the ID of the HW NVM section * @apmg_wake_up_wa: should the MAC access REQ be asserted when a command * is in flight. This is due to a HW bug in 7260, 3160 and 7265. + * @nvm_type: see &enum iwl_nvm_type */ struct iwm_cfg { const char *name; @@ -120,6 +134,7 @@ struct iwm_cfg { int host_interrupt_operation_mode; uint8_t nvm_hw_section_num; int apmg_wake_up_wa; + enum iwm_nvm_type nvm_type; }; /* Modified: stable/12/sys/dev/iwm/if_iwmreg.h ============================================================================== --- stable/12/sys/dev/iwm/if_iwmreg.h Fri Mar 15 02:11:28 2019 (r345171) +++ stable/12/sys/dev/iwm/if_iwmreg.h Fri Mar 15 07:34:06 2019 (r345172) @@ -1992,6 +1992,7 @@ enum { IWM_NVM_SECTION_TYPE_REGULATORY = 3, IWM_NVM_SECTION_TYPE_CALIBRATION = 4, IWM_NVM_SECTION_TYPE_PRODUCTION = 5, + IWM_NVM_SECTION_TYPE_REGULATORY_SDP = 8, IWM_NVM_SECTION_TYPE_MAC_OVERRIDE = 11, IWM_NVM_SECTION_TYPE_PHY_SKU = 12, IWM_NVM_MAX_NUM_SECTIONS = 13, From owner-svn-src-stable-12@freebsd.org Fri Mar 15 08:18:03 2019 Return-Path: Delivered-To: svn-src-stable-12@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 5ECAF154233D; Fri, 15 Mar 2019 08:18:03 +0000 (UTC) (envelope-from avos@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 037B68DC8B; Fri, 15 Mar 2019 08:18:03 +0000 (UTC) (envelope-from avos@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 E5537762E; Fri, 15 Mar 2019 08:18:02 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2F8I2AJ071736; Fri, 15 Mar 2019 08:18:02 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2F8I2hO071735; Fri, 15 Mar 2019 08:18:02 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201903150818.x2F8I2hO071735@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Fri, 15 Mar 2019 08:18:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345173 - in stable: 11/sbin/ifconfig 12/sbin/ifconfig X-SVN-Group: stable-12 X-SVN-Commit-Author: avos X-SVN-Commit-Paths: in stable: 11/sbin/ifconfig 12/sbin/ifconfig X-SVN-Commit-Revision: 345173 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 037B68DC8B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 08:18:03 -0000 Author: avos Date: Fri Mar 15 08:18:02 2019 New Revision: 345173 URL: https://svnweb.freebsd.org/changeset/base/345173 Log: MFC r344748: Allow to build ifconfig(8) without wireless support The change removes SIOC[GS]IEEE80211 handling from ifconfig(8) if WITHOUT_WIRELESS_SUPPORT=yes is set in src.conf(5). Reviewed by: bz Differential Revision: https://reviews.freebsd.org/D19289 Modified: stable/12/sbin/ifconfig/Makefile Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sbin/ifconfig/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/12/sbin/ifconfig/Makefile ============================================================================== --- stable/12/sbin/ifconfig/Makefile Fri Mar 15 07:34:06 2019 (r345172) +++ stable/12/sbin/ifconfig/Makefile Fri Mar 15 08:18:02 2019 (r345173) @@ -39,8 +39,10 @@ SRCS+= ifipsec.c # IPsec VTI SRCS+= sfp.c # SFP/SFP+ information LIBADD+= m +.if ${MK_WIRELESS_SUPPORT} != "no" SRCS+= ifieee80211.c # SIOC[GS]IEEE80211 support LIBADD+= 80211 +.endif SRCS+= carp.c # SIOC[GS]VH support SRCS+= ifgroup.c # ... From owner-svn-src-stable-12@freebsd.org Fri Mar 15 11:01:50 2019 Return-Path: Delivered-To: svn-src-stable-12@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 A51B31545F8A; Fri, 15 Mar 2019 11:01:50 +0000 (UTC) (envelope-from kp@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 45E2B92A6F; Fri, 15 Mar 2019 11:01:50 +0000 (UTC) (envelope-from kp@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 3158592CC; Fri, 15 Mar 2019 11:01:50 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2FB1nO0060730; Fri, 15 Mar 2019 11:01:49 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2FB1n2N060729; Fri, 15 Mar 2019 11:01:49 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201903151101.x2FB1n2N060729@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Fri, 15 Mar 2019 11:01:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345175 - stable/12/sys/netpfil/pf X-SVN-Group: stable-12 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/12/sys/netpfil/pf X-SVN-Commit-Revision: 345175 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 45E2B92A6F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.94)[-0.941,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 11:01:50 -0000 Author: kp Date: Fri Mar 15 11:01:49 2019 New Revision: 345175 URL: https://svnweb.freebsd.org/changeset/base/345175 Log: MFC r344921: pf: Fix DIOCGETSRCNODES r343295 broke DIOCGETSRCNODES by failing to reset 'nr' after counting the number of source tracking nodes. This meant that we never copied the information to userspace, leading to '? -> ?' output from pfctl. PR: 236368 Modified: stable/12/sys/netpfil/pf/pf_ioctl.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netpfil/pf/pf_ioctl.c ============================================================================== --- stable/12/sys/netpfil/pf/pf_ioctl.c Fri Mar 15 08:21:11 2019 (r345174) +++ stable/12/sys/netpfil/pf/pf_ioctl.c Fri Mar 15 11:01:49 2019 (r345175) @@ -3754,6 +3754,8 @@ DIOCCHANGEADDR_error: break; } + nr = 0; + p = pstore = malloc(psn->psn_len, M_TEMP, M_WAITOK); for (i = 0, sh = V_pf_srchash; i <= pf_srchashmask; i++, sh++) { From owner-svn-src-stable-12@freebsd.org Fri Mar 15 14:16:20 2019 Return-Path: Delivered-To: svn-src-stable-12@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 23DA8154A249; Fri, 15 Mar 2019 14:16:20 +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.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 CA42C6A170; Fri, 15 Mar 2019 14:16:19 +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 B6A81B355; Fri, 15 Mar 2019 14:16:19 +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 x2FEGJVY059913; Fri, 15 Mar 2019 14:16:19 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2FEGGsF059896; Fri, 15 Mar 2019 14:16:16 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201903151416.x2FEGGsF059896@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 15 Mar 2019 14:16:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345181 - in stable/12: lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12: lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys X-SVN-Commit-Revision: 345181 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: CA42C6A170 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.96)[-0.963,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 14:16:20 -0000 Author: kib Date: Fri Mar 15 14:16:16 2019 New Revision: 345181 URL: https://svnweb.freebsd.org/changeset/base/345181 Log: MFC r341689, r341711, r341712, r341809: Add getfhat(2), fhlink(2), fhlinkat(2), fhreadlink(2) file handle system calls. To easier potential MFC of the AT_BENEATH feature, some vestiges of it were left in the merged product but commented out. Due to a lot of conflicts, it was impossible to split the merge and regeneration of the syscall tables, because I needed to test the result. It is fine for stable branch to commit the whole change with the generated diff. Added: stable/12/lib/libc/sys/fhlink.2 - copied unchanged from r341689, head/lib/libc/sys/fhlink.2 stable/12/lib/libc/sys/fhreadlink.2 - copied unchanged from r341689, head/lib/libc/sys/fhreadlink.2 Modified: stable/12/lib/libc/sys/Makefile.inc stable/12/lib/libc/sys/Symbol.map stable/12/lib/libc/sys/getfh.2 stable/12/sys/compat/freebsd32/freebsd32_syscall.h stable/12/sys/compat/freebsd32/freebsd32_syscalls.c stable/12/sys/compat/freebsd32/freebsd32_sysent.c stable/12/sys/compat/freebsd32/freebsd32_systrace_args.c stable/12/sys/compat/freebsd32/syscalls.master stable/12/sys/kern/init_sysent.c stable/12/sys/kern/syscalls.c stable/12/sys/kern/syscalls.master stable/12/sys/kern/systrace_args.c stable/12/sys/kern/vfs_syscalls.c stable/12/sys/sys/mount.h stable/12/sys/sys/syscall.h stable/12/sys/sys/syscall.mk stable/12/sys/sys/sysproto.h Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/sys/Makefile.inc ============================================================================== --- stable/12/lib/libc/sys/Makefile.inc Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/lib/libc/sys/Makefile.inc Fri Mar 15 14:16:16 2019 (r345181) @@ -184,7 +184,9 @@ MAN+= abort2.2 \ extattr_get_file.2 \ fcntl.2 \ ffclock.2 \ + fhlink.2 \ fhopen.2 \ + fhreadlink.2 \ flock.2 \ fork.2 \ fsync.2 \ @@ -395,7 +397,8 @@ MLINKS+=ffclock.2 ffclock_getcounter.2 \ MLINKS+=fhopen.2 fhstat.2 fhopen.2 fhstatfs.2 MLINKS+=fsync.2 fdatasync.2 MLINKS+=getdirentries.2 getdents.2 -MLINKS+=getfh.2 lgetfh.2 +MLINKS+=getfh.2 lgetfh.2 \ + getfh.2 getfhat.2 MLINKS+=getgid.2 getegid.2 MLINKS+=getitimer.2 setitimer.2 MLINKS+=getlogin.2 getlogin_r.3 Modified: stable/12/lib/libc/sys/Symbol.map ============================================================================== --- stable/12/lib/libc/sys/Symbol.map Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/lib/libc/sys/Symbol.map Fri Mar 15 14:16:16 2019 (r345181) @@ -401,6 +401,13 @@ FBSD_1.5 { cpuset_setdomain; }; +FBSD_1.6 { + fhlink; + fhlinkat; + fhreadlink; + getfhat; +}; + FBSDprivate_1.0 { ___acl_aclcheck_fd; __sys___acl_aclcheck_fd; Copied: stable/12/lib/libc/sys/fhlink.2 (from r341689, head/lib/libc/sys/fhlink.2) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/lib/libc/sys/fhlink.2 Fri Mar 15 14:16:16 2019 (r345181, copy of r341689, head/lib/libc/sys/fhlink.2) @@ -0,0 +1,268 @@ +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.\" Copyright (c) 2018 Gandi +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd November 29, 2018 +.Dt FHLINK 2 +.Os +.Sh NAME +.Nm fhlink , +.Nm fhlinkat +.Nd make a hard file link +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fn fhlink "fhandle_t *fhp" "const char *to" +.Ft int +.Fn fhlinkat "fhandle_t *fhp" "int tofd" "const char *to" +.Fc +.Sh DESCRIPTION +The +.Fn fhlink +system call +atomically creates the specified directory entry (hard link) +.Fa to +with the attributes of the underlying object pointed at by +.Fa fhp . +If the link is successful: the link count of the underlying object +is incremented; +.Fa fhp +and +.Fa to +share equal access and rights +to the +underlying object. +.Pp +If +.Fa fhp +is removed, the file +.Fa to +is not deleted and the link count of the +underlying object is +decremented. +.Pp +The object pointed at by the +.Fa fhp +argument +must exist for the hard link to +succeed and +both +.Fa fhp +and +.Fa to +must be in the same file system. +The +.Fa fhp +argument +may not be a directory. +.Pp +The +.Fn fhlinkat +system call is equivalent to +.Fa fhlink +except in the case where +.Fa to +is a relative paths. +In this case a relative path +.Fa to +is interpreted relative to +the directory associated with the file descriptor +.Fa tofd +instead of the current working directory. +.Pp +Values for +.Fa flag +are constructed by a bitwise-inclusive OR of flags from the following +list, defined in +.In fcntl.h : +.Bl -tag -width indent +.It Dv AT_SYMLINK_FOLLOW +If +.Fa fhp +names a symbolic link, a new link for the target of the symbolic link is +created. +.It Dv AT_BENEATH +Only allow to link to a file which is beneath of the topping directory. +See the description of the +.Dv O_BENEATH +flag in the +.Xr open 2 +manual page. +.El +.Pp +If +.Fn fhlinkat +is passed the special value +.Dv AT_FDCWD +in the +.Fa tofd +parameter, the current working directory is used for the +.Fa to +argument. +If +.Fa tofd +has value +.Dv AT_FDCWD , +the behavior is identical to a call to +.Fn link . +Unless +.Fa flag +contains the +.Dv AT_SYMLINK_FOLLOW +flag, if +.Fa fhp +names a symbolic link, a new link is created for the symbolic link +.Fa fhp +and not its target. +.Sh RETURN VALUES +.Rv -std link +.Sh ERRORS +The +.Fn fhlink +system call +will fail and no link will be created if: +.Bl -tag -width Er +.It Bq Er ENOTDIR +A component of +.Fa to +prefix is not a directory. +.It Bq Er ENAMETOOLONG +A component of +.Fa to +exceeded 255 characters, +or entire length of +.Fa to +name exceeded 1023 characters. +.It Bq Er ENOENT +A component of +.Fa to +prefix does not exist. +.It Bq Er EOPNOTSUPP +The file system containing the file pointed at by +.Fa fhp +does not support links. +.It Bq Er EMLINK +The link count of the file pointed at by +.Fa fhp +would exceed 32767. +.It Bq Er EACCES +A component of +.Fa to +prefix denies search permission. +.It Bq Er EACCES +The requested link requires writing in a directory with a mode +that denies write permission. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating one of the pathnames. +.It Bq Er ENOENT +The file pointed at by +.Fa fhp +does not exist. +.It Bq Er EEXIST +The link named by +.Fa to +does exist. +.It Bq Er EPERM +The file pointed at by +.Fa fhp +is a directory. +.It Bq Er EPERM +The file pointed at by +.Fa fhp +has its immutable or append-only flag set, see the +.Xr chflags 2 +manual page for more information. +.It Bq Er EPERM +The parent directory of the file named by +.Fa to +has its immutable flag set. +.It Bq Er EXDEV +The link named by +.Fa to +and the file pointed at by +.Fa fhp +are on different file systems. +.It Bq Er ENOSPC +The directory in which the entry for the new link is being placed +cannot be extended because there is no space left on the file +system containing the directory. +.It Bq Er EDQUOT +The directory in which the entry for the new link +is being placed cannot be extended because the +user's quota of disk blocks on the file system +containing the directory has been exhausted. +.It Bq Er EIO +An I/O error occurred while reading from or writing to +the file system to make the directory entry. +.It Bq Er EROFS +The requested link requires writing in a directory on a read-only file +system. +.It Bq Er EFAULT +One of the pathnames specified +is outside the process's allocated address space. +.It Bq Er ESTALE +The file handle +.Fa fhp +is no longer valid +.El +.Pp +In addition to the errors returned by the +.Fn fhlink , +the +.Fn fhlinkat +system call may fail if: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa fhp +or +.Fa to +argument does not specify an absolute path and the +.Fa tofd +argument, is not +.Dv AT_FDCWD +nor a valid file descriptor open for searching. +.It Bq Er EINVAL +The value of the +.Fa flag +argument is not valid. +.It Bq Er ENOTDIR +The +.Fa fhp +or +.Fa to +argument is not an absolute path and +.Fa tofd +is not +.Dv AT_FDCWD +nor a file descriptor associated with a directory. +.El +.Sh SEE ALSO +.Xr fhstat 2 , +.Xr fhreadlink 2 , +.Xr fhopen 2 , Copied: stable/12/lib/libc/sys/fhreadlink.2 (from r341689, head/lib/libc/sys/fhreadlink.2) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/lib/libc/sys/fhreadlink.2 Fri Mar 15 14:16:16 2019 (r345181, copy of r341689, head/lib/libc/sys/fhreadlink.2) @@ -0,0 +1,92 @@ +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.\" Copyright (c) 2018 Gandi +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd November 29, 2018 +.Dt FHREADLINK 2 +.Os +.Sh NAME +.Nm fhreadlink +.Nd read value of a symbolic link +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/param.h +.In sys/mount.h +.Ft int +.Fn fhreadlink "fhandle_t *fhp" "char *buf" "size_t bufsize" +.Fc +.Sh DESCRIPTION +The +.Fn fhreadlink +system call +places the contents of the symbolic link +.Fa fhp +in the buffer +.Fa buf , +which has size +.Fa bufsiz . +The +.Fn fhreadlink +system call does not append a +.Dv NUL +character to +.Fa buf . +.Pp +.Sh RETURN VALUES +The call returns the count of characters placed in the buffer +if it succeeds, or a \-1 if an error occurs, placing the error +code in the global variable +.Va errno . +.Sh ERRORS +The +.Fn readlink +system call +will fail if: +.Bl -tag -width Er +.It Bq Er ENOENT +The named file does not exist. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the file handle +.Fa fhp . +.It Bq Er EINVAL +The named file is not a symbolic link. +.It Bq Er EIO +An I/O error occurred while reading from the file system. +.It Bq Er EFAULT +The +.Fa buf +argument +extends outside the process's allocated address space. +.It Bq Er ESTALE +The file handle +.Fa fhp +is no longer valid +.El +.El +.Sh SEE ALSO +.Xr fhstat 2 , +.Xr fhlink 2 , Modified: stable/12/lib/libc/sys/getfh.2 ============================================================================== --- stable/12/lib/libc/sys/getfh.2 Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/lib/libc/sys/getfh.2 Fri Mar 15 14:16:16 2019 (r345181) @@ -1,5 +1,6 @@ .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. +.\" Copyright (c) 2018 Gandi .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -28,12 +29,13 @@ .\" @(#)getfh.2 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd April 14, 2011 +.Dd December 11, 2018 .Dt GETFH 2 .Os .Sh NAME .Nm getfh , -.Nm lgetfh +.Nm lgetfh , +.Nm getfhat .Nd get file handle .Sh LIBRARY .Lb libc @@ -44,6 +46,8 @@ .Fn getfh "const char *path" "fhandle_t *fhp" .Ft int .Fn lgetfh "const char *path" "fhandle_t *fhp" +.Ft int +.Fn getfhat "int fd" "const char *path" "fhandle_t *fhp" "int flag" .Sh DESCRIPTION The .Fn getfh @@ -51,6 +55,7 @@ system call returns a file handle for the specified file or directory in the file handle pointed to by .Fa fhp . +.Pp The .Fn lgetfh system call is like @@ -62,6 +67,85 @@ returns information about the link, while .Fn getfh returns information about the file the link references. +.Pp +The +.Fn getfhat +system call is equivalent to +.Fn getfh +and +.Fn lgetfh +except when the +.Fa path +specifies a relative path, or the +.Dv AT_BENEATH +flag is provided. +For +.Fn getfhat +and relative +.Fa path , +the status is retrieved from a file relative to +the directory associated with the file descriptor +.Fa fd +instead of the current working directory. +For +.Dv AT_BENEATH +and absolute +.Fa path , +the status is retrieved from a file specified by the +.Fa path , +but additional permission checks are performed, see below. +.Pp +The values for the +.Fa flag +are constructed by a bitwise-inclusive OR of flags from this list, +defined in +.In fcntl.h : +.Bl -tag -width indent +.It Dv AT_SYMLINK_NOFOLLOW +If +.Fa path +names a symbolic link, the status of the symbolic link is returned. +.It Dv AT_BENEATH +Only stat files and directories below the topping directory. +See the description of the +.Dv O_BENEATH +flag in the +.Xr open 2 +manual page. +.El +.Pp +If +.Fn getfhat +is passed the special value +.Dv AT_FDCWD +in the +.Fa fd +parameter, the current working directory is used and the behavior is +identical to a call to +.Fn getfth +or +.Fn lgetfh +respectively, depending on whether or not the +.Dv AT_SYMLINK_NOFOLLOW +bit is set in +.Fa flag . +.Pp +When +.Fn getfhat +is called with an absolute +.Fa path +without the +.Dv AT_BENEATH +flag, it ignores the +.Fa fd +argument. +When +.Dv AT_BENEATH +is specified with an absolute +.Fa path , +a directory passed by the +.Fa fd +argument is used as the topping point for the resolution. These system calls are restricted to the superuser. .Sh RETURN VALUES .Rv -std @@ -99,11 +183,49 @@ The .Fa fhp argument points to an invalid address. +.It Bq Er EFAULT +The +.Fa path +argument +points to an invalid address. .It Bq Er EIO An .Tn I/O error occurred while reading from or writing to the file system. +.It Bq Er ESTALE +The file handle +.Fa fhp +is no longer valid. .El +.Pp +In addition to the errors returned by +.Fn getfh , +and +.Fn lgetfh , +the +.Fn getfhat +system call may fail if: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa path +argument does not specify an absolute path and the +.Fa fd +argument, is neither +.Dv AT_FDCWD +nor a valid file descriptor open for searching. +.It Bq Er EINVAL +The value of the +.Fa flag +argument is not valid. +.It Bq Er ENOTDIR +The +.Fa path +argument is not an absolute path and +.Fa fd +is neither +.Dv AT_FDCWD +nor a file descriptor associated with a directory. .Sh SEE ALSO .Xr fhopen 2 , .Xr open 2 , Modified: stable/12/sys/compat/freebsd32/freebsd32_syscall.h ============================================================================== --- stable/12/sys/compat/freebsd32/freebsd32_syscall.h Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/sys/compat/freebsd32/freebsd32_syscall.h Fri Mar 15 14:16:16 2019 (r345181) @@ -490,4 +490,8 @@ #define FREEBSD32_SYS_freebsd32_cpuset_getdomain 561 #define FREEBSD32_SYS_freebsd32_cpuset_setdomain 562 #define FREEBSD32_SYS_getrandom 563 -#define FREEBSD32_SYS_MAXSYSCALL 564 +#define FREEBSD32_SYS_getfhat 564 +#define FREEBSD32_SYS_fhlink 565 +#define FREEBSD32_SYS_fhlinkat 566 +#define FREEBSD32_SYS_fhreadlink 567 +#define FREEBSD32_SYS_MAXSYSCALL 568 Modified: stable/12/sys/compat/freebsd32/freebsd32_syscalls.c ============================================================================== --- stable/12/sys/compat/freebsd32/freebsd32_syscalls.c Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/sys/compat/freebsd32/freebsd32_syscalls.c Fri Mar 15 14:16:16 2019 (r345181) @@ -600,4 +600,8 @@ const char *freebsd32_syscallnames[] = { "freebsd32_cpuset_getdomain", /* 561 = freebsd32_cpuset_getdomain */ "freebsd32_cpuset_setdomain", /* 562 = freebsd32_cpuset_setdomain */ "getrandom", /* 563 = getrandom */ + "getfhat", /* 564 = getfhat */ + "fhlink", /* 565 = fhlink */ + "fhlinkat", /* 566 = fhlinkat */ + "fhreadlink", /* 567 = fhreadlink */ }; Modified: stable/12/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- stable/12/sys/compat/freebsd32/freebsd32_sysent.c Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/sys/compat/freebsd32/freebsd32_sysent.c Fri Mar 15 14:16:16 2019 (r345181) @@ -647,4 +647,8 @@ struct sysent freebsd32_sysent[] = { { AS(freebsd32_cpuset_getdomain_args), (sy_call_t *)freebsd32_cpuset_getdomain, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 561 = freebsd32_cpuset_getdomain */ { AS(freebsd32_cpuset_setdomain_args), (sy_call_t *)freebsd32_cpuset_setdomain, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 562 = freebsd32_cpuset_setdomain */ { AS(getrandom_args), (sy_call_t *)sys_getrandom, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 563 = getrandom */ + { AS(getfhat_args), (sy_call_t *)sys_getfhat, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 564 = getfhat */ + { AS(fhlink_args), (sy_call_t *)sys_fhlink, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 565 = fhlink */ + { AS(fhlinkat_args), (sy_call_t *)sys_fhlinkat, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 566 = fhlinkat */ + { AS(fhreadlink_args), (sy_call_t *)sys_fhreadlink, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 567 = fhreadlink */ }; Modified: stable/12/sys/compat/freebsd32/freebsd32_systrace_args.c ============================================================================== --- stable/12/sys/compat/freebsd32/freebsd32_systrace_args.c Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/sys/compat/freebsd32/freebsd32_systrace_args.c Fri Mar 15 14:16:16 2019 (r345181) @@ -3274,6 +3274,42 @@ systrace_args(int sysnum, void *params, uint64_t *uarg *n_args = 3; break; } + /* getfhat */ + case 564: { + struct getfhat_args *p = params; + iarg[0] = p->fd; /* int */ + uarg[1] = (intptr_t) p->path; /* char * */ + uarg[2] = (intptr_t) p->fhp; /* struct fhandle * */ + iarg[3] = p->flags; /* int */ + *n_args = 4; + break; + } + /* fhlink */ + case 565: { + struct fhlink_args *p = params; + uarg[0] = (intptr_t) p->fhp; /* struct fhandle * */ + uarg[1] = (intptr_t) p->to; /* const char * */ + *n_args = 2; + break; + } + /* fhlinkat */ + case 566: { + struct fhlinkat_args *p = params; + uarg[0] = (intptr_t) p->fhp; /* struct fhandle * */ + iarg[1] = p->tofd; /* int */ + uarg[2] = (intptr_t) p->to; /* const char * */ + *n_args = 3; + break; + } + /* fhreadlink */ + case 567: { + struct fhreadlink_args *p = params; + uarg[0] = (intptr_t) p->fhp; /* struct fhandle * */ + uarg[1] = (intptr_t) p->buf; /* char * */ + uarg[2] = p->bufsize; /* size_t */ + *n_args = 3; + break; + } default: *n_args = 0; break; @@ -8805,6 +8841,70 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d break; }; break; + /* getfhat */ + case 564: + switch(ndx) { + case 0: + p = "int"; + break; + case 1: + p = "userland char *"; + break; + case 2: + p = "userland struct fhandle *"; + break; + case 3: + p = "int"; + break; + default: + break; + }; + break; + /* fhlink */ + case 565: + switch(ndx) { + case 0: + p = "userland struct fhandle *"; + break; + case 1: + p = "userland const char *"; + break; + default: + break; + }; + break; + /* fhlinkat */ + case 566: + switch(ndx) { + case 0: + p = "userland struct fhandle *"; + break; + case 1: + p = "int"; + break; + case 2: + p = "userland const char *"; + break; + default: + break; + }; + break; + /* fhreadlink */ + case 567: + switch(ndx) { + case 0: + p = "userland struct fhandle *"; + break; + case 1: + p = "userland char *"; + break; + case 2: + p = "size_t"; + break; + default: + break; + }; + break; default: break; }; @@ -10651,6 +10751,26 @@ systrace_return_setargdesc(int sysnum, int ndx, char * break; /* getrandom */ case 563: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* getfhat */ + case 564: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* fhlink */ + case 565: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* fhlinkat */ + case 566: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* fhreadlink */ + case 567: if (ndx == 0 || ndx == 1) p = "int"; break; Modified: stable/12/sys/compat/freebsd32/syscalls.master ============================================================================== --- stable/12/sys/compat/freebsd32/syscalls.master Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/sys/compat/freebsd32/syscalls.master Fri Mar 15 14:16:16 2019 (r345181) @@ -1120,5 +1120,12 @@ int policy); } 563 AUE_NULL NOPROTO { int getrandom(void *buf, size_t buflen, \ unsigned int flags); } +564 AUE_NULL NOPROTO { int getfhat( int fd, char *path, \ + struct fhandle *fhp, int flags); } +565 AUE_NULL NOPROTO { int fhlink( struct fhandle *fhp, const char *to ); } +566 AUE_NULL NOPROTO { int fhlinkat( struct fhandle *fhp, int tofd, \ + const char *to); } +567 AUE_NULL NOPROTO { int fhreadlink( struct fhandle *fhp, char *buf, \ + size_t bufsize); } ; vim: syntax=off Modified: stable/12/sys/kern/init_sysent.c ============================================================================== --- stable/12/sys/kern/init_sysent.c Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/sys/kern/init_sysent.c Fri Mar 15 14:16:16 2019 (r345181) @@ -613,4 +613,8 @@ struct sysent sysent[] = { { AS(cpuset_getdomain_args), (sy_call_t *)sys_cpuset_getdomain, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 561 = cpuset_getdomain */ { AS(cpuset_setdomain_args), (sy_call_t *)sys_cpuset_setdomain, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 562 = cpuset_setdomain */ { AS(getrandom_args), (sy_call_t *)sys_getrandom, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 563 = getrandom */ + { AS(getfhat_args), (sy_call_t *)sys_getfhat, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 564 = getfhat */ + { AS(fhlink_args), (sy_call_t *)sys_fhlink, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 565 = fhlink */ + { AS(fhlinkat_args), (sy_call_t *)sys_fhlinkat, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 566 = fhlinkat */ + { AS(fhreadlink_args), (sy_call_t *)sys_fhreadlink, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 567 = fhreadlink */ }; Modified: stable/12/sys/kern/syscalls.c ============================================================================== --- stable/12/sys/kern/syscalls.c Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/sys/kern/syscalls.c Fri Mar 15 14:16:16 2019 (r345181) @@ -570,4 +570,8 @@ const char *syscallnames[] = { "cpuset_getdomain", /* 561 = cpuset_getdomain */ "cpuset_setdomain", /* 562 = cpuset_setdomain */ "getrandom", /* 563 = getrandom */ + "getfhat", /* 564 = getfhat */ + "fhlink", /* 565 = fhlink */ + "fhlinkat", /* 566 = fhlinkat */ + "fhreadlink", /* 567 = fhreadlink */ }; Modified: stable/12/sys/kern/syscalls.master ============================================================================== --- stable/12/sys/kern/syscalls.master Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/sys/kern/syscalls.master Fri Mar 15 14:16:16 2019 (r345181) @@ -1340,6 +1340,34 @@ 563 AUE_NULL STD { int getrandom( \ _Out_writes_bytes_(buflen) void *buf, \ size_t buflen, unsigned int flags); } +564 AUE_NULL STD { \ + int getfhat( \ + int fd, \ + _In_z_ char *path, \ + _Out_ struct fhandle *fhp, \ + int flags \ + ); \ + } +565 AUE_NULL STD { \ + int fhlink( \ + _In_ struct fhandle *fhp, \ + _In_z_ const char *to \ + ); \ + } +566 AUE_NULL STD { \ + int fhlinkat( \ + _In_ struct fhandle *fhp, \ + int tofd, \ + _In_z_ const char *to, \ + ); \ + } +567 AUE_NULL STD { \ + int fhreadlink( \ + _In_ struct fhandle *fhp, \ + _Out_writes_(bufsize) char *buf, \ + size_t bufsize \ + ); \ + } ; Please copy any additions and changes to the following compatability tables: ; sys/compat/freebsd32/syscalls.master Modified: stable/12/sys/kern/systrace_args.c ============================================================================== --- stable/12/sys/kern/systrace_args.c Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/sys/kern/systrace_args.c Fri Mar 15 14:16:16 2019 (r345181) @@ -3266,6 +3266,42 @@ systrace_args(int sysnum, void *params, uint64_t *uarg *n_args = 3; break; } + /* getfhat */ + case 564: { + struct getfhat_args *p = params; + iarg[0] = p->fd; /* int */ + uarg[1] = (intptr_t) p->path; /* char * */ + uarg[2] = (intptr_t) p->fhp; /* struct fhandle * */ + iarg[3] = p->flags; /* int */ + *n_args = 4; + break; + } + /* fhlink */ + case 565: { + struct fhlink_args *p = params; + uarg[0] = (intptr_t) p->fhp; /* struct fhandle * */ + uarg[1] = (intptr_t) p->to; /* const char * */ + *n_args = 2; + break; + } + /* fhlinkat */ + case 566: { + struct fhlinkat_args *p = params; + uarg[0] = (intptr_t) p->fhp; /* struct fhandle * */ + iarg[1] = p->tofd; /* int */ + uarg[2] = (intptr_t) p->to; /* const char * */ + *n_args = 3; + break; + } + /* fhreadlink */ + case 567: { + struct fhreadlink_args *p = params; + uarg[0] = (intptr_t) p->fhp; /* struct fhandle * */ + uarg[1] = (intptr_t) p->buf; /* char * */ + uarg[2] = p->bufsize; /* size_t */ + *n_args = 3; + break; + } default: *n_args = 0; break; @@ -8710,6 +8746,70 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *d break; }; break; + /* getfhat */ + case 564: + switch(ndx) { + case 0: + p = "int"; + break; + case 1: + p = "userland char *"; + break; + case 2: + p = "userland struct fhandle *"; + break; + case 3: + p = "int"; + break; + default: + break; + }; + break; + /* fhlink */ + case 565: + switch(ndx) { + case 0: + p = "userland struct fhandle *"; + break; + case 1: + p = "userland const char *"; + break; + default: + break; + }; + break; + /* fhlinkat */ + case 566: + switch(ndx) { + case 0: + p = "userland struct fhandle *"; + break; + case 1: + p = "int"; + break; + case 2: + p = "userland const char *"; + break; + default: + break; + }; + break; + /* fhreadlink */ + case 567: + switch(ndx) { + case 0: + p = "userland struct fhandle *"; + break; + case 1: + p = "userland char *"; + break; + case 2: + p = "size_t"; + break; + default: + break; + }; + break; default: break; }; @@ -10583,6 +10683,26 @@ systrace_return_setargdesc(int sysnum, int ndx, char * break; /* getrandom */ case 563: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* getfhat */ + case 564: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* fhlink */ + case 565: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* fhlinkat */ + case 566: + if (ndx == 0 || ndx == 1) + p = "int"; + break; + /* fhreadlink */ + case 567: if (ndx == 0 || ndx == 1) p = "int"; break; Modified: stable/12/sys/kern/vfs_syscalls.c ============================================================================== --- stable/12/sys/kern/vfs_syscalls.c Fri Mar 15 13:19:52 2019 (r345180) +++ stable/12/sys/kern/vfs_syscalls.c Fri Mar 15 14:16:16 2019 (r345181) @@ -105,6 +105,14 @@ static int setutimes(struct thread *td, struct vnode * const struct timespec *, int, int); static int vn_access(struct vnode *vp, int user_flags, struct ucred *cred, struct thread *td); +static int kern_fhlinkat(struct thread *td, int fd, const char *path, + enum uio_seg pathseg, fhandle_t *fhp); +static int kern_getfhat(struct thread *td, int flags, int fd, + const char *path, enum uio_seg pathseg, fhandle_t *fhp); +static int kern_readlink_vp(struct vnode *vp, char *buf, enum uio_seg bufseg, + size_t count, struct thread *td); +static int kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, + const char *path, enum uio_seg segflag); /* * Sync each mounted filesystem. @@ -1491,28 +1499,37 @@ can_hardlink(struct vnode *vp, struct ucred *cred) int kern_linkat(struct thread *td, int fd1, int fd2, char *path1, char *path2, - enum uio_seg segflg, int follow) + enum uio_seg segflag, int follow) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Fri Mar 15 14:18:20 2019 Return-Path: Delivered-To: svn-src-stable-12@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 5CCB8154A2E1; Fri, 15 Mar 2019 14:18:20 +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.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 F14F66A335; Fri, 15 Mar 2019 14:18:19 +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 E4490B357; Fri, 15 Mar 2019 14:18:19 +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 x2FEIJQg060045; Fri, 15 Mar 2019 14:18:19 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2FEIJGS060044; Fri, 15 Mar 2019 14:18:19 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201903151418.x2FEIJGS060044@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 15 Mar 2019 14:18:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345182 - stable/12/sys/dev/hwpmc X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/dev/hwpmc X-SVN-Commit-Revision: 345182 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: F14F66A335 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 14:18:20 -0000 Author: kib Date: Fri Mar 15 14:18:19 2019 New Revision: 345182 URL: https://svnweb.freebsd.org/changeset/base/345182 Log: MFC r345074: Remove useless version check. Modified: stable/12/sys/dev/hwpmc/hwpmc_core.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/hwpmc/hwpmc_core.c ============================================================================== --- stable/12/sys/dev/hwpmc/hwpmc_core.c Fri Mar 15 14:16:16 2019 (r345181) +++ stable/12/sys/dev/hwpmc/hwpmc_core.c Fri Mar 15 14:18:19 2019 (r345182) @@ -40,11 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include -#if (__FreeBSD_version >= 1100000) #include -#else -#include -#endif #include #include #include From owner-svn-src-stable-12@freebsd.org Fri Mar 15 14:19:46 2019 Return-Path: Delivered-To: svn-src-stable-12@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 6CDA7154A359; Fri, 15 Mar 2019 14:19:46 +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.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 1082F6A530; Fri, 15 Mar 2019 14:19:46 +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 02291B358; Fri, 15 Mar 2019 14:19:46 +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 x2FEJjCT060152; Fri, 15 Mar 2019 14:19:45 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2FEJjRg060150; Fri, 15 Mar 2019 14:19:45 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201903151419.x2FEJjRg060150@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 15 Mar 2019 14:19:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345183 - in stable/12/sys/x86: include x86 X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys/x86: include x86 X-SVN-Commit-Revision: 345183 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1082F6A530 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 14:19:46 -0000 Author: kib Date: Fri Mar 15 14:19:45 2019 New Revision: 345183 URL: https://svnweb.freebsd.org/changeset/base/345183 Log: MFC r345075: Add register number, CPUID bits, and print identification for TSX force abort errata. Modified: stable/12/sys/x86/include/specialreg.h stable/12/sys/x86/x86/identcpu.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/x86/include/specialreg.h ============================================================================== --- stable/12/sys/x86/include/specialreg.h Fri Mar 15 14:18:19 2019 (r345182) +++ stable/12/sys/x86/include/specialreg.h Fri Mar 15 14:19:45 2019 (r345183) @@ -431,6 +431,7 @@ /* * CPUID instruction 7 Structured Extended Features, leaf 0 edx info */ +#define CPUID_STDEXT3_TSXFA 0x00002000 #define CPUID_STDEXT3_IBPB 0x04000000 #define CPUID_STDEXT3_STIBP 0x08000000 #define CPUID_STDEXT3_L1D_FLUSH 0x10000000 @@ -489,6 +490,7 @@ #define MSR_MTRRcap 0x0fe #define MSR_IA32_ARCH_CAP 0x10a #define MSR_IA32_FLUSH_CMD 0x10b +#define MSR_TSX_FORCE_ABORT 0x10f #define MSR_BBL_CR_ADDR 0x116 #define MSR_BBL_CR_DECC 0x118 #define MSR_BBL_CR_CTL 0x119 Modified: stable/12/sys/x86/x86/identcpu.c ============================================================================== --- stable/12/sys/x86/x86/identcpu.c Fri Mar 15 14:18:19 2019 (r345182) +++ stable/12/sys/x86/x86/identcpu.c Fri Mar 15 14:19:45 2019 (r345183) @@ -992,6 +992,7 @@ printcpuinfo(void) printf("\n Structured Extended Features3=0x%b", cpu_stdext_feature3, "\020" + "\016TSXFA" "\033IBPB" "\034STIBP" "\035L1DFL" From owner-svn-src-stable-12@freebsd.org Sat Mar 16 10:51:12 2019 Return-Path: Delivered-To: svn-src-stable-12@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 2CA7715173BE; Sat, 16 Mar 2019 10:51:12 +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.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 C1BE082ECE; Sat, 16 Mar 2019 10:51:11 +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 A3D2520F18; Sat, 16 Mar 2019 10:51:11 +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 x2GApBnm012752; Sat, 16 Mar 2019 10:51:11 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2GApBoD012751; Sat, 16 Mar 2019 10:51:11 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201903161051.x2GApBoD012751@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 16 Mar 2019 10:51:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r345224 - stable/12/usr.bin/proccontrol X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/usr.bin/proccontrol X-SVN-Commit-Revision: 345224 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C1BE082ECE X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Mar 2019 10:51:12 -0000 Author: kib Date: Sat Mar 16 10:51:11 2019 New Revision: 345224 URL: https://svnweb.freebsd.org/changeset/base/345224 Log: MFC r345089: Some fixes for proccontrol(1) man page. Modified: stable/12/usr.bin/proccontrol/proccontrol.1 Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/proccontrol/proccontrol.1 ============================================================================== --- stable/12/usr.bin/proccontrol/proccontrol.1 Sat Mar 16 10:14:03 2019 (r345223) +++ stable/12/usr.bin/proccontrol/proccontrol.1 Sat Mar 16 10:51:11 2019 (r345224) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 22, 2019 +.Dd March 13, 2019 .Dt PROCCONTROL 1 .Os .Sh NAME @@ -62,12 +62,14 @@ Control the Address Space Layout Randomization. Only applicable to the new process spawned. .It Ar trace Control the permission for debuggers to attach. +Note that process is only allowed to enable tracing for itself, +not for any other process. .It Ar trapcap Controls the signalling of capability mode access violations. .El .Pp The -Ar control +.Ar control specifies if the selected .Ar mode should be enabled or disabled. @@ -84,9 +86,13 @@ for detailed description of each mode effects and inte process control facilities. .Pp The -.Op Fl q +.Fl q switch makes the utility query and print the current setting for the selected mode. +The +.Fl q +requires the query target process specification with +.Fl p . .Sh EXIT STATUS .Ex -std .Sh EXAMPLES