From cc6742f14d25c9c52a5464fe16951e172b23949b Mon Sep 17 00:00:00 2001 From: purplerain Date: Sun, 21 Jan 2024 01:41:26 +0000 Subject: [PATCH] sync with OpenBSD -current --- bin/pax/tar.c | 25 ++++-- lib/libc/sys/mimmutable.2 | 17 +--- lib/libz/compress.3 | 37 +++++++- regress/lib/libz/Makefile | 5 +- sys/arch/amd64/include/vmmvar.h | 4 +- sys/arch/arm64/dev/apldart.c | 154 +++++++++++++++++++++++--------- sys/arch/arm64/dev/apldc.c | 83 ++++++++++++++--- sys/arch/arm64/include/bus.h | 3 +- sys/sys/acct.h | 3 +- sys/uvm/uvm_map.c | 10 ++- usr.sbin/smtpd/control.c | 5 +- usr.sbin/smtpd/enqueue.c | 4 +- usr.sbin/smtpd/lka.c | 13 +-- usr.sbin/smtpd/mda.c | 27 +++--- usr.sbin/smtpd/mproc.c | 4 +- usr.sbin/smtpd/mta_session.c | 19 ++-- usr.sbin/smtpd/queue.c | 4 +- usr.sbin/smtpd/queue_proc.c | 4 +- usr.sbin/smtpd/smtp_session.c | 26 +++--- usr.sbin/smtpd/smtpd.c | 23 ++--- 20 files changed, 315 insertions(+), 155 deletions(-) diff --git a/bin/pax/tar.c b/bin/pax/tar.c index 949e9ce4e..cd64ec7ba 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tar.c,v 1.78 2023/12/27 08:29:41 jca Exp $ */ +/* $OpenBSD: tar.c,v 1.79 2024/01/20 17:34:50 jca Exp $ */ /* $NetBSD: tar.c,v 1.5 1995/03/21 09:07:49 cgd Exp $ */ /*- @@ -984,13 +984,28 @@ xheader_add_ts(struct xheader *xhdr, const char *keyword, { struct xheader_record *rec; int reclen, tmplen; + char frac[sizeof(".111222333")] = ""; char *s; + /* Only write subsecond part if non-zero */ + if (value->tv_nsec != 0) { + int n; + + n = snprintf(frac, sizeof(frac), ".%09ld", + (long)value->tv_nsec); + if (n <= 0) + return -1; + + /* Zap trailing zeros */ + for (n--; n > 1 && frac[n] == '0'; n--) + frac[n] = '\0'; + } + tmplen = MINXHDRSZ; do { reclen = tmplen; - tmplen = snprintf(NULL, 0, "%d %s=%lld.%09ld\n", reclen, - keyword, (long long)value->tv_sec, (long)value->tv_nsec); + tmplen = snprintf(NULL, 0, "%d %s=%lld%s\n", reclen, + keyword, (long long)value->tv_sec, frac); } while (tmplen >= 0 && tmplen != reclen); if (tmplen < 0) return -1; @@ -999,8 +1014,8 @@ xheader_add_ts(struct xheader *xhdr, const char *keyword, if (rec == NULL) return -1; rec->reclen = reclen; - if (asprintf(&s, "%d %s=%lld.%09ld\n", reclen, keyword, - (long long)value->tv_sec, (long)value->tv_nsec) < 0) { + if (asprintf(&s, "%d %s=%lld%s\n", reclen, keyword, + (long long)value->tv_sec, frac) < 0) { free(rec); return -1; } diff --git a/lib/libc/sys/mimmutable.2 b/lib/libc/sys/mimmutable.2 index b97783559..03fff5cc7 100644 --- a/lib/libc/sys/mimmutable.2 +++ b/lib/libc/sys/mimmutable.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mimmutable.2,v 1.3 2022/11/06 20:15:44 jmc Exp $ +.\" $OpenBSD: mimmutable.2,v 1.4 2024/01/20 13:19:37 deraadt Exp $ .\" .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)mimmutable.2 8.1 (Berkeley) 6/9/93 .\" -.Dd $Mdocdate: November 6 2022 $ +.Dd $Mdocdate: January 20 2024 $ .Dt MIMMUTABLE 2 .Os .Sh NAME @@ -81,16 +81,3 @@ The .Fn mimmutable function first appeared in .Ox 7.3 . -.Sh CAVEATS -At present, -.Xr mprotect 2 -may reduce permissions on immutable pages marked -.Dv PROT_READ | PROT_WRITE -to the less permissive -.Dv PROT_READ . -This one-way operation is permitted for an introductory period to observe how -software uses this mechanism. -It may change to require explicit mutable region annotation with -.Va __attribute__((section(".openbsd.mutable"))) -and explicit calls to -.Fn mimmutable . diff --git a/lib/libz/compress.3 b/lib/libz/compress.3 index eb25a9dc8..96db2af96 100644 --- a/lib/libz/compress.3 +++ b/lib/libz/compress.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: compress.3,v 1.25 2023/08/18 06:08:19 tb Exp $ +.\" $OpenBSD: compress.3,v 1.26 2024/01/20 11:16:27 tb Exp $ .\" .\" Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler .\" @@ -23,7 +23,7 @@ .\" .\" This page corresponds to zlib version 1.2.3 .\" -.Dd $Mdocdate: August 18 2023 $ +.Dd $Mdocdate: January 20 2024 $ .Dt COMPRESS 3 .Os .Sh NAME @@ -95,7 +95,9 @@ .Nm adler32_combine , .Nm crc32 , .Nm crc32_z , -.Nm crc32_combine +.Nm crc32_combine , +.Nm crc32_combine_gen , +.Nm crc32_combine_op .Nd zlib general purpose compression library .Sh SYNOPSIS .In zlib.h @@ -251,6 +253,8 @@ Checksum functions .Fn crc32_z "uLong adler" "const Bytef *buf" "z_size_t len" .Ft uLong .Fn crc32_combine "uLong crc1" "uLong crc2" "z_off_t len2" +.Fn crc32_combine_gen "z_off_t len2" +.Fn crc32_combine_op "uLong crc1" "uLong crc2" "uLong op" .Sh DESCRIPTION This manual page describes the .Nm zlib @@ -3433,6 +3437,33 @@ CRC-32 check values are calculated for each, crc1 and crc2. .Fn crc32_combine returns the CRC-32 check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and len2. +len2 must be non-negative. +.It Xo +.Fa uLong +.Fn crc32_combine_gen "z_off_t len2" ; +.Xc +.Pp +The +.Fn crc32_combine_gen +function returns the operator corresponding to the length len2, +to be used with +.Fn crc32_combine_op . +len2 must be non-negative. +.It Xo +.Fa uLong +.Fn crc32_combine_op "uLong crc1" "uLong crc2" "uLong op" ; +.Xc +.Pp +The +.Fn crc32_combine_op +function gives the same result as +.Fn crc32_combine , +using op in place of len2. +op is generated from len2 by +.Fn crc32_combine_gen . +This is faster than +.Fn crc32_combine +if the generated op is used more than once. .El .Sh STRUCTURES .Bd -unfilled diff --git a/regress/lib/libz/Makefile b/regress/lib/libz/Makefile index 73e787129..6f9bc4564 100644 --- a/regress/lib/libz/Makefile +++ b/regress/lib/libz/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.4 2022/03/29 23:12:30 tb Exp $ +# $OpenBSD: Makefile,v 1.5 2024/01/20 11:29:40 tb Exp $ # compile and run zlib test files from upstream # https://github.com/madler/zlib/tree/master/test @@ -14,6 +14,9 @@ CPPFLAGS= -I${.CURDIR}/../../../lib/libz WARNINGS= Yes CLEANFILES= foo.gz in out out.gz +# infcover uses the internal inflate_table, so link it statically +LDADD_infcover = -Wl,-Bstatic -lz -Wl,-Bdynamic + REGRESS_TARGETS= run-regress-example run-regress-infcover .for stategy in default filtered huffman rle diff --git a/sys/arch/amd64/include/vmmvar.h b/sys/arch/amd64/include/vmmvar.h index a0131892e..e6a35211b 100644 --- a/sys/arch/amd64/include/vmmvar.h +++ b/sys/arch/amd64/include/vmmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmmvar.h,v 1.97 2024/01/10 04:13:59 dv Exp $ */ +/* $OpenBSD: vmmvar.h,v 1.98 2024/01/20 20:11:24 mlarkin Exp $ */ /* * Copyright (c) 2014 Mike Larkin * @@ -28,7 +28,7 @@ #define VMM_MAX_NAME_LEN 64 #define VMM_MAX_VCPUS 512 #define VMM_MAX_VCPUS_PER_VM 64 -#define VMM_MAX_VM_MEM_SIZE 32L * 1024 * 1024 * 1024 /* 32 GiB */ +#define VMM_MAX_VM_MEM_SIZE 128L * 1024 * 1024 * 1024 #define VMM_MAX_NICS_PER_VM 4 #define VMM_PCI_MMIO_BAR_BASE 0xF0000000ULL diff --git a/sys/arch/arm64/dev/apldart.c b/sys/arch/arm64/dev/apldart.c index 66c2da7b5..3d285ec6c 100644 --- a/sys/arch/arm64/dev/apldart.c +++ b/sys/arch/arm64/dev/apldart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apldart.c,v 1.19 2023/12/23 18:28:38 kettenis Exp $ */ +/* $OpenBSD: apldart.c,v 1.20 2024/01/20 11:22:46 kettenis Exp $ */ /* * Copyright (c) 2021 Mark Kettenis * @@ -61,6 +61,10 @@ #define DART_T8020_TTBR_BASE 0x0200 #define DART_T8020_TTBR_VALID (1U << 31) +#define DART_T8110_PARAMS3 0x0008 +#define DART_T8110_PARAMS3_REV_MIN(x) (((x) >> 0) & 0xff) +#define DART_T8110_PARAMS3_REV_MAJ(x) (((x) >> 8) & 0xff) +#define DART_T8110_PARAMS3_VA_WIDTH(x) (((x) >> 16) & 0x3f) #define DART_T8110_PARAMS4 0x000c #define DART_T8110_PARAMS4_NSID_MASK (0x1ff << 0) #define DART_T8110_TLB_CMD 0x0080 @@ -155,6 +159,7 @@ struct apldart_softc { bus_dma_tag_t sc_dmat; int sc_node; + int sc_ias; int sc_nsid; int sc_nttbr; int sc_shift; @@ -168,6 +173,7 @@ struct apldart_softc { bus_addr_t sc_dvabase; bus_addr_t sc_dvaend; + bus_addr_t sc_dvamask; struct apldart_stream **sc_as; struct iommu_device sc_id; @@ -219,7 +225,7 @@ int apldart_t8110_intr(void *); void apldart_t8020_flush_tlb(struct apldart_softc *, int); void apldart_t8110_flush_tlb(struct apldart_softc *, int); -int apldart_load_map(struct apldart_stream *, bus_dmamap_t); +int apldart_load_map(struct apldart_stream *, bus_dmamap_t, int); void apldart_unload_map(struct apldart_stream *, bus_dmamap_t); int apldart_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t, @@ -252,7 +258,8 @@ apldart_attach(struct device *parent, struct device *self, void *aux) { struct apldart_softc *sc = (struct apldart_softc *)self; struct fdt_attach_args *faa = aux; - uint32_t config, params2, params4, tcr, ttbr; + uint64_t dva_range[2]; + uint32_t config, maj, min, params2, params3, params4, tcr, ttbr; int sid, idx; if (faa->fa_nreg < 1) { @@ -273,7 +280,9 @@ apldart_attach(struct device *parent, struct device *self, void *aux) power_domain_enable(sc->sc_node); if (OF_is_compatible(sc->sc_node, "apple,t8110-dart")) { + params3 = HREAD4(sc, DART_T8110_PARAMS3); params4 = HREAD4(sc, DART_T8110_PARAMS4); + sc->sc_ias = DART_T8110_PARAMS3_VA_WIDTH(params3); sc->sc_nsid = params4 & DART_T8110_PARAMS4_NSID_MASK; sc->sc_nttbr = 1; sc->sc_sid_enable_base = DART_T8110_SID_ENABLE_BASE; @@ -284,7 +293,10 @@ apldart_attach(struct device *parent, struct device *self, void *aux) sc->sc_ttbr_base = DART_T8110_TTBR_BASE; sc->sc_ttbr_valid = DART_T8110_TTBR_VALID; sc->sc_flush_tlb = apldart_t8110_flush_tlb; + maj = DART_T8110_PARAMS3_REV_MAJ(params3); + min = DART_T8110_PARAMS3_REV_MIN(params3); } else { + sc->sc_ias = 32; sc->sc_nsid = 16; sc->sc_nttbr = 4; sc->sc_sid_enable_base = DART_T8020_SID_ENABLE; @@ -295,6 +307,7 @@ apldart_attach(struct device *parent, struct device *self, void *aux) sc->sc_ttbr_base = DART_T8020_TTBR_BASE; sc->sc_ttbr_valid = DART_T8020_TTBR_VALID; sc->sc_flush_tlb = apldart_t8020_flush_tlb; + maj = min = 0; } if (OF_is_compatible(sc->sc_node, "apple,t6000-dart") || @@ -312,6 +325,19 @@ apldart_attach(struct device *parent, struct device *self, void *aux) sc->sc_locked = 1; } + if (maj != 0 || min != 0) + printf(" rev %d.%d", maj, min); + + printf(": %d bits", sc->sc_ias); + + /* + * Anything over 36 bits requires 4-level page tables which we + * don't implement yet. So limit to 36 bits. + */ + if (sc->sc_ias > 36) + sc->sc_ias = 36; + sc->sc_dvamask = (1ULL << sc->sc_ias) - 1; + /* * Resetting the DART used for the display controller will * kill the framebuffer. This should be the only DART that @@ -346,25 +372,33 @@ apldart_attach(struct device *parent, struct device *self, void *aux) !sc->sc_locked && !sc->sc_translating) { for (sid = 0; sid < sc->sc_nsid; sid++) HWRITE4(sc, DART_TCR(sc, sid), sc->sc_tcr_bypass); - printf(": bypass\n"); + printf(", bypass\n"); return; } if (sc->sc_locked) - printf(": locked\n"); + printf(", locked\n"); else if (sc->sc_translating) - printf(": translating\n"); + printf(", translating\n"); else printf("\n"); - /* - * Skip the first page to help catching bugs where a device is - * doing DMA to/from address zero because we didn't properly - * set up the DMA transfer. Skip the last page to avoid using - * the address reserved for MSIs. - */ - sc->sc_dvabase = DART_PAGE_SIZE; - sc->sc_dvaend = 0xffffffff - DART_PAGE_SIZE; + if (OF_getpropint64array(sc->sc_node, "apple,dma-range", + dva_range, sizeof(dva_range)) == sizeof(dva_range)) { + sc->sc_dvabase = dva_range[0]; + sc->sc_dvaend = dva_range[0] + dva_range[1] - 1; + } else { + /* + * Restrict ourselves to 32-bit addresses to cater for + * devices that don't do 64-bit DMA. Skip the first + * page to help catching bugs where a device is doing + * DMA to/from address zero because we didn't properly + * set up the DMA transfer. Skip the last page to + * avoid using the address reserved for MSIs. + */ + sc->sc_dvabase = DART_PAGE_SIZE; + sc->sc_dvaend = 0xffffffff - DART_PAGE_SIZE; + } if (!sc->sc_locked && !sc->sc_translating) { /* Disable translations. */ @@ -430,7 +464,7 @@ apldart_resume(struct apldart_softc *sc) return; } - ntte = howmany(sc->sc_dvaend, DART_PAGE_SIZE); + ntte = howmany((sc->sc_dvaend & sc->sc_dvamask), DART_PAGE_SIZE); nl2 = howmany(ntte, DART_PAGE_SIZE / sizeof(uint64_t)); nl1 = howmany(nl2, DART_PAGE_SIZE / sizeof(uint64_t)); @@ -495,7 +529,7 @@ apldart_init_locked_stream(struct apldart_stream *as) uint32_t ttbr; vaddr_t startva, endva, va; paddr_t pa; - bus_addr_t dva, dvaend; + bus_addr_t dva, dvaend, dvabase; volatile uint64_t *l1; int nl1, nl2, ntte; int idx; @@ -510,15 +544,23 @@ apldart_init_locked_stream(struct apldart_stream *as) nl2 = idx * (DART_PAGE_SIZE / sizeof(uint64_t)); ntte = nl2 * (DART_PAGE_SIZE / sizeof(uint64_t)); - dvaend = (bus_addr_t)ntte * DART_PAGE_SIZE; + dvabase = sc->sc_dvabase & ~sc->sc_dvamask; + dvaend = dvabase + (bus_addr_t)ntte * DART_PAGE_SIZE; if (dvaend < sc->sc_dvaend) sc->sc_dvaend = dvaend; - as->as_dvamap = extent_create(sc->sc_dev.dv_xname, - sc->sc_dvabase, sc->sc_dvaend, M_DEVBUF, - NULL, 0, EX_WAITOK | EX_NOCOALESCE); + as->as_dvamap = extent_create(sc->sc_dev.dv_xname, 0, ULONG_MAX, + M_DEVBUF, NULL, 0, EX_WAITOK | EX_NOCOALESCE); + if (sc->sc_dvabase > 0) { + extent_alloc_region(as->as_dvamap, 0, sc->sc_dvabase, + EX_WAITOK); + } + if (sc->sc_dvaend < ULONG_MAX) { + extent_alloc_region(as->as_dvamap, sc->sc_dvaend + 1, + ULONG_MAX - sc->sc_dvaend, EX_WAITOK); + } - ntte = howmany(sc->sc_dvaend, DART_PAGE_SIZE); + ntte = howmany((sc->sc_dvaend & sc->sc_dvamask), DART_PAGE_SIZE); nl2 = howmany(ntte, DART_PAGE_SIZE / sizeof(uint64_t)); nl1 = howmany(nl2, DART_PAGE_SIZE / sizeof(uint64_t)); @@ -545,12 +587,8 @@ apldart_init_locked_stream(struct apldart_stream *as) dva = idx * (DART_PAGE_SIZE / sizeof(uint64_t)) * DART_PAGE_SIZE; dvaend = dva + DART_PAGE_SIZE * DART_PAGE_SIZE - 1; - if (dva < sc->sc_dvabase) - dva = sc->sc_dvabase; - if (dvaend > sc->sc_dvaend) - dvaend = sc->sc_dvaend; - extent_alloc_region(as->as_dvamap, dva, - dvaend - dva + 1, EX_CONFLICTOK); + extent_alloc_region(as->as_dvamap, dvabase + dva, + dvaend - dva + 1, EX_WAITOK | EX_CONFLICTOK); } else { as->as_l2[idx] = apldart_dmamem_alloc(sc->sc_dmat, DART_PAGE_SIZE, DART_PAGE_SIZE); @@ -593,9 +631,16 @@ apldart_alloc_stream(struct apldart_softc *sc, int sid) return as; } - as->as_dvamap = extent_create(sc->sc_dev.dv_xname, - sc->sc_dvabase, sc->sc_dvaend, M_DEVBUF, - NULL, 0, EX_WAITOK | EX_NOCOALESCE); + as->as_dvamap = extent_create(sc->sc_dev.dv_xname, 0, ULONG_MAX, + M_DEVBUF, NULL, 0, EX_WAITOK | EX_NOCOALESCE); + if (sc->sc_dvabase > 0) { + extent_alloc_region(as->as_dvamap, 0, sc->sc_dvabase, + EX_WAITOK); + } + if (sc->sc_dvaend < ULONG_MAX) { + extent_alloc_region(as->as_dvamap, sc->sc_dvaend + 1, + ULONG_MAX - sc->sc_dvaend, EX_WAITOK); + } /* * Build translation tables. We pre-allocate the translation @@ -603,7 +648,7 @@ apldart_alloc_stream(struct apldart_softc *sc, int sid) * worry about growing them in an mpsafe manner later. */ - ntte = howmany(sc->sc_dvaend, DART_PAGE_SIZE); + ntte = howmany((sc->sc_dvaend & sc->sc_dvamask), DART_PAGE_SIZE); nl2 = howmany(ntte, DART_PAGE_SIZE / sizeof(uint64_t)); nl1 = howmany(nl2, DART_PAGE_SIZE / sizeof(uint64_t)); @@ -730,7 +775,7 @@ apldart_t8110_flush_tlb(struct apldart_softc *sc, int sid) volatile uint64_t * apldart_lookup_tte(struct apldart_stream *as, bus_addr_t dva) { - int idx = dva / DART_PAGE_SIZE; + int idx = (dva & as->as_sc->sc_dvamask) / DART_PAGE_SIZE; int l2_idx = idx / (DART_PAGE_SIZE / sizeof(uint64_t)); int tte_idx = idx % (DART_PAGE_SIZE / sizeof(uint64_t)); volatile uint64_t *l2; @@ -740,7 +785,7 @@ apldart_lookup_tte(struct apldart_stream *as, bus_addr_t dva) } int -apldart_load_map(struct apldart_stream *as, bus_dmamap_t map) +apldart_load_map(struct apldart_stream *as, bus_dmamap_t map, int flags) { struct apldart_softc *sc = as->as_sc; struct apldart_map_state *ams = map->_dm_cookie; @@ -757,8 +802,18 @@ apldart_load_map(struct apldart_stream *as, bus_dmamap_t map) len = apldart_round_page(map->dm_segs[seg].ds_len + off); mtx_enter(&as->as_dvamap_mtx); - error = extent_alloc_with_descr(as->as_dvamap, len, - DART_PAGE_SIZE, 0, 0, EX_NOWAIT, &ams[seg].ams_er, &dva); + if (flags & BUS_DMA_FIXED) { + dva = apldart_trunc_page(map->dm_segs[seg].ds_addr); + /* XXX truncate because "apple,dma-range" mismatch */ + if (dva > sc->sc_dvaend) + dva &= sc->sc_dvamask; + error = extent_alloc_region_with_descr(as->as_dvamap, + dva, len, EX_NOWAIT, &ams[seg].ams_er); + } else { + error = extent_alloc_with_descr(as->as_dvamap, len, + DART_PAGE_SIZE, 0, 0, EX_NOWAIT, &ams[seg].ams_er, + &dva); + } mtx_leave(&as->as_dvamap_mtx); if (error) { apldart_unload_map(as, map); @@ -887,7 +942,7 @@ apldart_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, if (error) return error; - error = apldart_load_map(as, map); + error = apldart_load_map(as, map, flags); if (error) sc->sc_dmat->_dmamap_unload(sc->sc_dmat, map); @@ -907,7 +962,7 @@ apldart_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, if (error) return error; - error = apldart_load_map(as, map); + error = apldart_load_map(as, map, flags); if (error) sc->sc_dmat->_dmamap_unload(sc->sc_dmat, map); @@ -927,7 +982,7 @@ apldart_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, if (error) return error; - error = apldart_load_map(as, map); + error = apldart_load_map(as, map, flags); if (error) sc->sc_dmat->_dmamap_unload(sc->sc_dmat, map); @@ -940,14 +995,25 @@ apldart_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, { struct apldart_stream *as = t->_cookie; struct apldart_softc *sc = as->as_sc; - int error; + int i, error; - error = sc->sc_dmat->_dmamap_load_raw(sc->sc_dmat, map, - segs, nsegs, size, flags); - if (error) - return error; + if (flags & BUS_DMA_FIXED) { + if (map->dm_nsegs != nsegs) + return EINVAL; + for (i = 0; i < nsegs; i++) { + if (map->dm_segs[i].ds_len != segs[i].ds_len) + return EINVAL; + map->dm_segs[i]._ds_paddr = segs[i].ds_addr; + map->dm_segs[i]._ds_vaddr = segs[i]._ds_vaddr; + } + } else { + error = sc->sc_dmat->_dmamap_load_raw(sc->sc_dmat, map, + segs, nsegs, size, flags); + if (error) + return error; + } - error = apldart_load_map(as, map); + error = apldart_load_map(as, map, flags); if (error) sc->sc_dmat->_dmamap_unload(sc->sc_dmat, map); diff --git a/sys/arch/arm64/dev/apldc.c b/sys/arch/arm64/dev/apldc.c index 96a4f3d14..8f755e8be 100644 --- a/sys/arch/arm64/dev/apldc.c +++ b/sys/arch/arm64/dev/apldc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apldc.c,v 1.11 2023/09/22 01:10:43 jsg Exp $ */ +/* $OpenBSD: apldc.c,v 1.12 2024/01/20 08:00:59 kettenis Exp $ */ /* * Copyright (c) 2022 Mark Kettenis * @@ -299,6 +299,12 @@ struct apldchidev_softc { uint8_t sc_mtdesc[APLDCHIDEV_DESC_MAX]; size_t sc_mtdesclen; int sc_mt_ready; + int sc_x_min; + int sc_x_max; + int sc_y_min; + int sc_y_max; + int sc_h_res; + int sc_v_res; struct apldchidev_gpio sc_gpio[APLDCHIDEV_NUM_GPIOS]; u_int sc_ngpios; @@ -307,6 +313,8 @@ struct apldchidev_softc { uint8_t sc_cmd_iface; uint8_t sc_cmd_seq; + uint8_t sc_data[APLDCHIDEV_DESC_MAX]; + size_t sc_data_len; uint32_t sc_retcode; int sc_busy; }; @@ -555,10 +563,20 @@ struct mtp_gpio_ack { uint8_t cmd[512]; } __packed; +struct mtp_dim { + uint32_t width; + uint32_t height; + int16_t x_min; + int16_t y_min; + int16_t x_max; + int16_t y_max; +}; + #define MTP_CMD_RESET_INTERFACE 0x40 #define MTP_CMD_SEND_FIRMWARE 0x95 #define MTP_CMD_ENABLE_INTERFACE 0xb4 #define MTP_CMD_ACK_GPIO_CMD 0xa1 +#define MTP_CMD_GET_DIMENSIONS 0xd9 void apldchidev_handle_gpio_req(struct apldchidev_softc *sc, uint8_t iface, @@ -770,6 +788,13 @@ apldchidev_rx_intr(void *arg) printf("%s: got ack with unexpected seq\n", sc->sc_dev.dv_xname); } + if (MTP_REQ(shdr->flags) == MTP_REQ_GET_REPORT && + shdr->len <= sizeof(sc->sc_data)) { + memcpy(sc->sc_data, (shdr + 1), shdr->len); + sc->sc_data_len = shdr->len; + } else { + sc->sc_data_len = 0; + } sc->sc_retcode = shdr->retcode; sc->sc_busy = 0; wakeup(sc); @@ -1021,6 +1046,30 @@ apldchidev_load_firmware(struct apldchidev_softc *sc, const char *name) return 0; } +void +apldchidev_get_dimensions(struct apldchidev_softc *sc) +{ + uint8_t cmd[1] = { MTP_CMD_GET_DIMENSIONS }; + struct mtp_dim dim; + uint8_t flags; + + flags = MTP_GROUP_CMD << MTP_GROUP_SHIFT; + flags |= MTP_REQ_GET_REPORT << MTP_REQ_SHIFT; + apldchidev_cmd(sc, sc->sc_iface_mt, flags, cmd, sizeof(cmd)); + apldchidev_wait(sc); + + if (sc->sc_retcode == 0 && sc->sc_data_len == sizeof(dim) + 1 && + sc->sc_data[0] == MTP_CMD_GET_DIMENSIONS) { + memcpy(&dim, &sc->sc_data[1], sizeof(dim)); + sc->sc_x_min = dim.x_min; + sc->sc_x_max = dim.x_max; + sc->sc_y_min = dim.y_min; + sc->sc_y_max = dim.y_max; + sc->sc_h_res = (100 * (dim.x_max - dim.x_min)) / dim.width; + sc->sc_v_res = (100 * (dim.y_max - dim.y_min)) / dim.height; + } +} + void apldchidev_attachhook(struct device *self) { @@ -1059,6 +1108,8 @@ apldchidev_attachhook(struct device *self) if (error) goto out; + apldchidev_get_dimensions(sc); + aa.aa_name = "multi-touch"; aa.aa_desc = sc->sc_mtdesc; aa.aa_desclen = sc->sc_mtdesclen; @@ -1277,17 +1328,18 @@ struct ubcmtp_finger { #define DEFAULT_PRESSURE 40 struct apldcms_softc { - struct device sc_dev; - struct device *sc_wsmousedev; + struct device sc_dev; + struct apldchidev_softc *sc_hidev; + struct device *sc_wsmousedev; - int sc_enabled; + int sc_enabled; - int tp_offset; - int tp_fingerpad; + int tp_offset; + int tp_fingerpad; - struct mtpoint frame[UBCMTP_MAX_FINGERS]; - int contacts; - int btn; + struct mtpoint frame[UBCMTP_MAX_FINGERS]; + int contacts; + int btn; }; int apldcms_enable(void *); @@ -1331,6 +1383,8 @@ apldcms_attach(struct device *parent, struct device *self, void *aux) struct apldcms_softc *sc = (struct apldcms_softc *)self; struct wsmousedev_attach_args aa; + sc->sc_hidev = (struct apldchidev_softc *)parent; + printf("\n"); sc->tp_offset = UBCMTP_TYPE4_TPOFF; @@ -1349,13 +1403,14 @@ apldcms_configure(struct apldcms_softc *sc) { struct wsmousehw *hw = wsmouse_get_hw(sc->sc_wsmousedev); - /* The values below are for the MacBookPro17,1 */ hw->type = WSMOUSE_TYPE_TOUCHPAD; hw->hw_type = WSMOUSEHW_CLICKPAD; - hw->x_min = -6046; - hw->x_max = 6536; - hw->y_min = -164; - hw->y_max = 7439; + hw->x_min = sc->sc_hidev->sc_x_min; + hw->x_max = sc->sc_hidev->sc_x_max; + hw->y_min = sc->sc_hidev->sc_y_min; + hw->y_max = sc->sc_hidev->sc_y_max; + hw->h_res = sc->sc_hidev->sc_h_res; + hw->v_res = sc->sc_hidev->sc_v_res; hw->mt_slots = UBCMTP_MAX_FINGERS; hw->flags = WSMOUSEHW_MT_TRACKING; diff --git a/sys/arch/arm64/include/bus.h b/sys/arch/arm64/include/bus.h index 49b5e42a7..84464eb45 100644 --- a/sys/arch/arm64/include/bus.h +++ b/sys/arch/arm64/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.9 2023/01/21 10:30:11 kettenis Exp $ */ +/* $OpenBSD: bus.h,v 1.10 2024/01/20 11:22:46 kettenis Exp $ */ /* * Copyright (c) 2003-2004 Opsycon AB Sweden. All rights reserved. * @@ -335,6 +335,7 @@ bus_space_barrier(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, #define BUS_DMA_ZERO 0x0800 /* zero memory in dmamem_alloc */ #define BUS_DMA_NOCACHE 0x1000 #define BUS_DMA_64BIT 0x2000 /* device handles 64bit dva */ +#define BUS_DMA_FIXED 0x4000 /* place mapping at specified dva */ /* Forwards needed by prototypes below. */ struct mbuf; diff --git a/sys/sys/acct.h b/sys/sys/acct.h index bd2ec2470..dba7b5ed6 100644 --- a/sys/sys/acct.h +++ b/sys/sys/acct.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acct.h,v 1.14 2023/12/11 00:39:43 deraadt Exp $ */ +/* $OpenBSD: acct.h,v 1.15 2024/01/20 12:16:55 deraadt Exp $ */ /* $NetBSD: acct.h,v 1.16 1995/03/26 20:23:52 jtc Exp $ */ /*- @@ -66,7 +66,6 @@ struct acct { #define APLEDGE 0x00000020 /* killed due to pledge violation */ #define ATRAP 0x00000040 /* memory access violation */ #define AUNVEIL 0x00000080 /* unveil access violation */ -#define AEXECVE 0x00000100 /* execve from wrong libc stub */ #define APINSYS 0x00000200 /* syscall pin violation */ u_int32_t ac_flag; /* accounting flags */ }; diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 786a7d690..7accb1b1c 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.c,v 1.320 2024/01/16 19:05:01 deraadt Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.323 2024/01/21 00:26:14 deraadt Exp $ */ /* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */ /* @@ -3144,13 +3144,15 @@ uvm_map_protect(struct vm_map *map, vaddr_t start, vaddr_t end, if (iter->start == iter->end || UVM_ET_ISHOLE(iter)) continue; - if (checkimmutable && - (iter->etype & UVM_ET_IMMUTABLE)) { + if (checkimmutable && (iter->etype & UVM_ET_IMMUTABLE)) { +#ifdef SMALL_KERNEL if (iter->protection == (PROT_READ | PROT_WRITE) && new_prot == PROT_READ) { /* Permit RW to R as a data-locking mechanism */ ; - } else { + } else +#endif + { error = EPERM; goto out; } diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index 8e50393b0..89c8c43f9 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.130 2023/05/31 16:51:46 op Exp $ */ +/* $OpenBSD: control.c,v 1.131 2024/01/20 09:01:03 claudio Exp $ */ /* * Copyright (c) 2012 Gilles Chehade @@ -107,7 +107,8 @@ control_imsg(struct mproc *p, struct imsg *imsg) c = tree_get(&ctl_conns, imsg->hdr.peerid); if (c == NULL) return; - m_compose(&c->mproc, IMSG_CTL_OK, 0, 0, imsg->fd, NULL, 0); + m_compose(&c->mproc, IMSG_CTL_OK, 0, 0, imsg_get_fd(imsg), + NULL, 0); return; case IMSG_STAT_INCREMENT: diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c index 95e6c04a4..51616d0d5 100644 --- a/usr.sbin/smtpd/enqueue.c +++ b/usr.sbin/smtpd/enqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enqueue.c,v 1.121 2023/05/31 16:51:46 op Exp $ */ +/* $OpenBSD: enqueue.c,v 1.122 2024/01/20 09:01:03 claudio Exp $ */ /* * Copyright (c) 2005 Henning Brauer @@ -808,7 +808,7 @@ open_connection(void) errx(1, "unexpected imsg reply type"); } - fd = imsg.fd; + fd = imsg_get_fd(&imsg); imsg_free(&imsg); break; diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index 49a18d6d2..30c93afbd 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.247 2021/06/14 17:58:15 eric Exp $ */ +/* $OpenBSD: lka.c,v 1.248 2024/01/20 09:01:03 claudio Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -47,7 +47,7 @@ static void lka_imsg(struct mproc *p, struct imsg *imsg) { struct table *table; - int ret; + int ret, fd; struct sockaddr_storage ss; struct userinfo userinfo; struct addrname addrname; @@ -305,7 +305,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg) return; case IMSG_LKA_OPEN_FORWARD: - lka_session_forward_reply(imsg->data, imsg->fd); + lka_session_forward_reply(imsg->data, imsg_get_fd(imsg)); return; case IMSG_LKA_AUTHENTICATE: @@ -351,7 +351,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg) m_add_string(p, procname); m_close(p); - lka_proc_forked(procname, subsystems, imsg->fd); + lka_proc_forked(procname, subsystems, imsg_get_fd(imsg)); return; case IMSG_LKA_PROCESSOR_ERRFD: @@ -359,8 +359,9 @@ lka_imsg(struct mproc *p, struct imsg *imsg) m_get_string(&m, &procname); m_end(&m); - lka_proc_errfd(procname, imsg->fd); - shutdown(imsg->fd, SHUT_WR); + fd = imsg_get_fd(imsg); + lka_proc_errfd(procname, fd); + shutdown(fd, SHUT_WR); return; case IMSG_REPORT_SMTP_LINK_CONNECT: diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c index b131f9d20..e9da77095 100644 --- a/usr.sbin/smtpd/mda.c +++ b/usr.sbin/smtpd/mda.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mda.c,v 1.146 2023/05/31 16:51:46 op Exp $ */ +/* $OpenBSD: mda.c,v 1.147 2024/01/20 09:01:03 claudio Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -113,7 +113,7 @@ mda_imsg(struct mproc *p, struct imsg *imsg) uint64_t reqid; size_t sz; char out[256], buf[LINE_MAX]; - int n; + int n, fd; enum lka_resp_status status; enum mda_resp_status mda_status; int mda_sysexit; @@ -196,7 +196,8 @@ mda_imsg(struct mproc *p, struct imsg *imsg) s = tree_xget(&sessions, reqid); e = s->evp; - if (imsg->fd == -1) { + fd = imsg_get_fd(imsg); + if (fd == -1) { log_debug("debug: mda: cannot get message fd"); mda_queue_tempfail(e->id, "Cannot get message fd", @@ -208,11 +209,11 @@ mda_imsg(struct mproc *p, struct imsg *imsg) log_debug("debug: mda: got message fd %d " "for session %016"PRIx64 " evpid %016"PRIx64, - imsg->fd, s->id, e->id); + fd, s->id, e->id); - if ((s->datafp = fdopen(imsg->fd, "r")) == NULL) { + if ((s->datafp = fdopen(fd, "r")) == NULL) { log_warn("warn: mda: fdopen"); - close(imsg->fd); + close(fd); mda_queue_tempfail(e->id, "fdopen failed", ESC_OTHER_MAIL_SYSTEM_STATUS); mda_log(e, "TempFail", "fdopen failed"); @@ -283,7 +284,8 @@ mda_imsg(struct mproc *p, struct imsg *imsg) s = tree_xget(&sessions, reqid); e = s->evp; - if (imsg->fd == -1) { + fd = imsg_get_fd(imsg); + if (fd == -1) { log_warn("warn: mda: fail to retrieve mda fd"); mda_queue_tempfail(e->id, "Cannot get mda fd", ESC_OTHER_MAIL_SYSTEM_STATUS); @@ -294,10 +296,10 @@ mda_imsg(struct mproc *p, struct imsg *imsg) log_debug("debug: mda: got mda fd %d " "for session %016"PRIx64 " evpid %016"PRIx64, - imsg->fd, s->id, s->evp->id); + fd, s->id, s->evp->id); - io_set_nonblocking(imsg->fd); - io_set_fd(s->io, imsg->fd); + io_set_nonblocking(fd); + io_set_fd(s->io, fd); io_set_write(s->io); return; @@ -315,8 +317,9 @@ mda_imsg(struct mproc *p, struct imsg *imsg) * Grab last line of mda stdout/stderr if available. */ out[0] = '\0'; - if (imsg->fd != -1) - mda_getlastline(imsg->fd, out, sizeof(out)); + fd = imsg_get_fd(imsg); + if (fd != -1) + mda_getlastline(fd, out, sizeof(out)); /* * Choose between parent's description of error and diff --git a/usr.sbin/smtpd/mproc.c b/usr.sbin/smtpd/mproc.c index 0beb00c81..95851a2e9 100644 --- a/usr.sbin/smtpd/mproc.c +++ b/usr.sbin/smtpd/mproc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mproc.c,v 1.39 2021/06/14 17:58:15 eric Exp $ */ +/* $OpenBSD: mproc.c,v 1.40 2024/01/20 09:01:03 claudio Exp $ */ /* * Copyright (c) 2012 Eric Faurot @@ -223,7 +223,7 @@ void m_forward(struct mproc *p, struct imsg *imsg) { imsg_compose(&p->imsgbuf, imsg->hdr.type, imsg->hdr.peerid, - imsg->hdr.pid, imsg->fd, imsg->data, + imsg->hdr.pid, imsg_get_fd(imsg), imsg->data, imsg->hdr.len - sizeof(imsg->hdr)); if (imsg->hdr.type != IMSG_STAT_DECREMENT && diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c index 070283d70..31a1546e9 100644 --- a/usr.sbin/smtpd/mta_session.c +++ b/usr.sbin/smtpd/mta_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta_session.c,v 1.150 2024/01/03 08:11:15 op Exp $ */ +/* $OpenBSD: mta_session.c,v 1.151 2024/01/20 09:01:03 claudio Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -269,7 +269,7 @@ mta_session_imsg(struct mproc *p, struct imsg *imsg) struct msg m; uint64_t reqid; const char *name; - int status; + int status, fd; struct stat sb; switch (imsg->hdr.type) { @@ -279,14 +279,15 @@ mta_session_imsg(struct mproc *p, struct imsg *imsg) m_get_id(&m, &reqid); m_end(&m); + fd = imsg_get_fd(imsg); s = mta_tree_pop(&wait_fd, reqid); if (s == NULL) { - if (imsg->fd != -1) - close(imsg->fd); + if (fd != -1) + close(fd); return; } - if (imsg->fd == -1) { + if (fd == -1) { log_debug("debug: mta: failed to obtain msg fd"); mta_flush_task(s, IMSG_MTA_DELIVERY_TEMPFAIL, "Could not get message fd", 0, 0); @@ -295,12 +296,12 @@ mta_session_imsg(struct mproc *p, struct imsg *imsg) } if ((s->ext & MTA_EXT_SIZE) && s->ext_size != 0) { - if (fstat(imsg->fd, &sb) == -1) { + if (fstat(fd, &sb) == -1) { log_debug("debug: mta: failed to stat msg fd"); mta_flush_task(s, IMSG_MTA_DELIVERY_TEMPFAIL, "Could not stat message fd", 0, 0); mta_enter_state(s, MTA_READY); - close(imsg->fd); + close(fd); return; } if (sb.st_size > (off_t)s->ext_size) { @@ -308,12 +309,12 @@ mta_session_imsg(struct mproc *p, struct imsg *imsg) mta_flush_task(s, IMSG_MTA_DELIVERY_PERMFAIL, "message too large for peer", 0, 0); mta_enter_state(s, MTA_READY); - close(imsg->fd); + close(fd); return; } } - s->datafp = fdopen(imsg->fd, "r"); + s->datafp = fdopen(fd, "r"); if (s->datafp == NULL) fatal("mta: fdopen"); diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index ad7980d57..8aba55576 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.195 2023/05/31 16:51:46 op Exp $ */ +/* $OpenBSD: queue.c,v 1.196 2024/01/20 09:01:03 claudio Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -126,7 +126,7 @@ queue_imsg(struct mproc *p, struct imsg *imsg) return; case IMSG_QUEUE_SMTP_SESSION: - bounce_fd(imsg->fd); + bounce_fd(imsg_get_fd(imsg)); return; case IMSG_LKA_ENVELOPE_SUBMIT: diff --git a/usr.sbin/smtpd/queue_proc.c b/usr.sbin/smtpd/queue_proc.c index 4f3dd4de1..a3601e5dd 100644 --- a/usr.sbin/smtpd/queue_proc.c +++ b/usr.sbin/smtpd/queue_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_proc.c,v 1.9 2021/06/14 17:58:16 eric Exp $ */ +/* $OpenBSD: queue_proc.c,v 1.10 2024/01/20 09:01:03 claudio Exp $ */ /* * Copyright (c) 2013 Eric Faurot @@ -170,7 +170,7 @@ queue_proc_message_fd_r(uint32_t msgid) queue_proc_call(); queue_proc_end(); - return (imsg.fd); + return (imsg_get_fd(&imsg)); } static int diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index bc048cfe3..94763e6d0 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.439 2024/01/03 08:11:15 op Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.440 2024/01/20 09:01:03 claudio Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -702,7 +702,7 @@ smtp_session_imsg(struct mproc *p, struct imsg *imsg) const char *line, *helo; uint64_t reqid, evpid; uint32_t msgid; - int status, success; + int status, success, fd; int filter_response; const char *filter_param; uint8_t i; @@ -802,19 +802,20 @@ smtp_session_imsg(struct mproc *p, struct imsg *imsg) m_get_int(&m, &success); m_end(&m); + fd = imsg_get_fd(imsg); s = tree_xpop(&wait_queue_fd, reqid); - if (!success || imsg->fd == -1) { - if (imsg->fd != -1) - close(imsg->fd); + if (!success || fd == -1) { + if (fd != -1) + close(fd); smtp_reply(s, "421 %s Temporary Error", esc_code(ESC_STATUS_TEMPFAIL, ESC_OTHER_MAIL_SYSTEM_STATUS)); smtp_enter_state(s, STATE_QUIT); return; } - log_debug("smtp: %p: fd %d from queue", s, imsg->fd); + log_debug("smtp: %p: fd %d from queue", s, fd); - if (smtp_message_fd(s->tx, imsg->fd)) { + if (smtp_message_fd(s->tx, fd)) { if (!SESSION_DATA_FILTERED(s)) smtp_message_begin(s->tx); else @@ -828,19 +829,20 @@ smtp_session_imsg(struct mproc *p, struct imsg *imsg) m_get_int(&m, &success); m_end(&m); + fd = imsg_get_fd(imsg); s = tree_xpop(&wait_filter_fd, reqid); - if (!success || imsg->fd == -1) { - if (imsg->fd != -1) - close(imsg->fd); + if (!success || fd == -1) { + if (fd != -1) + close(fd); smtp_reply(s, "421 %s Temporary Error", esc_code(ESC_STATUS_TEMPFAIL, ESC_OTHER_MAIL_SYSTEM_STATUS)); smtp_enter_state(s, STATE_QUIT); return; } - log_debug("smtp: %p: fd %d from lka", s, imsg->fd); + log_debug("smtp: %p: fd %d from lka", s, fd); - smtp_filter_fd(s->tx, imsg->fd); + smtp_filter_fd(s->tx, fd); smtp_message_begin(s->tx); return; diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index d663efcfa..cc9ad7a17 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.346 2023/06/18 17:28:42 op Exp $ */ +/* $OpenBSD: smtpd.c,v 1.347 2024/01/20 09:01:03 claudio Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -917,7 +917,8 @@ setup_proc(void) env->sc_queue_key = strdup(imsg.data); break; case IMSG_SETUP_PEER: - setup_peer(imsg.hdr.peerid, imsg.hdr.pid, imsg.fd); + setup_peer(imsg.hdr.peerid, imsg.hdr.pid, + imsg_get_fd(&imsg)); break; case IMSG_SETUP_DONE: setup = 0; @@ -1866,19 +1867,11 @@ log_imsg(int to, int from, struct imsg *imsg) if (to == PROC_CONTROL && imsg->hdr.type == IMSG_STAT_SET) return; - if (imsg->fd != -1) - log_trace(TRACE_IMSG, "imsg: %s <- %s: %s (len=%zu, fd=%d)", - proc_name(to), - proc_name(from), - imsg_to_str(imsg->hdr.type), - imsg->hdr.len - IMSG_HEADER_SIZE, - imsg->fd); - else - log_trace(TRACE_IMSG, "imsg: %s <- %s: %s (len=%zu)", - proc_name(to), - proc_name(from), - imsg_to_str(imsg->hdr.type), - imsg->hdr.len - IMSG_HEADER_SIZE); + log_trace(TRACE_IMSG, "imsg: %s <- %s: %s (len=%zu)", + proc_name(to), + proc_name(from), + imsg_to_str(imsg->hdr.type), + imsg->hdr.len - IMSG_HEADER_SIZE); } const char *