git: 5f00292fe3b7 - main - cxgbe(4): Move the hw-specific parts of VXLAN setup to a separate function.
The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=5f00292fe3b76aba9115f3b2dfc887acb647eb91 commit 5f00292fe3b76aba9115f3b2dfc887acb647eb91 Author: Navdeep Parhar AuthorDate: 2021-04-23 07:26:47 + Commit: Navdeep Parhar CommitDate: 2021-04-23 07:26:47 + cxgbe(4): Move the hw-specific parts of VXLAN setup to a separate function. It can be called to (re)apply the settings in the driver softc to the hardware. MFC after: 2 weeks Sponsored by: Chelsio Communications --- sys/dev/cxgbe/t4_main.c | 58 - 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 6774e1bbb833..6e5d263c7649 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -823,6 +823,7 @@ static int mod_event(module_t, int, void *); static int notify_siblings(device_t, int); static uint64_t vi_get_counter(struct ifnet *, ift_counter); static uint64_t cxgbe_get_counter(struct ifnet *, ift_counter); +static void enable_vxlan_rx(struct adapter *); struct { uint16_t device; @@ -11671,12 +11672,38 @@ struct vxlan_evargs { }; static void -t4_vxlan_start(struct adapter *sc, void *arg) +enable_vxlan_rx(struct adapter *sc) { - struct vxlan_evargs *v = arg; + int i, rc; struct port_info *pi; uint8_t match_all_mac[ETHER_ADDR_LEN] = {0}; - int i, rc; + + ASSERT_SYNCHRONIZED_OP(sc); + + t4_write_reg(sc, A_MPS_RX_VXLAN_TYPE, V_VXLAN(sc->vxlan_port) | + F_VXLAN_EN); + for_each_port(sc, i) { + pi = sc->port[i]; + if (pi->vxlan_tcam_entry == true) + continue; + rc = t4_alloc_raw_mac_filt(sc, pi->vi[0].viid, match_all_mac, + match_all_mac, sc->rawf_base + pi->port_id, 1, pi->port_id, + true); + if (rc < 0) { + rc = -rc; + CH_ERR(&pi->vi[0], + "failed to add VXLAN TCAM entry: %d.\n", rc); + } else { + MPASS(rc == sc->rawf_base + pi->port_id); + pi->vxlan_tcam_entry = true; + } + } +} + +static void +t4_vxlan_start(struct adapter *sc, void *arg) +{ + struct vxlan_evargs *v = arg; if (sc->nrawf == 0 || chip_id(sc) <= CHELSIO_T5) return; @@ -11686,32 +11713,13 @@ t4_vxlan_start(struct adapter *sc, void *arg) if (sc->vxlan_refcount == 0) { sc->vxlan_port = v->port; sc->vxlan_refcount = 1; - t4_write_reg(sc, A_MPS_RX_VXLAN_TYPE, - V_VXLAN(v->port) | F_VXLAN_EN); - for_each_port(sc, i) { - pi = sc->port[i]; - if (pi->vxlan_tcam_entry == true) - continue; - rc = t4_alloc_raw_mac_filt(sc, pi->vi[0].viid, - match_all_mac, match_all_mac, - sc->rawf_base + pi->port_id, 1, pi->port_id, true); - if (rc < 0) { - rc = -rc; - log(LOG_ERR, - "%s: failed to add VXLAN TCAM entry: %d.\n", - device_get_name(pi->vi[0].dev), rc); - } else { - MPASS(rc == sc->rawf_base + pi->port_id); - rc = 0; - pi->vxlan_tcam_entry = true; - } - } + enable_vxlan_rx(sc); } else if (sc->vxlan_port == v->port) { sc->vxlan_refcount++; } else { - log(LOG_ERR, "%s: VXLAN already configured on port %d; " + CH_ERR(sc, "VXLAN already configured on port %d; " "ignoring attempt to configure it on port %d\n", - device_get_nameunit(sc->dev), sc->vxlan_port, v->port); + sc->vxlan_port, v->port); } end_synchronized_op(sc, 0); } ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: d76eb0da7283 - stable/13 - tcp: keep SACK scoreboard sorted when doing rescue retransmission
The branch stable/13 has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=d76eb0da7283f83b09d5491d81e25485d87298ab commit d76eb0da7283f83b09d5491d81e25485d87298ab Author: Richard Scheffenegger AuthorDate: 2021-04-18 20:14:14 + Commit: Richard Scheffenegger CommitDate: 2021-04-23 07:25:57 + tcp: keep SACK scoreboard sorted when doing rescue retransmission Reviewed By: tuexen, kbowling, #transport MFC after: 3 days Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D29825 (cherry picked from commit b87cf2bc841b2a336b7f0c6cd89573610412a84f) --- sys/netinet/tcp_sack.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_sack.c b/sys/netinet/tcp_sack.c index f8d983da723b..08ce2a0882b1 100644 --- a/sys/netinet/tcp_sack.c +++ b/sys/netinet/tcp_sack.c @@ -491,7 +491,7 @@ static struct sackhole * tcp_sackhole_insert(struct tcpcb *tp, tcp_seq start, tcp_seq end, struct sackhole *after) { - struct sackhole *hole; + struct sackhole *hole, *tail; /* Allocate a new SACK hole. */ hole = tcp_sackhole_alloc(tp, start, end); @@ -502,7 +502,15 @@ tcp_sackhole_insert(struct tcpcb *tp, tcp_seq start, tcp_seq end, if (after != NULL) TAILQ_INSERT_AFTER(&tp->snd_holes, after, hole, scblink); else - TAILQ_INSERT_TAIL(&tp->snd_holes, hole, scblink); + /* +* With Rescue Retransmission, new holes may need to +* be inserted just before the tail. +*/ + if (((tail = TAILQ_LAST_FAST(&tp->snd_holes, sackhole, + scblink)) != NULL) && SEQ_LEQ(end, tail->start)) + TAILQ_INSERT_BEFORE(tail, hole, scblink); + else + TAILQ_INSERT_TAIL(&tp->snd_holes, hole, scblink); /* Update SACK hint. */ if (tp->sackhint.nexthole == NULL) ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: ab9104cbe4d5 - stable/13 - tcp: Deal with DSACKs, and adjust rescue hole on success.
The branch stable/13 has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=ab9104cbe4d53ee337a7281151540e32bfcb8d25 commit ab9104cbe4d53ee337a7281151540e32bfcb8d25 Author: Richard Scheffenegger AuthorDate: 2021-04-20 12:53:56 + Commit: Richard Scheffenegger CommitDate: 2021-04-23 07:26:18 + tcp: Deal with DSACKs, and adjust rescue hole on success. When a rescue retransmission is successful, rather than inserting new holes to the left of it, adjust the old rescue entry to cover the missed sequence space. Also, as snd_fack may be stale by that point, pull it forward in order to never create a hole left of snd_una/th_ack. Finally, with DSACKs, tcp_sack_doack() may be called with new full ACKs but a DSACK block. Account for this eventuality properly to keep sacked_bytes >= 0. MFC after: 3 days Reviewed By: kbowling, tuexen, #transport Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D29835 (cherry picked from commit a649f1f6fd7a098ab173a69fe87916c04a8c6f8d) --- sys/netinet/tcp_sack.c | 76 +++--- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/sys/netinet/tcp_sack.c b/sys/netinet/tcp_sack.c index 08ce2a0882b1..40d63bd3832f 100644 --- a/sys/netinet/tcp_sack.c +++ b/sys/netinet/tcp_sack.c @@ -491,7 +491,7 @@ static struct sackhole * tcp_sackhole_insert(struct tcpcb *tp, tcp_seq start, tcp_seq end, struct sackhole *after) { - struct sackhole *hole, *tail; + struct sackhole *hole; /* Allocate a new SACK hole. */ hole = tcp_sackhole_alloc(tp, start, end); @@ -502,15 +502,7 @@ tcp_sackhole_insert(struct tcpcb *tp, tcp_seq start, tcp_seq end, if (after != NULL) TAILQ_INSERT_AFTER(&tp->snd_holes, after, hole, scblink); else - /* -* With Rescue Retransmission, new holes may need to -* be inserted just before the tail. -*/ - if (((tail = TAILQ_LAST_FAST(&tp->snd_holes, sackhole, - scblink)) != NULL) && SEQ_LEQ(end, tail->start)) - TAILQ_INSERT_BEFORE(tail, hole, scblink); - else - TAILQ_INSERT_TAIL(&tp->snd_holes, hole, scblink); + TAILQ_INSERT_TAIL(&tp->snd_holes, hole, scblink); /* Update SACK hint. */ if (tp->sackhint.nexthole == NULL) @@ -567,6 +559,15 @@ tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack) left_edge_delta = th_ack - tp->snd_una; sack_blocks[num_sack_blks].start = tp->snd_una; sack_blocks[num_sack_blks++].end = th_ack; + /* +* Pulling snd_fack forward if we got here +* due to DSACK blocks +*/ + if (SEQ_LT(tp->snd_fack, th_ack)) { + delivered_data += th_ack - tp->snd_una; + tp->snd_fack = th_ack; + sack_changed = 1; + } } /* * Append received valid SACK blocks to sack_blocks[], but only if we @@ -636,35 +637,52 @@ tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack) tp->sackhint.last_sack_ack = sblkp->end; if (SEQ_LT(tp->snd_fack, sblkp->start)) { /* -* The highest SACK block is beyond fack. Append new SACK -* hole at the tail. If the second or later highest SACK -* blocks are also beyond the current fack, they will be -* inserted by way of hole splitting in the while-loop below. +* The highest SACK block is beyond fack. First, +* check if there was a successful Rescue Retransmission, +* and move this hole left. With normal holes, snd_fack +* is always to the right of the end. */ - temp = tcp_sackhole_insert(tp, tp->snd_fack,sblkp->start,NULL); - if (temp != NULL) { + if (((temp = TAILQ_LAST(&tp->snd_holes, sackhole_head)) != NULL) && + SEQ_LEQ(tp->snd_fack,temp->end)) { + temp->start = SEQ_MAX(tp->snd_fack, SEQ_MAX(tp->snd_una, th_ack)); + temp->end = sblkp->start; + temp->rxmit = temp->start; delivered_data += sblkp->end - sblkp->start; tp->snd_fack = sblkp->end; - /* Go to the previous sack block. */ sblkp--; sack_changed = 1; } else { /* -* We failed to add a new hole based on the current -* sack block. Skip over all the sack blocks that -* fall complete
git: 3183d0b68072 - main - iflib: initialize LRO unconditionally
The branch main has been updated by gallatin: URL: https://cgit.FreeBSD.org/src/commit/?id=3183d0b68072dda0e80bb6e03c970625f2823e97 commit 3183d0b68072dda0e80bb6e03c970625f2823e97 Author: Andrew Gallatin AuthorDate: 2021-04-23 09:51:22 + Commit: Andrew Gallatin CommitDate: 2021-04-23 09:55:20 + iflib: initialize LRO unconditionally Changes to the LRO code have exposed a bug in iflib where devices which are not capable of doing LRO are still calling tcp_lro_flush_all(), even when they have not initialized the LRO context. This used to be mostly harmless, but the LRO code now sets the VNET based on the ifp in the lro context and will try to access it through a NULL ifp resulting in a panic at boot. To fix this, we unconditionally initializes LRO so that we have a valid LRO context when calling tcp_lro_flush_all(). One alternative is to check the device capabilities before calling tcp_lro_flush_all() or adding a new state flag in the ctx. However, it seems unwise to add an extra, mostly useless test for higher performance devices when we can just initialize LRO for all devices. Reviewed by: erj, hselasky, markj, olivier Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D29928 --- sys/net/iflib.c | 22 +- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 6dbaff556a15..fc0814d0fc19 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -5891,15 +5891,13 @@ iflib_rx_structures_setup(if_ctx_t ctx) for (q = 0; q < ctx->ifc_softc_ctx.isc_nrxqsets; q++, rxq++) { #if defined(INET6) || defined(INET) - if (if_getcapabilities(ctx->ifc_ifp) & IFCAP_LRO) { - err = tcp_lro_init_args(&rxq->ifr_lc, ctx->ifc_ifp, - TCP_LRO_ENTRIES, min(1024, - ctx->ifc_softc_ctx.isc_nrxd[rxq->ifr_fl_offset])); - if (err != 0) { - device_printf(ctx->ifc_dev, - "LRO Initialization failed!\n"); - goto fail; - } + err = tcp_lro_init_args(&rxq->ifr_lc, ctx->ifc_ifp, + TCP_LRO_ENTRIES, min(1024, + ctx->ifc_softc_ctx.isc_nrxd[rxq->ifr_fl_offset])); + if (err != 0) { + device_printf(ctx->ifc_dev, + "LRO Initialization failed!\n"); + goto fail; } #endif IFDI_RXQ_SETUP(ctx, rxq->ifr_id); @@ -5914,8 +5912,7 @@ fail: */ rxq = ctx->ifc_rxqs; for (i = 0; i < q; ++i, rxq++) { - if (if_getcapabilities(ctx->ifc_ifp) & IFCAP_LRO) - tcp_lro_free(&rxq->ifr_lc); + tcp_lro_free(&rxq->ifr_lc); } return (err); #endif @@ -5938,8 +5935,7 @@ iflib_rx_structures_free(if_ctx_t ctx) iflib_dma_free(&rxq->ifr_ifdi[j]); iflib_rx_sds_free(rxq); #if defined(INET6) || defined(INET) - if (if_getcapabilities(ctx->ifc_ifp) & IFCAP_LRO) - tcp_lro_free(&rxq->ifr_lc); + tcp_lro_free(&rxq->ifr_lc); #endif } free(ctx->ifc_rxqs, M_IFLIB); ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 8845eea6e288 - stable/13 - Fix leak in libc NFSv4 ACL flags parsing
The branch stable/13 has been updated by freqlabs: URL: https://cgit.FreeBSD.org/src/commit/?id=8845eea6e288e96e7114f41fb3d8e25aae810a2d commit 8845eea6e288e96e7114f41fb3d8e25aae810a2d Author: Andrew Walker AuthorDate: 2021-04-20 19:34:44 + Commit: Ryan Moeller CommitDate: 2021-04-23 10:41:23 + Fix leak in libc NFSv4 ACL flags parsing Free memory allocated by strdup() in parse_flags_verbose(). Submitted by: Andrew Walker Reported by:valgrind Reviewed by:allanjude, freqlabs, rpokala Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D29871 (cherry picked from commit dd559118ab3f065ae230b324c3fe4bb1c9b7ca56) --- lib/libc/posix1e/acl_support_nfs4.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/libc/posix1e/acl_support_nfs4.c b/lib/libc/posix1e/acl_support_nfs4.c index 3962eaa6daa8..92ec666b2313 100644 --- a/lib/libc/posix1e/acl_support_nfs4.c +++ b/lib/libc/posix1e/acl_support_nfs4.c @@ -142,9 +142,10 @@ parse_flags_verbose(const char *strp, uint32_t *var, int *try_compact) { int i, found, ever_found = 0; - char *str, *flag; + char *str, *flag, *to_free; str = strdup(strp); + to_free = str; *try_compact = 0; *var = 0; @@ -166,12 +167,12 @@ parse_flags_verbose(const char *strp, uint32_t *var, "invalid flag \"%s\"", flags_name, flag); else *try_compact = 1; - free(str); + free(to_free); return (-1); } } - free(str); + free(to_free); return (0); } ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 7b61f67f398a - stable/12 - Fix leak in libc NFSv4 ACL flags parsing
The branch stable/12 has been updated by freqlabs: URL: https://cgit.FreeBSD.org/src/commit/?id=7b61f67f398ab589f629ee7c4ea705d65d700630 commit 7b61f67f398ab589f629ee7c4ea705d65d700630 Author: Andrew Walker AuthorDate: 2021-04-20 19:34:44 + Commit: Ryan Moeller CommitDate: 2021-04-23 10:42:37 + Fix leak in libc NFSv4 ACL flags parsing Free memory allocated by strdup() in parse_flags_verbose(). Submitted by: Andrew Walker Reported by:valgrind Reviewed by:allanjude, freqlabs, rpokala Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D29871 (cherry picked from commit dd559118ab3f065ae230b324c3fe4bb1c9b7ca56) --- lib/libc/posix1e/acl_support_nfs4.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/libc/posix1e/acl_support_nfs4.c b/lib/libc/posix1e/acl_support_nfs4.c index fe6f6f69cf21..845db5cc7b28 100644 --- a/lib/libc/posix1e/acl_support_nfs4.c +++ b/lib/libc/posix1e/acl_support_nfs4.c @@ -143,9 +143,10 @@ parse_flags_verbose(const char *strp, uint32_t *var, int *try_compact) { int i, found, ever_found = 0; - char *str, *flag; + char *str, *flag, *to_free; str = strdup(strp); + to_free = str; *try_compact = 0; *var = 0; @@ -167,12 +168,12 @@ parse_flags_verbose(const char *strp, uint32_t *var, "invalid flag \"%s\"", flags_name, flag); else *try_compact = 1; - free(str); + free(to_free); return (-1); } } - free(str); + free(to_free); return (0); } ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 550fcd830db7 - stable/11 - Fix leak in libc NFSv4 ACL flags parsing
The branch stable/11 has been updated by freqlabs: URL: https://cgit.FreeBSD.org/src/commit/?id=550fcd830db7e8d644795e5fc9bd83ef4604a1c1 commit 550fcd830db7e8d644795e5fc9bd83ef4604a1c1 Author: Andrew Walker AuthorDate: 2021-04-20 19:34:44 + Commit: Ryan Moeller CommitDate: 2021-04-23 10:43:51 + Fix leak in libc NFSv4 ACL flags parsing Free memory allocated by strdup() in parse_flags_verbose(). Submitted by: Andrew Walker Reported by:valgrind Reviewed by:allanjude, freqlabs, rpokala Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D29871 (cherry picked from commit dd559118ab3f065ae230b324c3fe4bb1c9b7ca56) --- lib/libc/posix1e/acl_support_nfs4.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/libc/posix1e/acl_support_nfs4.c b/lib/libc/posix1e/acl_support_nfs4.c index 7dd7f04daaf3..ffed4446c1b2 100644 --- a/lib/libc/posix1e/acl_support_nfs4.c +++ b/lib/libc/posix1e/acl_support_nfs4.c @@ -141,9 +141,10 @@ parse_flags_verbose(const char *strp, uint32_t *var, int *try_compact) { int i, found, ever_found = 0; - char *str, *flag; + char *str, *flag, *to_free; str = strdup(strp); + to_free = str; *try_compact = 0; *var = 0; @@ -165,12 +166,12 @@ parse_flags_verbose(const char *strp, uint32_t *var, "invalid flag \"%s\"", flags_name, flag); else *try_compact = 1; - free(str); + free(to_free); return (-1); } } - free(str); + free(to_free); return (0); } ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 694407528fb5 - main - Correctly skip rtsock_l3 test when if_epair is not available
The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=694407528fb506755f1e1f0fa2d343b7e2c3177e commit 694407528fb506755f1e1f0fa2d343b7e2c3177e Author: Alex Richardson AuthorDate: 2021-04-23 10:21:28 + Commit: Alex Richardson CommitDate: 2021-04-23 10:28:26 + Correctly skip rtsock_l3 test when if_epair is not available This logic was accidentally changed in 67f2f67fc8ce8484066e95dabac5af892888fca1 Reported By:olivier X-MFC-With: 67f2f67fc8ce8484066e95dabac5af892888fca1 Tested By: kp Reviewed By:kp, melifaro Fixes: 67f2f67fc8ce ("Update rtsock_l3 test after 2fe5a79425c7") Differential Revision: https://reviews.freebsd.org/D29944 --- tests/sys/net/routing/rtsock_config.h | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/sys/net/routing/rtsock_config.h b/tests/sys/net/routing/rtsock_config.h index d9eccb6a19f6..ff89814a61da 100644 --- a/tests/sys/net/routing/rtsock_config.h +++ b/tests/sys/net/routing/rtsock_config.h @@ -129,13 +129,11 @@ config_setup(const atf_tc_t *tc, struct rtsock_config_options *co) ATF_CHECK_ERRNO(0, true); if (co->num_interfaces > 0) { - if (kldload("if_epair") == -1) { - /* Any errno other than EEXIST is fatal. */ - ATF_REQUIRE_ERRNO(EEXIST, true); - /* Clear errno for the following tests. */ - errno = 0; - } + /* Try loading if_epair and if that fails skip the test. */ + kldload("if_epair"); ATF_REQUIRE_KERNEL_MODULE("if_epair"); + /* Clear errno for the following tests. */ + errno = 0; c->ifnames = calloc(co->num_interfaces, sizeof(char *)); for (int i = 0; i < co->num_interfaces; i++) ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: cd317a921331 - stable/13 - linuxkpi: copy ldev into local to test and free the same pointer
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=cd317a92133140ad78f296af5315cd8ffb08b046 commit cd317a92133140ad78f296af5315cd8ffb08b046 Author: Konstantin Belousov AuthorDate: 2021-03-30 08:41:00 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:06 + linuxkpi: copy ldev into local to test and free the same pointer (cherry picked from commit 7b0125cbec1579a0a1bf38f7abe583b5f6fd79e7) --- sys/compat/linuxkpi/common/src/linux_compat.c |5 +- sys/compat/linuxkpi/common/src/linux_compat.c.orig | 2598 2 files changed, 2601 insertions(+), 2 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 5f7e2664bee1..a9fa50ded219 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -1513,8 +1513,9 @@ linux_file_close(struct file *file, struct thread *td) if (filp->f_vnode != NULL) vdrop(filp->f_vnode); linux_drop_fop(ldev); - if (filp->f_cdev != NULL) - linux_cdev_deref(filp->f_cdev); + ldev = filp->f_cdev; + if (ldev != NULL) + linux_cdev_deref(ldev); kfree(filp); return (error); diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c.orig b/sys/compat/linuxkpi/common/src/linux_compat.c.orig new file mode 100644 index ..42f47b6e510a --- /dev/null +++ b/sys/compat/linuxkpi/common/src/linux_compat.c.orig @@ -0,0 +1,2598 @@ +/*- + * Copyright (c) 2010 Isilon Systems, Inc. + * Copyright (c) 2010 iX Systems, Inc. + * Copyright (c) 2010 Panasas, Inc. + * Copyright (c) 2013-2018 Mellanox Technologies, Ltd. + * All rights reserved. + * + * 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 unmodified, 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 ``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 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_stack.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#if defined(__i386__) || defined(__amd64__) +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(__i386__) || defined(__amd64__) +#include +#endif + +SYSCTL_NODE(_compat, OID_AUTO, linuxkpi, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, +"LinuxKPI parameters"); + +int linuxkpi_debug; +SYSCTL_INT(_compat_linuxkpi, OID_AUTO, debug, CTLFLAG_RWTUN, +&linuxkpi_debug, 0, "Set to enable pr_debug() prints. Clear to disable."); + +static struct timeval lkpi_net_lastlog; +static int lkpi_net_curpps; +static int lkpi_net_maxpps = 99; +SYSCTL_INT(_compat_linuxkpi, OID_AUTO, net_ratelimit, CTLFLAG_RWTUN, +&lkpi_net_maxpps, 0, "Limit number of LinuxKPI net messages per second."); + +MALLOC_DEFINE(M_KMALLOC, "linux", "Linux kmalloc compat"); + +#include +/* Undo Linux compat changes. */ +#undef RB_ROOT +#undef file +#undef cdev +#defineRB_ROOT(head) (head)->rbh_root + +static void linux_cdev_deref(struct linux_cdev *ldev); +static struct vm_area_struct *linux_cdev_handle_find(void *handle); + +struct kobject linux_class_root; +struct device linux_root_device; +struct class linux_class_misc; +struct list_head pci_drivers; +struct list_head pci_devices; +spinlock_t pci_lock; + +unsigned long linux_timer_hz_mask; + +wait_queue_head_t linux_bit_waitq; +wait_queue_head_t linux_var_waitq; + +int +panic_
git: 1f13502192bc - stable/13 - linuxkpi: rename cdev to ldev
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1f13502192bc42a517c618ed1ada494e6a5471a5 commit 1f13502192bc42a517c618ed1ada494e6a5471a5 Author: Konstantin Belousov AuthorDate: 2021-03-30 08:43:21 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:06 + linuxkpi: rename cdev to ldev (cherry picked from commit 28b482e2baf43cdd30e8b9bd090e6d9f405cf4b3) --- sys/compat/linuxkpi/common/src/linux_compat.c | 6 +++--- sys/compat/linuxkpi/common/src/linux_compat.c.orig | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index a9fa50ded219..45ccd1279057 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -2213,12 +2213,12 @@ linux_cdev_release(struct kobject *kobj) static void linux_cdev_static_release(struct kobject *kobj) { - struct linux_cdev *cdev; + struct linux_cdev *ldev; struct kobject *parent; - cdev = container_of(kobj, struct linux_cdev, kobj); + ldev = container_of(kobj, struct linux_cdev, kobj); parent = kobj->parent; - linux_destroy_dev(cdev); + linux_destroy_dev(ldev); kobject_put(parent); } diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c.orig b/sys/compat/linuxkpi/common/src/linux_compat.c.orig index 42f47b6e510a..b7a7ba8b4f18 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c.orig +++ b/sys/compat/linuxkpi/common/src/linux_compat.c.orig @@ -1520,8 +1520,9 @@ linux_file_close(struct file *file, struct thread *td) if (filp->f_vnode != NULL) vdrop(filp->f_vnode); linux_drop_fop(ldev); - if (filp->f_cdev != NULL) - linux_cdev_deref(filp->f_cdev); + ldev = filp->f_cdev; + if (ldev != NULL) + linux_cdev_deref(ldev); kfree(filp); return (error); ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: a574fbf34ba9 - stable/13 - linuxkpi: remove erronously committed diff save file
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a574fbf34ba94be106c8c8dea11cdb13ab2fbe54 commit a574fbf34ba94be106c8c8dea11cdb13ab2fbe54 Author: Konstantin Belousov AuthorDate: 2021-04-06 00:42:13 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:06 + linuxkpi: remove erronously committed diff save file (cherry picked from commit 5b3b19db7305f8255f021d6f8d94d17ab778660f) --- sys/compat/linuxkpi/common/src/linux_compat.c.orig | 2615 1 file changed, 2615 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c.orig b/sys/compat/linuxkpi/common/src/linux_compat.c.orig deleted file mode 100644 index 28413c59bb76.. --- a/sys/compat/linuxkpi/common/src/linux_compat.c.orig +++ /dev/null @@ -1,2615 +0,0 @@ -/*- - * Copyright (c) 2010 Isilon Systems, Inc. - * Copyright (c) 2010 iX Systems, Inc. - * Copyright (c) 2010 Panasas, Inc. - * Copyright (c) 2013-2018 Mellanox Technologies, Ltd. - * All rights reserved. - * - * 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 unmodified, 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 ``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 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. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "opt_stack.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#if defined(__i386__) || defined(__amd64__) -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(__i386__) || defined(__amd64__) -#include -#endif - -SYSCTL_NODE(_compat, OID_AUTO, linuxkpi, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, -"LinuxKPI parameters"); - -int linuxkpi_debug; -SYSCTL_INT(_compat_linuxkpi, OID_AUTO, debug, CTLFLAG_RWTUN, -&linuxkpi_debug, 0, "Set to enable pr_debug() prints. Clear to disable."); - -static struct timeval lkpi_net_lastlog; -static int lkpi_net_curpps; -static int lkpi_net_maxpps = 99; -SYSCTL_INT(_compat_linuxkpi, OID_AUTO, net_ratelimit, CTLFLAG_RWTUN, -&lkpi_net_maxpps, 0, "Limit number of LinuxKPI net messages per second."); - -MALLOC_DEFINE(M_KMALLOC, "linux", "Linux kmalloc compat"); - -#include -/* Undo Linux compat changes. */ -#undef RB_ROOT -#undef file -#undef cdev -#defineRB_ROOT(head) (head)->rbh_root - -static void linux_cdev_deref(struct linux_cdev *ldev); -static struct vm_area_struct *linux_cdev_handle_find(void *handle); - -struct kobject linux_class_root; -struct device linux_root_device; -struct class linux_class_misc; -struct list_head pci_drivers; -struct list_head pci_devices; -spinlock_t pci_lock; - -unsigned long linux_timer_hz_mask; - -wait_queue_head_t linux_bit_waitq; -wait_queue_head_t linux_var_waitq; - -int -panic_cmp(struct rb_node *one, struct rb_node *two) -{ - panic("no cmp"); -} - -RB_GENERATE(linux_root, rb_node, __entry, panic_cmp); - -int -kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list args) -{ - va_list tmp_va; - int len; - char *old; - char *name; - char dummy; - - old = kobj->name; - - if (old && fmt == NULL) - return (0); - - /* compute length of string */ - va_copy(tmp_va, args); - len = vsnprintf(&dummy, 0, fmt, tmp_va); - va_end(tmp_va); - - /* account for zero termination */ - len++; - - /* check for error */ - if (len < 1) - return (-EINVAL); - - /* allocate memory for string *
git: c3f97dd75a1c - stable/13 - rtld dl_iterate_phdr(): dlpi_tls_data is wrong
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c3f97dd75a1c294c4f60f42b604ee8bcda17be09 commit c3f97dd75a1c294c4f60f42b604ee8bcda17be09 Author: Konstantin Belousov AuthorDate: 2021-04-05 03:05:44 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:06 + rtld dl_iterate_phdr(): dlpi_tls_data is wrong (cherry picked from commit d36d6816151705907393889d661cbfd25c630ca8) --- lib/libc/gen/dl_iterate_phdr.3 | 7 +-- libexec/rtld-elf/Symbol.map| 1 + libexec/rtld-elf/rtld.1| 7 +++ libexec/rtld-elf/rtld.c| 8 +++- sys/sys/param.h| 2 +- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/libc/gen/dl_iterate_phdr.3 b/lib/libc/gen/dl_iterate_phdr.3 index 6e952dc13b57..fe4face9eeb7 100644 --- a/lib/libc/gen/dl_iterate_phdr.3 +++ b/lib/libc/gen/dl_iterate_phdr.3 @@ -15,7 +15,7 @@ .\" .\" $OpenBSD: dl_iterate_phdr.3,v 1.3 2007/05/31 19:19:48 jmc Exp $ .\" $FreeBSD$ -.Dd October 9, 2014 +.Dd April 5, 2021 .Dt DL_ITERATE_PHDR 3 .Os .Sh NAME @@ -80,7 +80,10 @@ The counter of the object unloads performed by the dynamic linker. .It Fa dlpi_tls_modid The TLS index of the object. .It Fa dlpi_tls_data -A pointer to the initialization data for the object TLS segment. +A pointer to the calling thread' TLS data segment for this module, +if it was allocated, +.Dv NULL +otherwise. .El .Pp Future versions of diff --git a/libexec/rtld-elf/Symbol.map b/libexec/rtld-elf/Symbol.map index 13068c5626dc..0a9eac82cf05 100644 --- a/libexec/rtld-elf/Symbol.map +++ b/libexec/rtld-elf/Symbol.map @@ -34,4 +34,5 @@ FBSDprivate_1.0 { _r_debug_postinit; _rtld_version__FreeBSD_version; _rtld_version_laddr_offset; +_rtld_version_dlpi_tls_data; }; diff --git a/libexec/rtld-elf/rtld.1 b/libexec/rtld-elf/rtld.1 index 10dd7986903a..47bdc028b22d 100644 --- a/libexec/rtld-elf/rtld.1 +++ b/libexec/rtld-elf/rtld.1 @@ -416,6 +416,13 @@ See Also it indicates the presence of .Va l_refname member of the structure. +.It Dv _rtld_version_dlpi_tls_data +The +.Va dlpi_tls_data +member of the structure +.Vt dl_phdr_info +contains the address of the module TLS segment for the calling thread, +and not the address of the initialization segment. .El .Sh FILES .Bl -tag -width ".Pa /var/run/ld-elf32.so.hints" -compact diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index b186bebbfefc..4749e3a50d72 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -3889,13 +3889,16 @@ dlinfo(void *handle, int request, void *p) static void rtld_fill_dl_phdr_info(const Obj_Entry *obj, struct dl_phdr_info *phdr_info) { + tls_index ti; phdr_info->dlpi_addr = (Elf_Addr)obj->relocbase; phdr_info->dlpi_name = obj->path; phdr_info->dlpi_phdr = obj->phdr; phdr_info->dlpi_phnum = obj->phsize / sizeof(obj->phdr[0]); phdr_info->dlpi_tls_modid = obj->tlsindex; - phdr_info->dlpi_tls_data = obj->tlsinit; + ti.ti_module = obj->tlsindex; + ti.ti_offset = 0; + phdr_info->dlpi_tls_data = __tls_get_addr(&ti); phdr_info->dlpi_adds = obj_loads; phdr_info->dlpi_subs = obj_loads - obj_count; } @@ -5894,3 +5897,6 @@ int _rtld_version__FreeBSD_version = __FreeBSD_version; extern char _rtld_version_laddr_offset __exported; char _rtld_version_laddr_offset; + +extern char _rtld_version_dlpi_tls_data __exported; +char _rtld_version_dlpi_tls_data; diff --git a/sys/sys/param.h b/sys/sys/param.h index 28a1cf981a58..1930af51f7da 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300500 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300501 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 1bcab3da2bb1 - stable/13 - rtld_lock.h: remove tautological extern's
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1bcab3da2bb1c13ab3d4f128d40eb88def5813df commit 1bcab3da2bb1c13ab3d4f128d40eb88def5813df Author: Konstantin Belousov AuthorDate: 2021-04-05 04:11:49 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:06 + rtld_lock.h: remove tautological extern's (cherry picked from commit 38e0610df7d5cd5ddd43a477c139ec6ce342c5c2) --- libexec/rtld-elf/rtld_lock.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libexec/rtld-elf/rtld_lock.h b/libexec/rtld-elf/rtld_lock.h index 339028c568dc..cc1fd83169f8 100644 --- a/libexec/rtld-elf/rtld_lock.h +++ b/libexec/rtld-elf/rtld_lock.h @@ -46,9 +46,9 @@ struct RtldLockInfo void (*at_fork)(void); }; -extern void _rtld_thread_init(struct RtldLockInfo *) __exported; -extern void _rtld_atfork_pre(int *) __exported; -extern void _rtld_atfork_post(int *) __exported; +void _rtld_thread_init(struct RtldLockInfo *) __exported; +void _rtld_atfork_pre(int *) __exported; +void _rtld_atfork_post(int *) __exported; #ifdef IN_RTLD ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 520085b20e04 - stable/13 - linuxkpi: do not destroy/free embedded linux cdevs
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=520085b20e045dbcb6e9c6389f67c9e0c849ad45 commit 520085b20e045dbcb6e9c6389f67c9e0c849ad45 Author: Konstantin Belousov AuthorDate: 2021-03-30 08:44:19 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:06 + linuxkpi: do not destroy/free embedded linux cdevs (cherry picked from commit 7f9867f8c65b1b3e590dba4dc432a4bc8cf01f68) --- sys/compat/linuxkpi/common/src/linux_compat.c | 13 ++--- sys/compat/linuxkpi/common/src/linux_compat.c.orig | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 45ccd1279057..1d75644105dd 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -2192,8 +2192,8 @@ linux_completion_done(struct completion *c) static void linux_cdev_deref(struct linux_cdev *ldev) { - - if (refcount_release(&ldev->refs)) + if (refcount_release(&ldev->refs) && + ldev->kobj.ktype == &linux_cdev_ktype) kfree(ldev); } @@ -2213,12 +2213,17 @@ linux_cdev_release(struct kobject *kobj) static void linux_cdev_static_release(struct kobject *kobj) { + struct cdev *cdev; struct linux_cdev *ldev; struct kobject *parent; ldev = container_of(kobj, struct linux_cdev, kobj); parent = kobj->parent; - linux_destroy_dev(ldev); + cdev = ldev->cdev; + if (cdev != NULL) { + destroy_dev(cdev); + ldev->cdev = NULL; + } kobject_put(parent); } @@ -2230,6 +2235,8 @@ linux_destroy_dev(struct linux_cdev *ldev) return; MPASS((ldev->siref & LDEV_SI_DTR) == 0); + MPASS(ldev->kobj.ktype == &linux_cdev_ktype); + atomic_set_int(&ldev->siref, LDEV_SI_DTR); while ((atomic_load_int(&ldev->siref) & ~LDEV_SI_DTR) != 0) pause("ldevdtr", hz / 4); diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c.orig b/sys/compat/linuxkpi/common/src/linux_compat.c.orig index b7a7ba8b4f18..0731859e7a53 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c.orig +++ b/sys/compat/linuxkpi/common/src/linux_compat.c.orig @@ -2220,12 +2220,12 @@ linux_cdev_release(struct kobject *kobj) static void linux_cdev_static_release(struct kobject *kobj) { - struct linux_cdev *cdev; + struct linux_cdev *ldev; struct kobject *parent; - cdev = container_of(kobj, struct linux_cdev, kobj); + ldev = container_of(kobj, struct linux_cdev, kobj); parent = kobj->parent; - linux_destroy_dev(cdev); + linux_destroy_dev(ldev); kobject_put(parent); } ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 520806c476b9 - stable/13 - rtld_lock.h: Expand scope for IN_RTLD to avoid some conflicts with libc
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=520806c476b9f628c2e8bfbc4c3835aeeec26c2e commit 520806c476b9f628c2e8bfbc4c3835aeeec26c2e Author: Konstantin Belousov AuthorDate: 2021-04-05 04:12:22 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:07 + rtld_lock.h: Expand scope for IN_RTLD to avoid some conflicts with libc (cherry picked from commit 34ca6025ddfea9899024eb6e7617091c5bc5149a) --- libexec/rtld-elf/rtld_lock.h | 4 1 file changed, 4 insertions(+) diff --git a/libexec/rtld-elf/rtld_lock.h b/libexec/rtld-elf/rtld_lock.h index cc1fd83169f8..9aa769b1f7e6 100644 --- a/libexec/rtld-elf/rtld_lock.h +++ b/libexec/rtld-elf/rtld_lock.h @@ -46,10 +46,14 @@ struct RtldLockInfo void (*at_fork)(void); }; +#if defined(IN_RTLD) || defined(PTHREAD_KERNEL) + void _rtld_thread_init(struct RtldLockInfo *) __exported; void _rtld_atfork_pre(int *) __exported; void _rtld_atfork_post(int *) __exported; +#endif /* IN_RTLD || PTHREAD_KERNEL */ + #ifdef IN_RTLD struct rtld_lock; ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 083df155ef5b - stable/13 - libc: constify dummy error message string for dlfcn
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=083df155ef5b6f718a04e21d7f47597b02d8b371 commit 083df155ef5b6f718a04e21d7f47597b02d8b371 Author: Konstantin Belousov AuthorDate: 2021-04-05 04:14:39 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:07 + libc: constify dummy error message string for dlfcn (cherry picked from commit 93c14c55ec0da311dc09c1c8c1c7ecd5f2fae51a) --- lib/libc/gen/dlfcn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c index 395a6d9402e8..6047f7ddd4d7 100644 --- a/lib/libc/gen/dlfcn.c +++ b/lib/libc/gen/dlfcn.c @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" #include "reentrant.h" -static char sorry[] = "Service unavailable"; +static const char sorry[] = "Service unavailable"; void _rtld_thread_init(void *); void _rtld_atfork_pre(int *); @@ -91,7 +91,7 @@ char * dlerror(void) { - return (sorry); + return (__DECONST(char *, sorry)); } #pragma weak dllockinit ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: d252df1e1154 - stable/13 - rtld/x86/reloc.c: style
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d252df1e1154bca19cc52470d71d1002895a5521 commit d252df1e1154bca19cc52470d71d1002895a5521 Author: Konstantin Belousov AuthorDate: 2021-04-07 06:12:10 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:06 + rtld/x86/reloc.c: style (cherry picked from commit f61ecf60cfce6172df803a9e5e099aab2d4aedcd) --- libexec/rtld-elf/amd64/reloc.c | 3 ++- libexec/rtld-elf/i386/reloc.c | 6 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libexec/rtld-elf/amd64/reloc.c b/libexec/rtld-elf/amd64/reloc.c index 00e538d4b647..309e105d8b5e 100644 --- a/libexec/rtld-elf/amd64/reloc.c +++ b/libexec/rtld-elf/amd64/reloc.c @@ -538,7 +538,8 @@ allocate_initial_tls(Obj_Entry *objs) sysarch(AMD64_SET_FSBASE, &addr); } -void *__tls_get_addr(tls_index *ti) +void * +__tls_get_addr(tls_index *ti) { Elf_Addr** segbase; diff --git a/libexec/rtld-elf/i386/reloc.c b/libexec/rtld-elf/i386/reloc.c index 7f8ecfa40f8f..5ed3abf65b31 100644 --- a/libexec/rtld-elf/i386/reloc.c +++ b/libexec/rtld-elf/i386/reloc.c @@ -519,7 +519,8 @@ allocate_initial_tls(Obj_Entry *objs) /* GNU ABI */ __attribute__((__regparm__(1))) -void *___tls_get_addr(tls_index *ti) +void * +___tls_get_addr(tls_index *ti) { Elf_Addr** segbase; @@ -529,7 +530,8 @@ void *___tls_get_addr(tls_index *ti) } /* Sun ABI */ -void *__tls_get_addr(tls_index *ti) +void * +__tls_get_addr(tls_index *ti) { Elf_Addr** segbase; ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 4959d4f3eaab - stable/13 - libc: implement __tls_get_addr() for static binaries
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4959d4f3eaab7e592657032a0b42b34c5d5c174b commit 4959d4f3eaab7e592657032a0b42b34c5d5c174b Author: Konstantin Belousov AuthorDate: 2021-04-05 03:29:47 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:07 + libc: implement __tls_get_addr() for static binaries (cherry picked from commit ca46b5698e8ac38ab45d781d592700be59e7de97) --- lib/libc/gen/tls.c | 23 +++ 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index 2a64b5266f4a..69b87aea52bf 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -103,25 +103,32 @@ static size_t libc_tls_init_align; static void *libc_tls_init; #endif +void * +__libc_tls_get_addr(void *vti) +{ + Elf_Addr **dtvp, *dtv; + tls_index *ti; + + dtvp = _get_tp(); + dtv = *dtvp; + ti = vti; + return ((char *)(dtv[ti->ti_module + 1] + ti->ti_offset) + + TLS_DTV_OFFSET); +} + #ifdef __i386__ /* GNU ABI */ __attribute__((__regparm__(1))) void * -___libc_tls_get_addr(void *ti __unused) +___libc_tls_get_addr(void *vti) { - return (0); + return (__libc_tls_get_addr(vti)); } #endif -void * -__libc_tls_get_addr(void *ti __unused) -{ - return (0); -} - #ifndef PIC static void * ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: e703bd6341a3 - stable/13 - rtld: avoid recursing on rtld_bind_lock for write
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e703bd6341a34b1fb49642b7fbf2a1d1b9078e6e commit e703bd6341a34b1fb49642b7fbf2a1d1b9078e6e Author: Konstantin Belousov AuthorDate: 2021-04-06 19:02:23 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:07 + rtld: avoid recursing on rtld_bind_lock for write (cherry picked from commit 7cb32a0d03437f881169b1c55cce89cf70ed43dd) --- libexec/rtld-elf/rtld-libc/Makefile.inc | 2 ++ libexec/rtld-elf/rtld.c | 8 libexec/rtld-elf/rtld.h | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libexec/rtld-elf/rtld-libc/Makefile.inc b/libexec/rtld-elf/rtld-libc/Makefile.inc index d682472c3cca..94d6cbb5b39f 100644 --- a/libexec/rtld-elf/rtld-libc/Makefile.inc +++ b/libexec/rtld-elf/rtld-libc/Makefile.inc @@ -67,6 +67,8 @@ _libc_other_objects+=syncicache abs _libc_other_objects+=syncicache .endif +_libc_other_objects+=_get_tp + # Extract all the .o files from libc_nossp_pic.a. This ensures that # we don't accidentally pull in the interposing table or similar by linking # directly against libc_nossp_pic.a diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 882aab4d76d8..69e096ad3e6e 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -3890,16 +3890,16 @@ dlinfo(void *handle, int request, void *p) static void rtld_fill_dl_phdr_info(const Obj_Entry *obj, struct dl_phdr_info *phdr_info) { - tls_index ti; + Elf_Addr **dtvp; phdr_info->dlpi_addr = (Elf_Addr)obj->relocbase; phdr_info->dlpi_name = obj->path; phdr_info->dlpi_phdr = obj->phdr; phdr_info->dlpi_phnum = obj->phsize / sizeof(obj->phdr[0]); phdr_info->dlpi_tls_modid = obj->tlsindex; - ti.ti_module = obj->tlsindex; - ti.ti_offset = 0; - phdr_info->dlpi_tls_data = __tls_get_addr(&ti); + dtvp = _get_tp(); + phdr_info->dlpi_tls_data = (char *)tls_get_addr_slow(dtvp, + obj->tlsindex, 0, true) + TLS_DTV_OFFSET; phdr_info->dlpi_adds = obj_loads; phdr_info->dlpi_subs = obj_loads - obj_count; } diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h index 85472826a4ec..6a2f62fc6189 100644 --- a/libexec/rtld-elf/rtld.h +++ b/libexec/rtld-elf/rtld.h @@ -401,6 +401,7 @@ bool allocate_tls_offset(Obj_Entry *obj); void free_tls_offset(Obj_Entry *obj); const Ver_Entry *fetch_ventry(const Obj_Entry *obj, unsigned long); int convert_prot(int elfflags); +void *_get_tp(void); /* libc implementation */ /* * MD function declarations. ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: e49760d9efda - stable/13 - linuxkpi: avoid counting per-thread use for the embedded linux cdevs
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e49760d9efda09a390476d64e6328fdd17aa3117 commit e49760d9efda09a390476d64e6328fdd17aa3117 Author: Konstantin Belousov AuthorDate: 2021-03-30 08:45:24 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:06 + linuxkpi: avoid counting per-thread use for the embedded linux cdevs (cherry picked from commit f6b108837e7df7d7bfb35ec447f7cb62afa79441) --- sys/compat/linuxkpi/common/src/linux_compat.c | 31 ++ sys/compat/linuxkpi/common/src/linux_compat.c.orig | 13 ++--- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 1d75644105dd..f8b939a5ec16 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -710,15 +710,19 @@ linux_get_fop(struct linux_file *filp, const struct file_operations **fop, ldev = filp->f_cdev; *fop = filp->f_op; if (ldev != NULL) { - for (siref = ldev->siref;;) { - if ((siref & LDEV_SI_DTR) != 0) { - ldev = &dummy_ldev; - siref = ldev->siref; - *fop = ldev->ops; - MPASS((ldev->siref & LDEV_SI_DTR) == 0); - } else if (atomic_fcmpset_int(&ldev->siref, &siref, - siref + LDEV_SI_REF)) { - break; + if (ldev->kobj.ktype == &linux_cdev_static_ktype) { + refcount_acquire(&ldev->refs); + } else { + for (siref = ldev->siref;;) { + if ((siref & LDEV_SI_DTR) != 0) { + ldev = &dummy_ldev; + *fop = ldev->ops; + siref = ldev->siref; + MPASS((ldev->siref & LDEV_SI_DTR) == 0); + } else if (atomic_fcmpset_int(&ldev->siref, + &siref, siref + LDEV_SI_REF)) { + break; + } } } } @@ -731,8 +735,13 @@ linux_drop_fop(struct linux_cdev *ldev) if (ldev == NULL) return; - MPASS((ldev->siref & ~LDEV_SI_DTR) != 0); - atomic_subtract_int(&ldev->siref, LDEV_SI_REF); + if (ldev->kobj.ktype == &linux_cdev_static_ktype) { + linux_cdev_deref(ldev); + } else { + MPASS(ldev->kobj.ktype == &linux_cdev_ktype); + MPASS((ldev->siref & ~LDEV_SI_DTR) != 0); + atomic_subtract_int(&ldev->siref, LDEV_SI_REF); + } } #defineOPW(fp,td,code) ({ \ diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c.orig b/sys/compat/linuxkpi/common/src/linux_compat.c.orig index 0731859e7a53..71ea7e0844dc 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c.orig +++ b/sys/compat/linuxkpi/common/src/linux_compat.c.orig @@ -2199,8 +2199,8 @@ linux_completion_done(struct completion *c) static void linux_cdev_deref(struct linux_cdev *ldev) { - - if (refcount_release(&ldev->refs)) + if (refcount_release(&ldev->refs) && + ldev->kobj.ktype == &linux_cdev_ktype) kfree(ldev); } @@ -2220,12 +2220,17 @@ linux_cdev_release(struct kobject *kobj) static void linux_cdev_static_release(struct kobject *kobj) { + struct cdev *cdev; struct linux_cdev *ldev; struct kobject *parent; ldev = container_of(kobj, struct linux_cdev, kobj); parent = kobj->parent; - linux_destroy_dev(ldev); + cdev = ldev->cdev; + if (cdev != NULL) { + destroy_dev(cdev); + ldev->cdev = NULL; + } kobject_put(parent); } @@ -2237,6 +2242,8 @@ linux_destroy_dev(struct linux_cdev *ldev) return; MPASS((ldev->siref & LDEV_SI_DTR) == 0); + MPASS(ldev->kobj.ktype == &linux_cdev_ktype); + atomic_set_int(&ldev->siref, LDEV_SI_DTR); while ((atomic_load_int(&ldev->siref) & ~LDEV_SI_DTR) != 0) pause("ldevdtr", hz / 4); ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 9c410fc7ce11 - stable/13 - linuxkpi: drop single-use variable
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9c410fc7ce116dfabf3ebd246bbfb416699a2a40 commit 9c410fc7ce116dfabf3ebd246bbfb416699a2a40 Author: Konstantin Belousov AuthorDate: 2021-03-30 08:46:42 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:06 + linuxkpi: drop single-use variable (cherry picked from commit 8011fb795baa59ba14371d6db5ab661a5db77615) --- sys/compat/linuxkpi/common/src/linux_compat.c | 4 +-- sys/compat/linuxkpi/common/src/linux_compat.c.orig | 31 ++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index f8b939a5ec16..8fe4f4509571 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -2224,16 +2224,14 @@ linux_cdev_static_release(struct kobject *kobj) { struct cdev *cdev; struct linux_cdev *ldev; - struct kobject *parent; ldev = container_of(kobj, struct linux_cdev, kobj); - parent = kobj->parent; cdev = ldev->cdev; if (cdev != NULL) { destroy_dev(cdev); ldev->cdev = NULL; } - kobject_put(parent); + kobject_put(kobj->parent); } void diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c.orig b/sys/compat/linuxkpi/common/src/linux_compat.c.orig index 71ea7e0844dc..28413c59bb76 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c.orig +++ b/sys/compat/linuxkpi/common/src/linux_compat.c.orig @@ -717,15 +717,19 @@ linux_get_fop(struct linux_file *filp, const struct file_operations **fop, ldev = filp->f_cdev; *fop = filp->f_op; if (ldev != NULL) { - for (siref = ldev->siref;;) { - if ((siref & LDEV_SI_DTR) != 0) { - ldev = &dummy_ldev; - siref = ldev->siref; - *fop = ldev->ops; - MPASS((ldev->siref & LDEV_SI_DTR) == 0); - } else if (atomic_fcmpset_int(&ldev->siref, &siref, - siref + LDEV_SI_REF)) { - break; + if (ldev->kobj.ktype == &linux_cdev_static_ktype) { + refcount_acquire(&ldev->refs); + } else { + for (siref = ldev->siref;;) { + if ((siref & LDEV_SI_DTR) != 0) { + ldev = &dummy_ldev; + *fop = ldev->ops; + siref = ldev->siref; + MPASS((ldev->siref & LDEV_SI_DTR) == 0); + } else if (atomic_fcmpset_int(&ldev->siref, + &siref, siref + LDEV_SI_REF)) { + break; + } } } } @@ -738,8 +742,13 @@ linux_drop_fop(struct linux_cdev *ldev) if (ldev == NULL) return; - MPASS((ldev->siref & ~LDEV_SI_DTR) != 0); - atomic_subtract_int(&ldev->siref, LDEV_SI_REF); + if (ldev->kobj.ktype == &linux_cdev_static_ktype) { + linux_cdev_deref(ldev); + } else { + MPASS(ldev->kobj.ktype == &linux_cdev_ktype); + MPASS((ldev->siref & ~LDEV_SI_DTR) != 0); + atomic_subtract_int(&ldev->siref, LDEV_SI_REF); + } } #defineOPW(fp,td,code) ({ \ ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 17ef58221ccc - stable/13 - libc dl_iterate_phdr(): dlpi_tls_data is wrong
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=17ef58221ccc39072eea716d4d68b2f0335ef3b6 commit 17ef58221ccc39072eea716d4d68b2f0335ef3b6 Author: Konstantin Belousov AuthorDate: 2021-04-05 03:38:07 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:07 + libc dl_iterate_phdr(): dlpi_tls_data is wrong (cherry picked from commit dbd2053026a6af28adb1aa32e27603ae0d4efea6) --- lib/libc/gen/dlfcn.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c index 16afdb6bf5d1..337ad48fd691 100644 --- a/lib/libc/gen/dlfcn.c +++ b/lib/libc/gen/dlfcn.c @@ -196,8 +196,6 @@ dl_init_phdr_info(void) for (i = 0; i < phdr_info.dlpi_phnum; i++) { if (phdr_info.dlpi_phdr[i].p_type == PT_TLS) { phdr_info.dlpi_tls_modid = 1; - phdr_info.dlpi_tls_data = - (void*)phdr_info.dlpi_phdr[i].p_vaddr; } } phdr_info.dlpi_adds = 1; @@ -210,13 +208,17 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused, void *data __unused) { #ifndef IN_LIBDL + tls_index ti; int ret; __init_elf_aux_vector(); if (__elf_aux_vector == NULL) return (1); _once(&dl_phdr_info_once, dl_init_phdr_info); + ti.ti_module = 1; + ti.ti_offset = 0; mutex_lock(&dl_phdr_info_lock); + phdr_info.dlpi_tls_data = __tls_get_addr(&ti); ret = callback(&phdr_info, sizeof(phdr_info), data); mutex_unlock(&dl_phdr_info_lock); return (ret); ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 127849157ab9 - stable/13 - rtld: style tls_get_addr_slow
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=127849157ab94c630533fdd7201422b36d3cf96f commit 127849157ab94c630533fdd7201422b36d3cf96f Author: Konstantin Belousov AuthorDate: 2021-04-06 18:55:10 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:07 + rtld: style tls_get_addr_slow (cherry picked from commit 85d846b369f4d8c0033993d3d1307779d3b9aa62) --- libexec/rtld-elf/rtld.c | 54 - 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 4749e3a50d72..134c2566b4cd 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -4855,35 +4855,35 @@ static void *tls_get_addr_slow(Elf_Addr **, int, size_t) __noinline; static void * tls_get_addr_slow(Elf_Addr **dtvp, int index, size_t offset) { -Elf_Addr *newdtv, *dtv; -RtldLockState lockstate; -int to_copy; + Elf_Addr *newdtv, *dtv; + RtldLockState lockstate; + int to_copy; -dtv = *dtvp; -/* Check dtv generation in case new modules have arrived */ -if (dtv[0] != tls_dtv_generation) { - wlock_acquire(rtld_bind_lock, &lockstate); - newdtv = xcalloc(tls_max_index + 2, sizeof(Elf_Addr)); - to_copy = dtv[1]; - if (to_copy > tls_max_index) - to_copy = tls_max_index; - memcpy(&newdtv[2], &dtv[2], to_copy * sizeof(Elf_Addr)); - newdtv[0] = tls_dtv_generation; - newdtv[1] = tls_max_index; - free(dtv); - lock_release(rtld_bind_lock, &lockstate); - dtv = *dtvp = newdtv; -} + dtv = *dtvp; + /* Check dtv generation in case new modules have arrived */ + if (dtv[0] != tls_dtv_generation) { + wlock_acquire(rtld_bind_lock, &lockstate); + newdtv = xcalloc(tls_max_index + 2, sizeof(Elf_Addr)); + to_copy = dtv[1]; + if (to_copy > tls_max_index) + to_copy = tls_max_index; + memcpy(&newdtv[2], &dtv[2], to_copy * sizeof(Elf_Addr)); + newdtv[0] = tls_dtv_generation; + newdtv[1] = tls_max_index; + free(dtv); + lock_release(rtld_bind_lock, &lockstate); + dtv = *dtvp = newdtv; + } -/* Dynamically allocate module TLS if necessary */ -if (dtv[index + 1] == 0) { - /* Signal safe, wlock will block out signals. */ - wlock_acquire(rtld_bind_lock, &lockstate); - if (!dtv[index + 1]) - dtv[index + 1] = (Elf_Addr)allocate_module_tls(index); - lock_release(rtld_bind_lock, &lockstate); -} -return ((void *)(dtv[index + 1] + offset)); + /* Dynamically allocate module TLS if necessary */ + if (dtv[index + 1] == 0) { + /* Signal safe, wlock will block out signals. */ + wlock_acquire(rtld_bind_lock, &lockstate); + if (!dtv[index + 1]) + dtv[index + 1] = (Elf_Addr)allocate_module_tls(index); + lock_release(rtld_bind_lock, &lockstate); + } + return ((void *)(dtv[index + 1] + offset)); } void * ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: ab349605821f - stable/13 - rtld: allow to use tls_get_addr_slow() from context where rtld_bind_lock is locked
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ab349605821f7e2bfc609ed69faccd068b402cb6 commit ab349605821f7e2bfc609ed69faccd068b402cb6 Author: Konstantin Belousov AuthorDate: 2021-04-06 18:56:58 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:07 + rtld: allow to use tls_get_addr_slow() from context where rtld_bind_lock is locked (cherry picked from commit 89508048424837ffdb32c8444dab02261711f77d) --- libexec/rtld-elf/rtld.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 134c2566b4cd..882aab4d76d8 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -166,6 +166,7 @@ static int symlook_list(SymLook *, const Objlist *, DoneList *); static int symlook_needed(SymLook *, const Needed_Entry *, DoneList *); static int symlook_obj1_sysv(SymLook *, const Obj_Entry *); static int symlook_obj1_gnu(SymLook *, const Obj_Entry *); +static void *tls_get_addr_slow(Elf_Addr **, int, size_t, bool) __noinline; static void trace_loaded_objects(Obj_Entry *); static void unlink_object(Obj_Entry *); static void unload_object(Obj_Entry *, RtldLockState *lockstate); @@ -4851,9 +4852,8 @@ unref_dag(Obj_Entry *root) /* * Common code for MD __tls_get_addr(). */ -static void *tls_get_addr_slow(Elf_Addr **, int, size_t) __noinline; static void * -tls_get_addr_slow(Elf_Addr **dtvp, int index, size_t offset) +tls_get_addr_slow(Elf_Addr **dtvp, int index, size_t offset, bool locked) { Elf_Addr *newdtv, *dtv; RtldLockState lockstate; @@ -4862,7 +4862,8 @@ tls_get_addr_slow(Elf_Addr **dtvp, int index, size_t offset) dtv = *dtvp; /* Check dtv generation in case new modules have arrived */ if (dtv[0] != tls_dtv_generation) { - wlock_acquire(rtld_bind_lock, &lockstate); + if (!locked) + wlock_acquire(rtld_bind_lock, &lockstate); newdtv = xcalloc(tls_max_index + 2, sizeof(Elf_Addr)); to_copy = dtv[1]; if (to_copy > tls_max_index) @@ -4871,17 +4872,20 @@ tls_get_addr_slow(Elf_Addr **dtvp, int index, size_t offset) newdtv[0] = tls_dtv_generation; newdtv[1] = tls_max_index; free(dtv); - lock_release(rtld_bind_lock, &lockstate); + if (!locked) + lock_release(rtld_bind_lock, &lockstate); dtv = *dtvp = newdtv; } /* Dynamically allocate module TLS if necessary */ if (dtv[index + 1] == 0) { /* Signal safe, wlock will block out signals. */ - wlock_acquire(rtld_bind_lock, &lockstate); + if (!locked) + wlock_acquire(rtld_bind_lock, &lockstate); if (!dtv[index + 1]) dtv[index + 1] = (Elf_Addr)allocate_module_tls(index); - lock_release(rtld_bind_lock, &lockstate); + if (!locked) + lock_release(rtld_bind_lock, &lockstate); } return ((void *)(dtv[index + 1] + offset)); } @@ -4896,7 +4900,7 @@ tls_get_addr_common(Elf_Addr **dtvp, int index, size_t offset) if (__predict_true(dtv[0] == tls_dtv_generation && dtv[index + 1] != 0)) return ((void *)(dtv[index + 1] + offset)); - return (tls_get_addr_slow(dtvp, index, offset)); + return (tls_get_addr_slow(dtvp, index, offset, false)); } #if defined(__aarch64__) || defined(__arm__) || defined(__mips__) || \ ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 88d6f049c12f - stable/13 - x86: add x86_clear_dbregs() helper
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=88d6f049c12f5d6945209c8805d4399a766de524 commit 88d6f049c12f5d6945209c8805d4399a766de524 Author: Konstantin Belousov AuthorDate: 2021-04-09 23:19:23 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:08 + x86: add x86_clear_dbregs() helper (cherry picked from commit a8b75a57c9b2cb3388746f097a55086a0f8c5d38) --- sys/amd64/amd64/machdep.c | 50 +++ sys/i386/i386/machdep.c | 50 +++ sys/x86/include/x86_var.h | 1 + 3 files changed, 59 insertions(+), 42 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 458d700a21e0..2901ef15e69a 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -581,6 +581,34 @@ freebsd4_sigreturn(struct thread *td, struct freebsd4_sigreturn_args *uap) } #endif +/* + * Reset the hardware debug registers if they were in use. + * They won't have any meaning for the newly exec'd process. + */ +void +x86_clear_dbregs(struct pcb *pcb) +{ + if ((pcb->pcb_flags & PCB_DBREGS) == 0) + return; + + pcb->pcb_dr0 = 0; + pcb->pcb_dr1 = 0; + pcb->pcb_dr2 = 0; + pcb->pcb_dr3 = 0; + pcb->pcb_dr6 = 0; + pcb->pcb_dr7 = 0; + + if (pcb == curpcb) { + /* +* Clear the debug registers on the running CPU, +* otherwise they will end up affecting the next +* process we switch to. +*/ + reset_dbregs(); + } + clear_pcb_flags(pcb, PCB_DBREGS); +} + /* * Reset registers to default values on exec. */ @@ -617,27 +645,7 @@ exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack) regs->tf_gs = _ugssel; regs->tf_flags = TF_HASSEGS; - /* -* Reset the hardware debug registers if they were in use. -* They won't have any meaning for the newly exec'd process. -*/ - if (pcb->pcb_flags & PCB_DBREGS) { - pcb->pcb_dr0 = 0; - pcb->pcb_dr1 = 0; - pcb->pcb_dr2 = 0; - pcb->pcb_dr3 = 0; - pcb->pcb_dr6 = 0; - pcb->pcb_dr7 = 0; - if (pcb == curpcb) { - /* -* Clear the debug registers on the running -* CPU, otherwise they will end up affecting -* the next process we switch to. -*/ - reset_dbregs(); - } - clear_pcb_flags(pcb, PCB_DBREGS); - } + x86_clear_dbregs(pcb); /* * Drop the FP state if we hold it, so that the process gets a diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index e847d97b8bcf..888550eab6ad 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -1121,6 +1121,34 @@ setup_priv_lcall_gate(struct proc *p) } #endif +/* + * Reset the hardware debug registers if they were in use. + * They won't have any meaning for the newly exec'd process. + */ +void +x86_clear_dbregs(struct pcb *pcb) +{ +if ((pcb->pcb_flags & PCB_DBREGS) == 0) + return; + + pcb->pcb_dr0 = 0; + pcb->pcb_dr1 = 0; + pcb->pcb_dr2 = 0; + pcb->pcb_dr3 = 0; + pcb->pcb_dr6 = 0; + pcb->pcb_dr7 = 0; + + if (pcb == curpcb) { + /* +* Clear the debug registers on the running CPU, +* otherwise they will end up affecting the next +* process we switch to. +*/ + reset_dbregs(); + } + pcb->pcb_flags &= ~PCB_DBREGS; +} + /* * Reset registers to default values on exec. */ @@ -1174,27 +1202,7 @@ exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack) /* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */ regs->tf_ebx = (register_t)imgp->ps_strings; -/* - * Reset the hardware debug registers if they were in use. - * They won't have any meaning for the newly exec'd process. - */ -if (pcb->pcb_flags & PCB_DBREGS) { -pcb->pcb_dr0 = 0; -pcb->pcb_dr1 = 0; -pcb->pcb_dr2 = 0; -pcb->pcb_dr3 = 0; -pcb->pcb_dr6 = 0; -pcb->pcb_dr7 = 0; -if (pcb == curpcb) { - /* -* Clear the debug registers on the running -* CPU, otherwise they will end up affecting -* the next process we switch to. -*/ - reset_dbregs(); -} - pcb->pcb_flags &= ~PCB_DBREGS; -} + x86_clear_dbregs(pcb); pcb->pcb_initial
git: 166b390bc586 - stable/13 - libc: include rtld.h into static implementations of rtld interface
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=166b390bc5869f5ac0f534291f49ff98e9291b42 commit 166b390bc5869f5ac0f534291f49ff98e9291b42 Author: Konstantin Belousov AuthorDate: 2021-04-05 03:41:46 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:07 + libc: include rtld.h into static implementations of rtld interface (cherry picked from commit 7f7489eba391a858b3930a34e7749d642b374c5c) --- lib/libc/Makefile | 8 + lib/libc/gen/Makefile.inc | 3 ++ lib/libc/gen/dlfcn.c | 1 + lib/libc/gen/tls.c| 76 --- lib/libdl/Makefile| 7 + 5 files changed, 58 insertions(+), 37 deletions(-) diff --git a/lib/libc/Makefile b/lib/libc/Makefile index d93091530721..958270e6ddf5 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -68,6 +68,14 @@ LIBADD+= ssp_nonshared # Extras that live in either libc.a or libc_nonshared.a LIBC_NONSHARED_SRCS= +RTLD_ELF_DIR=${SRCTOP}/libexec/rtld-elf +.if exists(${RTLD_ELF_DIR}/${MACHINE_ARCH:S/powerpc64le/powerpc64/}) +RTLD_ARCH= ${MACHINE_ARCH:S/powerpc64le/powerpc64/} +.else +RTLD_ARCH= ${MACHINE_CPUARCH} +.endif +RTLD_HDRS= -I${RTLD_ELF_DIR}/${RTLD_ARCH} -I${RTLD_ELF_DIR} + # Define (empty) variables so that make doesn't give substitution # errors if the included makefiles don't change these: MDSRCS= diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 0ab717600e56..aa9a4c0cbf67 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -172,6 +172,9 @@ SRCS+= __getosreldate.c \ CFLAGS.arc4random.c= -I${SRCTOP}/sys -I${SRCTOP}/sys/crypto/chacha20 +CFLAGS.dlfcn.c= ${RTLD_HDRS} +CFLAGS.tls.c= ${RTLD_HDRS} + .PATH: ${SRCTOP}/contrib/libc-pwcache SRCS+= pwcache.c pwcache.h diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c index 6047f7ddd4d7..16afdb6bf5d1 100644 --- a/lib/libc/gen/dlfcn.c +++ b/lib/libc/gen/dlfcn.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include #include "un-namespace.h" +#include "rtld.h" #include "libc_private.h" #include "reentrant.h" diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index 719391130827..2a64b5266f4a 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -41,6 +41,7 @@ #include #include +#include "rtld.h" #include "libc_private.h" #definetls_assert(cond)((cond) ? (void) 0 : \ @@ -96,10 +97,10 @@ void __libc_free_tls(void *tls, size_t tcbsize, size_t tcbalign); #ifndef PIC -static size_t tls_static_space; -static size_t tls_init_size; -static size_t tls_init_align; -static void *tls_init; +static size_t libc_tls_static_space; +static size_t libc_tls_init_size; +static size_t libc_tls_init_align; +static void *libc_tls_init; #endif #ifdef __i386__ @@ -124,7 +125,7 @@ __libc_tls_get_addr(void *ti __unused) #ifndef PIC static void * -malloc_aligned(size_t size, size_t align) +libc_malloc_aligned(size_t size, size_t align) { void *mem, *res; @@ -138,7 +139,7 @@ malloc_aligned(size_t size, size_t align) } static void -free_aligned(void *ptr) +libc_free_aligned(void *ptr) { void *mem; uintptr_t x; @@ -188,8 +189,6 @@ free_aligned(void *ptr) * [5] I'm not able to validate "values are biased" assertions. */ -#defineTLS_TCB_SIZE(2 * sizeof(void *)) - /* * Return pointer to allocated TLS block */ @@ -201,12 +200,13 @@ get_tls_block_ptr(void *tcb, size_t tcbsize) /* Compute fragments sizes. */ extra_size = tcbsize - TLS_TCB_SIZE; #if defined(__aarch64__) || defined(__arm__) - post_size = roundup2(TLS_TCB_SIZE, tls_init_align) - TLS_TCB_SIZE; + post_size = roundup2(TLS_TCB_SIZE, libc_tls_init_align) - TLS_TCB_SIZE; #else post_size = 0; #endif tls_block_size = tcbsize + post_size; - pre_size = roundup2(tls_block_size, tls_init_align) - tls_block_size; + pre_size = roundup2(tls_block_size, libc_tls_init_align) - + tls_block_size; return ((char *)tcb - pre_size - extra_size); } @@ -225,7 +225,7 @@ __libc_free_tls(void *tcb, size_t tcbsize, size_t tcbalign __unused) tls = (Elf_Addr **)tcb; dtv = tls[0]; __je_bootstrap_free(dtv); - free_aligned(get_tls_block_ptr(tcb, tcbsize)); + libc_free_aligned(get_tls_block_ptr(tcb, tcbsize)); } /* @@ -259,21 +259,22 @@ __libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign) return (oldtcb); tls_assert(tcbalign >= TLS_TCB_ALIGN); - maxalign = MAX(tcbalign, tls_init_align); + maxalign = MAX(tcbalign, libc_tls_init_align); /* Compute fragmets sizes. */ extra_size = tcbsize - TLS_TCB_SIZE; #if defined(__aarch64__) || defined(__arm__) - post_size = roundup2(TLS_TCB_SIZE, tls_init_align) - TLS_TCB_SIZE; + post_size = roundup2(TLS_TCB_SIZE, l
git: fe86eb8f346e - stable/13 - rtld: unstaticise lockinfo and obj_from_addr()
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=fe86eb8f346eb6706833bf34d5837ef68a40f887 commit fe86eb8f346eb6706833bf34d5837ef68a40f887 Author: Konstantin Belousov AuthorDate: 2021-04-10 12:30:59 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:08 + rtld: unstaticise lockinfo and obj_from_addr() (cherry picked from commit 4d7f08c84bcfcd75ba23b06e07a8e5dba1d4a44f) --- libexec/rtld-elf/rtld.c | 3 +-- libexec/rtld-elf/rtld.h | 1 + libexec/rtld-elf/rtld_lock.c | 2 +- libexec/rtld-elf/rtld_lock.h | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 69e096ad3e6e..5e99b8db8ff7 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -124,7 +124,6 @@ static Obj_Entry *load_object(const char *, int fd, const Obj_Entry *, int); static void map_stacks_exec(RtldLockState *); static int obj_disable_relro(Obj_Entry *); static int obj_enforce_relro(Obj_Entry *); -static Obj_Entry *obj_from_addr(const void *); static void objlist_call_fini(Objlist *, Obj_Entry *, RtldLockState *); static void objlist_call_init(Objlist *, RtldLockState *); static void objlist_clear(Objlist *); @@ -2668,7 +2667,7 @@ errp: return (NULL); } -static Obj_Entry * +Obj_Entry * obj_from_addr(const void *addr) { Obj_Entry *obj; diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h index 6a2f62fc6189..060b83b2cdad 100644 --- a/libexec/rtld-elf/rtld.h +++ b/libexec/rtld-elf/rtld.h @@ -389,6 +389,7 @@ Obj_Entry *globallist_curr(const Obj_Entry *obj); Obj_Entry *globallist_next(const Obj_Entry *obj); void obj_free(Obj_Entry *); Obj_Entry *obj_new(void); +Obj_Entry *obj_from_addr(const void *); void _rtld_bind_start(void); void *rtld_resolve_ifunc(const Obj_Entry *obj, const Elf_Sym *def); void symlook_init(SymLook *, const char *); diff --git a/libexec/rtld-elf/rtld_lock.c b/libexec/rtld-elf/rtld_lock.c index c453584b96e2..d94bd1a283e9 100644 --- a/libexec/rtld-elf/rtld_lock.c +++ b/libexec/rtld-elf/rtld_lock.c @@ -192,7 +192,7 @@ def_thread_clr_flag(int mask) /* * Public interface exposed to the rest of the dynamic linker. */ -static struct RtldLockInfo lockinfo; +struct RtldLockInfo lockinfo; static struct RtldLockInfo deflockinfo; static __inline int diff --git a/libexec/rtld-elf/rtld_lock.h b/libexec/rtld-elf/rtld_lock.h index 9aa769b1f7e6..ecc733a06e44 100644 --- a/libexec/rtld-elf/rtld_lock.h +++ b/libexec/rtld-elf/rtld_lock.h @@ -63,6 +63,8 @@ extern rtld_lock_trtld_bind_lock; extern rtld_lock_t rtld_libc_lock; extern rtld_lock_t rtld_phdr_lock; +extern struct RtldLockInfo lockinfo; + #defineRTLD_LOCK_UNLOCKED 0 #defineRTLD_LOCK_RLOCKED 1 #defineRTLD_LOCK_WLOCKED 2 ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: f06f6654303a - stable/13 - x86: use x86_clear_dbregs() on fork
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f06f6654303acc8ac5957b01787582b5d1e26a0f commit f06f6654303acc8ac5957b01787582b5d1e26a0f Author: Konstantin Belousov AuthorDate: 2021-04-09 23:20:55 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:08 + x86: use x86_clear_dbregs() on fork (cherry picked from commit 290b0d123ae2136ad84b268cd1884b1624d1d37f) --- sys/amd64/amd64/vm_machdep.c | 7 +-- sys/i386/i386/vm_machdep.c | 7 +-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 98d212dc8771..1acc5dc55c85 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -230,12 +230,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) copy_thread(td1, td2); /* Reset debug registers in the new process */ - pcb2->pcb_dr0 = 0; - pcb2->pcb_dr1 = 0; - pcb2->pcb_dr2 = 0; - pcb2->pcb_dr3 = 0; - pcb2->pcb_dr6 = 0; - pcb2->pcb_dr7 = 0; + x86_clear_dbregs(pcb2); /* Point mdproc and then copy over p1's contents */ mdp2 = &p2->p_md; diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index ed40ebe5d1c8..57377575b9bf 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -242,12 +242,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) copy_thread(td1, td2); /* Reset debug registers in the new process */ - pcb2->pcb_dr0 = 0; - pcb2->pcb_dr1 = 0; - pcb2->pcb_dr2 = 0; - pcb2->pcb_dr3 = 0; - pcb2->pcb_dr6 = 0; - pcb2->pcb_dr7 = 0; + x86_clear_dbregs(pcb2); /* Point mdproc and then copy over td1's contents */ mdp2 = &p2->p_md; ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 41331ef7f618 - stable/13 - libc: add _get_tp() private function
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=41331ef7f618e15732b84f960cc236e70e38e253 commit 41331ef7f618e15732b84f960cc236e70e38e253 Author: Konstantin Belousov AuthorDate: 2021-04-05 03:30:35 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:07 + libc: add _get_tp() private function (cherry picked from commit 06d8a116bd6b6f70b8aedc6a6a2c4085c53f63ac) --- lib/libc/aarch64/gen/Makefile.inc| 1 + lib/libc/aarch64/gen/_get_tp.c | 45 +++ lib/libc/amd64/gen/Makefile.inc | 2 +- lib/libc/amd64/gen/_get_tp.c | 46 lib/libc/arm/gen/Makefile.inc| 1 + lib/libc/arm/gen/_get_tp.c | 51 + lib/libc/i386/gen/Makefile.inc | 2 +- lib/libc/i386/gen/_get_tp.c | 45 +++ lib/libc/include/libc_private.h | 3 +- lib/libc/mips/gen/Makefile.inc | 2 +- lib/libc/mips/gen/_get_tp.c | 103 +++ lib/libc/powerpc/gen/Makefile.common | 4 +- lib/libc/powerpc/gen/_get_tp.c | 47 lib/libc/powerpc64/gen/Makefile.inc | 3 +- lib/libc/powerpc64/gen/_get_tp.c | 47 lib/libc/riscv/gen/Makefile.inc | 3 + lib/libc/riscv/gen/_get_tp.c | 47 17 files changed, 446 insertions(+), 6 deletions(-) diff --git a/lib/libc/aarch64/gen/Makefile.inc b/lib/libc/aarch64/gen/Makefile.inc index fe39136f5b41..7c530b93b4e4 100644 --- a/lib/libc/aarch64/gen/Makefile.inc +++ b/lib/libc/aarch64/gen/Makefile.inc @@ -7,6 +7,7 @@ SRCS+= _ctx_start.S \ flt_rounds.c \ fpgetmask.c \ fpsetmask.c \ + _get_tp.c \ infinity.c \ ldexp.c \ makecontext.c \ diff --git a/lib/libc/aarch64/gen/_get_tp.c b/lib/libc/aarch64/gen/_get_tp.c new file mode 100644 index ..ce51b400b542 --- /dev/null +++ b/lib/libc/aarch64/gen/_get_tp.c @@ -0,0 +1,45 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 The FreeBSD Foundation + * + * This software were developed 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 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include "libc_private.h" + +void * +_get_tp(void) +{ + void *res; + + __asm __volatile("mrs %0, tpidr_el0" : "=r" (res)); + return (res); +} diff --git a/lib/libc/amd64/gen/Makefile.inc b/lib/libc/amd64/gen/Makefile.inc index 30fb05f89cb7..4df3c044493e 100644 --- a/lib/libc/amd64/gen/Makefile.inc +++ b/lib/libc/amd64/gen/Makefile.inc @@ -1,7 +1,7 @@ # @(#)Makefile.inc8.1 (Berkeley) 6/4/93 # $FreeBSD$ -SRCS+= _setjmp.S _set_tp.c rfork_thread.S setjmp.S sigsetjmp.S \ +SRCS+= _setjmp.S _get_tp.c _set_tp.c rfork_thread.S setjmp.S sigsetjmp.S \ fabs.S \ infinity.c ldexp.c makecontext.c signalcontext.c \ flt_rounds.c fpgetmask.c fpsetmask.c fpgetprec.c fpsetprec.c \ diff --git a/lib/libc/amd64/gen/_get_tp.c b/lib/libc/amd64/gen/_get_tp.c new file mode 100644 index ..3c74b9e769c1 --- /dev/null +++ b/lib/libc/amd64/gen/_get_tp.c @@ -0,0 +1,46 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 The FreeBSD Foundation + * + * This software were developed 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, th
git: 7bbfb5d95932 - stable/13 - rtld: make dlerror() thread-local
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7bbfb5d959329fe0c322c0b59c9268b75ace commit 7bbfb5d959329fe0c322c0b59c9268b75ace Author: Konstantin Belousov AuthorDate: 2021-04-07 22:02:33 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:08 + rtld: make dlerror() thread-local (cherry picked from commit 4d9128da54f8f8e2a29190ffb18880c4f116a205) --- lib/libthr/thread/thr_private.h | 4 lib/libthr/thread/thr_rtld.c| 21 + libexec/rtld-elf/rtld.c | 38 -- libexec/rtld-elf/rtld_lock.c| 33 + libexec/rtld-elf/rtld_lock.h| 7 ++- 5 files changed, 84 insertions(+), 19 deletions(-) diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h index a1258940a896..a5bbc5997d30 100644 --- a/lib/libthr/thread/thr_private.h +++ b/lib/libthr/thread/thr_private.h @@ -577,6 +577,10 @@ struct pthread { /* pthread_set/get_name_np */ char*name; + + /* rtld thread-local dlerror message and seen control */ + chardlerror_msg[512]; + int dlerror_seen; }; #define THR_SHOULD_GC(thrd)\ diff --git a/lib/libthr/thread/thr_rtld.c b/lib/libthr/thread/thr_rtld.c index 5848fc6d5f61..1967ea14859d 100644 --- a/lib/libthr/thread/thr_rtld.c +++ b/lib/libthr/thread/thr_rtld.c @@ -189,6 +189,24 @@ _thr_rtld_clr_flag(int mask __unused) extern char _pli_rtli_version; char _pli_rtli_version; +static char * +_thr_dlerror_loc(void) +{ + struct pthread *curthread; + + curthread = _get_curthread(); + return (curthread->dlerror_msg); +} + +static int * +_thr_dlerror_seen(void) +{ + struct pthread *curthread; + + curthread = _get_curthread(); + return (&curthread->dlerror_seen); +} + void _thr_rtld_init(void) { @@ -221,6 +239,9 @@ _thr_rtld_init(void) li.thread_set_flag = _thr_rtld_set_flag; li.thread_clr_flag = _thr_rtld_clr_flag; li.at_fork = NULL; + li.dlerror_loc = _thr_dlerror_loc; + li.dlerror_loc_sz = sizeof(curthread->dlerror_msg); + li.dlerror_seen = _thr_dlerror_seen; /* * Preresolve the symbols needed for the fork interposer. We diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 5e99b8db8ff7..d50774868908 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -195,7 +195,6 @@ int __sys_openat(int, const char *, int, ...); /* * Data declarations. */ -static char *error_message;/* Message for dlerror(), or NULL */ struct r_debug r_debug __exported; /* for GDB; */ static bool libmap_disable;/* Disable libmap */ static bool ld_loadfltr; /* Immediate filters processing */ @@ -441,6 +440,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp) assert(aux_info[AT_BASE] != NULL); init_rtld((caddr_t) aux_info[AT_BASE]->a_un.a_ptr, aux_info); +dlerror_dflt_init(); + __progname = obj_rtld.path; argv0 = argv[0] != NULL ? argv[0] : "(null)"; environ = env; @@ -919,14 +920,14 @@ _rtld_bind(Obj_Entry *obj, Elf_Size reloff) void _rtld_error(const char *fmt, ...) { -static char buf[512]; -va_list ap; + va_list ap; -va_start(ap, fmt); -rtld_vsnprintf(buf, sizeof buf, fmt, ap); -error_message = buf; -va_end(ap); -LD_UTRACE(UTRACE_RTLD_ERROR, NULL, NULL, 0, 0, error_message); + va_start(ap, fmt); + rtld_vsnprintf(lockinfo.dlerror_loc(), lockinfo.dlerror_loc_sz, + fmt, ap); + va_end(ap); + *lockinfo.dlerror_seen() = 0; + LD_UTRACE(UTRACE_RTLD_ERROR, NULL, NULL, 0, 0, lockinfo.dlerror_loc()); } /* @@ -935,7 +936,7 @@ _rtld_error(const char *fmt, ...) static char * errmsg_save(void) { -return error_message == NULL ? NULL : xstrdup(error_message); + return (xstrdup(lockinfo.dlerror_loc())); } /* @@ -945,12 +946,12 @@ errmsg_save(void) static void errmsg_restore(char *saved_msg) { -if (saved_msg == NULL) - error_message = NULL; -else { - _rtld_error("%s", saved_msg); - free(saved_msg); -} + if (saved_msg == NULL) + _rtld_error(""); + else { + _rtld_error("%s", saved_msg); + free(saved_msg); + } } static const char * @@ -3369,9 +3370,10 @@ dlclose_locked(void *handle, RtldLockState *lockstate) char * dlerror(void) { -char *msg = error_message; -error_message = NULL; -return msg; + if (*(lockinfo.dlerror_seen()) != 0) + return (NULL); + *lockinfo.dlerror_seen() = 1; + return (lockinfo.dlerror_loc()); } /* diff --git a/libexec/rtld-elf/rtld_lock.c b/libexec/rtld-elf/rtld_lock.c index 4d54c687ee6f..94e931c2f760 100644 --- a/libexec/rtld-elf/rtld_lock.c
git: b75aa0eaf3de - stable/13 - rtld: workaround for broken ABI
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b75aa0eaf3de1343a349c867bfcff993188f9231 commit b75aa0eaf3de1343a349c867bfcff993188f9231 Author: Konstantin Belousov AuthorDate: 2021-04-10 12:32:24 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:08 + rtld: workaround for broken ABI (cherry picked from commit 08bfbd43594b7642de0d2487550f36b0ee1eceba) --- lib/libthr/pthread.map | 3 +++ lib/libthr/thread/thr_rtld.c | 8 libexec/rtld-elf/rtld_lock.c | 17 - libexec/rtld-elf/rtld_lock.h | 4 +++- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/libthr/pthread.map b/lib/libthr/pthread.map index 232d65084ba9..15195ce0847b 100644 --- a/lib/libthr/pthread.map +++ b/lib/libthr/pthread.map @@ -296,6 +296,9 @@ FBSDprivate_1.0 { _thread_size_key; _thread_state_running; _thread_state_zoombie; + + /* ABI bug workaround, indicate that pli->rtli_version is valid */ + _pli_rtli_version; }; FBSD_1.1 { diff --git a/lib/libthr/thread/thr_rtld.c b/lib/libthr/thread/thr_rtld.c index 291ca17e2068..5848fc6d5f61 100644 --- a/lib/libthr/thread/thr_rtld.c +++ b/lib/libthr/thread/thr_rtld.c @@ -182,6 +182,13 @@ _thr_rtld_clr_flag(int mask __unused) return (0); } +/* + * ABI bug workaround: This symbol must be present for rtld to accept + * RTLI_VERSION from RtldLockInfo + */ +extern char _pli_rtli_version; +char _pli_rtli_version; + void _thr_rtld_init(void) { @@ -205,6 +212,7 @@ _thr_rtld_init(void) mprotect(NULL, 0, 0); _rtld_get_stack_prot(); + li.rtli_version = RTLI_VERSION; li.lock_create = _thr_rtld_lock_create; li.lock_destroy = _thr_rtld_lock_destroy; li.rlock_acquire = _thr_rtld_rlock_acquire; diff --git a/libexec/rtld-elf/rtld_lock.c b/libexec/rtld-elf/rtld_lock.c index d94bd1a283e9..4d54c687ee6f 100644 --- a/libexec/rtld-elf/rtld_lock.c +++ b/libexec/rtld-elf/rtld_lock.c @@ -344,8 +344,23 @@ lockdflt_init(void) void _rtld_thread_init(struct RtldLockInfo *pli) { - int flags, i; + const Obj_Entry *obj; + SymLook req; void *locks[RTLD_LOCK_CNT]; + int flags, i, res; + + if (pli == NULL) { + lockinfo.rtli_version = RTLI_VERSION; + } else { + lockinfo.rtli_version = RTLI_VERSION_ONE; + obj = obj_from_addr(pli->lock_create); + if (obj != NULL) { + symlook_init(&req, "_pli_rtli_version"); + res = symlook_obj(&req, obj); + if (res == 0) + lockinfo.rtli_version = pli->rtli_version; + } + } /* disable all locking while this function is running */ flags = thread_mask_set(~0); diff --git a/libexec/rtld-elf/rtld_lock.h b/libexec/rtld-elf/rtld_lock.h index ecc733a06e44..7a61a1a525e2 100644 --- a/libexec/rtld-elf/rtld_lock.h +++ b/libexec/rtld-elf/rtld_lock.h @@ -30,7 +30,9 @@ #ifndef _RTLD_LOCK_H_ #define_RTLD_LOCK_H_ -#defineRTLI_VERSION0x01 +#defineRTLI_VERSION_ONE0x01 +#defineRTLI_VERSION0x01 + #defineMAX_RTLD_LOCKS 8 struct RtldLockInfo ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: a635232c7614 - stable/13 - ptrace: restructure comments around reparenting on PT_DETACH
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a635232c76145209adeb2157c394a12cc6b8313e commit a635232c76145209adeb2157c394a12cc6b8313e Author: Konstantin Belousov AuthorDate: 2021-04-11 09:06:21 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:08 + ptrace: restructure comments around reparenting on PT_DETACH (cherry picked from commit a091c353235e0ee97d2531e80d9d64e1648350f4) --- sys/kern/sys_process.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index a63cf9a80834..0b1305f49a93 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1005,14 +1005,16 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) break; case PT_DETACH: /* -* Reset the process parent. -* -* NB: This clears P_TRACED before reparenting +* Clear P_TRACED before reparenting * a detached process back to its original * parent. Otherwise the debugee will be set * as an orphan of the debugger. */ p->p_flag &= ~(P_TRACED | P_WAITED); + + /* +* Reset the process parent. +*/ if (p->p_oppid != p->p_pptr->p_pid) { PROC_LOCK(p->p_pptr); sigqueue_take(p->p_ksi); @@ -1025,9 +1027,11 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) CTR3(KTR_PTRACE, "PT_DETACH: pid %d reparented to pid %d, sig %d", p->p_pid, pp->p_pid, data); - } else + } else { CTR2(KTR_PTRACE, "PT_DETACH: pid %d, sig %d", p->p_pid, data); + } + p->p_ptevents = 0; FOREACH_THREAD_IN_PROC(p, td3) { if ((td3->td_dbgflags & TDB_FSTP) != 0) { ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 13e0ef823047 - stable/13 - rtld_lock.h: add some comments about versioning of struct RtldLockInfo
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=13e0ef823047491f8c246dd721ec22778c4d5384 commit 13e0ef823047491f8c246dd721ec22778c4d5384 Author: Konstantin Belousov AuthorDate: 2021-04-11 08:12:48 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:08 + rtld_lock.h: add some comments about versioning of struct RtldLockInfo (cherry picked from commit 9b33518ada2ebda727ca3c7979cdcdb30716f737) --- libexec/rtld-elf/rtld_lock.h | 13 + 1 file changed, 13 insertions(+) diff --git a/libexec/rtld-elf/rtld_lock.h b/libexec/rtld-elf/rtld_lock.h index fdbdc9917075..c88b558b72b8 100644 --- a/libexec/rtld-elf/rtld_lock.h +++ b/libexec/rtld-elf/rtld_lock.h @@ -35,9 +35,20 @@ #defineMAX_RTLD_LOCKS 8 +/* + * This structure is part of the ABI between rtld and threading + * libraries, like libthr and even libc_r. Its layout is fixed and + * can be changed only by appending new fields at the end, with the + * bump of RTLI_VERSION. + */ struct RtldLockInfo { + /* +* Valid if the object calling _rtld_thread_init() exported +* symbol _pli_rtli_version. Otherwise assume RTLI_VERSION_ONE. +*/ unsigned int rtli_version; + void *(*lock_create)(void); void (*lock_destroy)(void *); void (*rlock_acquire)(void *); @@ -46,6 +57,8 @@ struct RtldLockInfo int (*thread_set_flag)(int); int (*thread_clr_flag)(int); void (*at_fork)(void); + + /* Version 2 fields */ char *(*dlerror_loc)(void); int *(*dlerror_seen)(void); int dlerror_loc_sz; ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 4bcc2e90a093 - stable/13 - rtld: define TLS_DTV_OFFSET on all architectures
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4bcc2e90a09330711bcc32f1f6d100c5d7989152 commit 4bcc2e90a09330711bcc32f1f6d100c5d7989152 Author: Konstantin Belousov AuthorDate: 2021-04-07 06:25:34 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:07 + rtld: define TLS_DTV_OFFSET on all architectures (cherry picked from commit 99c2ce7ef12f0852f25155d1d6718beccafbae0e) --- libexec/rtld-elf/aarch64/rtld_machdep.h | 2 ++ libexec/rtld-elf/amd64/rtld_machdep.h | 2 ++ libexec/rtld-elf/arm/rtld_machdep.h | 2 ++ libexec/rtld-elf/i386/rtld_machdep.h| 2 ++ libexec/rtld-elf/mips/rtld_machdep.h| 2 ++ 5 files changed, 10 insertions(+) diff --git a/libexec/rtld-elf/aarch64/rtld_machdep.h b/libexec/rtld-elf/aarch64/rtld_machdep.h index 0824219c00c2..bdd5620867ba 100644 --- a/libexec/rtld-elf/aarch64/rtld_machdep.h +++ b/libexec/rtld-elf/aarch64/rtld_machdep.h @@ -93,4 +93,6 @@ extern void *__tls_get_addr(tls_index *ti); #define md_abi_variant_hook(x) +#defineTLS_DTV_OFFSET 0 + #endif diff --git a/libexec/rtld-elf/amd64/rtld_machdep.h b/libexec/rtld-elf/amd64/rtld_machdep.h index 86027a04788f..30c82dcb0625 100644 --- a/libexec/rtld-elf/amd64/rtld_machdep.h +++ b/libexec/rtld-elf/amd64/rtld_machdep.h @@ -73,6 +73,8 @@ void *__tls_get_addr(tls_index *ti) __exported; #define md_abi_variant_hook(x) +#defineTLS_DTV_OFFSET 0 + size_t calculate_first_tls_offset(size_t size, size_t align, size_t offset); size_t calculate_tls_offset(size_t prev_offset, size_t prev_size, size_t size, size_t align, size_t offset); diff --git a/libexec/rtld-elf/arm/rtld_machdep.h b/libexec/rtld-elf/arm/rtld_machdep.h index 57420c65593f..b333b1f153eb 100644 --- a/libexec/rtld-elf/arm/rtld_machdep.h +++ b/libexec/rtld-elf/arm/rtld_machdep.h @@ -86,4 +86,6 @@ extern void arm_abi_variant_hook(Elf_Auxinfo **); #define md_abi_variant_hook(x) #endif +#defineTLS_DTV_OFFSET 0 + #endif diff --git a/libexec/rtld-elf/i386/rtld_machdep.h b/libexec/rtld-elf/i386/rtld_machdep.h index 5116f9707337..78154a1992d4 100644 --- a/libexec/rtld-elf/i386/rtld_machdep.h +++ b/libexec/rtld-elf/i386/rtld_machdep.h @@ -74,6 +74,8 @@ void *__tls_get_addr(tls_index *ti) __exported; #define md_abi_variant_hook(x) +#defineTLS_DTV_OFFSET 0 + size_t calculate_first_tls_offset(size_t size, size_t align, size_t offset); size_t calculate_tls_offset(size_t prev_offset, size_t prev_size, size_t size, size_t align, size_t offset); diff --git a/libexec/rtld-elf/mips/rtld_machdep.h b/libexec/rtld-elf/mips/rtld_machdep.h index b1556c93c3d6..d2498dbb9aa4 100644 --- a/libexec/rtld-elf/mips/rtld_machdep.h +++ b/libexec/rtld-elf/mips/rtld_machdep.h @@ -80,4 +80,6 @@ extern void *__tls_get_addr(tls_index *ti); #define md_abi_variant_hook(x) +#defineTLS_DTV_OFFSET 0 + #endif ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 8bffc9b49248 - stable/13 - link(2): correct descriptor name in AT_RESOLVE_BENEATH description
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8bffc9b49248a21a6b5943dc17f4fc47fc122fb0 commit 8bffc9b49248a21a6b5943dc17f4fc47fc122fb0 Author: Konstantin Belousov AuthorDate: 2021-03-30 21:56:28 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:09 + link(2): correct descriptor name in AT_RESOLVE_BENEATH description (cherry picked from commit c78e124535febc6c0bc7c0756b42d6b845428d2e) --- lib/libc/sys/link.2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/sys/link.2 b/lib/libc/sys/link.2 index de0efd5e510f..bcf03f17f3bb 100644 --- a/lib/libc/sys/link.2 +++ b/lib/libc/sys/link.2 @@ -117,7 +117,7 @@ names a symbolic link, a new link for the target of the symbolic link is created. .It Dv AT_RESOLVE_BENEATH Only walk paths below the directory specified by the -.Ar fd +.Ar fd1 descriptor. See the description of the .Dv O_RESOLVE_BENEATH ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 0d5114825576 - stable/13 - amd64: clear debug registers on execing 32bit Linux binary
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0d511482557677ef7aecb3109955d1596d5cf9d9 commit 0d511482557677ef7aecb3109955d1596d5cf9d9 Author: Konstantin Belousov AuthorDate: 2021-04-09 23:25:06 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:08 + amd64: clear debug registers on execing 32bit Linux binary (cherry picked from commit 94172affa43af15fe3b50293a96c292eca30c386) --- sys/amd64/linux32/linux32_sysvec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index bb86baefaec4..3790d0fcb69c 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -722,6 +722,8 @@ linux_exec_setregs(struct thread *td, struct image_params *imgp, regs->tf_cs = _ucode32sel; regs->tf_rbx = (register_t)imgp->ps_strings; + x86_clear_dbregs(pcb); + fpstate_drop(td); /* Do full restore on return so that we can change to a different %cs */ ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 6c74b122953d - stable/13 - amd64 linux64: use x86_clear_dbregs()
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6c74b122953d6981278c2061bc1b60d1d764c020 commit 6c74b122953d6981278c2061bc1b60d1d764c020 Author: Konstantin Belousov AuthorDate: 2021-04-09 23:22:48 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:08 + amd64 linux64: use x86_clear_dbregs() (cherry picked from commit 2f1588474768f61f3a983af207e753bd0340a9e7) --- sys/amd64/linux/linux_sysvec.c | 22 +- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index abc750c63682..252579a4809e 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -477,27 +477,7 @@ linux_exec_setregs(struct thread *td, struct image_params *imgp, regs->tf_gs = _ugssel; regs->tf_flags = TF_HASSEGS; - /* -* Reset the hardware debug registers if they were in use. -* They won't have any meaning for the newly exec'd process. -*/ - if (pcb->pcb_flags & PCB_DBREGS) { - pcb->pcb_dr0 = 0; - pcb->pcb_dr1 = 0; - pcb->pcb_dr2 = 0; - pcb->pcb_dr3 = 0; - pcb->pcb_dr6 = 0; - pcb->pcb_dr7 = 0; - if (pcb == curpcb) { - /* -* Clear the debug registers on the running -* CPU, otherwise they will end up affecting -* the next process we switch to. -*/ - reset_dbregs(); - } - clear_pcb_flags(pcb, PCB_DBREGS); - } + x86_clear_dbregs(pcb); /* * Drop the FP state if we hold it, so that the process gets a ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: b26e7715b072 - stable/13 - rtld: use _get_tp() in __tls_get_addr()
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b26e7715b072ad9c67c80e74d7b8e80de4159bee commit b26e7715b072ad9c67c80e74d7b8e80de4159bee Author: Konstantin Belousov AuthorDate: 2021-04-07 03:49:28 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:07 + rtld: use _get_tp() in __tls_get_addr() (cherry picked from commit e8b9c508b7ae5be618ada089103468c400e465cd) --- libexec/rtld-elf/amd64/reloc.c | 7 ++-- libexec/rtld-elf/i386/reloc.c| 14 libexec/rtld-elf/mips/reloc.c| 62 +++- libexec/rtld-elf/mips/rtld_machdep.h | 2 -- 4 files changed, 13 insertions(+), 72 deletions(-) diff --git a/libexec/rtld-elf/amd64/reloc.c b/libexec/rtld-elf/amd64/reloc.c index 309e105d8b5e..689b0d8635d4 100644 --- a/libexec/rtld-elf/amd64/reloc.c +++ b/libexec/rtld-elf/amd64/reloc.c @@ -541,11 +541,10 @@ allocate_initial_tls(Obj_Entry *objs) void * __tls_get_addr(tls_index *ti) { -Elf_Addr** segbase; + Elf_Addr **dtvp; -__asm __volatile("movq %%fs:0, %0" : "=r" (segbase)); - -return tls_get_addr_common(&segbase[1], ti->ti_module, ti->ti_offset); + dtvp = _get_tp(); + return (tls_get_addr_common(dtvp, ti->ti_module, ti->ti_offset)); } size_t diff --git a/libexec/rtld-elf/i386/reloc.c b/libexec/rtld-elf/i386/reloc.c index 5ed3abf65b31..cab163b35e6a 100644 --- a/libexec/rtld-elf/i386/reloc.c +++ b/libexec/rtld-elf/i386/reloc.c @@ -522,22 +522,20 @@ __attribute__((__regparm__(1))) void * ___tls_get_addr(tls_index *ti) { -Elf_Addr** segbase; + Elf_Addr **dtvp; -__asm __volatile("movl %%gs:0, %0" : "=r" (segbase)); - -return tls_get_addr_common(&segbase[1], ti->ti_module, ti->ti_offset); + dtvp = _get_tp(); + return (tls_get_addr_common(dtvp, ti->ti_module, ti->ti_offset)); } /* Sun ABI */ void * __tls_get_addr(tls_index *ti) { -Elf_Addr** segbase; - -__asm __volatile("movl %%gs:0, %0" : "=r" (segbase)); + Elf_Addr **dtvp; -return tls_get_addr_common(&segbase[1], ti->ti_module, ti->ti_offset); + dtvp = _get_tp(); + return (tls_get_addr_common(dtvp, ti->ti_module, ti->ti_offset)); } size_t diff --git a/libexec/rtld-elf/mips/reloc.c b/libexec/rtld-elf/mips/reloc.c index 163f9a170872..44ecbd66a707 100644 --- a/libexec/rtld-elf/mips/reloc.c +++ b/libexec/rtld-elf/mips/reloc.c @@ -776,69 +776,15 @@ allocate_initial_tls(Obj_Entry *objs) sysarch(MIPS_SET_TLS, tls); } -#ifdef __mips_n64 -void * -_mips_get_tls(void) -{ - uint64_t _rv; - - __asm__ __volatile__ ( - ".set\tpush\n\t" - ".set\tmips64r2\n\t" - "rdhwr\t%0, $29\n\t" - ".set\tpop" - : "=r" (_rv)); - /* -* XXXSS See 'git show c6be4f4d2d1b71c04de5d3bbb6933ce2dbcdb317' -* -* Remove the offset since this really a request to get the TLS -* pointer via sysarch() (in theory). Of course, this may go away -* once the TLS code is rewritten. -*/ - _rv = _rv - TLS_TP_OFFSET - TLS_TCB_SIZE; - - return (void *)_rv; -} - -#else /* mips 32 */ - -void * -_mips_get_tls(void) -{ - uint32_t _rv; - - __asm__ __volatile__ ( - ".set\tpush\n\t" - ".set\tmips32r2\n\t" - "rdhwr\t%0, $29\n\t" - ".set\tpop" - : "=r" (_rv)); - /* -* XXXSS See 'git show c6be4f4d2d1b71c04de5d3bbb6933ce2dbcdb317' -* -* Remove the offset since this really a request to get the TLS -* pointer via sysarch() (in theory). Of course, this may go away -* once the TLS code is rewritten. -*/ - _rv = _rv - TLS_TP_OFFSET - TLS_TCB_SIZE; - - return (void *)_rv; -} -#endif /* ! __mips_n64 */ - void * __tls_get_addr(tls_index* ti) { - Elf_Addr** tls; + Elf_Addr **tls; char *p; -#ifdef TLS_USE_SYSARCH - sysarch(MIPS_GET_TLS, &tls); -#else - tls = _mips_get_tls(); -#endif - - p = tls_get_addr_common(tls, ti->ti_module, ti->ti_offset + TLS_DTP_OFFSET); + tls = _get_tp(); + p = tls_get_addr_common(tls, ti->ti_module, ti->ti_offset + + TLS_DTP_OFFSET); return (p); } diff --git a/libexec/rtld-elf/mips/rtld_machdep.h b/libexec/rtld-elf/mips/rtld_machdep.h index d2498dbb9aa4..041a5d05f9a7 100644 --- a/libexec/rtld-elf/mips/rtld_machdep.h +++ b/libexec/rtld-elf/mips/rtld_machdep.h @@ -44,8 +44,6 @@ Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj, const Elf_Rel *rel); Elf_Addr _mips_rtld_bind(struct Struct_Obj_Entry *obj, Elf_Size reloff); -void *_mips_get_tls(void); - #define make_function_pointer(def, defobj) \ ((defobj)->relocbase + (def)->st_value) ___ dev-commits-src-all@freebsd.org mailing list https://
git: 2df5e7711bee - stable/13 - sbuf_uionew(): sbuf_new() takes int as length
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2df5e7711bee3c35209d576aa57ef09a7a839d79 commit 2df5e7711bee3c35209d576aa57ef09a7a839d79 Author: Konstantin Belousov AuthorDate: 2021-04-13 19:12:19 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:09 + sbuf_uionew(): sbuf_new() takes int as length (cherry picked from commit 116f26f947b8bbf868dcd85d79226406029a45ee) --- sys/kern/subr_sbuf.c | 4 1 file changed, 4 insertions(+) diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c index cdeaf690208f..b7f135e81206 100644 --- a/sys/kern/subr_sbuf.c +++ b/sys/kern/subr_sbuf.c @@ -266,6 +266,10 @@ sbuf_uionew(struct sbuf *s, struct uio *uio, int *error) KASSERT(error != NULL, ("%s called with NULL error pointer", __func__)); + if (uio->uio_resid >= INT_MAX || uio->uio_resid < SBUF_MINSIZE - 1) { + *error = EINVAL; + return (NULL); + } s = sbuf_new(s, NULL, uio->uio_resid + 1, 0); if (s == NULL) { *error = ENOMEM; ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: f6b3c49256ed - stable/13 - amd64: clear debug registers on execing 32bit native binary
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f6b3c49256edd4f402393a1d0276bd3ff3b5d458 commit f6b3c49256edd4f402393a1d0276bd3ff3b5d458 Author: Konstantin Belousov AuthorDate: 2021-04-09 23:23:54 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:08 + amd64: clear debug registers on execing 32bit native binary (cherry picked from commit d50adfec9ee73e88e8d365525f1acef2c1db798a) --- sys/amd64/ia32/ia32_signal.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/amd64/ia32/ia32_signal.c b/sys/amd64/ia32/ia32_signal.c index 51dd1f38090f..c114cf1d240a 100644 --- a/sys/amd64/ia32/ia32_signal.c +++ b/sys/amd64/ia32/ia32_signal.c @@ -968,6 +968,8 @@ ia32_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack) regs->tf_gs = _ugssel; regs->tf_flags = TF_HASSEGS; + x86_clear_dbregs(pcb); + fpstate_drop(td); /* Return via doreti so that we can change to a different %cs */ ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: ed6b9e2ff0b3 - stable/13 - ptrace: remove dead call to FIX_SSTEP()
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ed6b9e2ff0b31b748c9433121649ded190d734a8 commit ed6b9e2ff0b31b748c9433121649ded190d734a8 Author: Konstantin Belousov AuthorDate: 2021-04-11 09:02:34 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:08 + ptrace: remove dead call to FIX_SSTEP() (cherry picked from commit 9d7e450b64f1e605c718fba0f357d49541c8147b) --- sys/kern/sys_process.c | 7 --- 1 file changed, 7 deletions(-) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 3a184f1d678f..a63cf9a80834 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -784,13 +784,6 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) /* Keep this process around until we finish this request. */ _PHOLD(p); -#ifdef FIX_SSTEP - /* -* Single step fixup ala procfs -*/ - FIX_SSTEP(td2); -#endif - /* * Actually do the requests */ ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 3cb7188a310c - stable/13 - Add helper for kqueue timers callout scheduling
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3cb7188a310c36359cf0493a2abf58df5d8bfec6 commit 3cb7188a310c36359cf0493a2abf58df5d8bfec6 Author: Konstantin Belousov AuthorDate: 2021-03-05 23:31:20 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:09 + Add helper for kqueue timers callout scheduling (cherry picked from commit 533e5057ed2503013643bf8450588e4aa58c2b7e) --- sys/kern/kern_event.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 5185723b8d10..5e9f1fc35dfe 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -676,10 +676,19 @@ timer2sbintime(int64_t data, int flags) struct kq_timer_cb_data { struct callout c; + struct knote *kn; + int cpuid; sbintime_t next;/* next timer event fires at */ sbintime_t to; /* precalculated timer period, 0 for abs */ }; +static void +kqtimer_sched_callout(struct kq_timer_cb_data *kc) +{ + callout_reset_sbt_on(&kc->c, kc->next, 0, filt_timerexpire, kc->kn, + kc->cpuid, C_ABSOLUTE); +} + static void filt_timerexpire(void *knx) { @@ -696,8 +705,7 @@ filt_timerexpire(void *knx) if (kc->to == 0) return; kc->next += kc->to; - callout_reset_sbt_on(&kc->c, kc->next, 0, filt_timerexpire, kn, - PCPU_GET(cpuid), C_ABSOLUTE); + kqtimer_sched_callout(kc); } /* @@ -753,6 +761,8 @@ filt_timerattach(struct knote *kn) kn->kn_flags |= EV_CLEAR; /* automatically set */ kn->kn_status &= ~KN_DETACHED; /* knlist_add clears it */ kn->kn_ptr.p_v = kc = malloc(sizeof(*kc), M_KQUEUE, M_WAITOK); + kc->kn = kn; + kc->cpuid = PCPU_GET(cpuid); callout_init(&kc->c, 1); filt_timerstart(kn, to); @@ -772,8 +782,7 @@ filt_timerstart(struct knote *kn, sbintime_t to) kc->next = to + sbinuptime(); kc->to = to; } - callout_reset_sbt_on(&kc->c, kc->next, 0, filt_timerexpire, kn, - PCPU_GET(cpuid), C_ABSOLUTE); + kqtimer_sched_callout(kc); } static void ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: a753730ca0aa - stable/13 - Stop arming kqueue timers on knote owner suspend or terminate
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a753730ca0aae7b540ff8fbb24197b4e159b40fa commit a753730ca0aae7b540ff8fbb24197b4e159b40fa Author: Konstantin Belousov AuthorDate: 2021-03-05 23:29:08 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:09 + Stop arming kqueue timers on knote owner suspend or terminate (cherry picked from commit 2fd1ffefaa4d2cd99a19f866a949cb2cd58ef998) --- sys/kern/init_main.c | 1 + sys/kern/kern_event.c | 60 -- sys/kern/kern_fork.c | 1 + sys/kern/kern_sig.c| 1 + sys/kern/sys_process.c | 1 + sys/sys/proc.h | 4 6 files changed, 61 insertions(+), 7 deletions(-) diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 5eb8186c23ca..e46f8f74c83d 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -524,6 +524,7 @@ proc0_init(void *dummy __unused) callout_init_mtx(&p->p_itcallout, &p->p_mtx, 0); callout_init_mtx(&p->p_limco, &p->p_mtx, 0); callout_init(&td->td_slpcallout, 1); + TAILQ_INIT(&p->p_kqtim_stop); /* Create credentials. */ newcred = crget(); diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 5e9f1fc35dfe..31b091e20984 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -676,8 +676,10 @@ timer2sbintime(int64_t data, int flags) struct kq_timer_cb_data { struct callout c; + struct proc *p; struct knote *kn; int cpuid; + TAILQ_ENTRY(kq_timer_cb_data) link; sbintime_t next;/* next timer event fires at */ sbintime_t to; /* precalculated timer period, 0 for abs */ }; @@ -689,22 +691,65 @@ kqtimer_sched_callout(struct kq_timer_cb_data *kc) kc->cpuid, C_ABSOLUTE); } +void +kqtimer_proc_continue(struct proc *p) +{ + struct kq_timer_cb_data *kc, *kc1; + struct bintime bt; + sbintime_t now; + + PROC_LOCK_ASSERT(p, MA_OWNED); + + getboottimebin(&bt); + now = bttosbt(bt); + + TAILQ_FOREACH_SAFE(kc, &p->p_kqtim_stop, link, kc1) { + TAILQ_REMOVE(&p->p_kqtim_stop, kc, link); + if (kc->next <= now) + filt_timerexpire(kc->kn); + else + kqtimer_sched_callout(kc); + } +} + static void filt_timerexpire(void *knx) { struct knote *kn; struct kq_timer_cb_data *kc; + struct proc *p; + sbintime_t now; kn = knx; - kn->kn_data++; - KNOTE_ACTIVATE(kn, 0); /* XXX - handle locking */ - - if ((kn->kn_flags & EV_ONESHOT) != 0) - return; kc = kn->kn_ptr.p_v; - if (kc->to == 0) + + if ((kn->kn_flags & EV_ONESHOT) != 0 || kc->to == 0) { + kn->kn_data++; + KNOTE_ACTIVATE(kn, 0); return; - kc->next += kc->to; + } + + for (now = sbinuptime(); kc->next <= now; kc->next += kc->to) + kn->kn_data++; + KNOTE_ACTIVATE(kn, 0); /* XXX - handle locking */ + + /* +* Initial check for stopped kc->p is racy. It is fine to +* miss the set of the stop flags, at worst we would schedule +* one more callout. On the other hand, it is not fine to not +* schedule when we we missed clearing of the flags, we +* recheck them under the lock and observe consistent state. +*/ + p = kc->p; + if (P_SHOULDSTOP(p) || P_KILLED(p)) { + PROC_LOCK(p); + if (P_SHOULDSTOP(p) || P_KILLED(p)) { + TAILQ_INSERT_TAIL(&p->p_kqtim_stop, kc, link); + PROC_UNLOCK(p); + return; + } + PROC_UNLOCK(p); + } kqtimer_sched_callout(kc); } @@ -762,6 +807,7 @@ filt_timerattach(struct knote *kn) kn->kn_status &= ~KN_DETACHED; /* knlist_add clears it */ kn->kn_ptr.p_v = kc = malloc(sizeof(*kc), M_KQUEUE, M_WAITOK); kc->kn = kn; + kc->p = curproc; kc->cpuid = PCPU_GET(cpuid); callout_init(&kc->c, 1); filt_timerstart(kn, to); diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 3da8205d8ab0..2a092b192878 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -606,6 +606,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct proc *p2, struct thread * LIST_INIT(&p2->p_orphans); callout_init_mtx(&p2->p_itcallout, &p2->p_mtx, 0); + TAILQ_INIT(&p2->p_kqtim_stop); /* * This begins the section where we must prevent the parent diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 212b4997dd5e..46b520030dcd 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2424,6 +2424,7 @@ runfast: PROC_SUNLOCK(p); out_cont: itimer_proc_continue(p); + kqtimer_proc_continue
git: 73a642c47955 - stable/13 - Add AT_EMPTY_PATH for several *at(2) syscalls
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=73a642c479550ea46b56d1f25cc32a99f917b891 commit 73a642c479550ea46b56d1f25cc32a99f917b891 Author: Konstantin Belousov AuthorDate: 2021-03-07 14:29:09 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:10 + Add AT_EMPTY_PATH for several *at(2) syscalls (cherry picked from commit 509124b62616f73dcdc42263ee109392dafafd99) --- lib/libc/sys/access.2| 13 +- lib/libc/sys/chflags.2 | 13 +- lib/libc/sys/chmod.2 | 13 +- lib/libc/sys/chown.2 | 13 +- lib/libc/sys/link.2 | 11 - lib/libc/sys/stat.2 | 13 +- lib/libc/sys/utimensat.2 | 13 +- sys/kern/vfs_lookup.c| 63 ++-- sys/kern/vfs_syscalls.c | 63 +--- sys/sys/fcntl.h | 1 + sys/sys/namei.h | 3 +++ 11 files changed, 185 insertions(+), 34 deletions(-) diff --git a/lib/libc/sys/access.2 b/lib/libc/sys/access.2 index 13bfd7e5a88a..12af63385780 100644 --- a/lib/libc/sys/access.2 +++ b/lib/libc/sys/access.2 @@ -28,7 +28,7 @@ .\" @(#)access.2 8.2 (Berkeley) 4/1/94 .\" $FreeBSD$ .\" -.Dd February 23, 2021 +.Dd March 30, 2021 .Dt ACCESS 2 .Os .Sh NAME @@ -129,6 +129,17 @@ See the description of the flag in the .Xr open 2 manual page. +.It Dv AT_EMPTY_PATH +If the +.Fa path +argument is an empty string, operate on the file or directory +referenced by the descriptor +.Fa fd . +If +.Fa fd +is equal to +.Dv AT_FDCWD , +operate on the current working directory. .El .Pp Even if a process's real or effective user has appropriate privileges diff --git a/lib/libc/sys/chflags.2 b/lib/libc/sys/chflags.2 index a44713904599..f8dfd59c39d3 100644 --- a/lib/libc/sys/chflags.2 +++ b/lib/libc/sys/chflags.2 @@ -28,7 +28,7 @@ .\"@(#)chflags.2 8.3 (Berkeley) 5/2/95 .\" $FreeBSD$ .\" -.Dd February 23, 2021 +.Dd March 30, 2021 .Dt CHFLAGS 2 .Os .Sh NAME @@ -103,6 +103,17 @@ See the description of the flag in the .Xr open 2 manual page. +.It Dv AT_EMPTY_PATH +If the +.Fa path +argument is an empty string, operate on the file or directory +referenced by the descriptor +.Fa fd . +If +.Fa fd +is equal to +.Dv AT_FDCWD , +operate on the current working directory. .El .Pp If diff --git a/lib/libc/sys/chmod.2 b/lib/libc/sys/chmod.2 index 0127a5b629e4..44a1b18718f1 100644 --- a/lib/libc/sys/chmod.2 +++ b/lib/libc/sys/chmod.2 @@ -28,7 +28,7 @@ .\" @(#)chmod.28.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd February 23, 2021 +.Dd March 30, 2021 .Dt CHMOD 2 .Os .Sh NAME @@ -110,6 +110,17 @@ See the description of the flag in the .Xr open 2 manual page. +.It Dv AT_EMPTY_PATH +If the +.Fa path +argument is an empty string, operate on the file or directory +referenced by the descriptor +.Fa fd . +If +.Fa fd +is equal to +.Dv AT_FDCWD , +operate on the current working directory. .El .Pp If diff --git a/lib/libc/sys/chown.2 b/lib/libc/sys/chown.2 index 4c45ce9174bb..467ff8a87e55 100644 --- a/lib/libc/sys/chown.2 +++ b/lib/libc/sys/chown.2 @@ -28,7 +28,7 @@ .\" @(#)chown.28.4 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd February 23, 2021 +.Dd March 30, 2021 .Dt CHOWN 2 .Os .Sh NAME @@ -127,6 +127,17 @@ See the description of the flag in the .Xr open 2 manual page. +.It Dv AT_EMPTY_PATH +If the +.Fa path +argument is an empty string, operate on the file or directory +referenced by the descriptor +.Fa fd . +If +.Fa fd +is equal to +.Dv AT_FDCWD , +operate on the current working directory. .El .Pp If diff --git a/lib/libc/sys/link.2 b/lib/libc/sys/link.2 index bcf03f17f3bb..37225f9571d0 100644 --- a/lib/libc/sys/link.2 +++ b/lib/libc/sys/link.2 @@ -28,7 +28,7 @@ .\" @(#)link.2 8.3 (Berkeley) 1/12/94 .\" $FreeBSD$ .\" -.Dd February 23, 2021 +.Dd March 30, 2021 .Dt LINK 2 .Os .Sh NAME @@ -124,6 +124,15 @@ See the description of the flag in the .Xr open 2 manual page. +.It Dv AT_EMPTY_PATH +If the +.Fa path2 +argument is an empty string, link the file referenced by the descriptor +.Fa fd2 . +The operation requires that the calling process has the +.Dv PRIV_VFS_FHOPEN +privilege, effectively being executed with effective user +.Dv root . .El .Pp If diff --git a/lib/libc/sys/stat.2 b/lib/libc/sys/stat.2 index 0ed70620af63..55221d05a60e 100644 --- a/lib/libc/sys/stat.2 +++ b/lib/libc/sys/stat.2 @@ -28,7 +28,7 @@ .\" @(#)stat.2 8.4 (Berkeley) 5/1/95 .\" $FreeBSD$ .\" -.Dd February 23, 2021 +.Dd March 30, 2021 .Dt STAT 2 .Os .Sh NAME @@ -111,6 +111,17 @@ See the description of the flag in the .Xr open 2 manual page. +.It Dv AT_EMPTY_PATH +If the +.Fa path +argument is an empty string, operate on the file or directory +referenced by the descriptor +.Fa fd . +If +.Fa fd +is equal to +.Dv AT_FDCWD , +operate on the current working directory. .El .Pp If diff --git a/lib/libc/sys/utimensat.2 b/
git: 9418bb8a1984 - stable/13 - AT_RESOLVE_BENEATH is bsd-specific
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9418bb8a198455c6b7a478a5e1cdd997bbf55621 commit 9418bb8a198455c6b7a478a5e1cdd997bbf55621 Author: Konstantin Belousov AuthorDate: 2021-03-11 15:07:02 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:10 + AT_RESOLVE_BENEATH is bsd-specific (cherry picked from commit d51b4b0aac43d9d25f7eb3f17b2d3034a5c851d8) --- sys/sys/fcntl.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h index 8db9b1fe80b9..bc2011c31e88 100644 --- a/sys/sys/fcntl.h +++ b/sys/sys/fcntl.h @@ -219,10 +219,12 @@ typedef __pid_t pid_t; #defineAT_SYMLINK_NOFOLLOW 0x0200 /* Do not follow symbolic links */ #defineAT_SYMLINK_FOLLOW 0x0400 /* Follow symbolic link */ #defineAT_REMOVEDIR0x0800 /* Remove directory instead of file */ +#endif /* __POSIX_VISIBLE >= 200809 */ +#if __BSD_VISIBLE /* #define AT_UNUSED1 0x1000 *//* Was AT_BENEATH */ #defineAT_RESOLVE_BENEATH 0x2000 /* Do not allow name resolution to walk out of dirfd */ -#endif +#endif /* __BSD_VISIBLE */ /* * Constants used for fcntl(2) ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 7f4d5d3cb4ef - stable/13 - nfs client: depend on xdr
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7f4d5d3cb4ef368f7b3e022ac72d3f9b239b552b commit 7f4d5d3cb4ef368f7b3e022ac72d3f9b239b552b Author: Konstantin Belousov AuthorDate: 2021-04-13 11:47:20 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:09 + nfs client: depend on xdr (cherry picked from commit 8cca7b7f28feaf0c5e2dfedb985ae334a4013ef6) --- sys/fs/nfsclient/nfs_clvfsops.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index 365b1c387cc2..08a25c6fe632 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -155,6 +155,7 @@ MODULE_VERSION(nfs, 1); MODULE_DEPEND(nfs, nfscommon, 1, 1, 1); MODULE_DEPEND(nfs, krpc, 1, 1, 1); MODULE_DEPEND(nfs, nfssvc, 1, 1, 1); +MODULE_DEPEND(nfs, xdr, 1, 1, 1); /* * This structure is now defined in sys/nfs/nfs_diskless.c so that it ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: b82fb18ee28f - stable/13 - vfs_vnops.c: Make vn_statfile() non-static
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b82fb18ee28f1e23c5fa6ebb3a420b2d43f0fa42 commit b82fb18ee28f1e23c5fa6ebb3a420b2d43f0fa42 Author: Konstantin Belousov AuthorDate: 2021-03-18 10:41:07 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:10 + vfs_vnops.c: Make vn_statfile() non-static (cherry picked from commit 437c241d0c78f77a9d9e54494a353db01ce1a3de) --- sys/kern/vfs_vnops.c | 3 +-- sys/sys/file.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 44cbf1a7893b..98f37d26ea8c 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -102,7 +102,6 @@ static fo_truncate_tvn_truncate; static fo_ioctl_t vn_ioctl; static fo_poll_t vn_poll; static fo_kqfilter_t vn_kqfilter; -static fo_stat_t vn_statfile; static fo_close_t vn_closefile; static fo_mmap_t vn_mmap; static fo_fallocate_t vn_fallocate; @@ -1616,7 +1615,7 @@ vn_truncate_locked(struct vnode *vp, off_t length, bool sync, /* * File table vnode stat routine. */ -static int +int vn_statfile(struct file *fp, struct stat *sb, struct ucred *active_cred, struct thread *td) { diff --git a/sys/sys/file.h b/sys/sys/file.h index c42ab09a7e03..c4fc70f517a4 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -262,7 +262,7 @@ fo_kqfilter_t invfo_kqfilter; fo_chmod_t invfo_chmod; fo_chown_t invfo_chown; fo_sendfile_t invfo_sendfile; - +fo_stat_t vn_statfile; fo_sendfile_t vn_sendfile; fo_seek_t vn_seek; fo_fill_kinfo_tvn_fill_kinfo; ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: b0c1b3827e2f - stable/13 - open(2): Implement O_PATH
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b0c1b3827e2f88bbde26d461417d8c25f9645d12 commit b0c1b3827e2f88bbde26d461417d8c25f9645d12 Author: Konstantin Belousov AuthorDate: 2021-03-18 10:41:47 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:10 + open(2): Implement O_PATH (cherry picked from commit 8d9ed174f3afba5f114742447e622fc1173d4774) --- lib/libc/sys/open.2 | 41 - sys/kern/kern_descrip.c | 46 + sys/kern/vfs_aio.c | 5 sys/kern/vfs_lookup.c | 6 +++-- sys/kern/vfs_syscalls.c | 61 ++--- sys/kern/vfs_vnops.c| 34 --- sys/sys/fcntl.h | 8 --- sys/sys/file.h | 1 + sys/sys/filedesc.h | 2 ++ 9 files changed, 168 insertions(+), 36 deletions(-) diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2 index e24c823d039a..f9c54bfc7581 100644 --- a/lib/libc/sys/open.2 +++ b/lib/libc/sys/open.2 @@ -28,7 +28,7 @@ .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" $FreeBSD$ .\" -.Dd February 23, 2021 +.Dd March 18, 2021 .Dt OPEN 2 .Os .Sh NAME @@ -168,6 +168,7 @@ O_DIRECTORY error if file is not a directory O_CLOEXEC set FD_CLOEXEC upon open O_VERIFY verify the contents of the file O_RESOLVE_BENEATH path resolution must not cross the fd directory +O_PATH record only the target path in the opened descriptor .Ed .Pp Opening a file with @@ -316,6 +317,44 @@ The primary use for this descriptor will be as the lookup descriptor for the .Fn *at family of functions. .Pp +.Dv O_PATH +returns a file descriptor that can be used as a directory file descriptor for +.Xr openat 2 +and other system calls taking a file descriptor argument, like +.Xr fstatat 2 +and others. +The other functionality of the returned file descriptor is limited to +the descriptor-level operations. +It can be used for +.Bl -tag -width SCM_RIGHTS -offset indent -compact +.It Xr fcntl 2 +but advisory locking is not allowed +.It Xr dup 2 +.It Xr close 2 +.It Xr fstat 2 +.It Xr fexecve 2 +requires that +.Dv O_EXEC +was also specified at open time +.It Dv SCM_RIGHTS +can be passed over a +.Xr unix 4 +socket using a +.Dv SCM_RIGHTS +message +.El +But operations like +.Xr read 2 , +.Xr ftruncate 2 , +and any other that operate on file and not on file descriptor (except +.Xr fstat 2 ), +are not allowed. +See also the description of +.Dv AT_EMPTY_PATH +flag for +.Xr fstatat 2 +and related syscalls. +.Pp If successful, .Fn open returns a non-negative integer, termed a file descriptor. diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 7a43fbb2eb80..81af58fbddd1 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -546,6 +547,11 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) error = fget_fcntl(td, fd, &cap_fcntl_rights, F_SETFL, &fp); if (error != 0) break; + if (fp->f_ops == &path_fileops) { + fdrop(fp, td); + error = EBADF; + break; + } do { tmp = flg = fp->f_flag; tmp &= ~FCNTLFLAGS; @@ -610,7 +616,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp); if (error != 0) break; - if (fp->f_type != DTYPE_VNODE) { + if (fp->f_type != DTYPE_VNODE || fp->f_ops == &path_fileops) { error = EBADF; fdrop(fp, td); break; @@ -715,7 +721,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp); if (error != 0) break; - if (fp->f_type != DTYPE_VNODE) { + if (fp->f_type != DTYPE_VNODE || fp->f_ops == &path_fileops) { error = EBADF; fdrop(fp, td); break; @@ -771,7 +777,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) error = fget_unlocked(fdp, fd, &cap_no_rights, &fp); if (error != 0) break; - if (fp->f_type != DTYPE_VNODE) { + if (fp->f_type != DTYPE_VNODE || fp->f_ops == &path_fileops) { fdrop(fp, td); error = EBADF; break; @@ -3544,7 +3550,7 @@ sys_flock(struct thread *td, struct flock_args *uap) error = fget(td, uap->fd, &cap_flock_rights, &fp); if (error !=
git: 131336da4072 - stable/13 - pseudofs: limit writes to 1M
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=131336da407264e9876a69291a028b91e804df16 commit 131336da407264e9876a69291a028b91e804df16 Author: Konstantin Belousov AuthorDate: 2021-04-13 19:48:44 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:09 + pseudofs: limit writes to 1M (cherry picked from commit 5edf7227ec339f651c7328e63df323f6ef10345f) --- sys/fs/pseudofs/pseudofs_vnops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/fs/pseudofs/pseudofs_vnops.c b/sys/fs/pseudofs/pseudofs_vnops.c index e386ceba71f8..29bb1544e7ad 100644 --- a/sys/fs/pseudofs/pseudofs_vnops.c +++ b/sys/fs/pseudofs/pseudofs_vnops.c @@ -1102,6 +1102,9 @@ pfs_write(struct vop_write_args *va) if (pn->pn_fill == NULL) PFS_RETURN (EIO); + if (uio->uio_resid > PFS_MAXBUFSIZ) + PFS_RETURN (EIO); + /* * This is necessary because either process' privileges may * have changed since the open() call. ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: f1d1021fde37 - stable/13 - O_PATH: allow vnode kevent filter on such files
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f1d1021fde37a4709162a1acbc28427206f66acc commit f1d1021fde37a4709162a1acbc28427206f66acc Author: Konstantin Belousov AuthorDate: 2021-04-07 18:31:48 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:10 + O_PATH: allow vnode kevent filter on such files (cherry picked from commit bbf7a4e878ed6828d13c7029c128a7e60dc25391) --- lib/libc/sys/open.2 | 3 +++ sys/kern/kern_descrip.c | 2 +- sys/kern/vfs_syscalls.c | 3 ++- sys/kern/vfs_vnops.c| 14 +- sys/sys/fcntl.h | 2 ++ sys/sys/file.h | 1 + 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2 index 06a877e34460..a7806df69daf 100644 --- a/lib/libc/sys/open.2 +++ b/lib/libc/sys/open.2 @@ -342,6 +342,9 @@ can be passed over a socket using a .Dv SCM_RIGHTS message +.It Xr kqueue 2 +using for +.Dv EVFILT_VNODE .El But operations like .Xr read 2 , diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index a28e94634326..30ac40ffe296 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -4988,7 +4988,7 @@ struct fileops path_fileops = { .fo_truncate = badfo_truncate, .fo_ioctl = badfo_ioctl, .fo_poll = path_poll, - .fo_kqfilter = badfo_kqfilter, + .fo_kqfilter = vn_kqfilter_opath, .fo_stat = vn_statfile, .fo_close = path_close, .fo_chmod = badfo_chmod, diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 9130843f6761..43104a472b5b 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1192,7 +1192,8 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, KASSERT(vp->v_type != VFIFO || (flags & O_PATH) != 0, ("Unexpected fifo fp %p vp %p", fp, vp)); if ((flags & O_PATH) != 0) { - finit_vnode(fp, flags, NULL, &path_fileops); + finit(fp, (flags & FMASK) | (fp->f_flag & FKQALLOWED), + DTYPE_VNODE, NULL, &path_fileops); vhold(vp); vunref(vp); } else { diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index bb9ee2cceb79..9da35721def4 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -426,8 +426,12 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred, if (error != 0) return (error); } - if ((fmode & O_PATH) != 0) + if ((fmode & O_PATH) != 0) { + error = VOP_ACCESS(vp, VREAD, cred, td); + if (error == 0) + fp->f_flag |= FKQALLOWED; return (0); + } if (vp->v_type == VFIFO && VOP_ISLOCKED(vp) != LK_EXCLUSIVE) vn_lock(vp, LK_UPGRADE | LK_RETRY); @@ -2139,6 +2143,14 @@ vn_kqfilter(struct file *fp, struct knote *kn) return (VOP_KQFILTER(fp->f_vnode, kn)); } +int +vn_kqfilter_opath(struct file *fp, struct knote *kn) +{ + if ((fp->f_flag & FKQALLOWED) == 0) + return (EBADF); + return (vn_kqfilter(fp, kn)); +} + /* * Simplified in-kernel wrapper calls for extended attribute access. * Both calls pass in a NULL credential, authorizing as "kernel" access. diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h index c328abaa02af..58d46ae26338 100644 --- a/sys/sys/fcntl.h +++ b/sys/sys/fcntl.h @@ -153,6 +153,8 @@ typedef __pid_t pid_t; #defineFREVOKE O_VERIFY /* Only for fo_close() from half-succeeded open */ #defineFOPENFAILED O_TTY_INIT +/* Only for O_PATH files which passed ACCESS FREAD check on open */ +#defineFKQALLOWED O_RESOLVE_BENEATH /* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */ #defineFFLAGS(oflags) ((oflags) & O_EXEC ? (oflags) : (oflags) + 1) diff --git a/sys/sys/file.h b/sys/sys/file.h index 9237ee5ceb9d..b16e23bdfbcf 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -267,6 +267,7 @@ fo_stat_t vn_statfile; fo_sendfile_t vn_sendfile; fo_seek_t vn_seek; fo_fill_kinfo_tvn_fill_kinfo; +fo_kqfilter_t vn_kqfilter_opath; int vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif); void finit(struct file *, u_int, short, void *, struct fileops *); ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 6d608fc5ab9c - stable/13 - Stop arming periodic process timers on suspend or terminate
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6d608fc5ab9c6c8eedc85d739b4e58b21c16d19d commit 6d608fc5ab9c6c8eedc85d739b4e58b21c16d19d Author: Konstantin Belousov AuthorDate: 2021-03-05 21:19:35 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:09 + Stop arming periodic process timers on suspend or terminate (cherry picked from commit dc47fdf1319f18be1aadbcdef17c721a83415d84) --- sys/kern/kern_sig.c| 6 -- sys/kern/kern_time.c | 38 -- sys/kern/sys_process.c | 1 + sys/sys/proc.h | 2 ++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 3d55405d3151..212b4997dd5e 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2322,7 +2322,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) thread_unsuspend(p); PROC_SUNLOCK(p); sigqueue_delete(sigqueue, sig); - goto out; + goto out_cont; } if (action == SIG_CATCH) { /* @@ -2337,7 +2337,7 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) */ thread_unsuspend(p); PROC_SUNLOCK(p); - goto out; + goto out_cont; } if (prop & SIGPROP_STOP) { @@ -2422,6 +2422,8 @@ runfast: PROC_SLOCK(p); thread_unsuspend(p); PROC_SUNLOCK(p); +out_cont: + itimer_proc_continue(p); out: /* If we jump here, proc slock should not be owned. */ PROC_SLOCK_ASSERT(p, MA_NOTOWNED); diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 44f6b4ad07f2..3010ee326105 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -881,6 +881,33 @@ kern_setitimer(struct thread *td, u_int which, struct itimerval *aitv, return (0); } +static void +realitexpire_reset_callout(struct proc *p, sbintime_t *isbtp) +{ + sbintime_t prec; + + prec = isbtp == NULL ? tvtosbt(p->p_realtimer.it_interval) : *isbtp; + callout_reset_sbt(&p->p_itcallout, tvtosbt(p->p_realtimer.it_value), + prec >> tc_precexp, realitexpire, p, C_ABSOLUTE); +} + +void +itimer_proc_continue(struct proc *p) +{ + struct timeval ctv; + + PROC_LOCK_ASSERT(p, MA_OWNED); + + if ((p->p_flag2 & P2_ITSTOPPED) != 0) { + p->p_flag2 &= ~P2_ITSTOPPED; + microuptime(&ctv); + if (timevalcmp(&p->p_realtimer.it_value, &ctv, >=)) + realitexpire(p); + else + realitexpire_reset_callout(p, NULL); + } +} + /* * Real interval timer expired: * send process whose timer expired an alarm signal. @@ -908,6 +935,7 @@ realitexpire(void *arg) wakeup(&p->p_itcallout); return; } + isbt = tvtosbt(p->p_realtimer.it_interval); if (isbt >= sbt_timethreshold) getmicrouptime(&ctv); @@ -917,8 +945,14 @@ realitexpire(void *arg) timevaladd(&p->p_realtimer.it_value, &p->p_realtimer.it_interval); } while (timevalcmp(&p->p_realtimer.it_value, &ctv, <=)); - callout_reset_sbt(&p->p_itcallout, tvtosbt(p->p_realtimer.it_value), - isbt >> tc_precexp, realitexpire, p, C_ABSOLUTE); + + if (P_SHOULDSTOP(p) || P_KILLED(p)) { + p->p_flag2 |= P2_ITSTOPPED; + return; + } + + p->p_flag2 &= ~P2_ITSTOPPED; + realitexpire_reset_callout(p, &isbt); } /* diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 0b1305f49a93..f00aa57c95d2 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1091,6 +1091,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) p->p_flag &= ~(P_STOPPED_TRACE | P_STOPPED_SIG | P_WAITED); thread_unsuspend(p); PROC_SUNLOCK(p); + itimer_proc_continue(p); break; case PT_WRITE_I: diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 783c3896298c..c0cf0be7e7d7 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -813,6 +813,7 @@ struct proc { MAP_STACK */ #defineP2_STKGAP_DISABLE_EXEC 0x1000 /* Stack gap disabled after exec */ +#defineP2_ITSTOPPED0x2000 /* Flags protected by proctree_lock, kept in p_treeflags. */ #defineP_TREE_ORPHANED 0x0001 /* Reparented, on orphan list */ @@ -1079,6 +1080,7 @@ void fork_exit(void (*)(
git: b5e557fda373 - stable/13 - O_PATH: Allow to open symlink
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b5e557fda3739992ff722c4eaeb535da31aa7ab9 commit b5e557fda3739992ff722c4eaeb535da31aa7ab9 Author: Konstantin Belousov AuthorDate: 2021-04-07 03:23:25 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:10 + O_PATH: Allow to open symlink (cherry picked from commit f9b923af34a6749c7703b957742f33cc02a485a2) --- sys/kern/vfs_vnops.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 6339295b0556..bb9ee2cceb79 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -385,8 +385,10 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred, accmode_t accmode; int error; - if (vp->v_type == VLNK) - return (EMLINK); + if (vp->v_type == VLNK) { + if ((fmode & O_PATH) == 0 || (fmode & FEXEC) != 0) + return (EMLINK); + } if (vp->v_type == VSOCK) return (EOPNOTSUPP); if (vp->v_type != VDIR && fmode & O_DIRECTORY) ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: bd881b1f1dc2 - stable/13 - linkat(2): check NIRES_EMPTYPATH on the first fd arg
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=bd881b1f1dc2e80b9ef3ab13861f64dc61016b62 commit bd881b1f1dc2e80b9ef3ab13861f64dc61016b62 Author: Konstantin Belousov AuthorDate: 2021-04-19 13:35:25 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:10 + linkat(2): check NIRES_EMPTYPATH on the first fd arg (cherry picked from commit 578c26f31c0c90c9e6b2f7125a8539c307a51dff) --- sys/kern/vfs_syscalls.c | 24 +++- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 43104a472b5b..26a8d31e4456 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1575,6 +1575,13 @@ kern_linkat(struct thread *td, int fd1, int fd2, const char *path1, if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); + if ((nd.ni_resflags & NIRES_EMPTYPATH) != 0) { + error = priv_check(td, PRIV_VFS_FHOPEN); + if (error != 0) { + vrele(nd.ni_vp); + return (error); + } + } error = kern_linkat_vp(td, nd.ni_vp, fd2, path2, segflag); } while (error == EAGAIN || error == ERELOOKUP); return (error); @@ -1596,23 +1603,6 @@ kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, const char *path, LOCKPARENT | SAVENAME | AUDITVNODE2 | NOCACHE, segflag, path, fd, &cap_linkat_target_rights, td); if ((error = namei(&nd)) == 0) { - if ((nd.ni_resflags & NIRES_EMPTYPATH) != 0) { - error = priv_check(td, PRIV_VFS_FHOPEN); - if (error != 0) { - NDFREE(&nd, NDF_ONLY_PNBUF); - if (nd.ni_vp != NULL) { - if (nd.ni_dvp == nd.ni_vp) - vrele(nd.ni_dvp); - else - vput(nd.ni_dvp); - vrele(nd.ni_vp); - } else { - vput(nd.ni_dvp); - } - vrele(vp); - return (error); - } - } if (nd.ni_vp != NULL) { NDFREE(&nd, NDF_ONLY_PNBUF); if (nd.ni_dvp == nd.ni_vp) ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 057e390dadaf - stable/13 - Stop arming realtime posix process timers on suspend or terminate
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=057e390dadaf942bb2bfb66a2c3d68f79ff6506a commit 057e390dadaf942bb2bfb66a2c3d68f79ff6506a Author: Konstantin Belousov AuthorDate: 2021-03-11 08:16:51 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:09 + Stop arming realtime posix process timers on suspend or terminate (cherry picked from commit 4d27d8d2f3b8ae4ef3efc86b220c7ff2dbdbac5a) --- sys/kern/kern_time.c | 48 +++- sys/sys/timers.h | 1 + 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 3010ee326105..d3b19111b0f3 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -895,6 +895,8 @@ void itimer_proc_continue(struct proc *p) { struct timeval ctv; + struct itimer *it; + int id; PROC_LOCK_ASSERT(p, MA_OWNED); @@ -906,6 +908,23 @@ itimer_proc_continue(struct proc *p) else realitexpire_reset_callout(p, NULL); } + + if (p->p_itimers != NULL) { + for (id = 3; id < TIMER_MAX; id++) { + it = p->p_itimers->its_timers[id]; + if (it == NULL) + continue; + if ((it->it_flags & ITF_PSTOPPED) != 0) { + ITIMER_LOCK(it); + if ((it->it_flags & ITF_PSTOPPED) != 0) { + it->it_flags &= ~ITF_PSTOPPED; + if ((it->it_flags & ITF_DELETING) == 0) + realtimer_expire(it); + } + ITIMER_UNLOCK(it); + } + } + } } /* @@ -1651,6 +1670,7 @@ realtimer_expire(void *arg) struct timespec cts, ts; struct timeval tv; struct itimer *it; + struct proc *p; uint64_t interval, now, overruns, value; it = (struct itimer *)arg; @@ -1689,10 +1709,15 @@ realtimer_expire(void *arg) timespecclear(&it->it_time.it_value); } if (timespecisset(&it->it_time.it_value)) { - timespecsub(&it->it_time.it_value, &cts, &ts); - TIMESPEC_TO_TIMEVAL(&tv, &ts); - callout_reset(&it->it_callout, tvtohz(&tv), - realtimer_expire, it); + p = it->it_proc; + if (P_SHOULDSTOP(p) || P_KILLED(p)) { + it->it_flags |= ITF_PSTOPPED; + } else { + timespecsub(&it->it_time.it_value, &cts, &ts); + TIMESPEC_TO_TIMEVAL(&tv, &ts); + callout_reset(&it->it_callout, tvtohz(&tv), + realtimer_expire, it); + } } itimer_enter(it); ITIMER_UNLOCK(it); @@ -1700,11 +1725,16 @@ realtimer_expire(void *arg) ITIMER_LOCK(it); itimer_leave(it); } else if (timespecisset(&it->it_time.it_value)) { - ts = it->it_time.it_value; - timespecsub(&ts, &cts, &ts); - TIMESPEC_TO_TIMEVAL(&tv, &ts); - callout_reset(&it->it_callout, tvtohz(&tv), realtimer_expire, - it); + p = it->it_proc; + if (P_SHOULDSTOP(p) || P_KILLED(p)) { + it->it_flags |= ITF_PSTOPPED; + } else { + ts = it->it_time.it_value; + timespecsub(&ts, &cts, &ts); + TIMESPEC_TO_TIMEVAL(&tv, &ts); + callout_reset(&it->it_callout, tvtohz(&tv), + realtimer_expire, it); + } } } diff --git a/sys/sys/timers.h b/sys/sys/timers.h index aa1912149452..5d6f0c95afa2 100644 --- a/sys/sys/timers.h +++ b/sys/sys/timers.h @@ -82,6 +82,7 @@ struct itimer { #defineITF_DELETING0x01 #defineITF_WANTED 0x02 +#defineITF_PSTOPPED0x04 #defineITCF_ONWORKLIST 0x01 ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 3df91ba10f31 - stable/13 - vn_open_vnode(): handle error when fp == NULL
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3df91ba10f31942067c55edd2f493daac19a81e4 commit 3df91ba10f31942067c55edd2f493daac19a81e4 Author: Konstantin Belousov AuthorDate: 2021-04-19 10:25:30 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:10 + vn_open_vnode(): handle error when fp == NULL PR: 255119 (cherry picked from commit 54f98c4dbf9b1203a4e3e1b13fd0738441226991) --- sys/kern/vfs_vnops.c | 32 +--- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 9da35721def4..f715c9828d04 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -451,16 +451,34 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred, /* * Error from advlock or VOP_ADD_WRITECOUNT() still requires * calling VOP_CLOSE() to pair with earlier VOP_OPEN(). -* Arrange for that by having fdrop() to use vn_closefile(). */ if (error != 0) { - fp->f_flag |= FOPENFAILED; - fp->f_vnode = vp; - if (fp->f_ops == &badfileops) { - fp->f_type = DTYPE_VNODE; - fp->f_ops = &vnops; + if (fp != NULL) { + /* +* Arrange the call by having fdrop() to use +* vn_closefile(). This is to satisfy +* filesystems like devfs or tmpfs, which +* override fo_close(). +*/ + fp->f_flag |= FOPENFAILED; + fp->f_vnode = vp; + if (fp->f_ops == &badfileops) { + fp->f_type = DTYPE_VNODE; + fp->f_ops = &vnops; + } + vref(vp); + } else { + /* +* If there is no fp, due to kernel-mode open, +* we can call VOP_CLOSE() now. +*/ + if (vp->v_type != VFIFO && (fmode & FWRITE) != 0 && + !MNT_EXTENDED_SHARED(vp->v_mount) && + VOP_ISLOCKED(vp) != LK_EXCLUSIVE) + vn_lock(vp, LK_UPGRADE | LK_RETRY); + (void)VOP_CLOSE(vp, fmode & (FREAD | FWRITE | FEXEC), + cred, td); } - vref(vp); } ASSERT_VOP_LOCKED(vp, "vn_open_vnode"); ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 1f3d09306bf5 - stable/13 - sysctl_handle_string: do not malloc when SYSCTL_IN cannot fault
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1f3d09306bf5d3572c0cda033a4c83603216c598 commit 1f3d09306bf5d3572c0cda033a4c83603216c598 Author: Konstantin Belousov AuthorDate: 2021-04-18 16:09:30 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:11 + sysctl_handle_string: do not malloc when SYSCTL_IN cannot fault (cherry picked from commit 4342ba184c15f3b8912e95f93fe313731963f065) --- sys/kern/kern_sysctl.c | 9 + 1 file changed, 9 insertions(+) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index ffb6ac196ba3..4bfe7073e5a3 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1785,6 +1785,15 @@ sysctl_handle_string(SYSCTL_HANDLER_ARGS) sx_xlock(&sysctlstringlock); ((char *)arg1)[0] = '\0'; sx_xunlock(&sysctlstringlock); + } else if (req->newfunc == sysctl_new_kernel) { + arg2 = req->newlen - req->newidx; + sx_xlock(&sysctlstringlock); + error = SYSCTL_IN(req, arg1, arg2); + if (error == 0) { + ((char *)arg1)[arg2] = '\0'; + req->newidx += arg2; + } + sx_xunlock(&sysctlstringlock); } else { arg2 = req->newlen - req->newidx; tmparg = malloc(arg2, M_SYSCTLTMP, M_WAITOK); ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 107bc3da39d3 - stable/13 - filt_timerexpire: avoid process lock recursion
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=107bc3da39d37bf81b1c9fd3d8b58452d4606404 commit 107bc3da39d37bf81b1c9fd3d8b58452d4606404 Author: Konstantin Belousov AuthorDate: 2021-04-13 14:25:11 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:09 + filt_timerexpire: avoid process lock recursion (cherry picked from commit 75c5cf7a720f5a73f17aff60adbc4a7b2fa86f84) --- sys/kern/kern_event.c | 22 +++--- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 31b091e20984..45d505fca757 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -161,6 +161,7 @@ static void filt_procdetach(struct knote *kn); static int filt_proc(struct knote *kn, long hint); static int filt_fileattach(struct knote *kn); static voidfilt_timerexpire(void *knx); +static voidfilt_timerexpire_l(struct knote *kn, bool proc_locked); static int filt_timerattach(struct knote *kn); static voidfilt_timerdetach(struct knote *kn); static voidfilt_timerstart(struct knote *kn, sbintime_t to); @@ -706,21 +707,19 @@ kqtimer_proc_continue(struct proc *p) TAILQ_FOREACH_SAFE(kc, &p->p_kqtim_stop, link, kc1) { TAILQ_REMOVE(&p->p_kqtim_stop, kc, link); if (kc->next <= now) - filt_timerexpire(kc->kn); + filt_timerexpire_l(kc->kn, true); else kqtimer_sched_callout(kc); } } static void -filt_timerexpire(void *knx) +filt_timerexpire_l(struct knote *kn, bool proc_locked) { - struct knote *kn; struct kq_timer_cb_data *kc; struct proc *p; sbintime_t now; - kn = knx; kc = kn->kn_ptr.p_v; if ((kn->kn_flags & EV_ONESHOT) != 0 || kc->to == 0) { @@ -742,17 +741,26 @@ filt_timerexpire(void *knx) */ p = kc->p; if (P_SHOULDSTOP(p) || P_KILLED(p)) { - PROC_LOCK(p); + if (!proc_locked) + PROC_LOCK(p); if (P_SHOULDSTOP(p) || P_KILLED(p)) { TAILQ_INSERT_TAIL(&p->p_kqtim_stop, kc, link); - PROC_UNLOCK(p); + if (!proc_locked) + PROC_UNLOCK(p); return; } - PROC_UNLOCK(p); + if (!proc_locked) + PROC_UNLOCK(p); } kqtimer_sched_callout(kc); } +static void +filt_timerexpire(void *knx) +{ + filt_timerexpire_l(knx, false); +} + /* * data contains amount of time to sleep */ ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 44a0bdad29d7 - stable/13 - sysctl vm.objects: report backing object and swap use
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=44a0bdad29d71e350ba752fc5414e17021485f6b commit 44a0bdad29d71e350ba752fc5414e17021485f6b Author: Konstantin Belousov AuthorDate: 2021-04-15 09:27:02 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:11 + sysctl vm.objects: report backing object and swap use (cherry picked from commit ecfbddf0cde3d4151217e3eb2d7c5388a423d397) --- sys/kern/kern_proc.c | 3 +++ sys/sys/user.h | 20 sys/vm/swap_pager.c | 23 +++ sys/vm/swap_pager.h | 1 + sys/vm/vm_object.c | 13 - 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index f8fed2573712..d2414df60d7a 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -2538,6 +2538,9 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, int flags) bzero(kve, sizeof(*kve)); obj = entry->object.vm_object; if (obj != NULL) { + if ((obj->flags & OBJ_ANON) != 0) + kve->kve_obj = (uintptr_t)obj; + for (tobj = obj; tobj != NULL; tobj = tobj->backing_object) { VM_OBJECT_RLOCK(tobj); diff --git a/sys/sys/user.h b/sys/sys/user.h index f882e7dcd699..14471c91572f 100644 --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -529,12 +529,17 @@ struct kinfo_vmentry { uint32_t kve_vn_rdev_freebsd11; /* Device id if device. */ uint16_t kve_vn_mode; /* File mode. */ uint16_t kve_status;/* Status flags. */ - uint64_t kve_vn_fsid; /* dev_t of vnode location */ + union { + uint64_t _kve_vn_fsid; /* dev_t of vnode location */ + uint64_t _kve_obj; /* handle of anon obj */ + } kve_type_spec; uint64_t kve_vn_rdev; /* Device id if device. */ int _kve_ispare[8];/* Space for more stuff. */ /* Truncated before copyout in sysctl */ char kve_path[PATH_MAX];/* Path to VM obj, if any. */ }; +#definekve_vn_fsid kve_type_spec._kve_vn_fsid +#definekve_obj kve_type_spec._kve_obj /* * The "vm.objects" sysctl provides a list of all VM objects in the system @@ -552,11 +557,18 @@ struct kinfo_vmobject { uint64_t kvo_resident; /* Number of resident pages. */ uint64_t kvo_active;/* Number of active pages. */ uint64_t kvo_inactive; /* Number of inactive pages. */ - uint64_t kvo_vn_fsid; - uint64_t _kvo_qspare[7]; - uint32_t _kvo_ispare[8]; + union { + uint64_t _kvo_vn_fsid; + uint64_t _kvo_backing_obj; /* Handle for the backing obj */ + } kvo_type_spec;/* Type-specific union */ + uint64_t kvo_me;/* Uniq handle for anon obj */ + uint64_t _kvo_qspare[6]; + uint32_t kvo_swapped; /* Number of swapped pages */ + uint32_t _kvo_ispare[7]; charkvo_path[PATH_MAX]; /* Pathname, if any. */ }; +#definekvo_vn_fsid kvo_type_spec._kvo_vn_fsid +#definekvo_backing_obj kvo_type_spec._kvo_backing_obj /* * The KERN_PROC_KSTACK sysctl allows a process to dump the kernel stacks of diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 3789a0217252..888df04741b4 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -1763,6 +1763,29 @@ swp_pager_force_dirty(vm_page_t m) vm_page_launder(m); } +u_long +swap_pager_swapped_pages(vm_object_t object) +{ + struct swblk *sb; + vm_pindex_t pi; + u_long res; + int i; + + VM_OBJECT_ASSERT_LOCKED(object); + if (object->type != OBJT_SWAP) + return (0); + + for (res = 0, pi = 0; (sb = SWAP_PCTRIE_LOOKUP_GE( + &object->un_pager.swp.swp_blks, pi)) != NULL; + pi = sb->p + SWAP_META_PAGES) { + for (i = 0; i < SWAP_META_PAGES; i++) { + if (sb->d[i] != SWAPBLK_NONE) + res++; + } + } + return (res); +} + /* * swap_pager_swapoff_object: * diff --git a/sys/vm/swap_pager.h b/sys/vm/swap_pager.h index 80dca93fbf85..59ca2cc2cfdb 100644 --- a/sys/vm/swap_pager.h +++ b/sys/vm/swap_pager.h @@ -81,6 +81,7 @@ void swap_pager_swap_init(void); int swap_pager_nswapdev(void); int swap_pager_reserve(vm_object_t, vm_pindex_t, vm_size_t); void swap_pager_status(int *total, int *used); +u_long swap_pager_swapped_pages(vm_object_t object); void swapoff_all(void); #endif /* _KERNEL */ diff --git a/sys/vm/v
git: c35473f4ab3a - stable/13 - realtimer_expire: avoid proc lock recursion when called from itimer_proc_continue()
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c35473f4ab3a58dcc2846713c131d6983d9ed009 commit c35473f4ab3a58dcc2846713c131d6983d9ed009 Author: Konstantin Belousov AuthorDate: 2021-04-13 13:47:24 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:09 + realtimer_expire: avoid proc lock recursion when called from itimer_proc_continue() (cherry picked from commit 5cc1d199412ead0b4c234e21e881a31ef893a4f0) --- sys/kern/kern_time.c | 24 +--- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index d3b19111b0f3..ab22ac4a1697 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -105,6 +105,7 @@ static int realtimer_settime(struct itimer *, int, static int realtimer_delete(struct itimer *); static voidrealtimer_clocktime(clockid_t, struct timespec *); static voidrealtimer_expire(void *); +static voidrealtimer_expire_l(struct itimer *it, bool proc_locked); static int register_posix_clock(int, const struct kclock *); static voiditimer_fire(struct itimer *it); @@ -919,7 +920,7 @@ itimer_proc_continue(struct proc *p) if ((it->it_flags & ITF_PSTOPPED) != 0) { it->it_flags &= ~ITF_PSTOPPED; if ((it->it_flags & ITF_DELETING) == 0) - realtimer_expire(it); + realtimer_expire_l(it, true); } ITIMER_UNLOCK(it); } @@ -1663,18 +1664,14 @@ itimespecfix(struct timespec *ts) .tv_nsec = (ns) % 10\ } -/* Timeout callback for realtime timer */ static void -realtimer_expire(void *arg) +realtimer_expire_l(struct itimer *it, bool proc_locked) { struct timespec cts, ts; struct timeval tv; - struct itimer *it; struct proc *p; uint64_t interval, now, overruns, value; - it = (struct itimer *)arg; - realtimer_clocktime(it->it_clockid, &cts); /* Only fire if time is reached. */ if (timespeccmp(&cts, &it->it_time.it_value, >=)) { @@ -1708,8 +1705,9 @@ realtimer_expire(void *arg) /* single shot timer ? */ timespecclear(&it->it_time.it_value); } + + p = it->it_proc; if (timespecisset(&it->it_time.it_value)) { - p = it->it_proc; if (P_SHOULDSTOP(p) || P_KILLED(p)) { it->it_flags |= ITF_PSTOPPED; } else { @@ -1719,9 +1717,14 @@ realtimer_expire(void *arg) realtimer_expire, it); } } + itimer_enter(it); ITIMER_UNLOCK(it); + if (proc_locked) + PROC_UNLOCK(p); itimer_fire(it); + if (proc_locked) + PROC_LOCK(p); ITIMER_LOCK(it); itimer_leave(it); } else if (timespecisset(&it->it_time.it_value)) { @@ -1738,6 +1741,13 @@ realtimer_expire(void *arg) } } +/* Timeout callback for realtime timer */ +static void +realtimer_expire(void *arg) +{ + realtimer_expire_l(arg, false); +} + static void itimer_fire(struct itimer *it) { ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 7a2452308633 - stable/13 - Make files opened with O_PATH to not block non-forced unmount
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7a2452308633ad62081f641b2fc8751dab49106c commit 7a2452308633ad62081f641b2fc8751dab49106c Author: Konstantin Belousov AuthorDate: 2021-04-03 18:55:11 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:10 + Make files opened with O_PATH to not block non-forced unmount (cherry picked from commit a5970a529c2d952714f20e4bc6e529c74fd2b3b5) --- lib/libc/sys/open.2 | 3 +++ sys/kern/kern_descrip.c | 6 +++--- sys/kern/vfs_lookup.c | 2 +- sys/kern/vfs_syscalls.c | 11 --- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2 index f9c54bfc7581..06a877e34460 100644 --- a/lib/libc/sys/open.2 +++ b/lib/libc/sys/open.2 @@ -349,6 +349,9 @@ But operations like and any other that operate on file and not on file descriptor (except .Xr fstat 2 ), are not allowed. +File opened with the +.Dv O_PATH +flag does not prevent non-forced unmount of the volume it belongs to. See also the description of .Dv AT_EMPTY_PATH flag for diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 81af58fbddd1..a28e94634326 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -3430,7 +3430,7 @@ _fgetvp(struct thread *td, int fd, int flags, cap_rights_t *needrightsp, error = EINVAL; } else { *vpp = fp->f_vnode; - vrefact(*vpp); + vref(*vpp); } fdrop(fp, td); @@ -3466,7 +3466,7 @@ fgetvp_rights(struct thread *td, int fd, cap_rights_t *needrightsp, *havecaps = caps; *vpp = fp->f_vnode; - vrefact(*vpp); + vref(*vpp); fdrop(fp, td); return (0); @@ -4978,7 +4978,7 @@ path_close(struct file *fp, struct thread *td) { MPASS(fp->f_type == DTYPE_VNODE); fp->f_ops = &badfileops; - vrele(fp->f_vnode); + vdrop(fp->f_vnode); return (0); } diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index f979676f4c7d..3050275c1b6f 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -380,7 +380,7 @@ namei_setup(struct nameidata *ndp, struct vnode **dpp, struct pwd **pwdp) error = ENOTDIR; } else { *dpp = dfp->f_vnode; - vrefact(*dpp); + vref(*dpp); if ((dfp->f_flag & FSEARCH) != 0) cnp->cn_flags |= NOEXECCHECK; diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 5a1efcdec467..9130843f6761 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -896,7 +896,7 @@ sys_fchdir(struct thread *td, struct fchdir_args *uap) if (error != 0) return (error); vp = fp->f_vnode; - vrefact(vp); + vref(vp); fdrop(fp, td); vn_lock(vp, LK_SHARED | LK_RETRY); AUDIT_ARG_VNODE1(vp); @@ -1191,8 +1191,13 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg, if (fp->f_ops == &badfileops) { KASSERT(vp->v_type != VFIFO || (flags & O_PATH) != 0, ("Unexpected fifo fp %p vp %p", fp, vp)); - finit_vnode(fp, flags, NULL, (flags & O_PATH) != 0 ? - &path_fileops : &vnops); + if ((flags & O_PATH) != 0) { + finit_vnode(fp, flags, NULL, &path_fileops); + vhold(vp); + vunref(vp); + } else { + finit_vnode(fp, flags, NULL, &vnops); + } } VOP_UNLOCK(vp); ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 22f23299b7ed - stable/13 - b_vflags update requries bufobj lock
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=22f23299b7ed96932a4b9e8b3a93fc233af1f2d4 commit 22f23299b7ed96932a4b9e8b3a93fc233af1f2d4 Author: Konstantin Belousov AuthorDate: 2021-04-13 10:22:56 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:10 + b_vflags update requries bufobj lock (cherry picked from commit e3d675958539eee899d42438f5b46a26f3c64902) --- sys/ufs/ffs/ffs_softdep.c | 2 ++ sys/ufs/ffs/ffs_vnops.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 786fb43c7d81..2cc16ab2a2c1 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -7523,7 +7523,9 @@ cleanrestart: BO_LOCK(bo); goto cleanrestart; } + BO_LOCK(bo); bp->b_vflags |= BV_SCANNED; + BO_UNLOCK(bo); bremfree(bp); if (blkoff != 0) { allocbuf(bp, blkoff); diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 582c2e12..4e4e0b78fe4d 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -321,8 +321,9 @@ loop: if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK, BO_LOCKPTR(bo)) != 0) { + BO_LOCK(bo); bp->b_vflags &= ~BV_SCANNED; - goto next; + goto next_locked; } } else continue; @@ -385,6 +386,7 @@ next: * to start from a known point. */ BO_LOCK(bo); +next_locked: nbp = TAILQ_FIRST(&bo->bo_dirty.bv_hd); } if (waitfor != MNT_WAIT) { ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 9a05597b8fee - stable/13 - Style.
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9a05597b8fee85d0193fdb4f31aef79c5e2e88b7 commit 9a05597b8fee85d0193fdb4f31aef79c5e2e88b7 Author: Konstantin Belousov AuthorDate: 2021-03-18 10:40:20 + Commit: Konstantin Belousov CommitDate: 2021-04-23 11:14:10 + Style. (cherry picked from commit 42be0a7b10b14113ba9c4e4a738e8f20e235b736) --- sys/kern/kern_descrip.c | 2 +- sys/kern/vfs_syscalls.c | 8 sys/kern/vfs_vnops.c| 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 67350f4ad71e..7a43fbb2eb80 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -550,7 +550,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) tmp = flg = fp->f_flag; tmp &= ~FCNTLFLAGS; tmp |= FFLAGS(arg & ~O_ACCMODE) & FCNTLFLAGS; - } while(atomic_cmpset_int(&fp->f_flag, flg, tmp) == 0); + } while (atomic_cmpset_int(&fp->f_flag, flg, tmp) == 0); tmp = fp->f_flag & FNONBLOCK; error = fo_ioctl(fp, FIONBIO, &tmp, td->td_ucred, td); if (error != 0) { diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 3db34c3689de..48df8a3e9051 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1881,8 +1881,8 @@ restart: if (vp->v_type == VDIR && oldinum == 0) { error = EPERM; /* POSIX */ } else if (oldinum != 0 && - ((error = VOP_STAT(vp, &sb, td->td_ucred, NOCRED, td)) == 0) && - sb.st_ino != oldinum) { + ((error = VOP_STAT(vp, &sb, td->td_ucred, NOCRED, td)) == 0) && + sb.st_ino != oldinum) { error = EIDRM; /* Identifier removed */ } else if (fp != NULL && fp->f_vnode != vp) { if (VN_IS_DOOMED(fp->f_vnode)) @@ -3818,8 +3818,8 @@ kern_frmdirat(struct thread *td, int dfd, const char *path, int fd, fp = NULL; if (fd != FD_NONE) { - error = getvnode(td, fd, cap_rights_init_one(&rights, CAP_LOOKUP), - &fp); + error = getvnode(td, fd, cap_rights_init_one(&rights, + CAP_LOOKUP), &fp); if (error != 0) return (error); } diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index f0914c569828..44cbf1a7893b 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1775,7 +1775,7 @@ vn_closefile(struct file *fp, struct thread *td) vp = fp->f_vnode; fp->f_ops = &badfileops; - ref= (fp->f_flag & FHASLOCK) != 0 && fp->f_type == DTYPE_VNODE; + ref = (fp->f_flag & FHASLOCK) != 0 && fp->f_type == DTYPE_VNODE; error = vn_close1(vp, fp->f_flag, fp->f_cred, td, ref); ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 8e8f1cc9bb94 - main - Re-enable network ioctls in capability mode
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8e8f1cc9bb945ffaa4b49231e1ebcead1baa62ce commit 8e8f1cc9bb945ffaa4b49231e1ebcead1baa62ce Author: Mark Johnston AuthorDate: 2021-04-23 13:14:42 + Commit: Mark Johnston CommitDate: 2021-04-23 13:22:49 + Re-enable network ioctls in capability mode This reverts a portion of 274579831b61 ("capsicum: Limit socket operations in capability mode") as at least rtsol and dhcpcd rely on being able to configure network interfaces while in capability mode. Reported by:bapt, Greg V Sponsored by: The FreeBSD Foundation --- contrib/capsicum-test/capmode.cc | 5 + sys/kern/sys_socket.c| 2 +- sys/net/if.c | 9 - sys/net/route.c | 5 + sys/net/route.h | 4 +--- sys/netinet/in.c | 4 sys/netinet6/in6.c | 4 7 files changed, 8 insertions(+), 25 deletions(-) diff --git a/contrib/capsicum-test/capmode.cc b/contrib/capsicum-test/capmode.cc index ba2de19879a0..f32d9e038744 100644 --- a/contrib/capsicum-test/capmode.cc +++ b/contrib/capsicum-test/capmode.cc @@ -227,6 +227,10 @@ FORK_TEST_F(WithFiles, AllowedSocketSyscallsIfRoot) { // Interface configuration ioctls are not permitted in capability // mode. + // + // This test is disabled for now as the corresponding kernel change was + // disabled. +#if 0 #ifdef __FreeBSD__ struct if_clonereq req; @@ -238,6 +242,7 @@ FORK_TEST_F(WithFiles, AllowedSocketSyscallsIfRoot) { free(req.ifcr_buffer); #endif +#endif } #ifdef HAVE_SEND_RECV_MMSG diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index 52f4b6cdf7f9..e53b0367960b 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -271,7 +271,7 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred, error = ifioctl(so, cmd, data, td); else if (IOCGROUP(cmd) == 'r') { CURVNET_SET(so->so_vnet); - error = rtioctl_fib(cmd, data, so->so_fibnum, td); + error = rtioctl_fib(cmd, data, so->so_fibnum); CURVNET_RESTORE(); } else { CURVNET_SET(so->so_vnet); diff --git a/sys/net/if.c b/sys/net/if.c index 5bf44d014db3..1e410142747f 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2968,15 +2968,6 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td) bool shutdown; #endif - /* -* Interface ioctls access a global namespace. There is currently no -* capability-based representation for interfaces, so the configuration -* interface is simply unaccessible from capability mode. If necessary, -* select ioctls may be permitted here. -*/ - if (IN_CAPABILITY_MODE(td)) - return (ECAPMODE); - CURVNET_SET(so->so_vnet); #ifdef VIMAGE /* Make sure the VNET is stable. */ diff --git a/sys/net/route.c b/sys/net/route.c index f093a71b7585..2416aa9a983f 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -43,7 +43,6 @@ #include #include -#include #include #include #include @@ -246,10 +245,8 @@ rib_add_redirect(u_int fibnum, struct sockaddr *dst, struct sockaddr *gateway, * Routing table ioctl interface. */ int -rtioctl_fib(u_long req, caddr_t data, u_int fibnum, struct thread *td) +rtioctl_fib(u_long req, caddr_t data, u_int fibnum) { - if (IN_CAPABILITY_MODE(td)) - return (ECAPMODE); /* * If more ioctl commands are added here, make sure the proper diff --git a/sys/net/route.h b/sys/net/route.h index 64e89965f9cd..67217f237e0b 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -431,13 +431,11 @@ void rt_updatemtu(struct ifnet *); void rt_flushifroutes(struct ifnet *ifp); -struct thread; - /* XXX MRT NEW VERSIONS THAT USE FIBs * For now the protocol indepedent versions are the same as the AF_INET ones * but this will change.. */ -intrtioctl_fib(u_long, caddr_t, u_int, struct thread *); +intrtioctl_fib(u_long, caddr_t, u_int); intrib_lookup_info(uint32_t, const struct sockaddr *, uint32_t, uint32_t, struct rt_addrinfo *); void rib_free_info(struct rt_addrinfo *info); diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 5f70dd1ec824..bcf071a81e0e 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include #include @@ -238,9 +237,6 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, if (ifp == NULL) return (EADDRNOTAVAIL); - if (td != NULL && IN_CAPABILITY_MODE(td)) - return (ECAPMODE); - /* * Filter out 4 ioctls we implement directly. Forward the rest * to specific
git: d500a85e640d - main - dtrace tests: Fix tst.system.d after ping/ping6 unification
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d500a85e640d1cd270747c12e17c511b53864436 commit d500a85e640d1cd270747c12e17c511b53864436 Author: Mark Johnston AuthorDate: 2021-04-23 14:28:09 + Commit: Mark Johnston CommitDate: 2021-04-23 14:28:09 + dtrace tests: Fix tst.system.d after ping/ping6 unification MFC after: 1 week Sponsored by: The FreeBSD Foundation --- .../opensolaris/cmd/dtrace/test/tst/common/funcs/tst.system.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.system.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.system.d index 63a850133b3f..4d5cced71c79 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.system.d +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.system.d @@ -35,11 +35,11 @@ BEGIN this->b = -2; system("echo %s %d %d", "foo", this->a, this->b); - system("ping -q -c 1 localhost 2>/dev/null | grep -v '^round-trip '"); + system("ping -q -c 1 127.0.0.1 2>/dev/null | grep -v '^round-trip '"); system("echo %d", ++this->a); - system("ping -q -c 1 localhost 2>/dev/null | grep -v '^round-trip '"); + system("ping -4 -q -c 1 127.0.0.1 2>/dev/null | grep -v '^round-trip '"); system("echo %d", ++this->a); - system("ping -q -c 1 localhost 2>/dev/null | grep -v '^round-trip '"); + system("ping -4 -q -c 1 127.0.0.1 2>/dev/null | grep -v '^round-trip '"); system("echo %d", ++this->a); exit(0); } ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: f4c3c0189f7d - stable/13 - readelf: return error in case of invalid file
The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=f4c3c0189f7ddc324643c843097247f6df316ec5 commit f4c3c0189f7ddc324643c843097247f6df316ec5 Author: Ed Maste AuthorDate: 2021-04-23 15:37:49 + Commit: Ed Maste CommitDate: 2021-04-23 15:37:49 + readelf: return error in case of invalid file GNU readelf exits with an error for a number of invalid file cases. Previously ELF Tool Chain readelf always exited with 0. Now we exit 1 upon detecting an error with one or more input files, but in any case all of them are processed. This should catch common failure cases. We still do not report an error for some types of malformed ELF files, but this is consistent with GNU readelf. PR: 252727 Reviewed by:jkoshy, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29377 (cherry picked from commit ea444392bb5b351c930f28a02a4e68f51b25ba69) --- contrib/elftoolchain/readelf/readelf.c | 36 +- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/contrib/elftoolchain/readelf/readelf.c b/contrib/elftoolchain/readelf/readelf.c index 022c9e9066ab..81e6897cf3cd 100644 --- a/contrib/elftoolchain/readelf/readelf.c +++ b/contrib/elftoolchain/readelf/readelf.c @@ -285,7 +285,7 @@ static const char *elf_osabi(unsigned int abi); static const char *elf_type(unsigned int type); static const char *elf_ver(unsigned int ver); static const char *dt_type(unsigned int mach, unsigned int dtype); -static void dump_ar(struct readelf *re, int); +static bool dump_ar(struct readelf *re, int); static void dump_arm_attributes(struct readelf *re, uint8_t *p, uint8_t *pe); static void dump_attributes(struct readelf *re); static uint8_t *dump_compatibility_tag(uint8_t *p, uint8_t *pe); @@ -315,7 +315,7 @@ static void dump_dwarf_ranges_foreach(struct readelf *re, Dwarf_Die die, Dwarf_Addr base); static void dump_dwarf_str(struct readelf *re); static void dump_eflags(struct readelf *re, uint64_t e_flags); -static void dump_elf(struct readelf *re); +static bool dump_elf(struct readelf *re); static void dump_flags(struct flag_desc *fd, uint64_t flags); static void dump_dyn_val(struct readelf *re, GElf_Dyn *dyn, uint32_t stab); static void dump_dynamic(struct readelf *re); @@ -7211,18 +7211,18 @@ unload_sections(struct readelf *re) } } -static void +static bool dump_elf(struct readelf *re) { /* Fetch ELF header. No need to continue if it fails. */ if (gelf_getehdr(re->elf, &re->ehdr) == NULL) { warnx("gelf_getehdr failed: %s", elf_errmsg(-1)); - return; + return (false); } if ((re->ec = gelf_getclass(re->elf)) == ELFCLASSNONE) { warnx("gelf_getclass failed: %s", elf_errmsg(-1)); - return; + return (false); } if (re->ehdr.e_ident[EI_DATA] == ELFDATA2MSB) { re->dw_read = _read_msb; @@ -7266,6 +7266,7 @@ dump_elf(struct readelf *re) dump_dwarf(re); if (re->options & ~RE_H) unload_sections(re); + return (true); } static void @@ -7311,7 +7312,7 @@ dump_dwarf(struct readelf *re) dwarf_finish(re->dbg, &de); } -static void +static bool dump_ar(struct readelf *re, int fd) { Elf_Arsym *arsym; @@ -7362,14 +7363,14 @@ dump_ar(struct readelf *re, int fd) } if (elf_rand(re->ar, SARMAG) != SARMAG) { warnx("elf_rand() failed: %s", elf_errmsg(-1)); - return; + return (false); } } process_members: if ((re->options & ~RE_C) == 0) - return; + return (true); cmd = ELF_C_READ; while ((re->elf = elf_begin(fd, cmd, re->ar)) != NULL) { @@ -7389,11 +7390,14 @@ process_members: elf_end(re->elf); } re->elf = re->ar; + return (true); } -static void +static bool dump_object(struct readelf *re, int fd) { + bool rv = false; + if ((re->flags & DISPLAY_FILENAME) != 0) printf("\nFile: %s\n", re->filename); @@ -7407,10 +7411,10 @@ dump_object(struct readelf *re, int fd) warnx("Not an ELF file."); goto done; case ELF_K_ELF: - dump_elf(re); + rv = dump_elf(re); break; case ELF_K_AR: - dump_ar(re, fd); + rv = dump_ar(re, fd); break; default: warnx("Internal: libelf returned unknown elf kind."); @@ -7418,6 +7422,7 @@ dump_object(struct readelf *re, int fd) done: elf_end(re->elf); + return (rv); } static void @@ -7765,7 +7770,7 @@ main(int argc, char **argv) fileargs_t
git: bba9922d9995 - stable/13 - flex: Regen bootstrap files
The branch stable/13 has been updated by jkim: URL: https://cgit.FreeBSD.org/src/commit/?id=bba9922d99959d1ec17e9869eda20ed023dab9e3 commit bba9922d99959d1ec17e9869eda20ed023dab9e3 Author: Jung-uk Kim AuthorDate: 2021-04-19 18:20:51 + Commit: Jung-uk Kim CommitDate: 2021-04-23 15:46:30 + flex: Regen bootstrap files This also partially reverts r326025 (8a16b7a18f5d). I do not see any point of adding SPDX tag in generated file. Submitted by: Dan McGregor (initial version) Differential Revision: https://reviews.freebsd.org/D28596 (cherry picked from commit 686cf5468c4a85c2a6385cdbab2383900876a41d) --- usr.bin/lex/initparse.c | 17 ++--- usr.bin/lex/initparse.h | 1 - usr.bin/lex/initscan.c | 5 - usr.bin/lex/initskel.c | 9 - 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/usr.bin/lex/initparse.c b/usr.bin/lex/initparse.c index c723c5b45c40..c95305aa1a91 100644 --- a/usr.bin/lex/initparse.c +++ b/usr.bin/lex/initparse.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* original parser id follows */ /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ @@ -6,7 +5,7 @@ #define YYBYACC 1 #define YYMAJOR 1 #define YYMINOR 9 -#define YYPATCH 20170430 +#define YYPATCH 20200330 #define YYEMPTY(-1) #define yyclearin (yychar = YYEMPTY) @@ -19,8 +18,6 @@ #define YYPURE 0 #line 35 "parse.y" -/* SPDX-License-Identifier: BSD-2-Clause */ - /* Copyright (c) 1990 The Regents of the University of California. */ /* All rights reserved. */ @@ -130,6 +127,10 @@ typedef int YYSTYPE; # define YYLEX yylex() #endif +#if !(defined(yylex) || defined(YYSTATE)) +int YYLEX_DECL(); +#endif + /* Parameters sent to yyerror. */ #ifndef YYERROR_DECL #define YYERROR_DECL() yyerror(const char *s) @@ -488,13 +489,15 @@ static const char *const yyrule[] = { }; #endif +#if YYDEBUG int yydebug; -int yynerrs; +#endif int yyerrflag; int yychar; YYSTYPE yyval; YYSTYPE yylval; +int yynerrs; /* define the initial stack-sizes */ #ifdef YYSTACKSIZE @@ -655,7 +658,7 @@ void yyerror( const char *msg ) { (void)msg; } -#line 656 "parse.c" +#line 662 "parse.c" #if YYDEBUG #include /* needed for printf */ @@ -1781,7 +1784,7 @@ case 96: #line 946 "parse.y" { yyval = mkstate( SYM_EPSILON ); } break; -#line 1782 "parse.c" +#line 1788 "parse.c" } yystack.s_mark -= yym; yystate = *yystack.s_mark; diff --git a/usr.bin/lex/initparse.h b/usr.bin/lex/initparse.h index fb0742445d55..b630d282c635 100644 --- a/usr.bin/lex/initparse.h +++ b/usr.bin/lex/initparse.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #define CHAR 257 #define NUMBER 258 #define SECTEND 259 diff --git a/usr.bin/lex/initscan.c b/usr.bin/lex/initscan.c index 46070a4c6dc5..9b6fb4ae5183 100644 --- a/usr.bin/lex/initscan.c +++ b/usr.bin/lex/initscan.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #line 2 "" @@ -4578,7 +4577,11 @@ static int yy_get_next_buffer (void) case EOB_ACT_END_OF_FILE: { if ( yywrap( ) ) +#ifdef YY_FLEX_LEX_COMPAT return 0; +#else + return EOF; +#endif if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; diff --git a/usr.bin/lex/initskel.c b/usr.bin/lex/initskel.c index a7a69875521d..53a0ae452aa8 100644 --- a/usr.bin/lex/initskel.c +++ b/usr.bin/lex/initskel.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* File created from flex.skl via mkskel.sh */ #include "flexdef.h" @@ -448,11 +447,7 @@ const char *skel[] = { "/* First, we deal with platform-specific or compiler-specific issues. */", "", "#if defined(__FreeBSD__)", - "#ifndef __STDC_LIMIT_MACROS", - "#define __STDC_LIMIT_MACROS", - "#endif", "#include ", - "#include ", "#else", "#define __dead2", "#endif", @@ -2301,7 +2296,11 @@ const char *skel[] = { "case EOB_ACT_END_OF_FILE:", "{", "if ( yywrap( M4_YY_CALL_ONLY_ARG ) )", + "#ifdef YY_FLEX_LEX_COMPAT", "return 0;", + "#else", + "return EOF;", + "#endif", "", "if ( ! YY_G(yy_did_buffer_switch_on_eof) )", "YY_NEW_FILE;", ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: f1dab9dbdf12 - stable/13 - lex: Use NULL instead of 0 for pointers
The branch stable/13 has been updated by jkim: URL: https://cgit.FreeBSD.org/src/commit/?id=f1dab9dbdf125d010213a7ac5ee778cd8fbf0a1a commit f1dab9dbdf125d010213a7ac5ee778cd8fbf0a1a Author: Jung-uk Kim AuthorDate: 2021-02-11 23:31:53 + Commit: Jung-uk Kim CommitDate: 2021-04-23 15:59:29 + lex: Use NULL instead of 0 for pointers Note araujo tried to fix it in r298241 but he only touched generated files for bootstrap. This commit properly fixes the problem. (cherry picked from commit 34e67bb5977049afb3e965b52b86ac12ea4899b4) --- contrib/flex/src/scan.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/flex/src/scan.l b/contrib/flex/src/scan.l index 1570f505b342..d01406ecdd4a 100644 --- a/contrib/flex/src/scan.l +++ b/contrib/flex/src/scan.l @@ -705,7 +705,7 @@ M4QEND "]""]" } nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ - if ( (nmdefptr = ndlookup( nmstr )) == 0 ) + if ( (nmdefptr = ndlookup( nmstr )) == NULL ) format_synerr( _( "undefined definition {%s}" ), nmstr ); ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 87c0db9d0174 - stable/13 - Cirrus-CI: use FreeBSD 13.0 image for base system CI build
The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=87c0db9d0174fb1906a58d2f3bd5aff6dad528de commit 87c0db9d0174fb1906a58d2f3bd5aff6dad528de Author: Ed Maste AuthorDate: 2021-04-19 18:36:21 + Commit: Ed Maste CommitDate: 2021-04-23 16:05:34 + Cirrus-CI: use FreeBSD 13.0 image for base system CI build We generally want to build and test on the highest release version, and FreeBSD 13.0 also brings some performance benefits. Reviewed by:lwhsu Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29842 (cherry picked from commit 407abff2b91847e23711625ad7c69c17e99b3d1d) --- .cirrus.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 323567685b68..ff144699675e 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,9 +1,9 @@ # $FreeBSD$ freebsd_instance: - # image: freebsd-12-1-stable-amd64 - # We need a newer image to install llvm11 - image_family: freebsd-12-1-snap + # Image list available via + # gcloud compute images list --project freebsd-org-cloud-dev --no-standard-images + image: freebsd-13-0-release-amd64 cpu: 8 memory: 24G ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: b0df36580d5b - main - etcupdate: Remove the old pre-world tree when rotating for -p.
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=b0df36580d5b0df67a0f58ded8f6356b268f7f71 commit b0df36580d5b0df67a0f58ded8f6356b268f7f71 Author: John Baldwin AuthorDate: 2021-04-23 16:40:04 + Commit: John Baldwin CommitDate: 2021-04-23 16:44:18 + etcupdate: Remove the old pre-world tree when rotating for -p. This fixes a bug in an earlier change to move tree rotation to the end of the update where the step to make room for the new preworld tree was deleting the old "current" tree instead of the old "preworld" tree. Reported by:olivier, dhw Fixes: 0611aec3cf3a373e6a06f103699dbc91c3d6d472 MFC after: 2 weeks --- usr.sbin/etcupdate/etcupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/etcupdate/etcupdate.sh b/usr.sbin/etcupdate/etcupdate.sh index bb9eb00bc646..254a72abae08 100755 --- a/usr.sbin/etcupdate/etcupdate.sh +++ b/usr.sbin/etcupdate/etcupdate.sh @@ -1644,7 +1644,7 @@ EOF if [ -z "$preworld" ]; then panic "New tree should be rotated to old" fi - if ! remove_tree $old; then + if ! remove_tree $new; then echo "Unable to remove previous pre-world tree." exit 1 fi ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 50f5d13eeb88 - main - cxgbe(4): hw.cxgbe.panic_on_fatal_err can be changed any time.
The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=50f5d13eeb8835fe8250d65f04d7d956d703 commit 50f5d13eeb8835fe8250d65f04d7d956d703 Author: Navdeep Parhar AuthorDate: 2021-04-23 19:17:54 + Commit: Navdeep Parhar CommitDate: 2021-04-23 19:17:54 + cxgbe(4): hw.cxgbe.panic_on_fatal_err can be changed any time. MFC after: 2 weeks Sponsored by: Chelsio Communications --- sys/dev/cxgbe/t4_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 6e5d263c7649..1650e15d16a0 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -593,7 +593,7 @@ SYSCTL_INT(_hw_cxgbe, OID_AUTO, pcie_relaxed_ordering, CTLFLAG_RDTUN, "PCIe Relaxed Ordering: 0 = disable, 1 = enable, 2 = leave alone"); static int t4_panic_on_fatal_err = 0; -SYSCTL_INT(_hw_cxgbe, OID_AUTO, panic_on_fatal_err, CTLFLAG_RDTUN, +SYSCTL_INT(_hw_cxgbe, OID_AUTO, panic_on_fatal_err, CTLFLAG_RWTUN, &t4_panic_on_fatal_err, 0, "panic on fatal errors"); static int t4_tx_vm_wr = 0; ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 576b477ba41c - main - openssh: add a note about pushing vendor updates
The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=576b477ba41c9916fae3a83e6b4dd98c682a0c2f commit 576b477ba41c9916fae3a83e6b4dd98c682a0c2f Author: Ed Maste AuthorDate: 2021-04-23 19:35:40 + Commit: Ed Maste CommitDate: 2021-04-23 19:36:42 + openssh: add a note about pushing vendor updates Sponsored by: The FreeBSD Foundation --- crypto/openssh/FREEBSD-upgrade | 7 +++ 1 file changed, 7 insertions(+) diff --git a/crypto/openssh/FREEBSD-upgrade b/crypto/openssh/FREEBSD-upgrade index bde003a1d183..397b68dee96f 100644 --- a/crypto/openssh/FREEBSD-upgrade +++ b/crypto/openssh/FREEBSD-upgrade @@ -39,6 +39,13 @@ $ git tag -a -m "Tag OpenSSH X.YpZ" vendor/openssh/X.YpZ +At this point the vendor branch can be pushed to the FreeBSD repo via: + +$ git push freebsd vendor/openssh + +(It could also be pushed later on, along with the merge to main, but +pushing now allows others to collaborate.) + 08) Check out head and run the pre-merge script, which strips our RCS tags from files that have them: ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 4281bfec3628 - main - nfsd: fix session slot handling for failed callbacks
The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=4281bfec36285e2212f41568459c077bf4dbd91c commit 4281bfec36285e2212f41568459c077bf4dbd91c Author: Rick Macklem AuthorDate: 2021-04-23 22:24:47 + Commit: Rick Macklem CommitDate: 2021-04-23 22:24:47 + nfsd: fix session slot handling for failed callbacks When the NFSv4.1/4.2 server does a callback to a client on the back channel, it will use a session slot in the back channel session. If the back channel has failed, the callback will fail and, without this patch, the session slot will not be released. As more callbacks are attempted, all session slots can become busy and then the nfsd thread gets stuck waiting for a back channel session slot. This patch frees the session slot upon callback failure to avoid this problem. Without this patch, the problem can be avoided by leaving delegations disabled in the NFS server. MFC after: 2 weeks --- sys/fs/nfsserver/nfs_nfsdstate.c | 30 ++ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdstate.c b/sys/fs/nfsserver/nfs_nfsdstate.c index 60647ab288d8..430f09844b83 100644 --- a/sys/fs/nfsserver/nfs_nfsdstate.c +++ b/sys/fs/nfsserver/nfs_nfsdstate.c @@ -166,7 +166,8 @@ static int nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, int trunc, fhandle_t *fhp, struct nfsvattr *nap, nfsattrbit_t *attrbitp, int laytype, NFSPROC_T *p); static int nfsrv_cbcallargs(struct nfsrv_descript *nd, struct nfsclient *clp, -uint32_t callback, int op, const char *optag, struct nfsdsession **sepp); +uint32_t callback, int op, const char *optag, struct nfsdsession **sepp, +int *slotposp); static u_int32_t nfsrv_nextclientindex(void); static u_int32_t nfsrv_nextstateindex(struct nfsclient *clp); static void nfsrv_markstable(struct nfsclient *clp); @@ -201,7 +202,7 @@ static void nfsrv_unlocklf(struct nfslockfile *lfp); static struct nfsdsession *nfsrv_findsession(uint8_t *sessionid); static int nfsrv_freesession(struct nfsdsession *sep, uint8_t *sessionid); static int nfsv4_setcbsequence(struct nfsrv_descript *nd, struct nfsclient *clp, -int dont_replycache, struct nfsdsession **sepp); +int dont_replycache, struct nfsdsession **sepp, int *slotposp); static int nfsv4_getcbsession(struct nfsclient *clp, struct nfsdsession **sepp); static int nfsrv_addlayout(struct nfsrv_descript *nd, struct nfslayout **lypp, nfsv4stateid_t *stateidp, char *layp, int *layoutlenp, NFSPROC_T *p); @@ -4434,7 +4435,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, u_int32_t *tl; struct nfsrv_descript *nd; struct ucred *cred; - int error = 0; + int error = 0, slotpos; u_int32_t callback; struct nfsdsession *sep = NULL; uint64_t tval; @@ -4492,7 +4493,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, if (procnum == NFSV4OP_CBGETATTR) { nd->nd_procnum = NFSV4PROC_CBCOMPOUND; error = nfsrv_cbcallargs(nd, clp, callback, NFSV4OP_CBGETATTR, - "CB Getattr", &sep); + "CB Getattr", &sep, &slotpos); if (error != 0) { m_freem(nd->nd_mreq); goto errout; @@ -4502,7 +4503,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, } else if (procnum == NFSV4OP_CBRECALL) { nd->nd_procnum = NFSV4PROC_CBCOMPOUND; error = nfsrv_cbcallargs(nd, clp, callback, NFSV4OP_CBRECALL, - "CB Recall", &sep); + "CB Recall", &sep, &slotpos); if (error != 0) { m_freem(nd->nd_mreq); goto errout; @@ -4521,7 +4522,7 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, NFSD_DEBUG(4, "docallback layout recall\n"); nd->nd_procnum = NFSV4PROC_CBCOMPOUND; error = nfsrv_cbcallargs(nd, clp, callback, - NFSV4OP_CBLAYOUTRECALL, "CB Reclayout", &sep); + NFSV4OP_CBLAYOUTRECALL, "CB Reclayout", &sep, &slotpos); NFSD_DEBUG(4, "aft cbcallargs=%d\n", error); if (error != 0) { m_freem(nd->nd_mreq); @@ -4570,6 +4571,8 @@ nfsrv_docallback(struct nfsclient *clp, int procnum, nfsv4stateid_t *stateidp, if (clp->lc_req.nr_client == NULL) { if ((clp->lc_flags & LCL_NFSV41) != 0) { error = ECONNREFUSED; + if (procnum != NFSV4PROC_CBNULL) + nfsv4_freeslot(&sep->sess_cbsess, slotpos); nfsrv_freesession(sep, NULL); }
git: f0077b4c1dcf - stable/13 - mpt(4): Remove incorrect S/G segments limits.
The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=f0077b4c1dcfa7eda6efadf197e8423fe002ac5d commit f0077b4c1dcfa7eda6efadf197e8423fe002ac5d Author: Alexander Motin AuthorDate: 2021-04-17 14:41:35 + Commit: Alexander Motin CommitDate: 2021-04-24 00:43:14 + mpt(4): Remove incorrect S/G segments limits. First, two of those four checks are unreachable. Second, I don't believe there should be ">=" instead of ">". Third, bus_dma(9) already returns the same EFBIG if ">". This fixes false I/O errors in worst S/G cases with maxphys >= 2MB. MFC after: 1 week (cherry picked from commit 0f29396e493bd87ffa6a63fcb602b12e79d21a1e) --- sys/dev/mpt/mpt_cam.c | 20 1 file changed, 20 deletions(-) diff --git a/sys/dev/mpt/mpt_cam.c b/sys/dev/mpt/mpt_cam.c index 90c84eee2442..64776d673674 100644 --- a/sys/dev/mpt/mpt_cam.c +++ b/sys/dev/mpt/mpt_cam.c @@ -1292,10 +1292,6 @@ mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) hdrp = req->req_vbuf; mpt_off = req->req_vbuf; - if (error == 0 && ((uint32_t)nseg) >= mpt->max_seg_cnt) { - error = EFBIG; - } - if (error == 0) { switch (hdrp->Function) { case MPI_FUNCTION_SCSI_IO_REQUEST: @@ -1315,12 +1311,6 @@ mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) } } - if (error == 0 && ((uint32_t)nseg) >= mpt->max_seg_cnt) { - error = EFBIG; - mpt_prt(mpt, "segment count %d too large (max %u)\n", - nseg, mpt->max_seg_cnt); - } - bad: if (error != 0) { if (error != EFBIG && error != ENOMEM) { @@ -1694,10 +1684,6 @@ mpt_execute_req(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) hdrp = req->req_vbuf; mpt_off = req->req_vbuf; - if (error == 0 && ((uint32_t)nseg) >= mpt->max_seg_cnt) { - error = EFBIG; - } - if (error == 0) { switch (hdrp->Function) { case MPI_FUNCTION_SCSI_IO_REQUEST: @@ -1716,12 +1702,6 @@ mpt_execute_req(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) } } - if (error == 0 && ((uint32_t)nseg) >= mpt->max_seg_cnt) { - error = EFBIG; - mpt_prt(mpt, "segment count %d too large (max %u)\n", - nseg, mpt->max_seg_cnt); - } - bad: if (error != 0) { if (error != EFBIG && error != ENOMEM) { ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: dd01826ad3ad - stable/12 - mpt(4): Remove incorrect S/G segments limits.
The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=dd01826ad3add7e5285f4f391c9f502906c78600 commit dd01826ad3add7e5285f4f391c9f502906c78600 Author: Alexander Motin AuthorDate: 2021-04-17 14:41:35 + Commit: Alexander Motin CommitDate: 2021-04-24 00:43:29 + mpt(4): Remove incorrect S/G segments limits. First, two of those four checks are unreachable. Second, I don't believe there should be ">=" instead of ">". Third, bus_dma(9) already returns the same EFBIG if ">". This fixes false I/O errors in worst S/G cases with maxphys >= 2MB. MFC after: 1 week (cherry picked from commit 0f29396e493bd87ffa6a63fcb602b12e79d21a1e) --- sys/dev/mpt/mpt_cam.c | 20 1 file changed, 20 deletions(-) diff --git a/sys/dev/mpt/mpt_cam.c b/sys/dev/mpt/mpt_cam.c index 4fbca1d9fe25..a861dafbd060 100644 --- a/sys/dev/mpt/mpt_cam.c +++ b/sys/dev/mpt/mpt_cam.c @@ -1293,10 +1293,6 @@ mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) hdrp = req->req_vbuf; mpt_off = req->req_vbuf; - if (error == 0 && ((uint32_t)nseg) >= mpt->max_seg_cnt) { - error = EFBIG; - } - if (error == 0) { switch (hdrp->Function) { case MPI_FUNCTION_SCSI_IO_REQUEST: @@ -1316,12 +1312,6 @@ mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) } } - if (error == 0 && ((uint32_t)nseg) >= mpt->max_seg_cnt) { - error = EFBIG; - mpt_prt(mpt, "segment count %d too large (max %u)\n", - nseg, mpt->max_seg_cnt); - } - bad: if (error != 0) { if (error != EFBIG && error != ENOMEM) { @@ -1696,10 +1686,6 @@ mpt_execute_req(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) hdrp = req->req_vbuf; mpt_off = req->req_vbuf; - if (error == 0 && ((uint32_t)nseg) >= mpt->max_seg_cnt) { - error = EFBIG; - } - if (error == 0) { switch (hdrp->Function) { case MPI_FUNCTION_SCSI_IO_REQUEST: @@ -1718,12 +1704,6 @@ mpt_execute_req(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) } } - if (error == 0 && ((uint32_t)nseg) >= mpt->max_seg_cnt) { - error = EFBIG; - mpt_prt(mpt, "segment count %d too large (max %u)\n", - nseg, mpt->max_seg_cnt); - } - bad: if (error != 0) { if (error != EFBIG && error != ENOMEM) { ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: 2acbe67787d2 - main - sound(4): fixing panic for INVARIANTS kernel
The branch main has been updated by avatar: URL: https://cgit.FreeBSD.org/src/commit/?id=2acbe67787d2ba08b62713ccc3abcef01e7ced09 commit 2acbe67787d2ba08b62713ccc3abcef01e7ced09 Author: Tai-hwa Liang AuthorDate: 2021-04-22 12:45:18 + Commit: Tai-hwa Liang CommitDate: 2021-04-24 03:27:43 + sound(4): fixing panic for INVARIANTS kernel 3e7bae08210e0 turns the BUS_READ_IVAR() failure from a warning into a KASSERT. For certain PCI audio devices such like snd_csa(4) and snd_emu10kx(4), the ac97_create() keeps the device handler generated by device_add_child(pci_dev, "pcm"), which is not really a PCI device handler. This in turn causes the subsequent pci_get_subdevice() inside ac97_initmixer() triggering a panic. This patch tries to put a bandaid for the aforementioned pcm device children such that they can use the correct PCI handler(from parent) to avoid a KASSERT panic in the INVARIANTS kernel. Tested with:snd_csa(4), snd_ich(4), snd_emu10kx(4) Reviewed by:imp MFC after: 1 month --- sys/dev/sound/pcm/ac97.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/dev/sound/pcm/ac97.c b/sys/dev/sound/pcm/ac97.c index 960176329b3e..3dc614083660 100644 --- a/sys/dev/sound/pcm/ac97.c +++ b/sys/dev/sound/pcm/ac97.c @@ -602,6 +602,7 @@ ac97_initmixer(struct ac97_info *codec) ac97_patch codec_patch; const char *cname, *vname; char desc[80]; + device_t pdev; u_int8_t model, step; unsigned i, j, k, bit, old; u_int32_t id; @@ -641,9 +642,14 @@ ac97_initmixer(struct ac97_info *codec) return ENODEV; } + pdev = codec->dev; + while (strcmp(device_get_name(device_get_parent(pdev)), "pci") != 0) { + /* find the top-level PCI device handler */ + pdev = device_get_parent(pdev); + } codec->id = id; - codec->subvendor = (u_int32_t)pci_get_subdevice(codec->dev) << 16; - codec->subvendor |= (u_int32_t)pci_get_subvendor(codec->dev) & + codec->subvendor = (u_int32_t)pci_get_subdevice(pdev) << 16; + codec->subvendor |= (u_int32_t)pci_get_subvendor(pdev) & 0x; codec->noext = 0; codec_patch = NULL; ___ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"
git: b99419aee49e - main - mpr/mps(4): Make device mapping some more robust.
The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=b99419aee49e2cc53747730be4d0ec4f9b330eb2 commit b99419aee49e2cc53747730be4d0ec4f9b330eb2 Author: Alexander Motin AuthorDate: 2021-04-24 03:18:01 + Commit: Alexander Motin CommitDate: 2021-04-24 03:36:51 + mpr/mps(4): Make device mapping some more robust. Allow new enclosure to replace previously existing one if there is no completely unused table entry, same as it is done for devices. If we can not process DPM due to corruption -- wipe it and restart from scratch. Otherwise I don't see a way to recover persistence if something go wrong and there is no BIOS to recover it for us. Together this solves a problem that appeared when 9300-8i firmware update to 16.00.10.00 somehow switched its mapping mode from Device Persistence to Enclosure/Slot without wiping the DPM table. It made HBA completely unusable, since overflowed and conflicting mapping table was unable to map any of enclosures and so devices. Also while there make some enclosure mapping errors more informative. MFC after: 1 month Sponsored by: iXsystems, Inc. --- sys/dev/mpr/mpr_mapping.c | 71 ++- sys/dev/mps/mps_mapping.c | 39 +- 2 files changed, 71 insertions(+), 39 deletions(-) diff --git a/sys/dev/mpr/mpr_mapping.c b/sys/dev/mpr/mpr_mapping.c index ef97080fb175..6c191672c24e 100644 --- a/sys/dev/mpr/mpr_mapping.c +++ b/sys/dev/mpr/mpr_mapping.c @@ -1213,9 +1213,10 @@ _mapping_get_dev_info(struct mpr_softc *sc, phy_change->is_processed = 1; mpr_dprint(sc, MPR_ERROR | MPR_MAPPING, "%s: " "failed to add the device with handle " - "0x%04x because the enclosure is not in " - "the mapping table\n", __func__, - phy_change->dev_handle); + "0x%04x because enclosure handle 0x%04x " + "is not in the mapping table\n", __func__, + phy_change->dev_handle, + topo_change->enc_handle); continue; } if (!((phy_change->device_info & @@ -1368,9 +1369,10 @@ _mapping_get_pcie_dev_info(struct mpr_softc *sc, port_change->is_processed = 1; mpr_dprint(sc, MPR_ERROR | MPR_MAPPING, "%s: " "failed to add the device with handle " - "0x%04x because the enclosure is not in " - "the mapping table\n", __func__, - port_change->dev_handle); + "0x%04x because enclosure handle 0x%04x " + "is not in the mapping table\n", __func__, + port_change->dev_handle, + topo_change->enc_handle); continue; } if (!(port_change->device_info & @@ -1609,9 +1611,10 @@ _mapping_add_new_device(struct mpr_softc *sc, phy_change->is_processed = 1; mpr_dprint(sc, MPR_ERROR | MPR_MAPPING, "%s: " "failed to add the device with handle " - "0x%04x because the enclosure is not in " - "the mapping table\n", __func__, - phy_change->dev_handle); + "0x%04x because enclosure handle 0x%04x " + "is not in the mapping table\n", __func__, + phy_change->dev_handle, + topo_change->enc_handle); continue; } @@ -1865,9 +1868,10 @@ _mapping_add_new_pcie_device(struct mpr_softc *sc, port_change->is_processed = 1; mpr_dprint(sc, MPR_ERROR | MPR_MAPPING, "%s: " "failed to add the device with handle " - "0x%04x because the enclosure is not in " - "the mapping table\n", __func__, - port_change->dev_handle); + "0x%04x because enclosure handle 0x%04x " + "is not in the mapping table\n", __func__, + port_change->dev_handle, + topo_