svn commit: r313006 - in head: sys/conf sys/libkern sys/libkern/x86 sys/sys tests/sys/kern
Author: cem Date: Tue Jan 31 03:26:32 2017 New Revision: 313006 URL: https://svnweb.freebsd.org/changeset/base/313006 Log: calculate_crc32c: Add SSE4.2 implementation on x86 Derived from an implementation by Mark Adler. The fast loop performs three simultaneous CRCs over subsets of the data before composing them. This takes advantage of certain properties of the CRC32 implementation in Intel hardware. (The CRC instruction takes 1 cycle but has 2-3 cycles of latency.) The CRC32 instruction does not manipulate FPU state. i386 does not have the crc32q instruction, so avoid it there. Otherwise the implementation is identical to amd64. Add basic userland tests to verify correctness on a variety of inputs. PR: 216467 Reported by: Ben RUBSON Reviewed by: kib@, markj@ (earlier version) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D9342 Added: head/sys/libkern/x86/ head/sys/libkern/x86/crc32_sse42.c (contents, props changed) head/tests/sys/kern/libkern_crc32.c (contents, props changed) Modified: head/sys/conf/files.amd64 head/sys/conf/files.i386 head/sys/libkern/crc32.c head/sys/sys/libkern.h head/tests/sys/kern/Makefile Modified: head/sys/conf/files.amd64 == --- head/sys/conf/files.amd64 Tue Jan 31 01:55:29 2017(r313005) +++ head/sys/conf/files.amd64 Tue Jan 31 03:26:32 2017(r313006) @@ -593,6 +593,11 @@ compat/ndis/subr_pe.c optionalndisapi compat/ndis/subr_usbd.coptionalndisapi pci compat/ndis/winx64_wrap.S optionalndisapi pci # +crc32_sse42.o standard\ + dependency "$S/libkern/x86/crc32_sse42.c" \ + compile-with"${CC} -c ${CFLAGS:N-nostdinc} ${WERROR} ${PROF} -msse4 ${.IMPSRC}" \ + no-implicit-rule\ + clean "crc32_sse42.o" libkern/memmove.c standard libkern/memset.c standard # Modified: head/sys/conf/files.i386 == --- head/sys/conf/files.i386Tue Jan 31 01:55:29 2017(r313005) +++ head/sys/conf/files.i386Tue Jan 31 03:26:32 2017(r313006) @@ -554,6 +554,11 @@ kern/kern_clocksource.cstandard kern/imgact_aout.c optional compat_aout kern/imgact_gzip.c optional gzip kern/subr_sfbuf.c standard +crc32_sse42.o standard\ + dependency "$S/libkern/x86/crc32_sse42.c" \ + compile-with"${CC} -c ${CFLAGS:N-nostdinc} ${WERROR} ${PROF} -msse4 ${.IMPSRC}" \ + no-implicit-rule\ + clean "crc32_sse42.o" libkern/divdi3.c standard libkern/ffsll.cstandard libkern/flsll.cstandard Modified: head/sys/libkern/crc32.c == --- head/sys/libkern/crc32.cTue Jan 31 01:55:29 2017(r313005) +++ head/sys/libkern/crc32.cTue Jan 31 03:26:32 2017(r313006) @@ -46,8 +46,14 @@ __FBSDID("$FreeBSD$"); #include +#include #include +#if defined(__amd64__) || defined(__i386__) +#include +#include +#endif + const uint32_t crc32_tab[] = { 0x, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, @@ -749,6 +755,11 @@ calculate_crc32c(uint32_t crc32c, const unsigned char *buffer, unsigned int length) { +#if defined(__amd64__) || defined(__i386__) + if ((cpu_feature2 & CPUID2_SSE42) != 0) { + return (sse42_crc32c(crc32c, buffer, length)); + } else +#endif if (length < 4) { return (singletable_crc32c(crc32c, buffer, length)); } else { Added: head/sys/libkern/x86/crc32_sse42.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/libkern/x86/crc32_sse42.c Tue Jan 31 03:26:32 2017 (r313006) @@ -0,0 +1,288 @@ +/* + * Derived from crc32c.c version 1.1 by Mark Adler. + * + * Copyright (C) 2013 Mark Adler + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the author be held liable for any damages arising from the + * use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be mis
svn commit: r312702 - in head/sys: kern libkern sys
Author: cem Date: Tue Jan 24 18:05:29 2017 New Revision: 312702 URL: https://svnweb.freebsd.org/changeset/base/312702 Log: Use time_t for intermediate values to avoid overflow in clock_ts_to_ct Add additionally safety and overflow checks to clock_ts_to_ct and the BCD routines while we're here. Perform a safety check in sys_clock_settime() first to avoid easy local root panic, without having to propagate an error value back through dozens of APIs currently lacking error returns. PR: 211960, 214300 Submitted by: Justin McOmie , kib@ Reported by: Tim Newsham Reviewed by: kib@ Sponsored by: Dell EMC Isilon, FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D9279 Modified: head/sys/kern/kern_time.c head/sys/kern/subr_clock.c head/sys/libkern/bcd.c head/sys/sys/libkern.h Modified: head/sys/kern/kern_time.c == --- head/sys/kern/kern_time.c Tue Jan 24 17:30:13 2017(r312701) +++ head/sys/kern/kern_time.c Tue Jan 24 18:05:29 2017(r312702) @@ -387,6 +387,11 @@ sys_clock_settime(struct thread *td, str return (kern_clock_settime(td, uap->clock_id, &ats)); } +static int allow_insane_settime = 0; +SYSCTL_INT(_debug, OID_AUTO, allow_insane_settime, CTLFLAG_RWTUN, +&allow_insane_settime, 0, +"do not perform possibly restrictive checks on settime(2) args"); + int kern_clock_settime(struct thread *td, clockid_t clock_id, struct timespec *ats) { @@ -400,6 +405,8 @@ kern_clock_settime(struct thread *td, cl if (ats->tv_nsec < 0 || ats->tv_nsec >= 10 || ats->tv_sec < 0) return (EINVAL); + if (!allow_insane_settime && ats->tv_sec > ULL * 366 * 24 * 60 * 60) + return (EINVAL); /* XXX Don't convert nsec->usec and back */ TIMESPEC_TO_TIMEVAL(&atv, ats); error = settime(td, &atv); Modified: head/sys/kern/subr_clock.c == --- head/sys/kern/subr_clock.c Tue Jan 24 17:30:13 2017(r312701) +++ head/sys/kern/subr_clock.c Tue Jan 24 18:05:29 2017(r312702) @@ -178,7 +178,7 @@ clock_ct_to_ts(struct clocktime *ct, str void clock_ts_to_ct(struct timespec *ts, struct clocktime *ct) { - int i, year, days; + time_t i, year, days; time_t rsec;/* remainder seconds */ time_t secs; @@ -214,6 +214,20 @@ clock_ts_to_ct(struct timespec *ts, stru print_ct(ct); printf("\n"); } + + KASSERT(ct->year >= 0 && ct->year < 1, + ("year %d isn't a 4 digit year", ct->year)); + KASSERT(ct->mon >= 1 && ct->mon <= 12, + ("month %d not in 1-12", ct->mon)); + KASSERT(ct->day >= 1 && ct->day <= 31, + ("day %d not in 1-31", ct->day)); + KASSERT(ct->hour >= 0 && ct->hour <= 23, + ("hour %d not in 0-23", ct->hour)); + KASSERT(ct->min >= 0 && ct->min <= 59, + ("minute %d not in 0-59", ct->min)); + /* Not sure if this interface needs to handle leapseconds or not. */ + KASSERT(ct->sec >= 0 && ct->sec <= 60, + ("seconds %d not in 0-60", ct->sec)); } int Modified: head/sys/libkern/bcd.c == --- head/sys/libkern/bcd.c Tue Jan 24 17:30:13 2017(r312701) +++ head/sys/libkern/bcd.c Tue Jan 24 18:05:29 2017(r312702) @@ -6,6 +6,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include u_char const bcd2bin_data[] = { @@ -20,6 +21,7 @@ u_char const bcd2bin_data[] = { 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 0, 0, 0, 0, 0, 0, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 }; +CTASSERT(nitems(bcd2bin_data) == LIBKERN_LEN_BCD2BIN); u_char const bin2bcd_data[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, @@ -33,6 +35,8 @@ u_char const bin2bcd_data[] = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99 }; +CTASSERT(nitems(bin2bcd_data) == LIBKERN_LEN_BIN2BCD); /* This is actually used with radix [2..36] */ char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz"; +CTASSERT(nitems(hex2ascii_data) == LIBKERN_LEN_HEX2ASCII + 1); Modified: head/sys/sys/libkern.h == --- head/sys/sys/libkern.h Tue Jan 24 17:30:13 2017(r312701) +++ head/sys/sys/libkern.h Tue Jan 24 18:05:29 2017(r312702) @@ -49,9 +49,36 @@ extern u_char const bcd2bin_data[]; extern u_char constbin2bcd_data[]; extern char const hex2ascii_data[]; -#definebcd2bin(bcd)(bcd2bin_data[bcd]) -#definebin2bcd(bin)(bin2bcd_data[bin]) -#definehex2ascii(hex) (hex2ascii_data[hex]) +#define
svn commit: r312599 - head/sys/sys
Author: cem Date: Sat Jan 21 17:39:10 2017 New Revision: 312599 URL: https://svnweb.freebsd.org/changeset/base/312599 Log: Add remaining ELF compression definitions and structs A follow-up to r300231. Sponsored by: Dell EMC Isilon Modified: head/sys/sys/elf32.h head/sys/sys/elf64.h head/sys/sys/elf_common.h Modified: head/sys/sys/elf32.h == --- head/sys/sys/elf32.hSat Jan 21 16:59:50 2017(r312598) +++ head/sys/sys/elf32.hSat Jan 21 17:39:10 2017(r312599) @@ -254,4 +254,10 @@ typedef struct { Elf32_Half si_flags; /* per symbol flags */ } Elf32_Syminfo; +typedef struct { + Elf32_Word ch_type; + Elf32_Word ch_size; + Elf32_Word ch_addralign; +} Elf32_Chdr; + #endif /* !_SYS_ELF32_H_ */ Modified: head/sys/sys/elf64.h == --- head/sys/sys/elf64.hSat Jan 21 16:59:50 2017(r312598) +++ head/sys/sys/elf64.hSat Jan 21 17:39:10 2017(r312599) @@ -257,4 +257,11 @@ typedef struct { Elf64_Half si_flags; /* per symbol flags */ } Elf64_Syminfo; +typedef struct { + Elf64_Word ch_type; + Elf64_Word ch_reserved; + Elf64_Xword ch_size; + Elf64_Xword ch_addralign; +} Elf64_Chdr; + #endif /* !_SYS_ELF64_H_ */ Modified: head/sys/sys/elf_common.h == --- head/sys/sys/elf_common.h Sat Jan 21 16:59:50 2017(r312598) +++ head/sys/sys/elf_common.h Sat Jan 21 17:39:10 2017(r312599) @@ -849,6 +849,13 @@ typedef struct { #defineSYMINFO_CURRENT 1 #defineSYMINFO_NUM 2 +/* Values for ch_type (compressed section headers). */ +#defineELFCOMPRESS_ZLIB1 /* ZLIB/DEFLATE */ +#defineELFCOMPRESS_LOOS0x6000 /* OS-specific */ +#defineELFCOMPRESS_HIOS0x6fff +#defineELFCOMPRESS_LOPROC 0x7000 /* Processor-specific */ +#defineELFCOMPRESS_HIPROC 0x7fff + /* * Relocation types. * ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r312416 - head/sys/ufs/ffs
Author: cem Date: Thu Jan 19 16:46:05 2017 New Revision: 312416 URL: https://svnweb.freebsd.org/changeset/base/312416 Log: ffs_vnops: Simplify extattr access As suggested in r167010, use the structure type and macros to access and modify UFS2 extended attributes. Add assertions that pointers are aligned in places where we now access the data through a structure pointer, instead of character-by-character. PR: 216127 Reported by: dewayne at heuristicsystems.com.au Reviewed by: kib@ Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D9225 Modified: head/sys/ufs/ffs/ffs_vnops.c Modified: head/sys/ufs/ffs/ffs_vnops.c == --- head/sys/ufs/ffs/ffs_vnops.cThu Jan 19 16:07:52 2017 (r312415) +++ head/sys/ufs/ffs/ffs_vnops.cThu Jan 19 16:46:05 2017 (r312416) @@ -100,6 +100,9 @@ __FBSDID("$FreeBSD$"); #include "opt_directio.h" #include "opt_ffs.h" +#defineALIGNED_TO(ptr, s) \ + (((uintptr_t)(ptr) & (_Alignof(s) - 1)) == 0) + #ifdef DIRECTIO extern int ffs_rawread(struct vnode *vp, struct uio *uio, int *workdone); #endif @@ -1100,46 +1103,30 @@ ffs_extwrite(struct vnode *vp, struct ui * the length of the EA, and possibly the pointer to the entry and to the data. */ static int -ffs_findextattr(u_char *ptr, u_int length, int nspace, const char *name, u_char **eap, u_char **eac) +ffs_findextattr(u_char *ptr, u_int length, int nspace, const char *name, +struct extattr **eapp, u_char **eac) { - u_char *p, *pe, *pn, *p0; - int eapad1, eapad2, ealength, ealen, nlen; - uint32_t ul; + struct extattr *eap, *eaend; + size_t nlen; - pe = ptr + length; nlen = strlen(name); - - for (p = ptr; p < pe; p = pn) { - p0 = p; - bcopy(p, &ul, sizeof(ul)); - pn = p + ul; + KASSERT(ALIGNED_TO(ptr, struct extattr), ("unaligned")); + eap = (struct extattr *)ptr; + eaend = (struct extattr *)(ptr + length); + for (; eap < eaend; eap = EXTATTR_NEXT(eap)) { /* make sure this entry is complete */ - if (pn > pe) + if (EXTATTR_NEXT(eap) > eaend) break; - p += sizeof(uint32_t); - if (*p != nspace) - continue; - p++; - eapad2 = *p++; - if (*p != nlen) - continue; - p++; - if (bcmp(p, name, nlen)) + if (eap->ea_namespace != nspace || eap->ea_namelength != nlen + || memcmp(eap->ea_name, name, nlen) != 0) continue; - ealength = sizeof(uint32_t) + 3 + nlen; - eapad1 = 8 - (ealength % 8); - if (eapad1 == 8) - eapad1 = 0; - ealength += eapad1; - ealen = ul - ealength - eapad2; - p += nlen + eapad1; - if (eap != NULL) - *eap = p0; + if (eapp != NULL) + *eapp = eap; if (eac != NULL) - *eac = p; - return (ealen); + *eac = EXTATTR_CONTENT(eap); + return (EXTATTR_CONTENT_SIZE(eap)); } - return(-1); + return (-1); } static int @@ -1380,9 +1367,11 @@ vop_deleteextattr { { struct inode *ip; struct fs *fs; - uint32_t ealength, ul; - int ealen, olen, eapad1, eapad2, error, i, easize; - u_char *eae, *p; + struct extattr *eap; + uint32_t ul; + int olen, error, i, easize; + u_char *eae; + void *tmp; ip = VTOI(ap->a_vp); fs = ITOFS(ip); @@ -1413,39 +1402,30 @@ vop_deleteextattr { if (error) return (error); - ealength = eapad1 = ealen = eapad2 = 0; - + /* CEM: delete could be done in-place instead */ eae = malloc(ip->i_ea_len, M_TEMP, M_WAITOK); bcopy(ip->i_ea_area, eae, ip->i_ea_len); easize = ip->i_ea_len; olen = ffs_findextattr(eae, easize, ap->a_attrnamespace, ap->a_name, - &p, NULL); + &eap, NULL); if (olen == -1) { /* delete but nonexistent */ free(eae, M_TEMP); ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td); - return(ENOATTR); + return (ENOATTR); } - bcopy(p, &ul, sizeof ul); - i = p - eae + ul; - if (ul != ealength) { - bcopy(p + ul, p + ealength, easize - i); - easize += (ealength - ul); - } - if (easize > NXADDR * fs->fs_bsize) { - free(eae, M_TEMP); - ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td); - if (ip->i_ea_ar
svn commit: r312393 - in head: sbin/restore sys/sys sys/ufs/ufs
Author: cem Date: Wed Jan 18 18:16:57 2017 New Revision: 312393 URL: https://svnweb.freebsd.org/changeset/base/312393 Log: restore(8): Handle extended attribute names correctly UFS2 extended attribute names are not NUL-terminated. Handle appropriately. Correct the EXTATTR_BASE_LENGTH() macro, which handled ea_namelength == one (mod eight) extended attributes incorrectly. PR: 216127 Reported by: dewayne at heuristicsystems.com.au Reviewed by: kib@ Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D9208 Modified: head/sbin/restore/dirs.c head/sbin/restore/extern.h head/sbin/restore/tape.c head/sys/sys/extattr.h head/sys/ufs/ufs/extattr.h Modified: head/sbin/restore/dirs.c == --- head/sbin/restore/dirs.cWed Jan 18 18:14:50 2017(r312392) +++ head/sbin/restore/dirs.cWed Jan 18 18:16:57 2017(r312393) @@ -645,7 +645,7 @@ setdirmodes(int flags) if (!Nflag) { if (node.extsize > 0) { if (bufsize >= node.extsize) { - set_extattr_file(cp, buf, node.extsize); + set_extattr(-1, cp, buf, node.extsize, SXA_FILE); } else { fprintf(stderr, "Cannot restore %s%s\n", "extended attributes for ", cp); Modified: head/sbin/restore/extern.h == --- head/sbin/restore/extern.h Wed Jan 18 18:14:50 2017(r312392) +++ head/sbin/restore/extern.h Wed Jan 18 18:16:57 2017(r312393) @@ -87,7 +87,12 @@ struct direct*rst_readdir(RST_DIR *); voidrst_closedir(void *); voidruncmdshell(void); char *savename(char *); -voidset_extattr_file(char *, void *, int); +enum set_extattr_mode { + SXA_FILE, + SXA_LINK, + SXA_FD, +}; +voidset_extattr(int, char *, void *, int, enum set_extattr_mode); voidsetdirmodes(int); voidsetinput(char *, int); voidsetup(void); Modified: head/sbin/restore/tape.c == --- head/sbin/restore/tape.cWed Jan 18 18:14:50 2017(r312392) +++ head/sbin/restore/tape.cWed Jan 18 18:16:57 2017(r312393) @@ -105,8 +105,6 @@ static void findinode(struct s_spcl *); static void findtapeblksize(void); static char*setupextattr(int); static void xtrattr(char *, size_t); -static void set_extattr_link(char *, void *, int); -static void set_extattr_fd(int, char *, void *, int); static void skiphole(void (*)(char *, size_t), size_t *); static int gethead(struct s_spcl *); static void readtape(char *); @@ -627,7 +625,7 @@ extractfile(char *name) } if (linkit(lnkbuf, name, SYMLINK) == GOOD) { if (extsize > 0) - set_extattr_link(name, buf, extsize); + set_extattr(-1, name, buf, extsize, SXA_LINK); (void) lchown(name, uid, gid); (void) lchmod(name, mode); (void) utimensat(AT_FDCWD, name, ctimep, @@ -658,7 +656,7 @@ extractfile(char *name) } else { buf = setupextattr(extsize); getfile(xtrnull, xtrattr, xtrnull); - set_extattr_file(name, buf, extsize); + set_extattr(-1, name, buf, extsize, SXA_FILE); } (void) chown(name, uid, gid); (void) chmod(name, mode); @@ -688,7 +686,7 @@ extractfile(char *name) } else { buf = setupextattr(extsize); getfile(xtrnull, xtrattr, xtrnull); - set_extattr_file(name, buf, extsize); + set_extattr(-1, name, buf, extsize, SXA_FILE); } (void) chown(name, uid, gid); (void) chmod(name, mode); @@ -715,7 +713,7 @@ extractfile(char *name) buf = setupextattr(extsize); getfile(xtrfile, xtrattr, xtrskip); if (extsize > 0) - set_extattr_fd(ofile, name, buf, extsize); + set_extattr(ofile, name, buf, extsize, SXA_FD); (void) fchown(ofile, uid, gid); (void) fchmod(ofile, mode); (void) futimens(ofile, ctimep); @@ -728,12 +726,16 @@ extractfile(char *name) } /* - * Set attributes for a file. + * Set attributes on a file descriptor, link, or file. */ void -set_extattr_file(char *name, void *buf, int size) +se
svn commit: r312391 - in head: share/man/man5 sys/ufs/ufs
Author: cem Date: Wed Jan 18 17:55:49 2017 New Revision: 312391 URL: https://svnweb.freebsd.org/changeset/base/312391 Log: ufs/extattr.h: Fix documentation of ea_name termination The ea_name string is not nul-terminated. Correct the documentation. Because the subsequent field is padded to 8 bytes, and the padding is zeroed, the ea_name string will appear to be nul-terminated whenever the length isn't exactly one (mod eight). This was introduced in r167010 (2007). Additionally, mark the length fields as unsigned. This particularly matters for the single byte ea_namelength field, which can represent extended attribute names up to 255 bytes long. No functional change. PR: 216127 Reported by: dewayne at heuristicsystems.com.au Reviewed by: kib@ Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D9206 Modified: head/share/man/man5/fs.5 head/sys/ufs/ufs/extattr.h Modified: head/share/man/man5/fs.5 == --- head/share/man/man5/fs.5Wed Jan 18 17:55:08 2017(r312390) +++ head/share/man/man5/fs.5Wed Jan 18 17:55:49 2017(r312391) @@ -28,7 +28,7 @@ .\" @(#)fs.5 8.2 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd April 23, 2016 +.Dd January 16, 2017 .Dt FS 5 .Os .Sh NAME @@ -388,18 +388,19 @@ For further information, see the include The format of an external attribute is defined by the extattr structure: .Bd -literal struct extattr { - int32_t ea_length; /* length of this attribute */ - int8_t ea_namespace; /* name space of this attribute */ - int8_t ea_contentpadlen; /* padding at end of attribute */ - int8_t ea_namelength; /* length of attribute name */ - charea_name[1]; /* null-terminated attribute name */ + uint32_t ea_length; /* length of this attribute */ + uint8_t ea_namespace; /* name space of this attribute */ + uint8_t ea_contentpadlen; /* bytes of padding at end of attribute */ + uint8_t ea_namelength; /* length of attribute name */ + charea_name[1]; /* attribute name (NOT nul-terminated) */ + /* padding, if any, to align attribute content to 8 byte boundary */ /* extended attribute content follows */ }; .Ed .Pp Several macros are defined to manipulate these structures. Each macro takes a pointer to an extattr structure. -.Bl -tag -width ".Dv EXTATTR_SET_LENGTHS(eap, size)" +.Bl -tag -width ".Dv EXTATTR_CONTENT_SIZE(eap)" .It Dv EXTATTR_NEXT(eap) Returns a pointer to the next extended attribute following .Fa eap . @@ -409,35 +410,19 @@ Returns a pointer to the extended attrib .It Dv EXTATTR_CONTENT_SIZE(eap) Returns the size of the extended attribute content referenced by .Fa eap . -.It Dv EXTATTR_SET_LENGTHS(eap, size) -Called with the size of the attribute content after initializing -the attribute name to calculate and set the -.Fa ea_length , -.Fa ea_namelength , -and -.Fa ea_contentpadlen -fields of the extended attribute structure. .El .Pp The following code identifies an ACL: .Bd -literal if (eap->ea_namespace == EXTATTR_NAMESPACE_SYSTEM && - !strcmp(eap->ea_name, POSIX1E_ACL_ACCESS_EXTATTR_NAME) { +eap->ea_namelength == sizeof(POSIX1E_ACL_ACCESS_EXTATTR_NAME) - 1 && + strncmp(eap->ea_name, POSIX1E_ACL_ACCESS_EXTATTR_NAME, + sizeof(POSIX1E_ACL_ACCESS_EXTATTR_NAME) - 1) == 0) { aclp = EXTATTR_CONTENT(eap); acllen = EXTATTR_CONTENT_SIZE(eap); ... } .Ed -.Pp -The following code creates an extended attribute -containing a copy of a structure -.Fa mygif : -.Bd -literal - eap->ea_namespace = EXTATTR_NAMESPACE_USER; - strcpy(eap->ea_name, "filepic.gif"); - EXTATTR_SET_LENGTHS(eap, sizeof(struct mygif)); - memcpy(EXTATTR_CONTENT(eap), &mygif, sizeof(struct mygif)); -.Ed .Sh HISTORY A super-block structure named filsys appeared in .At v6 . Modified: head/sys/ufs/ufs/extattr.h == --- head/sys/ufs/ufs/extattr.h Wed Jan 18 17:55:08 2017(r312390) +++ head/sys/ufs/ufs/extattr.h Wed Jan 18 17:55:49 2017(r312391) @@ -73,11 +73,12 @@ struct ufs_extattr_header { * This structure defines the required fields of an extended-attribute header. */ struct extattr { - int32_t ea_length; /* length of this attribute */ - int8_t ea_namespace; /* name space of this attribute */ - int8_t ea_contentpadlen; /* bytes of padding at end of attribute */ - int8_t ea_namelength; /* length of attribute name */ - charea_name[1]; /* null-terminated attribute name */ + uint32_t ea_length; /* length of this attribute */ + uint8_t ea_namespace; /* name sp
svn commit: r312235 - in head/sys: amd64/vmm cam netinet/cc sys
Author: cem Date: Sun Jan 15 18:00:45 2017 New Revision: 312235 URL: https://svnweb.freebsd.org/changeset/base/312235 Log: Fix a variety of cosmetic typos and misspellings No functional change. PR: 216096, 216097, 216098, 216101, 216102, 216106, 216109, 216110 Reported by: Bulat Sponsored by: Dell EMC Isilon Modified: head/sys/amd64/vmm/vmm_host.h head/sys/cam/cam_compat.h head/sys/cam/cam_iosched.h head/sys/netinet/cc/cc.h head/sys/sys/buf_ring.h head/sys/sys/bus.h head/sys/sys/busdma_bufalloc.h head/sys/sys/devmap.h head/sys/sys/eventvar.h head/sys/sys/gtaskqueue.h head/sys/sys/ksem.h head/sys/sys/pipe.h head/sys/sys/sockopt.h head/sys/sys/taskqueue.h Modified: head/sys/amd64/vmm/vmm_host.h == --- head/sys/amd64/vmm/vmm_host.h Sun Jan 15 17:54:01 2017 (r312234) +++ head/sys/amd64/vmm/vmm_host.h Sun Jan 15 18:00:45 2017 (r312235) @@ -30,7 +30,7 @@ #define_VMM_HOST_H_ #ifndef_KERNEL -#error "no user-servicable parts inside" +#error "no user-serviceable parts inside" #endif struct xsave_limits { Modified: head/sys/cam/cam_compat.h == --- head/sys/cam/cam_compat.h Sun Jan 15 17:54:01 2017(r312234) +++ head/sys/cam/cam_compat.h Sun Jan 15 18:00:45 2017(r312235) @@ -31,7 +31,7 @@ #ifndef _CAM_CAM_COMPAT_H #define _CAM_CAM_COMPAT_H -/* No user-servicable parts in here. */ +/* No user-serviceable parts in here. */ #ifdef _KERNEL int cam_compat_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, Modified: head/sys/cam/cam_iosched.h == --- head/sys/cam/cam_iosched.h Sun Jan 15 17:54:01 2017(r312234) +++ head/sys/cam/cam_iosched.h Sun Jan 15 18:00:45 2017(r312235) @@ -31,7 +31,7 @@ #ifndef _CAM_CAM_IOSCHED_H #define _CAM_CAM_IOSCHED_H -/* No user-servicable parts in here. */ +/* No user-serviceable parts in here. */ #ifdef _KERNEL /* Forward declare all structs to keep interface thin */ Modified: head/sys/netinet/cc/cc.h == --- head/sys/netinet/cc/cc.hSun Jan 15 17:54:01 2017(r312234) +++ head/sys/netinet/cc/cc.hSun Jan 15 18:00:45 2017(r312235) @@ -52,7 +52,7 @@ #define _NETINET_CC_CC_H_ #if !defined(_KERNEL) -#error "no user-servicable parts inside" +#error "no user-serviceable parts inside" #endif /* Global CC vars. */ Modified: head/sys/sys/buf_ring.h == --- head/sys/sys/buf_ring.h Sun Jan 15 17:54:01 2017(r312234) +++ head/sys/sys/buf_ring.h Sun Jan 15 18:00:45 2017(r312235) @@ -250,16 +250,16 @@ buf_ring_advance_sc(struct buf_ring *br) /* * Used to return a buffer (most likely already there) - * to the top od the ring. The caller should *not* + * to the top of the ring. The caller should *not* * have used any dequeue to pull it out of the ring * but instead should have used the peek() function. * This is normally used where the transmit queue - * of a driver is full, and an mubf must be returned. + * of a driver is full, and an mbuf must be returned. * Most likely whats in the ring-buffer is what * is being put back (since it was not removed), but * sometimes the lower transmit function may have * done a pullup or other function that will have - * changed it. As an optimzation we always put it + * changed it. As an optimization we always put it * back (since jhb says the store is probably cheaper), * if we have to do a multi-queue version we will need * the compare and an atomic. Modified: head/sys/sys/bus.h == --- head/sys/sys/bus.h Sun Jan 15 17:54:01 2017(r312234) +++ head/sys/sys/bus.h Sun Jan 15 18:00:45 2017(r312235) @@ -662,7 +662,7 @@ voidbus_data_generation_update(void); * Some convenience defines for probe routines to return. These are just * suggested values, and there's nothing magical about them. * BUS_PROBE_SPECIFIC is for devices that cannot be reprobed, and that no - * possible other driver may exist (typically legacy drivers who don't fallow + * possible other driver may exist (typically legacy drivers who don't follow * all the rules, or special needs drivers). BUS_PROBE_VENDOR is the * suggested value that vendor supplied drivers use. This is for source or * binary drivers that are not yet integrated into the FreeBSD tree. Its use @@ -675,7 +675,7 @@ voidbus_data_generation_update(void); * supports the newer ones would return BUS_PROBE_DEFAULT. BUS_PROBE_GENERIC * is for drivers that wish to have a generic form and a specialized form,
svn commit: r312234 - in head: sbin/camcontrol share/man/man4 share/man/man9 sys/arm/arm sys/arm/freescale/imx sys/arm/mv sys/cam sys/dev/bhnd sys/dev/fdt sys/dev/isp sys/dev/mmc sys/dev/mpt sys/de...
Author: cem Date: Sun Jan 15 17:54:01 2017 New Revision: 312234 URL: https://svnweb.freebsd.org/changeset/base/312234 Log: "Buses" is the preferred plural of "bus" Replace archaic "busses" with modern form "buses." Intentionally excluded: * Old/random drivers I didn't recognize * Old hardware in general * Use of "busses" in code as identifiers No functional change. http://grammarist.com/spelling/buses-busses/ PR: 216099 Reported by: bltsrc at mail.ru Sponsored by: Dell EMC Isilon Modified: head/sbin/camcontrol/camcontrol.8 head/sbin/camcontrol/camcontrol.c head/share/man/man4/ehci.4 head/share/man/man4/iicbus.4 head/share/man/man4/scsi.4 head/share/man/man9/BUS_CONFIG_INTR.9 head/share/man/man9/DEVICE_ATTACH.9 head/share/man/man9/DEVICE_IDENTIFY.9 head/share/man/man9/DRIVER_MODULE.9 head/share/man/man9/bus_generic_attach.9 head/share/man/man9/bus_generic_detach.9 head/share/man/man9/bus_generic_new_pass.9 head/share/man/man9/bus_generic_print_child.9 head/share/man/man9/bus_generic_read_ivar.9 head/share/man/man9/bus_generic_shutdown.9 head/share/man/man9/bus_space.9 head/share/man/man9/device.9 head/share/man/man9/device_add_child.9 head/share/man/man9/pci.9 head/sys/arm/arm/ofw_machdep.c head/sys/arm/freescale/imx/imx6_ccm.c head/sys/arm/freescale/imx/imx6_machdep.c head/sys/arm/freescale/imx/imx_i2c.c head/sys/arm/mv/mv_pci.c head/sys/cam/cam_xpt.c head/sys/cam/cam_xpt_internal.h head/sys/dev/bhnd/bhnd.h head/sys/dev/fdt/simplebus.c head/sys/dev/isp/isp.c head/sys/dev/mmc/mmcreg.h head/sys/dev/mpt/mpt.c head/sys/dev/mpt/mpt.h head/sys/dev/mpt/mpt_raid.c head/sys/dev/pccbb/pccbb_pci.c head/sys/dev/pci/hostb_pci.c head/sys/dev/pci/pci.c head/sys/dev/pci/pci_private.h head/sys/dev/pci/pci_subr.c head/sys/dev/usb/usb_hub.c head/sys/kern/bus_if.m head/sys/kern/sched_ule.c head/sys/kern/subr_bus.c head/sys/sys/bus.h head/sys/x86/pci/pci_bus.c head/sys/x86/x86/mptable.c head/sys/x86/x86/nexus.c head/sys/xen/xenbus/xenbusb.c head/sys/xen/xenbus/xenbusb.h head/usr.sbin/mptutil/mpt_cam.c Modified: head/sbin/camcontrol/camcontrol.8 == --- head/sbin/camcontrol/camcontrol.8 Sun Jan 15 15:43:19 2017 (r312233) +++ head/sbin/camcontrol/camcontrol.8 Sun Jan 15 17:54:01 2017 (r312234) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 6, 2017 +.Dd January 15, 2017 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -565,12 +565,12 @@ start bit set and the load/eject bit set Send the SCSI Start/Stop Unit (0x1B) command to the given device with the start bit cleared and the load/eject bit set. .It Ic rescan -Tell the kernel to scan all busses in the system (with the +Tell the kernel to scan all buses in the system (with the .Ar all argument), the given bus (XPT_SCAN_BUS), or bus:target:lun (XPT_SCAN_LUN) for new devices or devices that have gone away. The user -may specify a scan of all busses, a single bus, or a lun. +may specify a scan of all buses, a single bus, or a lun. Scanning all luns on a target is not supported. .It Ic reprobe @@ -580,7 +580,7 @@ notify the upper layer, This includes sending the SCSI READ CAPACITY command and updating the disk size visible to the rest of the system. .It Ic reset -Tell the kernel to reset all busses in the system (with the +Tell the kernel to reset all buses in the system (with the .Ar all argument) or the given bus (XPT_RESET_BUS) by issuing a SCSI bus reset for that bus, or to reset the given bus:target:lun @@ -2557,7 +2557,7 @@ write reallocation settings, among other .Pp .Dl camcontrol rescan all .Pp -Rescan all SCSI busses in the system for devices that have been added, +Rescan all SCSI buses in the system for devices that have been added, removed or changed. .Pp .Dl camcontrol rescan 0 Modified: head/sbin/camcontrol/camcontrol.c == --- head/sbin/camcontrol/camcontrol.c Sun Jan 15 15:43:19 2017 (r312233) +++ head/sbin/camcontrol/camcontrol.c Sun Jan 15 17:54:01 2017 (r312234) @@ -3179,8 +3179,8 @@ rescan_or_reset_bus(path_id_t bus, int r /* * The right way to handle this is to modify the xpt so that it can * handle a wildcarded bus in a rescan or reset CCB. At the moment -* that isn't implemented, so instead we enumerate the busses and -* send the rescan or reset to those busses in the case where the +* that isn't implemented, so instead we enumerate the buses and +* send the rescan or reset to those buses in the case where the * given bus is -1 (wildcard). We don't send a rescan or reset * to the xpt bus; sending a rescan to the xpt bus is effectively a * no-op, sending a rescan to the xpt bus would result in a status of @@ -8954,8 +8954,8 @
svn commit: r312212 - head/sys/sys
Author: cem Date: Sun Jan 15 08:05:00 2017 New Revision: 312212 URL: https://svnweb.freebsd.org/changeset/base/312212 Log: Fix a minor typo (Seiral) PR: 216095 Reported by: Modified: head/sys/sys/ata.h Modified: head/sys/sys/ata.h == --- head/sys/sys/ata.h Sun Jan 15 06:35:00 2017(r312211) +++ head/sys/sys/ata.h Sun Jan 15 08:05:00 2017(r312212) @@ -682,7 +682,7 @@ struct atapi_sense { #defineATA_IDL_ATA_STRINGS 0x05/* ATA Strings */ #defineATA_IDL_SECURITY0x06/* Security */ #defineATA_IDL_PARALLEL_ATA0x07/* Parallel ATA */ -#defineATA_IDL_SERIAL_ATA 0x08/* Seiral ATA */ +#defineATA_IDL_SERIAL_ATA 0x08/* Serial ATA */ #defineATA_IDL_ZDI 0x09/* Zoned Device Information */ struct ata_gp_log_dir { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r312107 - head/tests/sys/vfs
Author: cem Date: Sat Jan 14 02:29:25 2017 New Revision: 312107 URL: https://svnweb.freebsd.org/changeset/base/312107 Log: Follow-up to r312103: Revert r310995 as well. Modified: head/tests/sys/vfs/Makefile Modified: head/tests/sys/vfs/Makefile == --- head/tests/sys/vfs/Makefile Sat Jan 14 02:26:46 2017(r312106) +++ head/tests/sys/vfs/Makefile Sat Jan 14 02:29:25 2017(r312107) @@ -9,6 +9,4 @@ CFLAGS.lookup_cap_dotdot.c+=-I${SRCTOP} PLAIN_TESTS_SH+= trailing_slash -WARNS?=6 - .include ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r312104 - head/usr.sbin/fstyp/tests
Author: cem Date: Sat Jan 14 01:08:04 2017 New Revision: 312104 URL: https://svnweb.freebsd.org/changeset/base/312104 Log: Fix broken fstyp exfat testcase Introduced in r312010. It helps to read the documentation before trying to test something. Modified: head/usr.sbin/fstyp/tests/fstyp_test.sh Modified: head/usr.sbin/fstyp/tests/fstyp_test.sh == --- head/usr.sbin/fstyp/tests/fstyp_test.sh Sat Jan 14 01:03:20 2017 (r312103) +++ head/usr.sbin/fstyp/tests/fstyp_test.sh Sat Jan 14 01:08:04 2017 (r312104) @@ -64,7 +64,7 @@ exfat_head() { } exfat_body() { bzcat $(atf_get_srcdir)/dfr-01-xfat.img.bz2 > exfat.img - atf_check -s exit:0 -o inline:"exfat\n" fstyp exfat.img + atf_check -s exit:0 -o inline:"exfat\n" fstyp -u exfat.img } atf_test_case empty ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r312103 - head/tests/sys/vfs
Author: cem Date: Sat Jan 14 01:03:20 2017 New Revision: 312103 URL: https://svnweb.freebsd.org/changeset/base/312103 Log: Revert r310994 Don't implement some terrible hack on a test by test basis. The framework fix is straightforward and can be chased up in the original bug. Reviewed by: ngie ("be my guest") Modified: head/tests/sys/vfs/lookup_cap_dotdot.c Modified: head/tests/sys/vfs/lookup_cap_dotdot.c == --- head/tests/sys/vfs/lookup_cap_dotdot.c Sat Jan 14 01:01:02 2017 (r312102) +++ head/tests/sys/vfs/lookup_cap_dotdot.c Sat Jan 14 01:03:20 2017 (r312103) @@ -31,27 +31,23 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include -#include #include #include #include #include "freebsd_test_suite/macros.h" -static char*abspath; -static int dirfd = -1; - -typedefvoid (*child_test_fn_t)(void); +static int dirfd = -1; +static char *abspath; static void -touchat(int _dirfd, const char *name) +touchat(int dirfd, const char *name) { int fd; - ATF_REQUIRE((fd = openat(_dirfd, name, O_CREAT | O_TRUNC | O_WRONLY, + ATF_REQUIRE((fd = openat(dirfd, name, O_CREAT | O_TRUNC | O_WRONLY, 0777)) >= 0); ATF_REQUIRE(close(fd) == 0); } @@ -82,43 +78,10 @@ prepare_dotdot_tests(void) static void check_capsicum(void) { - ATF_REQUIRE_FEATURE("security_capabilities"); ATF_REQUIRE_FEATURE("security_capability_mode"); } -static void -run_capsicum_test(child_test_fn_t test_func) -{ - int child_exit_code, child_status; - pid_t child_pid; - - check_capsicum(); - prepare_dotdot_tests(); - - ATF_REQUIRE_MSG((child_pid = fork()) != -1, - "fork failed: %s", strerror(errno)); - - if (child_pid == 0) { - test_func(); - _exit(0); - } - - ATF_REQUIRE_MSG(waitpid(child_pid, &child_status, 0) != -1, - "waitpid failed: %s", strerror(errno)); - if (WIFEXITED(child_status)) { - child_exit_code = WEXITSTATUS(child_status); - ATF_REQUIRE_MSG(child_exit_code == 0, - "child exited with non-zero exit code: %d", - child_exit_code); - } else if (WIFSIGNALED(child_status)) - atf_tc_fail("child exited with signal: %d", - WTERMSIG(child_status)); - else - atf_tc_fail("child exited with unexpected status: %d", - child_status); -} - /* * Positive tests */ @@ -130,7 +93,6 @@ ATF_TC_HEAD(openat__basic_positive, tc) ATF_TC_BODY(openat__basic_positive, tc) { - prepare_dotdot_tests(); ATF_REQUIRE(openat(dirfd, "d1/d2/d3/f3", O_RDONLY) >= 0); @@ -152,22 +114,21 @@ ATF_TC_HEAD(lookup_cap_dotdot__basic, tc "Validate cap-mode (testdir)/d1/.. lookup"); } -static void -lookup_cap_dotdot__basic_child(void) +ATF_TC_BODY(lookup_cap_dotdot__basic, tc) { cap_rights_t rights; + int fd; - cap_rights_init(&rights, CAP_LOOKUP, CAP_READ); + check_capsicum(); + prepare_dotdot_tests(); - assert(cap_rights_limit(dirfd, &rights) >= 0); - assert(cap_enter() >= 0); - assert(openat(dirfd, "d1/..", O_RDONLY) >= 0); -} + cap_rights_init(&rights, CAP_LOOKUP, CAP_READ); + ATF_REQUIRE(cap_rights_limit(dirfd, &rights) >= 0); -ATF_TC_BODY(lookup_cap_dotdot__basic, tc) -{ + ATF_REQUIRE(cap_enter() >= 0); - run_capsicum_test(lookup_cap_dotdot__basic_child); + ATF_REQUIRE_MSG(openat(dirfd, "d1/..", O_RDONLY) >= 0, "%s", + strerror(errno)); } ATF_TC(lookup_cap_dotdot__advanced); @@ -177,26 +138,23 @@ ATF_TC_HEAD(lookup_cap_dotdot__advanced, "Validate cap-mode (testdir)/d1/.. lookup"); } -static void -lookup_cap_dotdot__advanced_child(void) +ATF_TC_BODY(lookup_cap_dotdot__advanced, tc) { cap_rights_t rights; + int fd; - cap_rights_init(&rights, CAP_LOOKUP, CAP_READ); - assert(cap_rights_limit(dirfd, &rights) >= 0); - - assert(cap_enter() >= 0); + check_capsicum(); + prepare_dotdot_tests(); - assert(openat(dirfd, "d1/d2/d3/../../f1", O_RDONLY) >= 0); - assert(openat(dirfd, "l3/../../f1", O_RDONLY) >= 0); - assert(openat(dirfd, "l3/ld1", O_RDONLY) >= 0); - assert(openat(dirfd, "l3/lf1", O_RDONLY) >= 0); -} + cap_rights_init(&rights, CAP_LOOKUP, CAP_READ); + ATF_REQUIRE(cap_rights_limit(dirfd, &rights) >= 0); -ATF_TC_BODY(lookup_cap_dotdot__advanced, tc) -{ + ATF_REQUIRE(cap_enter() >= 0); - run_capsicum_test(lookup_cap_dotdot__advanced_child); + ATF_REQUIRE(openat(dirfd, "d1/d2/d3/../../f1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/../../f1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/ld1", O_RDONLY) >= 0); + ATF_REQUIRE(ope
svn commit: r312078 - head/usr.sbin/fstyp
Author: cem Date: Fri Jan 13 16:46:01 2017 New Revision: 312078 URL: https://svnweb.freebsd.org/changeset/base/312078 Log: fstyp.8: Move initial exFAT blurb to the -u section Didn't notice the second list in r312003. Reported by: trasz@ Modified: head/usr.sbin/fstyp/fstyp.8 Modified: head/usr.sbin/fstyp/fstyp.8 == --- head/usr.sbin/fstyp/fstyp.8 Fri Jan 13 16:37:38 2017(r312077) +++ head/usr.sbin/fstyp/fstyp.8 Fri Jan 13 16:46:01 2017(r312078) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 12, 2017 +.Dd January 13, 2017 .Dt FSTYP 8 .Os .Sh NAME @@ -43,7 +43,7 @@ The .Nm utility is used to determine the filesystem type on a given device. -It can recognize ISO-9660, exFAT, Ext2, FAT, NTFS, and UFS filesystems. +It can recognize ISO-9660, Ext2, FAT, NTFS, and UFS filesystems. When the .Fl u flag is specified, @@ -51,9 +51,10 @@ flag is specified, also recognizes certain additional metadata formats that cannot be handled using .Xr mount 8 , -such as ZFS pools and +such as exFAT filesystems, .Xr geli 8 -providers. +providers, and +ZFS pools. .Pp The filesystem name is printed to the standard output as, respectively: ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r312003 - head/usr.sbin/fstyp
Author: cem Date: Fri Jan 13 02:12:58 2017 New Revision: 312003 URL: https://svnweb.freebsd.org/changeset/base/312003 Log: fstyp(8): Detect exFAT filesystems Simply detect the exFAT filesystem name in the Volume Boot Record (superblock). PR: 214908 Reported by: Added: head/usr.sbin/fstyp/exfat.c (contents, props changed) Modified: head/usr.sbin/fstyp/Makefile head/usr.sbin/fstyp/fstyp.8 head/usr.sbin/fstyp/fstyp.c head/usr.sbin/fstyp/fstyp.h Modified: head/usr.sbin/fstyp/Makefile == --- head/usr.sbin/fstyp/MakefileFri Jan 13 02:11:16 2017 (r312002) +++ head/usr.sbin/fstyp/MakefileFri Jan 13 02:12:58 2017 (r312003) @@ -3,7 +3,7 @@ .include PROG= fstyp -SRCS= cd9660.c ext2fs.c fstyp.c geli.c msdosfs.c ntfs.c ufs.c +SRCS= cd9660.c exfat.c ext2fs.c fstyp.c geli.c msdosfs.c ntfs.c ufs.c .if ${MK_ZFS} != "no" SRCS +=zfs.c Added: head/usr.sbin/fstyp/exfat.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/fstyp/exfat.c Fri Jan 13 02:12:58 2017(r312003) @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017 Conrad Meyer + * 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, 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 +#include + +#include "fstyp.h" + +struct exfat_vbr { + charev_jmp[3]; + charev_fsname[8]; + charev_zeros[53]; + uint64_tev_part_offset; + uint64_tev_vol_length; + uint32_tev_fat_offset; + uint32_tev_fat_length; + uint32_tev_cluster_offset; + uint32_tev_cluster_count; + uint32_tev_rootdir_cluster; + uint32_tev_vol_serial; + uint16_tev_fs_revision; + uint16_tev_vol_flags; + uint8_t ev_log_bytes_per_sect; + uint8_t ev_log_sect_per_clust; + uint8_t ev_num_fats; + uint8_t ev_drive_sel; + uint8_t ev_percent_used; +} __packed; + +int +fstyp_exfat(FILE *fp, char *label, size_t size) +{ + struct exfat_vbr *ev; + + ev = (struct exfat_vbr *)read_buf(fp, 0, 512); + if (ev == NULL || strncmp(ev->ev_fsname, "EXFAT ", 8) != 0) + goto fail; + + /* +* Reading the volume label requires walking the root directory to look +* for a special label file. Left as an exercise for the reader. +*/ + free(ev); + return (0); + +fail: + free(ev); + return (1); +} Modified: head/usr.sbin/fstyp/fstyp.8 == --- head/usr.sbin/fstyp/fstyp.8 Fri Jan 13 02:11:16 2017(r312002) +++ head/usr.sbin/fstyp/fstyp.8 Fri Jan 13 02:12:58 2017(r312003) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 28, 2016 +.Dd January 12, 2017 .Dt FSTYP 8 .Os .Sh NAME @@ -43,7 +43,7 @@ The .Nm utility is used to determine the filesystem type on a given device. -It can recognize ISO-9660, Ext2, FAT, NTFS, and UFS filesystems. +It can recognize ISO-9660, exFAT, Ext2, FAT, NTFS, and UFS filesystems. When the .Fl u flag is specified, @@ -61,6 +61,8 @@ as, respectively: .It cd9660 .It +exfat +.It ext2fs .It geli Modified: head/usr.sbin/fstyp/fstyp.c == --- head/usr.sbin/fstyp/fstyp.c Fri Jan 13 02:11:16 2017(r312002) +++ head/usr.sbin/fstyp/fstyp.c Fri Jan
svn commit: r311989 - head/sys/libkern
Author: cem Date: Thu Jan 12 17:02:29 2017 New Revision: 311989 URL: https://svnweb.freebsd.org/changeset/base/311989 Log: libkern: Remove obsolete 'register' keyword Sponsored by: Dell EMC Isilon Modified: head/sys/libkern/bcmp.c head/sys/libkern/bsearch.c head/sys/libkern/iconv_ucs.c head/sys/libkern/iconv_xlat16.c head/sys/libkern/memmem.c head/sys/libkern/qdivrem.c head/sys/libkern/qsort.c head/sys/libkern/random.c head/sys/libkern/scanc.c head/sys/libkern/strcmp.c head/sys/libkern/strncpy.c Modified: head/sys/libkern/bcmp.c == --- head/sys/libkern/bcmp.c Thu Jan 12 16:44:40 2017(r311988) +++ head/sys/libkern/bcmp.c Thu Jan 12 17:02:29 2017(r311989) @@ -44,7 +44,7 @@ typedef const unsigned long *culp; int bcmp(b1, b2, length) const void *b1, *b2; - register size_t length; + size_t length; { #if BYTE_ORDER == LITTLE_ENDIAN /* Modified: head/sys/libkern/bsearch.c == --- head/sys/libkern/bsearch.c Thu Jan 12 16:44:40 2017(r311988) +++ head/sys/libkern/bsearch.c Thu Jan 12 17:02:29 2017(r311989) @@ -54,16 +54,16 @@ __FBSDID("$FreeBSD$"); */ void * bsearch(key, base0, nmemb, size, compar) - register const void *key; + const void *key; const void *base0; size_t nmemb; - register size_t size; - register int (*compar)(const void *, const void *); + size_t size; + int (*compar)(const void *, const void *); { - register const char *base = base0; - register size_t lim; - register int cmp; - register const void *p; + const char *base = base0; + size_t lim; + int cmp; + const void *p; for (lim = nmemb; lim != 0; lim >>= 1) { p = base + (lim >> 1) * size; Modified: head/sys/libkern/iconv_ucs.c == --- head/sys/libkern/iconv_ucs.cThu Jan 12 16:44:40 2017 (r311988) +++ head/sys/libkern/iconv_ucs.cThu Jan 12 17:02:29 2017 (r311989) @@ -523,14 +523,14 @@ ucs4_to_utf8(uint32_t ucs4, char *dst, s } static uint32_t -encode_surrogate(register uint32_t code) +encode_surrogate(uint32_t code) { return code - 0x1) << 6) & 0x3ff) | ((code - 0x1) & 0x3ff) | 0xd800dc00); } static uint32_t -decode_surrogate(register const u_char *ucs) +decode_surrogate(const u_char *ucs) { return ucs[0] & 0x3) << 18) | (ucs[1] << 10) | ((ucs[2] & 0x3) << 8) | ucs[3]) + 0x1); Modified: head/sys/libkern/iconv_xlat16.c == --- head/sys/libkern/iconv_xlat16.c Thu Jan 12 16:44:40 2017 (r311988) +++ head/sys/libkern/iconv_xlat16.c Thu Jan 12 17:02:29 2017 (r311989) @@ -298,10 +298,10 @@ iconv_xlat16_name(struct iconv_converter } static int -iconv_xlat16_tolower(void *d2p, register int c) +iconv_xlat16_tolower(void *d2p, int c) { struct iconv_xlat16 *dp = (struct iconv_xlat16*)d2p; - register int c1, c2, out; + int c1, c2, out; if (c < 0x100) { c1 = C2I1(c << 8); @@ -323,10 +323,10 @@ iconv_xlat16_tolower(void *d2p, register } static int -iconv_xlat16_toupper(void *d2p, register int c) +iconv_xlat16_toupper(void *d2p, int c) { struct iconv_xlat16 *dp = (struct iconv_xlat16*)d2p; - register int c1, c2, out; + int c1, c2, out; if (c < 0x100) { c1 = C2I1(c << 8); Modified: head/sys/libkern/memmem.c == --- head/sys/libkern/memmem.c Thu Jan 12 16:44:40 2017(r311988) +++ head/sys/libkern/memmem.c Thu Jan 12 17:02:29 2017(r311989) @@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$"); void * memmem(const void *l, size_t l_len, const void *s, size_t s_len) { -register char *cur, *last; +char *cur, *last; const char *cl = (const char *)l; const char *cs = (const char *)s; Modified: head/sys/libkern/qdivrem.c == --- head/sys/libkern/qdivrem.c Thu Jan 12 16:44:40 2017(r311988) +++ head/sys/libkern/qdivrem.c Thu Jan 12 17:02:29 2017(r311989) @@ -59,9 +59,9 @@ typedef u_long digit; * We may assume len >= 0. NOTE THAT THIS WRITES len+1 DIGITS. */ static void -__shl(register digit *p, register int len, register int sh) +__shl(digit *p, int len, int sh) { - register int i; + int i; for (i = 0; i < len; i++) p[i] = LHALF(p[i] << sh) | (p[i + 1] >> (HALF_BITS - sh)); @@ -82,7 +82,7 @@ __qdivrem(uq, vq, arq) { union uu tmp; digit *u, *v,
svn commit: r311964 - head/sys/geom/raid
Author: cem Date: Thu Jan 12 06:58:31 2017 New Revision: 311964 URL: https://svnweb.freebsd.org/changeset/base/311964 Log: g_raid: Prevent tasters from attempting excessively large reads Some g_raid tasters attempt metadata reads in multiples of the provider sectorsize. Reads larger than MAXPHYS are invalid, so detect and abort in such situations. Spiritually similar to r217305 / PR 147851. PR: 214721 Sponsored by: Dell EMC Isilon Modified: head/sys/geom/raid/md_ddf.c head/sys/geom/raid/md_promise.c Modified: head/sys/geom/raid/md_ddf.c == --- head/sys/geom/raid/md_ddf.c Thu Jan 12 06:38:03 2017(r311963) +++ head/sys/geom/raid/md_ddf.c Thu Jan 12 06:58:31 2017(r311964) @@ -1161,6 +1161,16 @@ hdrerror: (GET16(meta, hdr->Configuration_Record_Length) * ss - 512) / 12)); } + if (GET32(meta, hdr->cd_length) * ss >= MAXPHYS || + GET32(meta, hdr->pdr_length) * ss >= MAXPHYS || + GET32(meta, hdr->vdr_length) * ss >= MAXPHYS || + GET32(meta, hdr->cr_length) * ss >= MAXPHYS || + GET32(meta, hdr->pdd_length) * ss >= MAXPHYS || + GET32(meta, hdr->bbmlog_length) * ss >= MAXPHYS) { + G_RAID_DEBUG(1, "%s: Blocksize is too big.", pp->name); + goto hdrerror; + } + /* Read controller data. */ buf = g_read_data(cp, (lba + GET32(meta, hdr->cd_section)) * ss, GET32(meta, hdr->cd_length) * ss, &error); Modified: head/sys/geom/raid/md_promise.c == --- head/sys/geom/raid/md_promise.c Thu Jan 12 06:38:03 2017 (r311963) +++ head/sys/geom/raid/md_promise.c Thu Jan 12 06:58:31 2017 (r311964) @@ -341,6 +341,11 @@ promise_meta_read(struct g_consumer *cp, pp = cp->provider; subdisks = 0; + + if (pp->sectorsize * 4 > MAXPHYS) { + G_RAID_DEBUG(1, "%s: Blocksize is too big.", pp->name); + return (subdisks); + } next: /* Read metadata block. */ buf = g_read_data(cp, pp->mediasize - pp->sectorsize * ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311953 - head/usr.sbin/pciconf
Author: cem Date: Thu Jan 12 00:34:37 2017 New Revision: 311953 URL: https://svnweb.freebsd.org/changeset/base/311953 Log: pciconf(8): Reallow trailing colon in selectors Reallow device selectors to have a trailing colon, as documented in the manual page. This was broken along with some unrelated cleanups in r295806. PR: 215979 Reported by: David Boyd Sponsored by: Dell EMC Isilon Modified: head/usr.sbin/pciconf/pciconf.c Modified: head/usr.sbin/pciconf/pciconf.c == --- head/usr.sbin/pciconf/pciconf.c Thu Jan 12 00:22:36 2017 (r311952) +++ head/usr.sbin/pciconf/pciconf.c Thu Jan 12 00:34:37 2017 (r311953) @@ -917,11 +917,8 @@ parsesel(const char *str) while (isdigit(*ep) && i < 4) { selarr[i++] = strtoul(ep, &eppos, 10); ep = eppos; - if (*ep == ':') { + if (*ep == ':') ep++; - if (*ep == '\0') - i = 0; - } } if (i > 0 && *ep == '\0') { sel.pc_func = (i > 2) ? selarr[--i] : 0; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311906 - in head/sys/contrib/dev/acpica: components/namespace components/tables include
Author: cem Date: Wed Jan 11 00:02:51 2017 New Revision: 311906 URL: https://svnweb.freebsd.org/changeset/base/311906 Log: Revert r311843, r311667 As jkim@ points out, it isn't needed. Modified: head/sys/contrib/dev/acpica/components/namespace/nsxfeval.c head/sys/contrib/dev/acpica/components/tables/tbxface.c head/sys/contrib/dev/acpica/include/acpixf.h Modified: head/sys/contrib/dev/acpica/components/namespace/nsxfeval.c == --- head/sys/contrib/dev/acpica/components/namespace/nsxfeval.c Tue Jan 10 22:13:44 2017(r311905) +++ head/sys/contrib/dev/acpica/components/namespace/nsxfeval.c Wed Jan 11 00:02:51 2017(r311906) @@ -1022,25 +1022,23 @@ ACPI_EXPORT_SYMBOL (AcpiDetachData) /*** * - * FUNCTION:AcpiGetDataFull + * FUNCTION:AcpiGetData * * PARAMETERS: ObjHandle - Namespace node - * Handle - Handler used in call to attach_data + * Handler - Handler used in call to AttachData * Data- Where the data is returned - * Callback- function to execute before returning * * RETURN: Status * - * DESCRIPTION: Retrieve data that was previously attached to a namespace node - * and execute a callback before returning. + * DESCRIPTION: Retrieve data that was previously attached to a namespace node. * **/ + ACPI_STATUS -AcpiGetDataFull ( +AcpiGetData ( ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler, -void**Data, -void (*Callback)(void *)) +void**Data) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; @@ -1071,34 +1069,10 @@ AcpiGetDataFull ( } Status = AcpiNsGetAttachedData (Node, Handler, Data); -if (ACPI_SUCCESS(Status) && Callback) { - Callback(*Data); -} + UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); } -ACPI_EXPORT_SYMBOL (AcpiGetDataFull) -/*** - * - * FUNCTION:AcpiGetData - * - * PARAMETERS: ObjHandle - Namespace node - * Handler - Handler used in call to AttachData - * Data- Where the data is returned - * - * RETURN: Status - * - * DESCRIPTION: Retrieve data that was previously attached to a namespace node. - * - **/ -ACPI_STATUS -AcpiGetData ( -ACPI_HANDLE ObjHandle, -ACPI_OBJECT_HANDLER Handler, -void**Data) -{ - return (AcpiGetDataFull(ObjHandle, Handler, Data, NULL)); -} ACPI_EXPORT_SYMBOL (AcpiGetData) Modified: head/sys/contrib/dev/acpica/components/tables/tbxface.c == --- head/sys/contrib/dev/acpica/components/tables/tbxface.c Tue Jan 10 22:13:44 2017(r311905) +++ head/sys/contrib/dev/acpica/components/tables/tbxface.c Wed Jan 11 00:02:51 2017(r311906) @@ -314,12 +314,11 @@ ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) /*** * - * FUNCTION:AcpiGetTableWithSize + * FUNCTION:AcpiGetTable * * PARAMETERS: Signature - ACPI signature of needed table * Instance- Which instance (for SSDTs) * OutTable- Where the pointer to the table is returned - * TblSize - Size of the table * * RETURN: Status and pointer to the requested table * @@ -334,11 +333,10 @@ ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) **/ ACPI_STATUS -AcpiGetTableWithSize ( +AcpiGetTable ( char*Signature, UINT32 Instance, -ACPI_TABLE_HEADER **OutTable, -ACPI_SIZE *TblSize) +ACPI_TABLE_HEADER **OutTable) { UINT32 i; UINT32 j; @@ -386,7 +384,7 @@ AcpiGetTableWithSize ( return (Status); } -ACPI_EXPORT_SYMBOL (AcpiGetTableWithSize) +ACPI_EXPORT_SYMBOL (AcpiGetTable) /*** @@ -436,36 +434,8 @@ AcpiPutTable ( (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_VOID; } -ACPI_EXPORT_SYMBOL (AcpiPutTable) - - -/*** - * - * FUNCTION:AcpiGetTable - * - * PARAMETERS: Signature - ACPI signature of needed table -
svn commit: r311843 - head/sys/contrib/dev/acpica/components/tables
Author: cem Date: Tue Jan 10 00:03:43 2017 New Revision: 311843 URL: https://svnweb.freebsd.org/changeset/base/311843 Log: Adjust ACPI_EXPORT_SYMBOL for AcpiGetTableWithSize Suggested by: jbeich@ Modified: head/sys/contrib/dev/acpica/components/tables/tbxface.c Modified: head/sys/contrib/dev/acpica/components/tables/tbxface.c == --- head/sys/contrib/dev/acpica/components/tables/tbxface.c Mon Jan 9 23:56:45 2017(r311842) +++ head/sys/contrib/dev/acpica/components/tables/tbxface.c Tue Jan 10 00:03:43 2017(r311843) @@ -386,7 +386,7 @@ AcpiGetTableWithSize ( return (Status); } -ACPI_EXPORT_SYMBOL (AcpiGetTable) +ACPI_EXPORT_SYMBOL (AcpiGetTableWithSize) /*** ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311842 - head/sys/fs/cd9660
Author: cem Date: Mon Jan 9 23:56:45 2017 New Revision: 311842 URL: https://svnweb.freebsd.org/changeset/base/311842 Log: cd9660: typedef cd_ino_t in preference to #define Suggested by: kib@ Modified: head/sys/fs/cd9660/iso.h Modified: head/sys/fs/cd9660/iso.h == --- head/sys/fs/cd9660/iso.hMon Jan 9 23:51:31 2017(r311841) +++ head/sys/fs/cd9660/iso.hMon Jan 9 23:56:45 2017(r311842) @@ -222,7 +222,7 @@ enum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_ /* * When ino_t becomes 64-bit, we can remove this definition in favor of ino_t. */ -#define cd_ino_t uint64_t +typedef __uint64_t cd_ino_t; struct iso_mnt { uint64_t im_flags; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311841 - head/sys/fs/cd9660
Author: cem Date: Mon Jan 9 23:51:31 2017 New Revision: 311841 URL: https://svnweb.freebsd.org/changeset/base/311841 Log: cd9660: Add a prototype for cd9660_vfs_hash_cmp GCC warns (and errors, with -Werror) about it otherwise. Clang doesn't care. Introduced in r311665. Reported by: np@ Modified: head/sys/fs/cd9660/cd9660_vfsops.c Modified: head/sys/fs/cd9660/cd9660_vfsops.c == --- head/sys/fs/cd9660/cd9660_vfsops.c Mon Jan 9 23:45:40 2017 (r311840) +++ head/sys/fs/cd9660/cd9660_vfsops.c Mon Jan 9 23:51:31 2017 (r311841) @@ -88,6 +88,7 @@ static struct vfsops cd9660_vfsops = { VFS_SET(cd9660_vfsops, cd9660, VFCF_READONLY); MODULE_VERSION(cd9660, 1); +static int cd9660_vfs_hash_cmp(struct vnode *vp, cd_ino_t *pino); static int iso_mountfs(struct vnode *devvp, struct mount *mp); /* ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311675 - head/sys/fs/cd9660
Author: cem Date: Sun Jan 8 09:16:07 2017 New Revision: 311675 URL: https://svnweb.freebsd.org/changeset/base/311675 Log: iso_rrip.h: Hide kernel definitions from makefs(8) Reported by: O. Hartmann Modified: head/sys/fs/cd9660/iso_rrip.h Modified: head/sys/fs/cd9660/iso_rrip.h == --- head/sys/fs/cd9660/iso_rrip.h Sun Jan 8 08:53:34 2017 (r311674) +++ head/sys/fs/cd9660/iso_rrip.h Sun Jan 8 09:16:07 2017 (r311675) @@ -54,6 +54,7 @@ #defineISO_SUSP_STOP 0x1000 #defineISO_SUSP_UNKNOWN0x8000 +#ifdef _KERNEL typedef struct { struct iso_node *inop; int fields; /* interesting fields in this analysis */ @@ -80,3 +81,4 @@ int cd9660_rrip_getsymname(struct iso_di struct iso_mnt *imp); int cd9660_rrip_offset(struct iso_directory_record *isodir, struct iso_mnt *imp); +#endif /* _KERNEL */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311671 - head/lib/libprocstat
Author: cem Date: Sun Jan 8 08:36:37 2017 New Revision: 311671 URL: https://svnweb.freebsd.org/changeset/base/311671 Log: libprocstat: Include cd9660 headers in the same order as the kernel Fix userspace build after r311665. Modified: head/lib/libprocstat/cd9660.c Modified: head/lib/libprocstat/cd9660.c == --- head/lib/libprocstat/cd9660.c Sun Jan 8 07:25:22 2017 (r311670) +++ head/lib/libprocstat/cd9660.c Sun Jan 8 08:36:37 2017 (r311671) @@ -53,10 +53,10 @@ __FBSDID("$FreeBSD$"); #include -#include #define _KERNEL #include #undef _KERNEL +#include #include #include ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311669 - head/usr.sbin/chown
Author: cem Date: Sun Jan 8 06:58:42 2017 New Revision: 311669 URL: https://svnweb.freebsd.org/changeset/base/311669 Log: chown/chgrp: Add SIGINFO handler PR: 191884 Submitted by: Dan McGregor Reviewed by: mjg@ (earlier version) Modified: head/usr.sbin/chown/chgrp.1 head/usr.sbin/chown/chown.8 head/usr.sbin/chown/chown.c Modified: head/usr.sbin/chown/chgrp.1 == --- head/usr.sbin/chown/chgrp.1 Sun Jan 8 06:50:53 2017(r311668) +++ head/usr.sbin/chown/chgrp.1 Sun Jan 8 06:58:42 2017(r311669) @@ -31,7 +31,7 @@ .\" @(#)chgrp.18.3 (Berkeley) 3/31/94 .\" $FreeBSD$ .\" -.Dd April 20, 2015 +.Dd January 7, 2017 .Dt CHGRP 1 .Os .Sh NAME @@ -120,6 +120,17 @@ The user invoking .Nm must belong to the specified group and be the owner of the file, or be the super-user. +.Pp +If +.Nm +receives a +.Dv SIGINFO +signal (see the +.Cm status +argument for +.Xr stty 1 ) , +then the current filename as well as the old and new group names are +displayed. .Sh FILES .Bl -tag -width /etc/group -compact .It Pa /etc/group Modified: head/usr.sbin/chown/chown.8 == --- head/usr.sbin/chown/chown.8 Sun Jan 8 06:50:53 2017(r311668) +++ head/usr.sbin/chown/chown.8 Sun Jan 8 06:58:42 2017(r311669) @@ -28,7 +28,7 @@ .\" @(#)chown.88.3 (Berkeley) 3/31/94 .\" $FreeBSD$ .\" -.Dd April 20, 2015 +.Dd January 7, 2017 .Dt CHOWN 8 .Os .Sh NAME @@ -135,6 +135,17 @@ group name. .Pp The ownership of a file may only be altered by a super-user for obvious security reasons. +.Pp +If +.Nm +receives a +.Dv SIGINFO +signal (see the +.Cm status +argument for +.Xr stty 1 ) , +then the current filename as well as the old and new file owner and group +are displayed. .Sh EXIT STATUS .Ex -std .Sh COMPATIBILITY Modified: head/usr.sbin/chown/chown.c == --- head/usr.sbin/chown/chown.c Sun Jan 8 06:50:53 2017(r311668) +++ head/usr.sbin/chown/chown.c Sun Jan 8 06:58:42 2017(r311669) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -63,11 +64,20 @@ static void a_uid(const char *); static voidchownerr(const char *); static uid_t id(const char *, const char *); static voidusage(void); +static voidprint_info(const FTSENT *, int); static uid_t uid; static gid_t gid; static int ischown; static const char *gname; +static volatile sig_atomic_t siginfo; + +static void +siginfo_handler(int sig __unused) +{ + + siginfo = 1; +} int main(int argc, char **argv) @@ -119,6 +129,8 @@ main(int argc, char **argv) if (argc < 2) usage(); + (void)signal(SIGINFO, siginfo_handler); + if (Rflag) { if (hflag && (Hflag || Lflag)) errx(1, "the -R%c and -h options may not be " @@ -189,6 +201,10 @@ main(int argc, char **argv) default: break; } + if (siginfo) { + print_info(p, 2); + siginfo = 0; + } if ((uid == (uid_t)-1 || uid == p->fts_statp->st_uid) && (gid == (gid_t)-1 || gid == p->fts_statp->st_gid)) continue; @@ -196,35 +212,8 @@ main(int argc, char **argv) == -1 && !fflag) { chownerr(p->fts_path); rval = 1; - } else if (vflag) { - printf("%s", p->fts_path); - if (vflag > 1) { - if (ischown) { - printf(": %ju:%ju -> %ju:%ju", - (uintmax_t) - p->fts_statp->st_uid, - (uintmax_t) - p->fts_statp->st_gid, - (uid == (uid_t)-1) ? - (uintmax_t) - p->fts_statp->st_uid : - (uintmax_t)uid, - (gid == (gid_t)-1) ? - (uintmax_t) - p->fts_statp->st_gid : - (uintmax_t)gid); - } else { - printf(": %ju -> %ju", - (uintmax_t) - p->fts_statp->st_gid, - (gid == (gid_t)-1) ? - (uin
svn commit: r311668 - head/bin/chmod
Author: cem Date: Sun Jan 8 06:50:53 2017 New Revision: 311668 URL: https://svnweb.freebsd.org/changeset/base/311668 Log: chmod: Add SIGINFO handler PR: 191884 Submitted by: Dan McGregor Reviewed by: mjg@ (earlier version) Modified: head/bin/chmod/chmod.1 head/bin/chmod/chmod.c Modified: head/bin/chmod/chmod.1 == --- head/bin/chmod/chmod.1 Sun Jan 8 06:26:33 2017(r311667) +++ head/bin/chmod/chmod.1 Sun Jan 8 06:50:53 2017(r311668) @@ -32,7 +32,7 @@ .\"@(#)chmod.1 8.4 (Berkeley) 3/31/94 .\" $FreeBSD$ .\" -.Dd April 20, 2015 +.Dd January 7, 2017 .Dt CHMOD 1 .Os .Sh NAME @@ -106,6 +106,16 @@ option is specified. In addition, these options override each other and the command's actions are determined by the last one specified. .Pp +If +.Nm +receives a +.Dv SIGINFO +signal (see the +.Cm status +argument for +.Xr stty 1 ) , +then the current filename as well as the old and new modes are displayed. +.Pp Only the owner of a file or the super-user is permitted to change the mode of a file. .Sh EXIT STATUS Modified: head/bin/chmod/chmod.c == --- head/bin/chmod/chmod.c Sun Jan 8 06:26:33 2017(r311667) +++ head/bin/chmod/chmod.c Sun Jan 8 06:50:53 2017(r311668) @@ -49,14 +49,24 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include +static volatile sig_atomic_t siginfo; + static void usage(void); static int may_have_nfs4acl(const FTSENT *ent, int hflag); +static void +siginfo_handler(int sig __unused) +{ + + siginfo = 1; +} + int main(int argc, char *argv[]) { @@ -125,6 +135,8 @@ done: argv += optind; if (argc < 2) usage(); + (void)signal(SIGINFO, siginfo_handler); + if (Rflag) { if (hflag) errx(1, "the -R and -h options may not be " @@ -192,10 +204,10 @@ done: argv += optind; && !fflag) { warn("%s", p->fts_path); rval = 1; - } else if (vflag) { + } else if (vflag || siginfo) { (void)printf("%s", p->fts_path); - if (vflag > 1) { + if (vflag > 1 || siginfo) { char m1[12], m2[12]; strmode(p->fts_statp->st_mode, m1); @@ -207,6 +219,7 @@ done: argv += optind; newmode, m2); } (void)printf("\n"); + siginfo = 0; } } if (errno) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311667 - in head/sys/contrib/dev/acpica: components/namespace components/tables include
Author: cem Date: Sun Jan 8 06:26:33 2017 New Revision: 311667 URL: https://svnweb.freebsd.org/changeset/base/311667 Log: Add some additional ACPI methods for DRM Add AcpiGetDataFull and AcpiGetTableWithSize. Submitted by: Matt Macy Modified: head/sys/contrib/dev/acpica/components/namespace/nsxfeval.c head/sys/contrib/dev/acpica/components/tables/tbxface.c head/sys/contrib/dev/acpica/include/acpixf.h Modified: head/sys/contrib/dev/acpica/components/namespace/nsxfeval.c == --- head/sys/contrib/dev/acpica/components/namespace/nsxfeval.c Sun Jan 8 06:22:35 2017(r311666) +++ head/sys/contrib/dev/acpica/components/namespace/nsxfeval.c Sun Jan 8 06:26:33 2017(r311667) @@ -1022,23 +1022,25 @@ ACPI_EXPORT_SYMBOL (AcpiDetachData) /*** * - * FUNCTION:AcpiGetData + * FUNCTION:AcpiGetDataFull * * PARAMETERS: ObjHandle - Namespace node - * Handler - Handler used in call to AttachData + * Handle - Handler used in call to attach_data * Data- Where the data is returned + * Callback- function to execute before returning * * RETURN: Status * - * DESCRIPTION: Retrieve data that was previously attached to a namespace node. + * DESCRIPTION: Retrieve data that was previously attached to a namespace node + * and execute a callback before returning. * **/ - ACPI_STATUS -AcpiGetData ( +AcpiGetDataFull ( ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler, -void**Data) +void**Data, +void (*Callback)(void *)) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; @@ -1069,10 +1071,34 @@ AcpiGetData ( } Status = AcpiNsGetAttachedData (Node, Handler, Data); - +if (ACPI_SUCCESS(Status) && Callback) { + Callback(*Data); +} UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); } +ACPI_EXPORT_SYMBOL (AcpiGetDataFull) +/*** + * + * FUNCTION:AcpiGetData + * + * PARAMETERS: ObjHandle - Namespace node + * Handler - Handler used in call to AttachData + * Data- Where the data is returned + * + * RETURN: Status + * + * DESCRIPTION: Retrieve data that was previously attached to a namespace node. + * + **/ +ACPI_STATUS +AcpiGetData ( +ACPI_HANDLE ObjHandle, +ACPI_OBJECT_HANDLER Handler, +void**Data) +{ + return (AcpiGetDataFull(ObjHandle, Handler, Data, NULL)); +} ACPI_EXPORT_SYMBOL (AcpiGetData) Modified: head/sys/contrib/dev/acpica/components/tables/tbxface.c == --- head/sys/contrib/dev/acpica/components/tables/tbxface.c Sun Jan 8 06:22:35 2017(r311666) +++ head/sys/contrib/dev/acpica/components/tables/tbxface.c Sun Jan 8 06:26:33 2017(r311667) @@ -314,11 +314,12 @@ ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) /*** * - * FUNCTION:AcpiGetTable + * FUNCTION:AcpiGetTableWithSize * * PARAMETERS: Signature - ACPI signature of needed table * Instance- Which instance (for SSDTs) * OutTable- Where the pointer to the table is returned + * TblSize - Size of the table * * RETURN: Status and pointer to the requested table * @@ -333,10 +334,11 @@ ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) **/ ACPI_STATUS -AcpiGetTable ( +AcpiGetTableWithSize ( char*Signature, UINT32 Instance, -ACPI_TABLE_HEADER **OutTable) +ACPI_TABLE_HEADER **OutTable, +ACPI_SIZE *TblSize) { UINT32 i; UINT32 j; @@ -434,12 +436,40 @@ AcpiPutTable ( (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_VOID; } - ACPI_EXPORT_SYMBOL (AcpiPutTable) /*** * + * FUNCTION:AcpiGetTable + * + * PARAMETERS: Signature - ACPI signature of needed table + * Instance- Which instance (for SSDTs) + * OutTable- Where the pointer to the table is returned + * + * RETURN: Status and p
svn commit: r311666 - head/sys/fs/cd9660
Author: cem Date: Sun Jan 8 06:22:35 2017 New Revision: 311666 URL: https://svnweb.freebsd.org/changeset/base/311666 Log: Do not truncate inode calculation from ISO9660 block offset PR: 190655 Reported by: Thomas Schmitt Obtained from:NetBSD sys/fs/cd9660/cd9660_node.c,r1.31 Modified: head/sys/fs/cd9660/cd9660_node.c Modified: head/sys/fs/cd9660/cd9660_node.c == --- head/sys/fs/cd9660/cd9660_node.cSun Jan 8 06:21:49 2017 (r311665) +++ head/sys/fs/cd9660/cd9660_node.cSun Jan 8 06:22:35 2017 (r311666) @@ -316,7 +316,14 @@ isodirino(isodir, imp) { cd_ino_t ino; - ino = (isonum_733(isodir->extent) + isonum_711(isodir->ext_attr_length)) - << imp->im_bshift; - return (ino); + /* +* Note there is an inverse calculation in +* cd9660_vfsops.c:cd9660_vget_internal(): +* ip->iso_start = ino >> imp->im_bshift; +* and also a calculation of the isodir pointer +* from an inode in cd9660_vnops.c:cd9660_readlink() +*/ + ino = ((cd_ino_t)isonum_733(isodir->extent) + + isonum_711(isodir->ext_attr_length)) << imp->im_bshift; + return ino; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311665 - head/sys/fs/cd9660
Author: cem Date: Sun Jan 8 06:21:49 2017 New Revision: 311665 URL: https://svnweb.freebsd.org/changeset/base/311665 Log: cd9660: Expand internal inum size to 64 bits Inums in cd9660 refer to byte offsets on the media. DVD and BD media can have entries above 4GB, especially with multi-session images. PR: 190655 Reported by: Thomas Schmitt Modified: head/sys/fs/cd9660/cd9660_lookup.c head/sys/fs/cd9660/cd9660_node.c head/sys/fs/cd9660/cd9660_node.h head/sys/fs/cd9660/cd9660_rrip.c head/sys/fs/cd9660/cd9660_vfsops.c head/sys/fs/cd9660/cd9660_vnops.c head/sys/fs/cd9660/iso.h head/sys/fs/cd9660/iso_rrip.h Modified: head/sys/fs/cd9660/cd9660_lookup.c == --- head/sys/fs/cd9660/cd9660_lookup.c Sun Jan 8 06:20:21 2017 (r311664) +++ head/sys/fs/cd9660/cd9660_lookup.c Sun Jan 8 06:21:49 2017 (r311665) @@ -51,8 +51,8 @@ __FBSDID("$FreeBSD$"); #include struct cd9660_ino_alloc_arg { - ino_t ino; - ino_t i_ino; + cd_ino_t ino; + cd_ino_t i_ino; struct iso_directory_record *ep; }; @@ -124,7 +124,7 @@ cd9660_lookup(ap) struct cd9660_ino_alloc_arg dd_arg; u_long bmask; /* block offset mask */ int error; - ino_t ino, i_ino; + cd_ino_t ino, i_ino; int ltype, reclen; u_short namelen; int isoflags; Modified: head/sys/fs/cd9660/cd9660_node.c == --- head/sys/fs/cd9660/cd9660_node.cSun Jan 8 06:20:21 2017 (r311664) +++ head/sys/fs/cd9660/cd9660_node.cSun Jan 8 06:21:49 2017 (r311665) @@ -309,12 +309,12 @@ cd9660_tstamp_conv17(pi,pu) return cd9660_tstamp_conv7(buf, pu, ISO_FTYPE_DEFAULT); } -ino_t +cd_ino_t isodirino(isodir, imp) struct iso_directory_record *isodir; struct iso_mnt *imp; { - ino_t ino; + cd_ino_t ino; ino = (isonum_733(isodir->extent) + isonum_711(isodir->ext_attr_length)) << imp->im_bshift; Modified: head/sys/fs/cd9660/cd9660_node.h == --- head/sys/fs/cd9660/cd9660_node.hSun Jan 8 06:20:21 2017 (r311664) +++ head/sys/fs/cd9660/cd9660_node.hSun Jan 8 06:21:49 2017 (r311665) @@ -58,7 +58,7 @@ typedef struct { struct iso_node { struct vnode *i_vnode; /* vnode associated with this inode */ - ino_t i_number; /* the identity of the inode */ + cd_ino_ti_number; /* the identity of the inode */ /* we use the actual starting block of the file */ struct iso_mnt *i_mnt; /* filesystem associated with this inode */ struct lockf *i_lockf; /* head of byte-level lock list */ Modified: head/sys/fs/cd9660/cd9660_rrip.c == --- head/sys/fs/cd9660/cd9660_rrip.cSun Jan 8 06:20:21 2017 (r311664) +++ head/sys/fs/cd9660/cd9660_rrip.cSun Jan 8 06:21:49 2017 (r311665) @@ -628,7 +628,7 @@ cd9660_rrip_getname(isodir,outbuf,outlen struct iso_directory_record *isodir; char *outbuf; u_short *outlen; - ino_t *inump; + cd_ino_t *inump; struct iso_mnt *imp; { ISO_RRIP_ANALYZE analyze; Modified: head/sys/fs/cd9660/cd9660_vfsops.c == --- head/sys/fs/cd9660/cd9660_vfsops.c Sun Jan 8 06:20:21 2017 (r311664) +++ head/sys/fs/cd9660/cd9660_vfsops.c Sun Jan 8 06:21:49 2017 (r311665) @@ -540,7 +540,7 @@ cd9660_root(mp, flags, vpp) struct iso_mnt *imp = VFSTOISOFS(mp); struct iso_directory_record *dp = (struct iso_directory_record *)imp->root; - ino_t ino = isodirino(dp, imp); + cd_ino_t ino = isodirino(dp, imp); /* * With RRIP we must use the `.' entry of the root directory. @@ -617,6 +617,11 @@ cd9660_fhtovp(mp, fhp, flags, vpp) return (0); } +/* + * Conform to standard VFS interface; can't vget arbitrary inodes beyond 4GB + * into media with current inode scheme and 32-bit ino_t. This shouldn't be + * needed for anything other than nfsd, and who exports a mounted DVD over NFS? + */ static int cd9660_vget(mp, ino, flags, vpp) struct mount *mp; @@ -640,10 +645,22 @@ cd9660_vget(mp, ino, flags, vpp) (struct iso_directory_record *)0)); } +/* Use special comparator for full 64-bit ino comparison. */ +static int +cd9660_vfs_hash_cmp(vp, pino) + struct vnode *vp; + cd_ino_t *pino; +{ + struct iso_node *ip; + + ip = VTOI(vp); + return (ip->i_number != *pino); +} + int cd9660_vget_internal(mp, ino, flags, vpp, relocated, isodir) struct mount *mp; - ino
svn commit: r311664 - head/sys/dev/mmc
Author: cem Date: Sun Jan 8 06:20:21 2017 New Revision: 311664 URL: https://svnweb.freebsd.org/changeset/base/311664 Log: mmc: Accept even lower voltage for Cherryview And HP x2 210, per DragonFlyBSD 240bd9cd58f8259c12c14a8006837e698. Submitted by: Johannes Lundberg No objection: gonzo@ Obtained from:DragonFlyBSD Modified: head/sys/dev/mmc/mmcreg.h Modified: head/sys/dev/mmc/mmcreg.h == --- head/sys/dev/mmc/mmcreg.h Sun Jan 8 04:27:08 2017(r311663) +++ head/sys/dev/mmc/mmcreg.h Sun Jan 8 06:20:21 2017(r311664) @@ -355,8 +355,8 @@ struct mmc_request { */ #defineMMC_OCR_VOLTAGE 0x3fffU /* Vdd Voltage mask */ #defineMMC_OCR_LOW_VOLTAGE (1u << 7) /* Low Voltage Range -- tbd */ +#defineMMC_OCR_MIN_VOLTAGE_SHIFT 7 #defineMMC_OCR_200_210 (1U << 8) /* Vdd voltage 2.00 ~ 2.10 */ -#defineMMC_OCR_MIN_VOLTAGE_SHIFT 8 #defineMMC_OCR_210_220 (1U << 9) /* Vdd voltage 2.10 ~ 2.20 */ #defineMMC_OCR_220_230 (1U << 10) /* Vdd voltage 2.20 ~ 2.30 */ #defineMMC_OCR_230_240 (1U << 11) /* Vdd voltage 2.30 ~ 2.40 */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310341 - head/sys/dev/sdhci
Author: cem Date: Tue Dec 20 22:47:09 2016 New Revision: 310341 URL: https://svnweb.freebsd.org/changeset/base/310341 Log: Follow-up to r310340: Add missing "Intel" to description Reported by: rpokala@ Modified: head/sys/dev/sdhci/sdhci_pci.c Modified: head/sys/dev/sdhci/sdhci_pci.c == --- head/sys/dev/sdhci/sdhci_pci.c Tue Dec 20 22:08:36 2016 (r310340) +++ head/sys/dev/sdhci/sdhci_pci.c Tue Dec 20 22:47:09 2016 (r310341) @@ -107,7 +107,7 @@ static const struct sdhci_device { SDHCI_QUIRK_RESET_AFTER_REQUEST }, { 0x16bc14e4, 0x, "Broadcom BCM577xx SDXC/MMC Card Reader", SDHCI_QUIRK_BCM577XX_400KHZ_CLKSRC }, - { 0x22948086, 0x, "Braswell Storage Cluster Control MMC Port", + { 0x22948086, 0x, "Intel Braswell Storage Cluster Control MMC Port", 0 }, { 0,0x, NULL, 0 } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310340 - in head/sys/dev: ichiic sdhci
Author: cem Date: Tue Dec 20 22:08:36 2016 New Revision: 310340 URL: https://svnweb.freebsd.org/changeset/base/310340 Log: Add Braswell PCI IDs for Intel Cherryview Submitted by: Johannes Lundberg Reviewed by: jhb Differential Revision:https://reviews.freebsd.org/D8861 Modified: head/sys/dev/ichiic/ig4_pci.c head/sys/dev/sdhci/sdhci_pci.c Modified: head/sys/dev/ichiic/ig4_pci.c == --- head/sys/dev/ichiic/ig4_pci.c Tue Dec 20 21:58:43 2016 (r310339) +++ head/sys/dev/ichiic/ig4_pci.c Tue Dec 20 22:08:36 2016 (r310340) @@ -68,6 +68,12 @@ static int ig4iic_pci_detach(device_t de #define PCI_CHIP_LYNXPT_LP_I2C_1 0x9c618086 #define PCI_CHIP_LYNXPT_LP_I2C_2 0x9c628086 +#define PCI_CHIP_BRASWELL_I2C_10x22c18086 +#define PCI_CHIP_BRASWELL_I2C_20x22c28086 +#define PCI_CHIP_BRASWELL_I2C_30x22c38086 +#define PCI_CHIP_BRASWELL_I2C_50x22c58086 +#define PCI_CHIP_BRASWELL_I2C_60x22c68086 +#define PCI_CHIP_BRASWELL_I2C_70x22c78086 static int ig4iic_pci_probe(device_t dev) @@ -79,6 +85,24 @@ ig4iic_pci_probe(device_t dev) case PCI_CHIP_LYNXPT_LP_I2C_2: device_set_desc(dev, "Intel Lynx Point-LP I2C Controller-2"); break; + case PCI_CHIP_BRASWELL_I2C_1: + device_set_desc(dev, "Intel Braswell Serial I/O I2C Port 1"); + break; + case PCI_CHIP_BRASWELL_I2C_2: + device_set_desc(dev, "Intel Braswell Serial I/O I2C Port 2"); + break; + case PCI_CHIP_BRASWELL_I2C_3: + device_set_desc(dev, "Intel Braswell Serial I/O I2C Port 3"); + break; + case PCI_CHIP_BRASWELL_I2C_5: + device_set_desc(dev, "Intel Braswell Serial I/O I2C Port 5"); + break; + case PCI_CHIP_BRASWELL_I2C_6: + device_set_desc(dev, "Intel Braswell Serial I/O I2C Port 6"); + break; + case PCI_CHIP_BRASWELL_I2C_7: + device_set_desc(dev, "Intel Braswell Serial I/O I2C Port 7"); + break; default: return (ENXIO); } Modified: head/sys/dev/sdhci/sdhci_pci.c == --- head/sys/dev/sdhci/sdhci_pci.c Tue Dec 20 21:58:43 2016 (r310339) +++ head/sys/dev/sdhci/sdhci_pci.c Tue Dec 20 22:08:36 2016 (r310340) @@ -107,6 +107,8 @@ static const struct sdhci_device { SDHCI_QUIRK_RESET_AFTER_REQUEST }, { 0x16bc14e4, 0x, "Broadcom BCM577xx SDXC/MMC Card Reader", SDHCI_QUIRK_BCM577XX_400KHZ_CLKSRC }, + { 0x22948086, 0x, "Braswell Storage Cluster Control MMC Port", + 0 }, { 0,0x, NULL, 0 } }; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310329 - head/usr.sbin/cron/crontab
Author: cem Date: Tue Dec 20 17:12:17 2016 New Revision: 310329 URL: https://svnweb.freebsd.org/changeset/base/310329 Log: Add a 'force' option for non-interactive crontab removal Add a '-f' option to force crontab '-r' to be non-interactive. Submitted by: Sam Gwydir Reviewed by: me, wblock (previous version) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8815 Modified: head/usr.sbin/cron/crontab/crontab.1 head/usr.sbin/cron/crontab/crontab.c Modified: head/usr.sbin/cron/crontab/crontab.1 == --- head/usr.sbin/cron/crontab/crontab.1Tue Dec 20 16:37:45 2016 (r310328) +++ head/usr.sbin/cron/crontab/crontab.1Tue Dec 20 17:12:17 2016 (r310329) @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 13, 2010 +.Dd December 20, 2016 .Dt CRONTAB 1 .Os .Sh NAME @@ -31,7 +31,8 @@ .Op Fl u Ar user { .Fl l | -.Fl r | +.Fl r Op Fl f +| .Fl e } .Sh DESCRIPTION @@ -97,6 +98,11 @@ option for safety's sake. Display the current crontab on standard output. .It Fl r Remove the current crontab. +By default the +.Fl r +option prompts for confirmation, adding the +.Fl f +option will attempt to remove the current crontab without confirmation. .It Fl e Edit the current crontab using the editor specified by the Modified: head/usr.sbin/cron/crontab/crontab.c == --- head/usr.sbin/cron/crontab/crontab.cTue Dec 20 16:37:45 2016 (r310328) +++ head/usr.sbin/cron/crontab/crontab.cTue Dec 20 17:12:17 2016 (r310329) @@ -63,6 +63,7 @@ staticcharFilename[MAX_FNAME]; static FILE*NewCrontab; static int CheckErrorCount; static enum opt_t Option; +static int fflag; static struct passwd *pw; static voidlist_cmd(void), delete_cmd(void), @@ -79,7 +80,7 @@ usage(char *msg) fprintf(stderr, "crontab: usage error: %s\n", msg); fprintf(stderr, "%s\n%s\n", "usage: crontab [-u user] file", - " crontab [-u user] { -e | -l | -r }"); + " crontab [-u user] { -l | -r [-f] | -e }"); exit(ERROR_EXIT); } @@ -142,7 +143,7 @@ parse_args(argc, argv) strcpy(RealUser, User); Filename[0] = '\0'; Option = opt_unknown; - while ((argch = getopt(argc, argv, "u:lerx:")) != -1) { + while ((argch = getopt(argc, argv, "u:lerx:f")) != -1) { switch (argch) { case 'x': if (!set_debug_flags(optarg)) @@ -172,6 +173,9 @@ parse_args(argc, argv) usage("only one operation permitted"); Option = opt_edit; break; + case 'f': + fflag = 1; + break; default: usage("unrecognized option"); } @@ -282,7 +286,7 @@ delete_cmd() { charn[MAX_FNAME]; int ch, first; - if (isatty(STDIN_FILENO)) { + if (!fflag && isatty(STDIN_FILENO)) { (void)fprintf(stderr, "remove crontab for %s? ", User); first = ch = getchar(); while (ch != '\n' && ch != EOF) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310309 - in head/sys/dev: mmc sdhci
Author: cem Date: Tue Dec 20 03:38:14 2016 New Revision: 310309 URL: https://svnweb.freebsd.org/changeset/base/310309 Log: sdhci/mmc: Minor whitespace cleanups No functional change. Submitted by: Johannes Lundberg Modified: head/sys/dev/mmc/mmc.c head/sys/dev/sdhci/sdhci_pci.c Modified: head/sys/dev/mmc/mmc.c == --- head/sys/dev/mmc/mmc.c Tue Dec 20 01:51:09 2016(r310308) +++ head/sys/dev/mmc/mmc.c Tue Dec 20 03:38:14 2016(r310309) @@ -401,7 +401,7 @@ mmc_wait_for_req(struct mmc_softc *sc, s msleep(req, &sc->sc_mtx, 0, "mmcreq", 0); MMC_UNLOCK(sc); if (mmc_debug > 2 || (mmc_debug > 0 && req->cmd->error != MMC_ERR_NONE)) - device_printf(sc->dev, "CMD%d RESULT: %d\n", + device_printf(sc->dev, "CMD%d RESULT: %d\n", req->cmd->opcode, req->cmd->error); return (0); } @@ -511,7 +511,7 @@ mmc_idle_cards(struct mmc_softc *sc) { device_t dev; struct mmc_command cmd; - + dev = sc->dev; mmcbr_set_chip_select(dev, cs_high); mmcbr_update_ios(dev); @@ -795,7 +795,7 @@ mmc_test_bus_width(struct mmc_softc *sc) data.len = 8; data.flags = MMC_DATA_WRITE; mmc_wait_for_cmd(sc, &cmd, 0); - + memset(&cmd, 0, sizeof(cmd)); memset(&data, 0, sizeof(data)); cmd.opcode = MMC_BUSTEST_R; @@ -808,7 +808,7 @@ mmc_test_bus_width(struct mmc_softc *sc) data.flags = MMC_DATA_READ; err = mmc_wait_for_cmd(sc, &cmd, 0); sc->squelched--; - + mmcbr_set_bus_width(sc->dev, bus_width_1); mmcbr_update_ios(sc->dev); @@ -832,7 +832,7 @@ mmc_test_bus_width(struct mmc_softc *sc) data.len = 4; data.flags = MMC_DATA_WRITE; mmc_wait_for_cmd(sc, &cmd, 0); - + memset(&cmd, 0, sizeof(cmd)); memset(&data, 0, sizeof(data)); cmd.opcode = MMC_BUSTEST_R; @@ -1017,7 +1017,7 @@ mmc_decode_csd_sd(uint32_t *raw_csd, str csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 128, 26, 3); csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 128, 22, 4); csd->write_bl_partial = mmc_get_bits(raw_csd, 128, 21, 1); - } else + } else panic("unknown SD CSD version"); } @@ -1349,9 +1349,9 @@ mmc_discover_cards(struct mmc_softc *sc) if (ivar->csd.csd_structure > 0) ivar->high_cap = 1; ivar->tran_speed = ivar->csd.tran_speed; - ivar->erase_sector = ivar->csd.erase_sector * + ivar->erase_sector = ivar->csd.erase_sector * ivar->csd.write_bl_len / MMC_SECTOR_SIZE; - + err = mmc_send_status(sc, ivar->rca, &status); if (err != MMC_ERR_NONE) { device_printf(sc->dev, @@ -1446,7 +1446,7 @@ mmc_discover_cards(struct mmc_softc *sc) mmc_decode_csd_mmc(ivar->raw_csd, &ivar->csd); ivar->sec_count = ivar->csd.capacity / MMC_SECTOR_SIZE; ivar->tran_speed = ivar->csd.tran_speed; - ivar->erase_sector = ivar->csd.erase_sector * + ivar->erase_sector = ivar->csd.erase_sector * ivar->csd.write_bl_len / MMC_SECTOR_SIZE; err = mmc_send_status(sc, ivar->rca, &status); @@ -1655,7 +1655,7 @@ mmc_calculate_clock(struct mmc_softc *sc int nkid, i, f_max; device_t *kids; struct mmc_ivars *ivar; - + f_max = mmcbr_get_f_max(sc->dev); max_dtr = max_hs_dtr = f_max; if ((mmcbr_get_caps(sc->dev) & MMC_CAP_HSPEED)) @@ -1770,7 +1770,7 @@ static void mmc_delayed_attach(void *xsc) { struct mmc_softc *sc = xsc; - + mmc_scan(sc); config_intrhook_disestablish(&sc->config_intrhook); } Modified: head/sys/dev/sdhci/sdhci_pci.c == --- head/sys/dev/sdhci/sdhci_pci.c Tue Dec 20 01:51:09 2016 (r310308) +++ head/sys/dev/sdhci/sdhci_pci.c Tue Dec 20 03:38:14 2016 (r310309) @@ -63,15 +63,15 @@ __FBSDID("$FreeBSD$"); #define PCI_SDHCI_IFVENDOR 0x02 #define PCI_SLOT_INFO 0x40/* 8 bits */ -#define PCI_SLOT_INFO_SLOTS(x)(((x >> 4) & 7) + 1) -#define PCI_SLOT_INFO_FIRST_BAR(x)((x) & 7) +#define PCI_SLOT_INFO_SLOTS(x) (((x >> 4) & 7) + 1) +#define PCI_SLOT_INFO_FIRST_BAR(x) ((x) & 7) /* * RICOH specific PCI registers */ #defineSDHC_PCI_MODE_KEY 0xf9 #defi
svn commit: r310145 - head/usr.bin/ident
Author: cem Date: Fri Dec 16 02:09:48 2016 New Revision: 310145 URL: https://svnweb.freebsd.org/changeset/base/310145 Log: ident(1): Capsicumify Preopen input file list before entering Capsicum capability mode. Feedback by: allanjude@, bapt@, emaste@ (earlier versions) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7918 Modified: head/usr.bin/ident/ident.c Modified: head/usr.bin/ident/ident.c == --- head/usr.bin/ident/ident.c Fri Dec 16 02:06:34 2016(r310144) +++ head/usr.bin/ident/ident.c Fri Dec 16 02:09:48 2016(r310145) @@ -28,11 +28,14 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include +#include #include #include +#include #include #include #include @@ -202,8 +205,9 @@ int main(int argc, char **argv) { bool quiet = false; - int ch, i; + int ch, i, *fds, fd; int ret = EXIT_SUCCESS; + size_t nfds; FILE *fp; while ((ch = getopt(argc, argv, "qV")) != -1) { @@ -223,17 +227,50 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if (argc == 0) - return (scan(stdin, NULL, quiet)); + if (caph_limit_stdio() < 0) + err(EXIT_FAILURE, "unable to limit stdio"); - for (i = 0; i < argc; i++) { - fp = fopen(argv[i], "r"); + if (argc == 0) { + nfds = 1; + fds = malloc(sizeof(*fds)); + if (fds == NULL) + err(EXIT_FAILURE, "unable to allocate fds array"); + fds[0] = STDIN_FILENO; + } else { + nfds = argc; + fds = malloc(sizeof(*fds) * nfds); + if (fds == NULL) + err(EXIT_FAILURE, "unable to allocate fds array"); + + for (i = 0; i < argc; i++) { + fds[i] = fd = open(argv[i], O_RDONLY); + if (fd < 0) { + warn("%s", argv[i]); + ret = EXIT_FAILURE; + continue; + } + if (caph_limit_stream(fd, CAPH_READ) < 0) + err(EXIT_FAILURE, + "unable to limit fcntls/rights for %s", + argv[i]); + } + } + + /* Enter Capsicum sandbox. */ + if (cap_enter() < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to enter capability mode"); + + for (i = 0; i < (int)nfds; i++) { + if (fds[i] < 0) + continue; + + fp = fdopen(fds[i], "r"); if (fp == NULL) { warn("%s", argv[i]); ret = EXIT_FAILURE; continue; } - if (scan(fp, argv[i], quiet) != EXIT_SUCCESS) + if (scan(fp, argc == 0 ? NULL : argv[i], quiet) != EXIT_SUCCESS) ret = EXIT_FAILURE; fclose(fp); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310144 - head/usr.bin/iconv
Author: cem Date: Fri Dec 16 02:06:34 2016 New Revision: 310144 URL: https://svnweb.freebsd.org/changeset/base/310144 Log: iconv(1): Capsicumify This takes the usual shortcut of only sandboxing the last input file. It's a first cut and this program will be easy to adapt to sandbox all files in the future. iconv(1) has been changed to only open the conversion descriptor once, since the input and output encodings are fixed over all inputs. Instead, the descriptor is simply reset after each use (documented in iconv(3) API). Reviewed by: no one, unfortunately Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7917 Modified: head/usr.bin/iconv/iconv.c Modified: head/usr.bin/iconv/iconv.c == --- head/usr.bin/iconv/iconv.c Fri Dec 16 02:03:40 2016(r310143) +++ head/usr.bin/iconv/iconv.c Fri Dec 16 02:06:34 2016(r310144) @@ -28,7 +28,9 @@ */ #include +#include +#include #include #include #include @@ -41,7 +43,7 @@ #include #include -static int do_conv(FILE *, const char *, const char *, bool, bool); +static int do_conv(FILE *, iconv_t, bool, bool); static int do_list(unsigned int, const char * const *, void *); static voidusage(void) __dead2; @@ -67,23 +69,16 @@ usage(void) #define INBUFSIZE 1024 #define OUTBUFSIZE (INBUFSIZE * 2) static int -do_conv(FILE *fp, const char *from, const char *to, bool silent, -bool hide_invalid) +do_conv(FILE *fp, iconv_t cd, bool silent, bool hide_invalid) { - iconv_t cd; char inbuf[INBUFSIZE], outbuf[OUTBUFSIZE], *in, *out; unsigned long long invalids; size_t inbytes, outbytes, ret; - if ((cd = iconv_open(to, from)) == (iconv_t)-1) - err(EXIT_FAILURE, "iconv_open(%s, %s)", to, from); - - if (hide_invalid) { - int arg = 1; + int arg = (int)hide_invalid; + if (iconvctl(cd, ICONV_SET_DISCARD_ILSEQ, (void *)&arg) == -1) + err(EXIT_FAILURE, "iconvctl(DISCARD_ILSEQ, %d)", arg); - if (iconvctl(cd, ICONV_SET_DISCARD_ILSEQ, (void *)&arg) == -1) - err(EXIT_FAILURE, NULL); - } invalids = 0; while ((inbytes = fread(inbuf, 1, INBUFSIZE, fp)) > 0) { in = inbuf; @@ -133,7 +128,6 @@ do_conv(FILE *fp, const char *from, cons if (invalids > 0 && !silent) warnx("warning: invalid characters: %llu", invalids); - iconv_close(cd); return (invalids > 0); } @@ -155,6 +149,7 @@ do_list(unsigned int n, const char * con int main(int argc, char **argv) { + iconv_t cd; FILE *fp; const char *opt_f, *opt_t; int ch, i, res; @@ -201,9 +196,28 @@ main(int argc, char **argv) argv += optind; if ((strcmp(opt_f, "") == 0) && (strcmp(opt_t, "") == 0)) usage(); - if (argc == 0) - res = do_conv(stdin, opt_f, opt_t, opt_s, opt_c); - else { + + if (caph_limit_stdio() < 0) + err(EXIT_FAILURE, "capsicum"); + + /* +* Cache NLS data, for strerror, for err(3), before entering capability +* mode. +*/ + caph_cache_catpages(); + + /* +* Cache iconv conversion handle before entering sandbox. +*/ + cd = iconv_open(opt_t, opt_f); + if (cd == (iconv_t)-1) + err(EXIT_FAILURE, "iconv_open(%s, %s)", opt_t, opt_f); + + if (argc == 0) { + if (cap_enter() < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to enter capability mode"); + res = do_conv(stdin, cd, opt_s, opt_c); + } else { res = 0; for (i = 0; i < argc; i++) { fp = (strcmp(argv[i], "-") != 0) ? @@ -211,9 +225,17 @@ main(int argc, char **argv) if (fp == NULL) err(EXIT_FAILURE, "Cannot open `%s'", argv[i]); - res |= do_conv(fp, opt_f, opt_t, opt_s, opt_c); + /* Enter Capsicum sandbox for final input file. */ + if (i + 1 == argc && cap_enter() < 0 && errno != ENOSYS) + err(EXIT_FAILURE, + "unable to enter capability mode"); + res |= do_conv(fp, cd, opt_s, opt_c); (void)fclose(fp); + + /* Reset iconv descriptor state. */ + (void)iconv(cd, NULL, NULL, NULL, NULL); } } + iconv_close(cd); return (res == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head
svn commit: r310143 - head/usr.bin/hexdump
Author: cem Date: Fri Dec 16 02:03:40 2016 New Revision: 310143 URL: https://svnweb.freebsd.org/changeset/base/310143 Log: hexdump(1): First cut capsicumification For now, only enter the sandbox for the last file processed (including stdin for zero-argument mode). Sandboxing all inputs will require a little restructuring of the program. Feedback by: emaste@ (earlier versions) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7915 Modified: head/usr.bin/hexdump/display.c head/usr.bin/hexdump/hexdump.c Modified: head/usr.bin/hexdump/display.c == --- head/usr.bin/hexdump/display.c Fri Dec 16 01:59:28 2016 (r310142) +++ head/usr.bin/hexdump/display.c Fri Dec 16 02:03:40 2016 (r310143) @@ -36,10 +36,13 @@ static char sccsid[] = "@(#)display.c 8. __FBSDID("$FreeBSD$"); #include +#include #include +#include #include #include +#include #include #include #include @@ -355,6 +358,19 @@ next(char **argv) return(0); statok = 0; } + + if (caph_limit_stream(fileno(stdin), CAPH_READ) < 0) + err(1, "unable to restrict %s", + statok ? _argv[-1] : "stdin"); + + /* +* We've opened our last input file; enter capsicum sandbox. +*/ + if (*_argv == NULL) { + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "unable to enter capability mode"); + } + if (skip) doskip(statok ? *_argv : "stdin", statok); if (*_argv) Modified: head/usr.bin/hexdump/hexdump.c == --- head/usr.bin/hexdump/hexdump.c Fri Dec 16 01:59:28 2016 (r310142) +++ head/usr.bin/hexdump/hexdump.c Fri Dec 16 02:03:40 2016 (r310143) @@ -42,6 +42,9 @@ static char sccsid[] = "@(#)hexdump.c 8. __FBSDID("$FreeBSD$"); #include +#include +#include +#include #include #include #include @@ -76,6 +79,14 @@ main(int argc, char *argv[]) for (tfs = fshead; tfs; tfs = tfs->nextfs) rewrite(tfs); + /* +* Cache NLS data, for strerror, for err(3), before entering capability +* mode. +*/ + caph_cache_catpages(); + if (caph_limit_stdio() < 0) + err(1, "capsicum"); + (void)next(argv); display(); exit(exitval); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310142 - head/usr.bin/ktrdump
Author: cem Date: Fri Dec 16 01:59:28 2016 New Revision: 310142 URL: https://svnweb.freebsd.org/changeset/base/310142 Log: ktrdump(8): Capsicumify We restrict the (optional) input file and output files. It would be nice to restrict the KVM files, but that's up to libkvm. We wait until after kvm_nlist() is invoked to cap_enter() because kldsym() isn't supported in the Capsicum sandbox. Feedback from:emaste@ (earlier versions) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7921 Modified: head/usr.bin/ktrdump/ktrdump.c Modified: head/usr.bin/ktrdump/ktrdump.c == --- head/usr.bin/ktrdump/ktrdump.c Fri Dec 16 01:51:12 2016 (r310141) +++ head/usr.bin/ktrdump/ktrdump.c Fri Dec 16 01:59:28 2016 (r310142) @@ -29,11 +29,14 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include +#include #include +#include #include #include #include @@ -70,6 +73,7 @@ static int hflag; static char corefile[PATH_MAX]; static char execfile[PATH_MAX]; +static char outfile[PATH_MAX] = "stdout"; static char desc[SBUFLEN]; static char errbuf[_POSIX2_LINE_MAX]; @@ -87,6 +91,7 @@ main(int ac, char **av) struct ktr_entry *buf; uintmax_t tlast, tnow; unsigned long bufptr; + cap_rights_t rights; struct stat sb; kvm_t *kd; FILE *out; @@ -122,6 +127,11 @@ main(int ac, char **av) iflag = 1; if ((in = open(optarg, O_RDONLY)) == -1) err(1, "%s", optarg); + cap_rights_init(&rights, CAP_FSTAT, CAP_MMAP_R); + if (cap_rights_limit(in, &rights) < 0 && + errno != ENOSYS) + err(1, "unable to limit rights for %s", + optarg); break; case 'M': case 'm': @@ -133,6 +143,7 @@ main(int ac, char **av) case 'o': if ((out = fopen(optarg, "w")) == NULL) err(1, "%s", optarg); + strlcpy(outfile, optarg, sizeof(outfile)); break; case 'q': qflag++; @@ -155,6 +166,10 @@ main(int ac, char **av) if (ac != 0) usage(); + cap_rights_init(&rights, CAP_FSTAT, CAP_WRITE); + if (cap_rights_limit(fileno(out), &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for %s", outfile); + /* * Open our execfile and corefile, resolve needed symbols and read in * the trace buffer. @@ -162,11 +177,28 @@ main(int ac, char **av) if ((kd = kvm_openfiles(Nflag ? execfile : NULL, Mflag ? corefile : NULL, NULL, O_RDONLY, errbuf)) == NULL) errx(1, "%s", errbuf); + + /* +* Cache NLS data, for strerror, for err(3), before entering capability +* mode. +*/ + caph_cache_catpages(); + if (kvm_nlist(kd, nl) != 0 || kvm_read(kd, nl[0].n_value, &version, sizeof(version)) == -1) errx(1, "%s", kvm_geterr(kd)); if (version != KTR_VERSION) errx(1, "ktr version mismatch"); + + /* +* Enter Capsicum sandbox. +* +* kvm_nlist() above uses kldsym(2) for native kernels, and that isn't +* allowed in the sandbox. +*/ + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "unable to enter capability mode"); + if (iflag) { if (fstat(in, &sb) == -1) errx(1, "stat"); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310141 - head/usr.bin/ministat
Author: cem Date: Fri Dec 16 01:51:12 2016 New Revision: 310141 URL: https://svnweb.freebsd.org/changeset/base/310141 Log: ministat(1): Capsicumify Separate dataset opening from reading/parsing. The number of input files is already capped to a small number, so just open all input files before sandboxing. Feedback from:allanjude@ (earlier version), emaste@ (earlier version) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7925 Modified: head/usr.bin/ministat/ministat.c Modified: head/usr.bin/ministat/ministat.c == --- head/usr.bin/ministat/ministat.cFri Dec 16 01:48:55 2016 (r310140) +++ head/usr.bin/ministat/ministat.cFri Dec 16 01:51:12 2016 (r310141) @@ -11,16 +11,20 @@ #include __FBSDID("$FreeBSD$"); -#include -#include +#include +#include +#include +#include + +#include #include #include -#include +#include +#include +#include #include +#include #include -#include -#include -#include #define NSTUDENT 100 #define NCONF 6 @@ -455,26 +459,14 @@ dbl_cmp(const void *a, const void *b) } static struct dataset * -ReadSet(const char *n, int column, const char *delim) +ReadSet(FILE *f, const char *n, int column, const char *delim) { - FILE *f; char buf[BUFSIZ], *p, *t; struct dataset *s; double d; int line; int i; - if (n == NULL) { - f = stdin; - n = ""; - } else if (!strcmp(n, "-")) { - f = stdin; - n = ""; - } else { - f = fopen(n, "r"); - } - if (f == NULL) - err(1, "Cannot open %s", n); s = NewSet(); s->name = strdup(n); line = 0; @@ -499,7 +491,6 @@ ReadSet(const char *n, int column, const if (*buf != '\0') AddPoint(s, d); } - fclose(f); if (s->n < 3) { fprintf(stderr, "Dataset %s must contain at least 3 data points\n", n); @@ -536,7 +527,9 @@ usage(char const *whine) int main(int argc, char **argv) { - struct dataset *ds[7]; + const char *setfilenames[MAX_DS - 1]; + struct dataset *ds[MAX_DS - 1]; + FILE *setfiles[MAX_DS - 1]; int nds; double a; const char *delim = " \t"; @@ -609,14 +602,36 @@ main(int argc, char **argv) argv += optind; if (argc == 0) { - ds[0] = ReadSet("-", column, delim); + setfilenames[0] = ""; + setfiles[0] = stdin; nds = 1; } else { if (argc > (MAX_DS - 1)) usage("Too many datasets."); nds = argc; - for (i = 0; i < nds; i++) - ds[i] = ReadSet(argv[i], column, delim); + for (i = 0; i < nds; i++) { + setfilenames[i] = argv[i]; + setfiles[i] = fopen(argv[i], "r"); + if (setfiles[i] == NULL) + err(2, "Cannot open %s", argv[i]); + } + } + + if (caph_limit_stdio() < 0) + err(2, "capsicum"); + + for (i = 0; i < nds; i++) + if (caph_limit_stream(fileno(setfiles[i]), CAPH_READ) < 0) + err(2, "unable to limit rights for %s", + setfilenames[i]); + + /* Enter Capsicum sandbox. */ + if (cap_enter() < 0 && errno != ENOSYS) + err(2, "unable to enter capability mode"); + + for (i = 0; i < nds; i++) { + ds[i] = ReadSet(setfiles[i], setfilenames[i], column, delim); + fclose(setfiles[i]); } for (i = 0; i < nds; i++) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310140 - head/contrib/dma
Author: cem Date: Fri Dec 16 01:48:55 2016 New Revision: 310140 URL: https://svnweb.freebsd.org/changeset/base/310140 Log: dma-mbox-create: Restrict with Capsicum The restriction here is pretty late and pretty minimal. We need a lot of authority to open password databases, and don't do much after that point. Feedback from:lifanov at mail.lifanov.com (earlier version), emaste (earlier version) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7988 Modified: head/contrib/dma/dma-mbox-create.c Modified: head/contrib/dma/dma-mbox-create.c == --- head/contrib/dma/dma-mbox-create.c Fri Dec 16 01:47:08 2016 (r310139) +++ head/contrib/dma/dma-mbox-create.c Fri Dec 16 01:48:55 2016 (r310140) @@ -38,9 +38,18 @@ * user-supplied information. Keep the root window as small as possible. */ +#ifdef __FreeBSD__ +#defineUSE_CAPSICUM1 +#endif + #include +#if USE_CAPSICUM +#include +#endif #include +#include +#include #include #include #include @@ -84,6 +93,9 @@ logfail(int exitcode, const char *fmt, . int main(int argc, char **argv) { +#if USE_CAPSICUM + cap_rights_t rights; +#endif const char *user; struct passwd *pw; struct group *gr; @@ -91,7 +103,10 @@ main(int argc, char **argv) gid_t mail_gid; int f, maildirfd; - openlog("dma-mbox-create", 0, LOG_MAIL); + /* +* Open log fd now for capability sandbox. +*/ + openlog("dma-mbox-create", LOG_NDELAY, LOG_MAIL); errno = 0; gr = getgrnam(DMA_GROUP); @@ -133,6 +148,28 @@ main(int argc, char **argv) if (maildirfd < 0) logfail(EX_NOINPUT, "cannot open maildir %s", _PATH_MAILDIR); + /* +* Cache NLS data, for strerror, for err(3), before entering capability +* mode. +*/ + caph_cache_catpages(); + + /* +* Cache local time before entering Capsicum capability sandbox. +*/ + caph_cache_tzdata(); + +#if USE_CAPSICUM + cap_rights_init(&rights, CAP_CREATE, CAP_FCHMOD, CAP_FCHOWN, + CAP_LOOKUP, CAP_READ); + if (cap_rights_limit(maildirfd, &rights) < 0 && errno != ENOSYS) + err(EX_OSERR, "can't limit maildirfd rights"); + + /* Enter Capsicum capability sandbox */ + if (cap_enter() < 0 && errno != ENOSYS) + err(EX_OSERR, "cap_enter"); +#endif + user_uid = pw->pw_uid; f = openat(maildirfd, user, O_RDONLY|O_CREAT|O_NOFOLLOW, 0600); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310139 - head/usr.bin/last
Author: cem Date: Fri Dec 16 01:47:08 2016 New Revision: 310139 URL: https://svnweb.freebsd.org/changeset/base/310139 Log: Capsicumify last(1) Reviewed by: ed (earlier version), emaste (earlier version) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8001 Modified: head/usr.bin/last/last.c Modified: head/usr.bin/last/last.c == --- head/usr.bin/last/last.cFri Dec 16 01:44:50 2016(r310138) +++ head/usr.bin/last/last.cFri Dec 16 01:47:08 2016(r310139) @@ -40,8 +40,11 @@ static const char sccsid[] = "@(#)last.c __FBSDID("$FreeBSD$"); #include +#include +#include #include +#include #include #include #include @@ -56,7 +59,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #defineNO 0 /* false/no */ #defineYES 1 /* true/yes */ @@ -176,6 +178,19 @@ main(int argc, char *argv[]) usage(); } + if (caph_limit_stdio() < 0) + err(1, "can't limit stdio rights"); + + caph_cache_catpages(); + caph_cache_tzdata(); + + /* Cache UTX database. */ + if (setutxdb(UTXDB_LOG, file) != 0) + err(1, "%s", file != NULL ? file : "(default utx db)"); + + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "cap_enter"); + if (sflag && width == 8) usage(); if (argc) { @@ -213,8 +228,6 @@ wtmp(void) (void)time(&t); /* Load the last entries from the file. */ - if (setutxdb(UTXDB_LOG, file) != 0) - err(1, "%s", file); while ((ut = getutxent()) != NULL) { if (amount % 128 == 0) { buf = realloc(buf, (amount + 128) * sizeof *ut); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310138 - head/lib/libc/stdio
Author: cem Date: Fri Dec 16 01:44:50 2016 New Revision: 310138 URL: https://svnweb.freebsd.org/changeset/base/310138 Log: vfprintf(3): Add support for kernel %b format This is a direct port of the kernel %b format. I'm unclear on if (more) non-portable printf extensions will be a problem. I think it's desirable to have userspace formats include all kernel formats, but there may be competing goals I'm not aware of. Reviewed by: no one, unfortunately Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8426 Modified: head/lib/libc/stdio/vfprintf.c Modified: head/lib/libc/stdio/vfprintf.c == --- head/lib/libc/stdio/vfprintf.c Fri Dec 16 01:42:51 2016 (r310137) +++ head/lib/libc/stdio/vfprintf.c Fri Dec 16 01:44:50 2016 (r310138) @@ -611,6 +611,37 @@ reswitch: switch (ch) { case 'z': flags |= SIZET; goto rflag; + case 'b': + { + const char *q; + int anybitset, bit; + + ulval = (u_int)GETARG(int); + cp = GETARG(char *); + + q = __ultoa(ulval, buf + BUF, *cp++, 0, xdigs_lower); + PRINT(q, buf + BUF - q); + + if (ulval == 0) + break; + + for (anybitset = 0; *cp;) { + bit = *cp++; + if (ulval & (1 << (bit - 1))) { + PRINT(anybitset ? "," : "<", 1); + q = cp; + for (; (bit = *cp) > ' '; ++cp) + continue; + PRINT(q, cp - q); + anybitset = 1; + } else + for (; *cp > ' '; ++cp) + continue; + } + if (anybitset) + PRINT(">", 1); + } + continue; case 'C': flags |= LONGINT; /*FALLTHROUGH*/ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310137 - head/contrib/elftoolchain/libelf
Author: cem Date: Fri Dec 16 01:42:51 2016 New Revision: 310137 URL: https://svnweb.freebsd.org/changeset/base/310137 Log: gelf_getphdr: Allow extended indices Needed for 'readelf -l' of extended phnum files. (Parity with GNU binutils.) Reviewed by: no one, unfortunately Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8703 Modified: head/contrib/elftoolchain/libelf/gelf_phdr.c Modified: head/contrib/elftoolchain/libelf/gelf_phdr.c == --- head/contrib/elftoolchain/libelf/gelf_phdr.cFri Dec 16 01:39:06 2016(r310136) +++ head/contrib/elftoolchain/libelf/gelf_phdr.cFri Dec 16 01:42:51 2016(r310137) @@ -53,10 +53,17 @@ gelf_getphdr(Elf *e, int index, GElf_Phd Elf64_Ehdr *eh64; Elf32_Phdr *ep32; Elf64_Phdr *ep64; + size_t phnum; if (d == NULL || e == NULL || ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64) || - (e->e_kind != ELF_K_ELF) || index < 0) { + (e->e_kind != ELF_K_ELF) || index < 0 || + elf_getphdrnum(e, &phnum) < 0) { + LIBELF_SET_ERROR(ARGUMENT, 0); + return (NULL); + } + + if ((size_t)index >= phnum) { LIBELF_SET_ERROR(ARGUMENT, 0); return (NULL); } @@ -66,11 +73,6 @@ gelf_getphdr(Elf *e, int index, GElf_Phd ((ep32 = _libelf_getphdr(e, ELFCLASS32)) == NULL)) return (NULL); - if (index >= eh32->e_phnum) { - LIBELF_SET_ERROR(ARGUMENT, 0); - return (NULL); - } - ep32 += index; d->p_type = ep32->p_type; @@ -87,11 +89,6 @@ gelf_getphdr(Elf *e, int index, GElf_Phd (ep64 = _libelf_getphdr(e, ELFCLASS64)) == NULL) return (NULL); - if (index >= eh64->e_phnum) { - LIBELF_SET_ERROR(ARGUMENT, 0); - return (NULL); - } - ep64 += index; *d = *ep64; @@ -125,13 +122,15 @@ gelf_newphdr(Elf *e, size_t count) int gelf_update_phdr(Elf *e, int ndx, GElf_Phdr *s) { - int ec, phnum; + int ec; + size_t phnum; void *ehdr; Elf32_Phdr *ph32; Elf64_Phdr *ph64; if (s == NULL || e == NULL || e->e_kind != ELF_K_ELF || - ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64)) { + ((ec = e->e_class) != ELFCLASS32 && ec != ELFCLASS64) || + elf_getphdrnum(e, &phnum) < 0) { LIBELF_SET_ERROR(ARGUMENT, 0); return (0); } @@ -144,12 +143,7 @@ gelf_update_phdr(Elf *e, int ndx, GElf_P if ((ehdr = _libelf_ehdr(e, ec, 0)) == NULL) return (0); - if (ec == ELFCLASS32) - phnum = ((Elf32_Ehdr *) ehdr)->e_phnum; - else - phnum = ((Elf64_Ehdr *) ehdr)->e_phnum; - - if (ndx < 0 || ndx > phnum) { + if (ndx < 0 || (size_t)ndx > phnum) { LIBELF_SET_ERROR(ARGUMENT, 0); return (0); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310136 - head/contrib/elftoolchain/libelf
Author: cem Date: Fri Dec 16 01:39:06 2016 New Revision: 310136 URL: https://svnweb.freebsd.org/changeset/base/310136 Log: libelf: Fix extended numbering detection Extended numbering is used for any of these fields overflowing. Reviewed by: emaste@ Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8701 Modified: head/contrib/elftoolchain/libelf/libelf_ehdr.c Modified: head/contrib/elftoolchain/libelf/libelf_ehdr.c == --- head/contrib/elftoolchain/libelf/libelf_ehdr.c Fri Dec 16 01:37:44 2016(r310135) +++ head/contrib/elftoolchain/libelf/libelf_ehdr.c Fri Dec 16 01:39:06 2016(r310136) @@ -170,10 +170,6 @@ _libelf_ehdr(Elf *e, int ec, int allocat (*xlator)((unsigned char*) ehdr, msz, e->e_rawfile, (size_t) 1, e->e_byteorder != LIBELF_PRIVATE(byteorder)); - /* -* If extended numbering is being used, read the correct -* number of sections and program header entries. -*/ if (ec == ELFCLASS32) { phnum = ((Elf32_Ehdr *) ehdr)->e_phnum; shnum = ((Elf32_Ehdr *) ehdr)->e_shnum; @@ -193,12 +189,19 @@ _libelf_ehdr(Elf *e, int ec, int allocat return (NULL); } - if (shnum != 0 || shoff == 0LL) { /* not using extended numbering */ + /* +* If extended numbering is being used, read the correct +* number of sections and program header entries. +*/ + if ((shnum == 0 && shoff != 0) || phnum == PN_XNUM || strndx == SHN_XINDEX) { + if (_libelf_load_extended(e, ec, shoff, phnum, strndx) == 0) + return (NULL); + } else { + /* not using extended numbering */ e->e_u.e_elf.e_nphdr = phnum; e->e_u.e_elf.e_nscn = shnum; e->e_u.e_elf.e_strndx = strndx; - } else if (_libelf_load_extended(e, ec, shoff, phnum, strndx) == 0) - return (NULL); + } return (ehdr); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310135 - head/lib/libcapsicum
Author: cem Date: Fri Dec 16 01:37:44 2016 New Revision: 310135 URL: https://svnweb.freebsd.org/changeset/base/310135 Log: capsicum_helpers: Add LOOKUP flag Add a helper routine for opening a directory that is restricted to being used for opening relative files as stdio streams. I think this will really help basic adaptation of multi-file programs to Capsicum. Rather than having each program initialize a rights object and ioctl/fcntl arrays for their root fd for relative opens, consolidate in the logical place. Reviewed by: oshogbo@ Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8743 Modified: head/lib/libcapsicum/capsicum_helpers.h Modified: head/lib/libcapsicum/capsicum_helpers.h == --- head/lib/libcapsicum/capsicum_helpers.h Fri Dec 16 01:14:00 2016 (r310134) +++ head/lib/libcapsicum/capsicum_helpers.h Fri Dec 16 01:37:44 2016 (r310135) @@ -41,6 +41,7 @@ #defineCAPH_IGNORE_EBADF 0x0001 #defineCAPH_READ 0x0002 #defineCAPH_WRITE 0x0004 +#defineCAPH_LOOKUP 0x0008 static __inline int caph_limit_stream(int fd, int flags) @@ -54,6 +55,8 @@ caph_limit_stream(int fd, int flags) cap_rights_set(&rights, CAP_READ); if ((flags & CAPH_WRITE) != 0) cap_rights_set(&rights, CAP_WRITE); + if ((flags & CAPH_LOOKUP) != 0) + cap_rights_set(&rights, CAP_LOOKUP); if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS) { if (errno == EBADF && (flags & CAPH_IGNORE_EBADF) != 0) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310031 - head/sys/compat/linuxkpi/common/include/linux
Author: cem Date: Tue Dec 13 19:58:21 2016 New Revision: 310031 URL: https://svnweb.freebsd.org/changeset/base/310031 Log: linuxkpi: Fix not-found case of linux_pci_find_irq_dev Linux list_for_each_entry() does not neccessarily end with the iterator NULL (it may be an offset from NULL if the list member is not the first element of the member struct). Reported by: Coverity CID: 1366940 Reviewed by: hselasky@ Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8780 Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h == --- head/sys/compat/linuxkpi/common/include/linux/pci.h Tue Dec 13 19:36:05 2016(r310030) +++ head/sys/compat/linuxkpi/common/include/linux/pci.h Tue Dec 13 19:58:21 2016(r310031) @@ -220,18 +220,19 @@ static inline struct device * linux_pci_find_irq_dev(unsigned int irq) { struct pci_dev *pdev; + struct device *found; + found = NULL; spin_lock(&pci_lock); list_for_each_entry(pdev, &pci_devices, links) { - if (irq == pdev->dev.irq) - break; - if (irq >= pdev->dev.msix && irq < pdev->dev.msix_max) + if (irq == pdev->dev.irq || + (irq >= pdev->dev.msix && irq < pdev->dev.msix_max)) { + found = &pdev->dev; break; + } } spin_unlock(&pci_lock); - if (pdev) - return &pdev->dev; - return (NULL); + return (found); } static inline unsigned long ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r309897 - head/tests/sys/vfs
Author: cem Date: Mon Dec 12 17:23:09 2016 New Revision: 309897 URL: https://svnweb.freebsd.org/changeset/base/309897 Log: Add basic ATF tests for Capability mode .. lookups A follow-up to r309887. Several tests copied verbatim from https://github.com/emaste/snippets/blob/master/test_openat.c . Reviewed by: kib@, ngie@ (earlier version) X-MFC-With: r309887 Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8748 Added: head/tests/sys/vfs/lookup_cap_dotdot.c (contents, props changed) Modified: head/tests/sys/vfs/Makefile Modified: head/tests/sys/vfs/Makefile == --- head/tests/sys/vfs/Makefile Mon Dec 12 17:08:52 2016(r309896) +++ head/tests/sys/vfs/Makefile Mon Dec 12 17:23:09 2016(r309897) @@ -4,6 +4,9 @@ PACKAGE=tests TESTSDIR= ${TESTSBASE}/sys/vfs +ATF_TESTS_C+= lookup_cap_dotdot +CFLAGS.lookup_cap_dotdot.c+= -I${SRCTOP}/tests + PLAIN_TESTS_SH+= trailing_slash .include Added: head/tests/sys/vfs/lookup_cap_dotdot.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/vfs/lookup_cap_dotdot.c Mon Dec 12 17:23:09 2016 (r309897) @@ -0,0 +1,251 @@ +/*- + * Copyright (c) 2016 Ed Maste + * Copyright (c) 2016 Conrad Meyer + * + * 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 +#include + +#include +#include +#include +#include + +#include "freebsd_test_suite/macros.h" + +static int dirfd = -1; +static char *abspath; + +static void +touchat(int dirfd, const char *name) +{ + int fd; + + ATF_REQUIRE((fd = openat(dirfd, name, O_CREAT | O_TRUNC | O_WRONLY, + 0777)) >= 0); + ATF_REQUIRE(close(fd) == 0); +} + +static void +prepare_dotdot_tests(void) +{ + char cwd[MAXPATHLEN]; + + ATF_REQUIRE(getcwd(cwd, sizeof(cwd)) != NULL); + asprintf(&abspath, "%s/testdir/d1/f1", cwd); + + ATF_REQUIRE(mkdir("testdir", 0777) == 0); + ATF_REQUIRE((dirfd = open("testdir", O_RDONLY)) >= 0); + + ATF_REQUIRE(mkdirat(dirfd, "d1", 0777) == 0); + ATF_REQUIRE(mkdirat(dirfd, "d1/d2", 0777) == 0); + ATF_REQUIRE(mkdirat(dirfd, "d1/d2/d3", 0777) == 0); + touchat(dirfd, "d1/f1"); + touchat(dirfd, "d1/d2/f2"); + touchat(dirfd, "d1/d2/d3/f3"); + ATF_REQUIRE(symlinkat("d1/d2/d3", dirfd, "l3") == 0); + ATF_REQUIRE(symlinkat("../testdir/d1", dirfd, "lup") == 0); + ATF_REQUIRE(symlinkat("../..", dirfd, "d1/d2/d3/ld1") == 0); + ATF_REQUIRE(symlinkat("../../f1", dirfd, "d1/d2/d3/lf1") == 0); +} + +static void +check_capsicum(void) +{ + ATF_REQUIRE_FEATURE("security_capabilities"); + ATF_REQUIRE_FEATURE("security_capability_mode"); +} + +/* + * Positive tests + */ +ATF_TC(openat__basic_positive); +ATF_TC_HEAD(openat__basic_positive, tc) +{ + atf_tc_set_md_var(tc, "descr", "Basic positive openat testcases"); +} + +ATF_TC_BODY(openat__basic_positive, tc) +{ + prepare_dotdot_tests(); + + ATF_REQUIRE(openat(dirfd, "d1/d2/d3/f3", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "d1/d2/d3/../../f1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/f3", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/../../f1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "../testdir/d1/f1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "lup/f1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/ld1", O_RDONLY) >= 0); + ATF_REQUIRE(openat(dirfd, "l3/lf1", O_RDO
svn commit: r309679 - head/contrib/elftoolchain/readelf
Author: cem Date: Wed Dec 7 18:33:40 2016 New Revision: 309679 URL: https://svnweb.freebsd.org/changeset/base/309679 Log: readelf(1) -S: Include zero index and match binutils' no-name Include the SHN_UNDEF (zero) index special section in extended-attribute ELF files, like GNU binutils' readelf. Additionally, print "" for sections without names, like GNU binutils. Reviewed by: kaiw@ Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8707 Modified: head/contrib/elftoolchain/readelf/readelf.c Modified: head/contrib/elftoolchain/readelf/readelf.c == --- head/contrib/elftoolchain/readelf/readelf.c Wed Dec 7 16:12:27 2016 (r309678) +++ head/contrib/elftoolchain/readelf/readelf.c Wed Dec 7 18:33:40 2016 (r309679) @@ -6557,13 +6557,14 @@ load_sections(struct readelf *re) } if ((name = elf_strptr(re->elf, shstrndx, sh.sh_name)) == NULL) { (void) elf_errno(); - name = "ERROR"; + name = ""; } if ((ndx = elf_ndxscn(scn)) == SHN_UNDEF) { - if ((elferr = elf_errno()) != 0) + if ((elferr = elf_errno()) != 0) { warnx("elf_ndxscn failed: %s", elf_errmsg(elferr)); - continue; + continue; + } } if (ndx >= re->shnum) { warnx("section index of '%s' out of range", name); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r309547 - head/contrib/elftoolchain/readelf
Author: cem Date: Mon Dec 5 03:11:52 2016 New Revision: 309547 URL: https://svnweb.freebsd.org/changeset/base/309547 Log: readelf(1): Add support for extended program header numbers Add support for extended program header numbers to elftoolchain 'readelf -h'. Reviewed by: emaste Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8702 Modified: head/contrib/elftoolchain/readelf/readelf.c Modified: head/contrib/elftoolchain/readelf/readelf.c == --- head/contrib/elftoolchain/readelf/readelf.c Mon Dec 5 02:27:50 2016 (r309546) +++ head/contrib/elftoolchain/readelf/readelf.c Mon Dec 5 03:11:52 2016 (r309547) @@ -2112,7 +2112,7 @@ dwarf_reg(unsigned int mach, unsigned in static void dump_ehdr(struct readelf *re) { - size_t shnum, shstrndx; + size_t phnum, shnum, shstrndx; int i; printf("ELF Header:\n"); @@ -2174,7 +2174,13 @@ dump_ehdr(struct readelf *re) re->ehdr.e_phentsize); /* e_phnum. */ - printf("%-37s%u\n", " Number of program headers:", re->ehdr.e_phnum); + printf("%-37s%u", " Number of program headers:", re->ehdr.e_phnum); + if (re->ehdr.e_phnum == PN_XNUM) { + /* Extended program header numbering is in use. */ + if (elf_getphnum(re->elf, &phnum)) + printf(" (%zu)", phnum); + } + putchar('\n'); /* e_shentsize. */ printf("%-37s%u (bytes)\n", " Size of section headers:", ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r309526 - head/sys/dev/ioat
Author: cem Date: Sun Dec 4 04:04:57 2016 New Revision: 309526 URL: https://svnweb.freebsd.org/changeset/base/309526 Log: ioat(4): Compile on i386 Truncate BUS_SPACE_MAXADDR_40BIT to essentially BUS_SPACE_MAXADDR_32BIT on platforms with 32-bit bus_addr_t (i.e., i386). PR: 215034 Reported by: ngie@ Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cSun Dec 4 03:50:57 2016(r309525) +++ head/sys/dev/ioat/ioat.cSun Dec 4 04:04:57 2016(r309526) @@ -486,8 +486,9 @@ ioat3_attach(device_t device) ringsz = sizeof(struct ioat_dma_hw_descriptor) * num_descriptors; error = bus_dma_tag_create(bus_get_dma_tag(ioat->device), - 2 * 1024 * 1024, 0x0, BUS_SPACE_MAXADDR_40BIT, BUS_SPACE_MAXADDR, - NULL, NULL, ringsz, 1, ringsz, 0, NULL, NULL, &ioat->hw_desc_tag); + 2 * 1024 * 1024, 0x0, (bus_addr_t)BUS_SPACE_MAXADDR_40BIT, + BUS_SPACE_MAXADDR, NULL, NULL, ringsz, 1, ringsz, 0, NULL, NULL, + &ioat->hw_desc_tag); if (error != 0) return (error); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r309525 - head/tests/sys/kern
Author: cem Date: Sun Dec 4 03:50:57 2016 New Revision: 309525 URL: https://svnweb.freebsd.org/changeset/base/309525 Log: coredump_phnum_test: Make expected pheader count more flexible Note: this test still requires binutils readelf (from ports) to pass, until a few issues are resolved in elftoolchain. PR: 215019 Reported by: ngie@ Sponsored by: Dell EMC Isilon Modified: head/tests/sys/kern/coredump_phnum_test.sh Modified: head/tests/sys/kern/coredump_phnum_test.sh == --- head/tests/sys/kern/coredump_phnum_test.sh Sun Dec 4 03:10:25 2016 (r309524) +++ head/tests/sys/kern/coredump_phnum_test.sh Sun Dec 4 03:50:57 2016 (r309525) @@ -39,7 +39,7 @@ coredump_phnum_head() } coredump_phnum_body() { - atf_expect_fail "the value parsed doesn't always match the value obtained on the running system; bug # 215019" + atf_expect_fail "elftoolchain (base) readelf doesn't handle extended program header numbers; bug # 215019" # Set up core dumping cat > coredump_phnum_restore_state.sh <<-EOF @@ -65,17 +65,17 @@ EOF # the result of running the helper program and dumping core. The only # important bit is that they're larger than 65535 (UINT16_MAX). readelf -h coredump_phnum_helper.core | \ - atf_check -o "match:65535 \(66169\)" \ + atf_check -o "match:65535 \(66[0-9]{3}\)" \ grep "Number of program headers:" readelf -l coredump_phnum_helper.core | \ - atf_check -o "match:There are 66169 program headers" \ + atf_check -o "match:There are 66[0-9]{3} program headers" \ grep -1 "program headers" readelf -S coredump_phnum_helper.core | \ - atf_check -o "match: 0001 .* 66169 " \ + atf_check -o "match: 0001 .* 66[0-9]{3} " \ grep -A1 "^ \[ 0\] " procstat -v coredump_phnum_helper.core | \ - atf_check -o "match:66545" wc -l + atf_check -o "match:66[0-9]{3}" wc -l } coredump_phnum_cleanup() { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r309366 - head/lib/libcapsicum
Author: cem Date: Thu Dec 1 17:28:45 2016 New Revision: 309366 URL: https://svnweb.freebsd.org/changeset/base/309366 Log: capsicum_helpers: Squash errors from closed fds Squash EBADF from closed stdin, stdout, or stderr in caph_limit_stdio(). Any program used during special shell scripts may commonly be forked from a parent process with closed standard stream. Do the common sense thing for this common use. Reported by: Iblis Lin Reviewed by: oshogbo@ (earlier version) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8657 Modified: head/lib/libcapsicum/capsicum_helpers.h Modified: head/lib/libcapsicum/capsicum_helpers.h == --- head/lib/libcapsicum/capsicum_helpers.h Thu Dec 1 17:26:37 2016 (r309365) +++ head/lib/libcapsicum/capsicum_helpers.h Thu Dec 1 17:28:45 2016 (r309366) @@ -94,12 +94,12 @@ caph_limit_stdout(void) static __inline int caph_limit_stdio(void) { + const int iebadf = CAPH_IGNORE_EBADF; - if (caph_limit_stdin() == -1 || caph_limit_stdout() == -1 || - caph_limit_stderr() == -1) { + if (caph_limit_stream(STDIN_FILENO, CAPH_READ | iebadf) == -1 || + caph_limit_stream(STDOUT_FILENO, CAPH_WRITE | iebadf) == -1 || + caph_limit_stream(STDERR_FILENO, CAPH_WRITE | iebadf) == -1) return (-1); - } - return (0); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r309344 - head/lib/libutil
Author: cem Date: Thu Dec 1 02:21:36 2016 New Revision: 309344 URL: https://svnweb.freebsd.org/changeset/base/309344 Log: Remove a death threat from the FreeBSD sources Reported by: koobs@, araujo@, linimon@, bjk@, emaste@, jhb@, ngie@, cem@ Maintainer timeout: des@ Modified: head/lib/libutil/flopen.c Modified: head/lib/libutil/flopen.c == --- head/lib/libutil/flopen.c Thu Dec 1 01:56:34 2016(r309343) +++ head/lib/libutil/flopen.c Thu Dec 1 02:21:36 2016(r309344) @@ -40,10 +40,10 @@ __FBSDID("$FreeBSD$"); /* * Reliably open and lock a file. * - * DO NOT, UNDER PAIN OF DEATH, modify this code without first reading the - * revision history and discussing your changes with . - * Don't be fooled by the code's apparent simplicity; there would be no - * need for this function if it was as easy to get right as you think. + * Please do not modify this code without first reading the revision history + * and discussing your changes with . Don't be fooled by the + * code's apparent simplicity; there would be no need for this function if it + * was easy to get right. */ int flopen(const char *path, int flags, ...) @@ -108,7 +108,11 @@ flopen(const char *path, int flags, ...) errno = serrno; return (-1); } -#ifdef DONT_EVEN_THINK_ABOUT_IT + /* +* The following change is provided as a specific example to +* avoid. +*/ +#if 0 if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0) { serrno = errno; (void)close(fd); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r309338 - head/sys/dev/ioat
Author: cem Date: Wed Nov 30 21:59:52 2016 New Revision: 309338 URL: https://svnweb.freebsd.org/changeset/base/309338 Log: ioat(4): Fix 'bogus completion_pending' KASSERT Fix ioat_release to only set is_completion_pending if DMAs were actually queued. Otherwise, the spurious flag could trigger an assert in the reset path on INVARIANTS kernels. Reviewed by: bdrewery, Suraj Raju @ Isilon Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c head/sys/dev/ioat/ioat_internal.h Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cWed Nov 30 21:53:06 2016(r309337) +++ head/sys/dev/ioat/ioat.cWed Nov 30 21:59:52 2016(r309338) @@ -947,6 +947,7 @@ ioat_acquire(bus_dmaengine_t dmaengine) ioat = to_ioat_softc(dmaengine); mtx_lock(&ioat->submit_lock); CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); + ioat->acq_head = ioat->head; } int @@ -976,12 +977,15 @@ ioat_release(bus_dmaengine_t dmaengine) CTR4(KTR_IOAT, "%s channel=%u dispatch2 hw_head=%u head=%u", __func__, ioat->chan_idx, ioat->hw_head & UINT16_MAX, ioat->head); - ioat_write_2(ioat, IOAT_DMACOUNT_OFFSET, (uint16_t)ioat->hw_head); - - if (!ioat->is_completion_pending) { - ioat->is_completion_pending = TRUE; - callout_reset(&ioat->poll_timer, 1, ioat_poll_timer_callback, - ioat); + if (ioat->acq_head != ioat->head) { + ioat_write_2(ioat, IOAT_DMACOUNT_OFFSET, + (uint16_t)ioat->hw_head); + + if (!ioat->is_completion_pending) { + ioat->is_completion_pending = TRUE; + callout_reset(&ioat->poll_timer, 1, + ioat_poll_timer_callback, ioat); + } } mtx_unlock(&ioat->submit_lock); } Modified: head/sys/dev/ioat/ioat_internal.h == --- head/sys/dev/ioat/ioat_internal.h Wed Nov 30 21:53:06 2016 (r309337) +++ head/sys/dev/ioat/ioat_internal.h Wed Nov 30 21:59:52 2016 (r309338) @@ -483,6 +483,7 @@ struct ioat_softc { boolean_t resetting_cleanup; /* cleanup_lock */ uint32_thead; + uint32_tacq_head; uint32_ttail; uint32_thw_head; uint32_tring_size_order; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r308657 - head/usr.bin/fold
Author: cem Date: Tue Nov 15 00:24:18 2016 New Revision: 308657 URL: https://svnweb.freebsd.org/changeset/base/308657 Log: fold(1): Revert incorrect r308432 As Jean-Sébastien notes, fold(1) requires handling argv-supplied files. That will require a slightly more sophisticated approach. Reported by: dumbbell@ Sponsored by: Dell EMC Isilon Modified: head/usr.bin/fold/fold.c Modified: head/usr.bin/fold/fold.c == --- head/usr.bin/fold/fold.cMon Nov 14 23:51:28 2016(r308656) +++ head/usr.bin/fold/fold.cTue Nov 15 00:24:18 2016(r308657) @@ -45,7 +45,6 @@ static char sccsid[] = "@(#)fold.c8.1 ( #include __FBSDID("$FreeBSD$"); -#include #include #include #include @@ -73,9 +72,6 @@ main(int argc, char **argv) (void) setlocale(LC_CTYPE, ""); - if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS)) - err(1, "capsicum"); - width = -1; previous_ch = 0; while ((ch = getopt(argc, argv, "0123456789bsw:")) != -1) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r308558 - head/sys/sys
Author: cem Date: Fri Nov 11 20:44:33 2016 New Revision: 308558 URL: https://svnweb.freebsd.org/changeset/base/308558 Log: queue.3: Document existing QMD_* macros Feedback from:bapt, bdrewery, emaste Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D3983 Modified: head/sys/sys/queue.h Modified: head/sys/sys/queue.h == --- head/sys/sys/queue.hFri Nov 11 20:31:23 2016(r308557) +++ head/sys/sys/queue.hFri Nov 11 20:44:33 2016(r308558) @@ -472,6 +472,12 @@ struct { \ */ #if (defined(_KERNEL) && defined(INVARIANTS)) +/* + * QMD_LIST_CHECK_HEAD(LIST_HEAD *head, LIST_ENTRY NAME) + * + * If the list is non-empty, validates that the first element of the list + * points back at 'head.' + */ #defineQMD_LIST_CHECK_HEAD(head, field) do { \ if (LIST_FIRST((head)) != NULL && \ LIST_FIRST((head))->field.le_prev !=\ @@ -479,6 +485,12 @@ struct { \ panic("Bad list head %p first->prev != head", (head)); \ } while (0) +/* + * QMD_LIST_CHECK_NEXT(TYPE *elm, LIST_ENTRY NAME) + * + * If an element follows 'elm' in the list, validates that the next element + * points back at 'elm.' + */ #defineQMD_LIST_CHECK_NEXT(elm, field) do { \ if (LIST_NEXT((elm), field) != NULL && \ LIST_NEXT((elm), field)->field.le_prev != \ @@ -486,6 +498,11 @@ struct { \ panic("Bad link elm %p next->prev != elm", (elm)); \ } while (0) +/* + * QMD_LIST_CHECK_PREV(TYPE *elm, LIST_ENTRY NAME) + * + * Validates that the previous element (or head of the list) points to 'elm.' + */ #defineQMD_LIST_CHECK_PREV(elm, field) do { \ if (*(elm)->field.le_prev != (elm)) \ panic("Bad link elm %p prev->next != elm", (elm)); \ @@ -634,6 +651,12 @@ struct { \ * Tail queue functions. */ #if (defined(_KERNEL) && defined(INVARIANTS)) +/* + * QMD_TAILQ_CHECK_HEAD(TAILQ_HEAD *head, TAILQ_ENTRY NAME) + * + * If the tailq is non-empty, validates that the first element of the tailq + * points back at 'head.' + */ #defineQMD_TAILQ_CHECK_HEAD(head, field) do { \ if (!TAILQ_EMPTY(head) && \ TAILQ_FIRST((head))->field.tqe_prev != \ @@ -641,11 +664,22 @@ struct { \ panic("Bad tailq head %p first->prev != head", (head)); \ } while (0) +/* + * QMD_TAILQ_CHECK_TAIL(TAILQ_HEAD *head, TAILQ_ENTRY NAME) + * + * Validates that the tail of the tailq is a pointer to pointer to NULL. + */ #defineQMD_TAILQ_CHECK_TAIL(head, field) do { \ if (*(head)->tqh_last != NULL) \ panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ } while (0) +/* + * QMD_TAILQ_CHECK_NEXT(TYPE *elm, TAILQ_ENTRY NAME) + * + * If an element follows 'elm' in the tailq, validates that the next element + * points back at 'elm.' + */ #defineQMD_TAILQ_CHECK_NEXT(elm, field) do { \ if (TAILQ_NEXT((elm), field) != NULL && \ TAILQ_NEXT((elm), field)->field.tqe_prev != \ @@ -653,6 +687,11 @@ struct { \ panic("Bad link elm %p next->prev != elm", (elm)); \ } while (0) +/* + * QMD_TAILQ_CHECK_PREV(TYPE *elm, TAILQ_ENTRY NAME) + * + * Validates that the previous element (or head of the tailq) points to 'elm.' + */ #defineQMD_TAILQ_CHECK_PREV(elm, field) do { \ if (*(elm)->field.tqe_prev != (elm))\ panic("Bad link elm %p prev->next != elm", (elm)); \ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r308553 - head/sys/dev/ioat
Author: cem Date: Fri Nov 11 20:09:54 2016 New Revision: 308553 URL: https://svnweb.freebsd.org/changeset/base/308553 Log: ioat(4): Fix race between process_events and reset_hw In the case where a hardware error is detected during ioat_process_events, hardware may advance (by one descriptor, probably) and a subsequent ioat_process_events may race the intended ioat_reset_hw followup. In that case, the second process_events would observe a completion update that does not match the software "last_seen" status, and attempt to successfully complete already-failed descriptors. Guard against this race with the resetting_cleanup flag. Reviewed by: bdrewery, markj Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cFri Nov 11 20:08:45 2016(r308552) +++ head/sys/dev/ioat/ioat.cFri Nov 11 20:09:54 2016(r308553) @@ -765,6 +765,15 @@ out: mtx_lock(&ioat->submit_lock); mtx_lock(&ioat->cleanup_lock); ioat->quiescing = TRUE; + /* +* This is safe to do here because we have both locks and the submit +* queue is quiesced. We know that we will drain all outstanding +* events, so ioat_reset_hw can't deadlock. It is necessary to +* protect other ioat_process_event threads from racing ioat_reset_hw, +* reading an indeterminate hw state, and attempting to continue +* issuing completions. +*/ + ioat->resetting_cleanup = TRUE; chanerr = ioat_read_4(ioat, IOAT_CHANERR_OFFSET); if (1 <= g_ioat_debug_level) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r308451 - in head/sys/cam: . scsi
Author: cem Date: Tue Nov 8 21:17:24 2016 New Revision: 308451 URL: https://svnweb.freebsd.org/changeset/base/308451 Log: cam: Zero bio pointer in user-supplied SCSI CCBs The BUF_TRACKING bio pointer only makes sense for kernel consumers of CCBs. PR: 214250 Reported by: trasz@ Reviewed by: imp@, markj@ Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8477 Modified: head/sys/cam/cam_xpt.c head/sys/cam/scsi/scsi_pass.c Modified: head/sys/cam/cam_xpt.c == --- head/sys/cam/cam_xpt.c Tue Nov 8 21:15:50 2016(r308450) +++ head/sys/cam/cam_xpt.c Tue Nov 8 21:17:24 2016(r308451) @@ -414,6 +414,10 @@ xptdoioctl(struct cdev *dev, u_long cmd, struct cam_eb *bus; inccb = (union ccb *)addr; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + if (inccb->ccb_h.func_code == XPT_SCSI_IO) + inccb->csio.bio = NULL; +#endif bus = xpt_find_bus(inccb->ccb_h.path_id); if (bus == NULL) @@ -593,6 +597,10 @@ xptdoioctl(struct cdev *dev, u_long cmd, unit = ccb->cgdl.unit_number; name = ccb->cgdl.periph_name; base_periph_found = 0; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + if (ccb->ccb_h.func_code == XPT_SCSI_IO) + ccb->csio.bio = NULL; +#endif /* * Sanity check -- make sure we don't get a null peripheral Modified: head/sys/cam/scsi/scsi_pass.c == --- head/sys/cam/scsi/scsi_pass.c Tue Nov 8 21:15:50 2016 (r308450) +++ head/sys/cam/scsi/scsi_pass.c Tue Nov 8 21:17:24 2016 (r308451) @@ -1777,6 +1777,10 @@ passdoioctl(struct cdev *dev, u_long cmd int ccb_malloced; inccb = (union ccb *)addr; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + if (inccb->ccb_h.func_code == XPT_SCSI_IO) + inccb->csio.bio = NULL; +#endif /* * Some CCB types, like scan bus and scan lun can only go @@ -1875,6 +1879,10 @@ passdoioctl(struct cdev *dev, u_long cmd cam_periph_lock(periph); break; } +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + if (ccb->ccb_h.func_code == XPT_SCSI_IO) + ccb->csio.bio = NULL; +#endif if (ccb->ccb_h.flags & CAM_CDB_POINTER) { if (ccb->csio.cdb_len > IOCDBLEN) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r308432 - in head: bin/echo bin/sleep usr.bin/basename usr.bin/dc usr.bin/dirname usr.bin/fold usr.bin/getopt usr.bin/locate/bigram usr.bin/logname usr.bin/printenv usr.bin/yes
Author: cem Date: Tue Nov 8 05:31:01 2016 New Revision: 308432 URL: https://svnweb.freebsd.org/changeset/base/308432 Log: Capsicumize some trivial stdio programs Trivially capsicumize some simple programs that just interact with stdio. This list of programs uses 'pledge("stdio")' in OpenBSD. No objection from:allanjude, emaste, oshogbo Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8307 Modified: head/bin/echo/echo.c head/bin/sleep/sleep.c head/usr.bin/basename/basename.c head/usr.bin/dc/dc.c head/usr.bin/dirname/dirname.c head/usr.bin/fold/fold.c head/usr.bin/getopt/getopt.c head/usr.bin/locate/bigram/locate.bigram.c head/usr.bin/logname/logname.c head/usr.bin/printenv/printenv.c head/usr.bin/yes/yes.c Modified: head/bin/echo/echo.c == --- head/bin/echo/echo.cTue Nov 8 00:24:49 2016(r308431) +++ head/bin/echo/echo.cTue Nov 8 05:31:01 2016(r308432) @@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include #include @@ -78,6 +80,9 @@ main(int argc, char *argv[]) char newline[] = "\n"; char *progname = argv[0]; + if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS)) + err(1, "capsicum"); + /* This utility may NOT do getopt(3) option parsing. */ if (*++argv && !strcmp(*argv, "-n")) { ++argv; Modified: head/bin/sleep/sleep.c == --- head/bin/sleep/sleep.c Tue Nov 8 00:24:49 2016(r308431) +++ head/bin/sleep/sleep.c Tue Nov 8 05:31:01 2016(r308432) @@ -41,6 +41,7 @@ static char sccsid[] = "@(#)sleep.c 8.3 #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -69,6 +70,9 @@ main(int argc, char *argv[]) time_t original; char buf[2]; + if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS)) + err(1, "capsicum"); + if (argc != 2) usage(); Modified: head/usr.bin/basename/basename.c == --- head/usr.bin/basename/basename.cTue Nov 8 00:24:49 2016 (r308431) +++ head/usr.bin/basename/basename.cTue Nov 8 05:31:01 2016 (r308432) @@ -42,6 +42,7 @@ static char sccsid[] = "@(#)basename.c8 #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -64,6 +65,9 @@ main(int argc, char **argv) setlocale(LC_ALL, ""); + if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno != ENOSYS)) + err(1, "capsicum"); + aflag = 0; suffix = NULL; suffixlen = 0; Modified: head/usr.bin/dc/dc.c == --- head/usr.bin/dc/dc.cTue Nov 8 00:24:49 2016(r308431) +++ head/usr.bin/dc/dc.cTue Nov 8 05:31:01 2016(r308432) @@ -22,9 +22,11 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include +#include #include #include #include @@ -58,11 +60,11 @@ usage(void) } static void -procfile(char *fname) { +procfd(int fd, char *fname) { struct stat st; FILE *file; - file = fopen(fname, "r"); + file = fdopen(fd, "r"); if (file == NULL) err(1, "cannot open file %s", fname); if (fstat(fileno(file), &st) == -1) @@ -80,7 +82,7 @@ procfile(char *fname) { int main(int argc, char *argv[]) { - int ch; + int ch, fd; bool extended_regs = false, preproc_done = false; /* accept and ignore a single dash to be 4.4BSD dc(1) compatible */ @@ -97,7 +99,10 @@ main(int argc, char *argv[]) case 'f': if (!preproc_done) init_bmachine(extended_regs); - procfile(optarg); + fd = open(optarg, O_RDONLY); + if (fd < 0) + err(1, "cannot open file %s", optarg); + procfd(fd, optarg); preproc_done = true; break; case 'x': @@ -126,12 +131,23 @@ main(int argc, char *argv[]) if (argc > 1) usage(); if (argc == 1) { - procfile(argv[0]); + fd = open(argv[0], O_RDONLY); + if (fd < 0) + err(1, "cannot open file %s", argv[0]); + + if (caph_limit_stream(fd, CAPH_READ) < 0 || + caph_limit_stdio() < 0 || + (cap_enter() < 0 && errno != ENOSYS)) + err(1, "capsicum"); + + procfd(fd, argv[0]); preproc_do
svn commit: r308230 - head/sys/dev/ioat
Author: cem Date: Wed Nov 2 23:18:16 2016 New Revision: 308230 URL: https://svnweb.freebsd.org/changeset/base/308230 Log: ioat(4): Read CHANSTS register for suspended/halted checks The device doesn't accurately update the CHANCMP address with the device state when the device is suspended or halted. So, read the CHANSTS register to check for those states. We still need to read the CHANCMP address for the last completed descriptor. Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cWed Nov 2 22:33:37 2016(r308229) +++ head/sys/dev/ioat/ioat.cWed Nov 2 23:18:16 2016(r308230) @@ -747,6 +747,12 @@ out: wakeup(&ioat->tail); } + /* +* The device doesn't seem to reliably push suspend/halt statuses to +* the channel completion memory address, so poll the device register +* here. +*/ + comp_update = ioat_get_chansts(ioat) & IOAT_CHANSTS_STATUS; if (!is_ioat_halted(comp_update) && !is_ioat_suspended(comp_update)) return; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r308179 - head/sys/dev/ioat
Author: cem Date: Tue Nov 1 19:18:54 2016 New Revision: 308179 URL: https://svnweb.freebsd.org/changeset/base/308179 Log: ioat(4): Allocate contiguous descriptors This allows us to make strong assertions about descriptor address validity. Additionally, future generations of the ioat(4) hardware will require contiguous descriptors. Reviewed by: markj Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c head/sys/dev/ioat/ioat_internal.h Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cTue Nov 1 19:18:52 2016(r308178) +++ head/sys/dev/ioat/ioat.cTue Nov 1 19:18:54 2016(r308179) @@ -81,13 +81,11 @@ static void ioat_process_events(struct i static inline uint32_t ioat_get_active(struct ioat_softc *ioat); static inline uint32_t ioat_get_ring_space(struct ioat_softc *ioat); static void ioat_free_ring(struct ioat_softc *, uint32_t size, -struct ioat_descriptor **); -static void ioat_free_ring_entry(struct ioat_softc *ioat, -struct ioat_descriptor *desc); -static struct ioat_descriptor *ioat_alloc_ring_entry(struct ioat_softc *, -int mflags); +struct ioat_descriptor *); static int ioat_reserve_space(struct ioat_softc *, uint32_t, int mflags); -static struct ioat_descriptor *ioat_get_ring_entry(struct ioat_softc *ioat, +static union ioat_hw_descriptor *ioat_get_descriptor(struct ioat_softc *, +uint32_t index); +static struct ioat_descriptor *ioat_get_ring_entry(struct ioat_softc *, uint32_t index); static void ioat_halted_debug(struct ioat_softc *, uint32_t); static void ioat_poll_timer_callback(void *arg); @@ -349,7 +347,12 @@ ioat_detach(device_t device) bus_dma_tag_destroy(ioat->comp_update_tag); } - bus_dma_tag_destroy(ioat->hw_desc_tag); + if (ioat->hw_desc_ring != NULL) { + bus_dmamap_unload(ioat->hw_desc_tag, ioat->hw_desc_map); + bus_dmamem_free(ioat->hw_desc_tag, ioat->hw_desc_ring, + ioat->hw_desc_map); + bus_dma_tag_destroy(ioat->hw_desc_tag); + } return (0); } @@ -383,8 +386,8 @@ ioat_start_channel(struct ioat_softc *io /* Submit 'NULL' operation manually to avoid quiescing flag */ desc = ioat_get_ring_entry(ioat, ioat->head); + hw_desc = &ioat_get_descriptor(ioat, ioat->head)->dma; dmadesc = &desc->bus_dmadesc; - hw_desc = desc->u.dma; dmadesc->callback_fn = NULL; dmadesc->callback_arg = NULL; @@ -421,9 +424,10 @@ static int ioat3_attach(device_t device) { struct ioat_softc *ioat; - struct ioat_descriptor **ring; - struct ioat_descriptor *next; + struct ioat_descriptor *ring; struct ioat_dma_hw_descriptor *dma_hw_desc; + void *hw_desc; + size_t ringsz; int i, num_descriptors; int error; uint8_t xfercap; @@ -478,36 +482,41 @@ ioat3_attach(device_t device) return (error); ioat->ring_size_order = g_ioat_ring_order; - num_descriptors = 1 << ioat->ring_size_order; + ringsz = sizeof(struct ioat_dma_hw_descriptor) * num_descriptors; - bus_dma_tag_create(bus_get_dma_tag(ioat->device), 0x40, 0x0, - BUS_SPACE_MAXADDR_40BIT, BUS_SPACE_MAXADDR, NULL, NULL, - sizeof(struct ioat_dma_hw_descriptor), 1, - sizeof(struct ioat_dma_hw_descriptor), 0, NULL, NULL, - &ioat->hw_desc_tag); + error = bus_dma_tag_create(bus_get_dma_tag(ioat->device), + 2 * 1024 * 1024, 0x0, BUS_SPACE_MAXADDR_40BIT, BUS_SPACE_MAXADDR, + NULL, NULL, ringsz, 1, ringsz, 0, NULL, NULL, &ioat->hw_desc_tag); + if (error != 0) + return (error); + + error = bus_dmamem_alloc(ioat->hw_desc_tag, &hw_desc, + BUS_DMA_ZERO | BUS_DMA_WAITOK, &ioat->hw_desc_map); + if (error != 0) + return (error); + + error = bus_dmamap_load(ioat->hw_desc_tag, ioat->hw_desc_map, hw_desc, + ringsz, ioat_dmamap_cb, &ioat->hw_desc_bus_addr, BUS_DMA_WAITOK); + if (error) + return (error); + + ioat->hw_desc_ring = hw_desc; ioat->ring = malloc(num_descriptors * sizeof(*ring), M_IOAT, M_ZERO | M_WAITOK); ring = ioat->ring; for (i = 0; i < num_descriptors; i++) { - ring[i] = ioat_alloc_ring_entry(ioat, M_WAITOK); - if (ring[i] == NULL) - return (ENOMEM); - - ring[i]->id = i; + memset(&ring[i].bus_dmadesc, 0, sizeof(ring[i].bus_dmadesc)); + ring[i].id = i; } - for (i = 0; i < num_descriptors - 1; i++) { - next = ring[i + 1]; - dma_hw_desc = ring[i]->u.dma; - - dma_hw_desc->next = next->hw_desc_bus_addr; + for (i = 0; i < num_descriptors; i++) { + dma
svn commit: r308178 - head/sys/dev/ioat
Author: cem Date: Tue Nov 1 19:18:52 2016 New Revision: 308178 URL: https://svnweb.freebsd.org/changeset/base/308178 Log: ioat(4): Simplify by removing dynamic scaling This paves the way for a contiguous descriptor array. A contiguous descriptor array has the benefit that we can make strong assertions about whether an address is a valid descriptor or not. The other benefit is that future generations of I/OAT hardware will require a contiguous descriptor array anyway. The downside is that after system boot, big chunks of contiguous memory is much harder to find. So dynamic scaling after boot is basically impossible. Reviewed by: markj Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c head/sys/dev/ioat/ioat_internal.h Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cTue Nov 1 19:18:16 2016(r308177) +++ head/sys/dev/ioat/ioat.cTue Nov 1 19:18:52 2016(r308178) @@ -63,7 +63,6 @@ __FBSDID("$FreeBSD$"); #defineBUS_SPACE_MAXADDR_40BIT 0xFFULL #endif #defineIOAT_REFLK (&ioat->submit_lock) -#defineIOAT_SHRINK_PERIOD (10 * hz) static int ioat_probe(device_t device); static int ioat_attach(device_t device); @@ -90,15 +89,8 @@ static struct ioat_descriptor *ioat_allo static int ioat_reserve_space(struct ioat_softc *, uint32_t, int mflags); static struct ioat_descriptor *ioat_get_ring_entry(struct ioat_softc *ioat, uint32_t index); -static struct ioat_descriptor **ioat_prealloc_ring(struct ioat_softc *, -uint32_t size, boolean_t need_dscr, int mflags); -static int ring_grow(struct ioat_softc *, uint32_t oldorder, -struct ioat_descriptor **); -static int ring_shrink(struct ioat_softc *, uint32_t oldorder, -struct ioat_descriptor **); static void ioat_halted_debug(struct ioat_softc *, uint32_t); static void ioat_poll_timer_callback(void *arg); -static void ioat_shrink_timer_callback(void *arg); static void dump_descriptor(void *hw_desc); static void ioat_submit_single(struct ioat_softc *ioat); static void ioat_comp_update_map(void *arg, bus_dma_segment_t *seg, int nseg, @@ -135,6 +127,10 @@ int g_ioat_debug_level = 0; SYSCTL_INT(_hw_ioat, OID_AUTO, debug_level, CTLFLAG_RWTUN, &g_ioat_debug_level, 0, "Set log level (0-3) for ioat(4). Higher is more verbose."); +unsigned g_ioat_ring_order = 13; +SYSCTL_UINT(_hw_ioat, OID_AUTO, ring_order, CTLFLAG_RDTUN, &g_ioat_ring_order, +0, "Set IOAT ring order. (1 << this) == ring size."); + /* * OS <-> Driver interface structures */ @@ -336,7 +332,6 @@ ioat_detach(device_t device) ioat_teardown_intr(ioat); callout_drain(&ioat->poll_timer); - callout_drain(&ioat->shrink_timer); pci_disable_busmaster(device); @@ -453,7 +448,6 @@ ioat3_attach(device_t device) mtx_init(&ioat->submit_lock, "ioat_submit", NULL, MTX_DEF); mtx_init(&ioat->cleanup_lock, "ioat_cleanup", NULL, MTX_DEF); callout_init(&ioat->poll_timer, 1); - callout_init(&ioat->shrink_timer, 1); TASK_INIT(&ioat->reset_task, 0, ioat_reset_hw_task, ioat); /* Establish lock order for Witness */ @@ -462,7 +456,6 @@ ioat3_attach(device_t device) mtx_unlock(&ioat->cleanup_lock); mtx_unlock(&ioat->submit_lock); - ioat->is_resize_pending = FALSE; ioat->is_submitter_processing = FALSE; ioat->is_completion_pending = FALSE; ioat->is_reset_pending = FALSE; @@ -484,7 +477,7 @@ ioat3_attach(device_t device) if (error != 0) return (error); - ioat->ring_size_order = IOAT_MIN_ORDER; + ioat->ring_size_order = g_ioat_ring_order; num_descriptors = 1 << ioat->ring_size_order; @@ -725,8 +718,6 @@ out: pending = (ioat_get_active(ioat) != 0); if (!pending && ioat->is_completion_pending) { ioat->is_completion_pending = FALSE; - callout_reset(&ioat->shrink_timer, IOAT_SHRINK_PERIOD, - ioat_shrink_timer_callback, ioat); callout_stop(&ioat->poll_timer); } mtx_unlock(&ioat->submit_lock); @@ -781,8 +772,6 @@ out: if (ioat->is_completion_pending) { ioat->is_completion_pending = FALSE; - callout_reset(&ioat->shrink_timer, IOAT_SHRINK_PERIOD, - ioat_shrink_timer_callback, ioat); callout_stop(&ioat->poll_timer); } @@ -964,7 +953,6 @@ ioat_release(bus_dmaengine_t dmaengine) ioat->is_completion_pending = TRUE; callout_reset(&ioat->poll_timer, 1, ioat_poll_timer_callback, ioat); - callout_stop(&ioat->shrink_timer); } mtx_unlock(&ioat->submit_lock); } @@ -1402,8 +1390,6 @@ ioat_free_ring_entry(struct ioat_so
svn commit: r308177 - head/tests/sys/kern
Author: cem Date: Tue Nov 1 19:18:16 2016 New Revision: 308177 URL: https://svnweb.freebsd.org/changeset/base/308177 Log: Add test case for >65535 segment coredumps A long-belated follow-up to r303099. With feedback from: jmmv, ngie Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7264 Added: head/tests/sys/kern/coredump_phnum_helper.c (contents, props changed) head/tests/sys/kern/coredump_phnum_test.sh (contents, props changed) Modified: head/tests/sys/kern/Makefile Modified: head/tests/sys/kern/Makefile == --- head/tests/sys/kern/MakefileTue Nov 1 18:42:44 2016 (r308176) +++ head/tests/sys/kern/MakefileTue Nov 1 19:18:16 2016 (r308177) @@ -14,6 +14,11 @@ ATF_TESTS_C+=unix_passfd_test TEST_METADATA.unix_seqpacket_test+=timeout="15" ATF_TESTS_C+= waitpid_nohang +ATF_TESTS_SH+= coredump_phnum_test + +BINDIR=${TESTSDIR} +PROGS+=coredump_phnum_helper + LIBADD.ptrace_test+= pthread LIBADD.unix_seqpacket_test+= pthread Added: head/tests/sys/kern/coredump_phnum_helper.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/kern/coredump_phnum_helper.c Tue Nov 1 19:18:16 2016 (r308177) @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, Conrad Meyer + * 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, + * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include + +#include +#include +#include + +/* + * This program is intended to create a bunch of segment mappings, then dump + * core. + */ +int +main(int argc __unused, char **argv __unused) +{ + void *v; + unsigned i; + + for (i = 0; i < UINT16_MAX + 1000; i++) { + /* +* Alternate protections; otherwise the kernel will just extend +* the adjacent same-protection previous mapping. +*/ + v = mmap(NULL, PAGE_SIZE, + (((i % 2) == 0) ? PROT_READ : 0) | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, -1, 0); + if (v == MAP_FAILED) + err(1, "mmap"); + } + + /* Dump core. */ + abort(); +} Added: head/tests/sys/kern/coredump_phnum_test.sh == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/kern/coredump_phnum_test.sh Tue Nov 1 19:18:16 2016 (r308177) @@ -0,0 +1,90 @@ +# +# Copyright (c) 2016 Dell EMC Isilon +# 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, this list of conditions, and the following disclaimer, +# without modification. +# 2. Redistributions in binary form must reproduce at minimum a disclaimer +# substantially similar to the "NO WARRANTY" disclaimer below +# ("Disclaimer") and any redistribution must be conditioned upon +# including a substantially similar Disclaimer requirement for further +# binary redistribution. +# +# NO WARRANTY +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
svn commit: r308155 - in head/sys: amd64/conf cam cam/scsi conf dev/mps geom geom/part kern sys vm
Author: cem Date: Mon Oct 31 23:09:52 2016 New Revision: 308155 URL: https://svnweb.freebsd.org/changeset/base/308155 Log: Add BUF_TRACKING and FULL_BUF_TRACKING buffer debugging Upstream the BUF_TRACKING and FULL_BUF_TRACKING buffer debugging code. This can be handy in tracking down what code touched hung bios and bufs last. The full history is especially useful, but adds enough bloat that it shouldn't be enabled in release builds. Function names (or arbitrary string constants) are tracked in a fixed-size ring in bufs. Bios gain a pointer to the upper buf for tracking. SCSI CCBs gain a pointer to the upper bio for tracking. Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8366 Modified: head/sys/amd64/conf/GENERIC head/sys/amd64/conf/GENERIC-NODEBUG head/sys/cam/cam_ccb.h head/sys/cam/cam_periph.c head/sys/cam/cam_xpt.c head/sys/cam/scsi/scsi_da.c head/sys/conf/options head/sys/dev/mps/mps_sas.c head/sys/geom/geom_dev.c head/sys/geom/geom_disk.c head/sys/geom/geom_io.c head/sys/geom/geom_subr.c head/sys/geom/geom_vfs.c head/sys/geom/part/g_part.c head/sys/kern/vfs_bio.c head/sys/kern/vfs_cluster.c head/sys/sys/bio.h head/sys/sys/buf.h head/sys/vm/vm_pager.c Modified: head/sys/amd64/conf/GENERIC == --- head/sys/amd64/conf/GENERIC Mon Oct 31 22:45:11 2016(r308154) +++ head/sys/amd64/conf/GENERIC Mon Oct 31 23:09:52 2016(r308155) @@ -83,7 +83,9 @@ options RCTL# Resource limits optionsKDB # Enable kernel debugger support. optionsKDB_TRACE # Print a stack trace for a panic. # For full debugger support use (turn off in stable branch): +optionsBUF_TRACKING# Track buffer history optionsDDB # Support DDB. +optionsFULL_BUF_TRACKING # Track more buffer history optionsGDB # Support remote GDB. optionsDEADLKRES # Enable the deadlock resolver optionsINVARIANTS # Enable calls of extra sanity checking Modified: head/sys/amd64/conf/GENERIC-NODEBUG == --- head/sys/amd64/conf/GENERIC-NODEBUG Mon Oct 31 22:45:11 2016 (r308154) +++ head/sys/amd64/conf/GENERIC-NODEBUG Mon Oct 31 23:09:52 2016 (r308155) @@ -34,5 +34,7 @@ nooptions INVARIANTS nooptions INVARIANT_SUPPORT nooptions WITNESS nooptions WITNESS_SKIPSPIN +nooptions BUF_TRACKING nooptions DEADLKRES +nooptions FULL_BUF_TRACKING Modified: head/sys/cam/cam_ccb.h == --- head/sys/cam/cam_ccb.h Mon Oct 31 22:45:11 2016(r308154) +++ head/sys/cam/cam_ccb.h Mon Oct 31 23:09:52 2016(r308155) @@ -744,6 +744,9 @@ struct ccb_scsiio { #defineCAM_TAG_ACTION_NONE 0x00 u_int tag_id; /* tag id from initator (target mode) */ u_int init_id; /* initiator id of who selected */ +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + struct bio *bio;/* Associated bio */ +#endif }; static __inline uint8_t * @@ -1335,6 +1338,9 @@ cam_fill_csio(struct ccb_scsiio *csio, u csio->sense_len = sense_len; csio->cdb_len = cdb_len; csio->tag_action = tag_action; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + csio->bio = NULL; +#endif } static __inline void Modified: head/sys/cam/cam_periph.c == --- head/sys/cam/cam_periph.c Mon Oct 31 22:45:11 2016(r308154) +++ head/sys/cam/cam_periph.c Mon Oct 31 23:09:52 2016(r308155) @@ -1427,6 +1427,11 @@ camperiphscsisenseerror(union ccb *ccb, union ccb *orig_ccb = ccb; int error, recoveryccb; +#if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) + if (ccb->ccb_h.func_code == XPT_SCSI_IO && ccb->csio.bio != NULL) + biotrack(ccb->csio.bio, __func__); +#endif + periph = xpt_path_periph(ccb->ccb_h.path); recoveryccb = (ccb->ccb_h.cbfcnp == camperiphdone); if ((periph->flags & CAM_PERIPH_RECOVERY_INPROG) && !recoveryccb) { Modified: head/sys/cam/cam_xpt.c == --- head/sys/cam/cam_xpt.c Mon Oct 31 22:45:11 2016(r308154) +++ head/sys/cam/cam_xpt.c Mon Oct 31 23:09:52 2016(r308155) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -4471,6 +4472,12 @@ xpt_done(union ccb *done_ccb) struct cam_doneq *queue; int run, hash; +#if d
svn commit: r308068 - head/sys/dev/ioat
Author: cem Date: Fri Oct 28 23:53:35 2016 New Revision: 308068 URL: https://svnweb.freebsd.org/changeset/base/308068 Log: ioat(4): Assert the submit lock in ioat_submit_single Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cFri Oct 28 23:53:33 2016(r308067) +++ head/sys/dev/ioat/ioat.cFri Oct 28 23:53:35 2016(r308068) @@ -1804,6 +1804,8 @@ static void ioat_submit_single(struct ioat_softc *ioat) { + mtx_assert(&ioat->submit_lock, MA_OWNED); + ioat_get(ioat, IOAT_ACTIVE_DESCR_REF); atomic_add_rel_int(&ioat->head, 1); atomic_add_rel_int(&ioat->hw_head, 1); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r308070 - head/sys/dev/ioat
Author: cem Date: Fri Oct 28 23:53:37 2016 New Revision: 308070 URL: https://svnweb.freebsd.org/changeset/base/308070 Log: ioat(4): Use memory completion rather than device register The CHANSTS register is a split 64-bit register on CBDMA units before hardware v3.3. If a torn read happens during ioat_process_events(), software cannot know when to stop completing descriptors correctly. So, just use the device-pushed main memory channel status instead. Remove the ioat_get_active() seatbelt as well. It does nothing if the completion address is valid. Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c head/sys/dev/ioat/ioat_internal.h Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cFri Oct 28 23:53:36 2016(r308069) +++ head/sys/dev/ioat/ioat.cFri Oct 28 23:53:37 2016(r308070) @@ -677,7 +677,7 @@ ioat_process_events(struct ioat_softc *i } completed = 0; - comp_update = ioat_get_chansts(ioat); + comp_update = *ioat->comp_update; status = comp_update & IOAT_CHANSTS_COMPLETED_DESCRIPTOR_MASK; if (status == ioat->last_seen) { @@ -691,7 +691,7 @@ ioat_process_events(struct ioat_softc *i __func__, ioat->chan_idx, comp_update, ioat->last_seen); desc = ioat_get_ring_entry(ioat, ioat->tail - 1); - while (desc->hw_desc_bus_addr != status && ioat_get_active(ioat) > 0) { + while (desc->hw_desc_bus_addr != status) { desc = ioat_get_ring_entry(ioat, ioat->tail); dmadesc = &desc->bus_dmadesc; CTR5(KTR_IOAT, "channel=%u completing desc idx %u (%p) ok cb %p(%p)", Modified: head/sys/dev/ioat/ioat_internal.h == --- head/sys/dev/ioat/ioat_internal.h Fri Oct 28 23:53:36 2016 (r308069) +++ head/sys/dev/ioat/ioat_internal.h Fri Oct 28 23:53:37 2016 (r308070) @@ -523,6 +523,15 @@ struct ioat_softc { void ioat_test_attach(void); void ioat_test_detach(void); +/* + * XXX DO NOT USE this routine for obtaining the current completed descriptor. + * + * The double_4 read on ioat<3.3 appears to result in torn reads. And v3.2 + * hardware is still commonplace (Broadwell Xeon has it). Instead, use the + * device-pushed *comp_update. + * + * It is safe to use ioat_get_chansts() for the low status bits. + */ static inline uint64_t ioat_get_chansts(struct ioat_softc *ioat) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r308069 - head/sys/dev/ioat
Author: cem Date: Fri Oct 28 23:53:36 2016 New Revision: 308069 URL: https://svnweb.freebsd.org/changeset/base/308069 Log: ioat(4): Add failpoint for delay() in ioat_release Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cFri Oct 28 23:53:35 2016(r308068) +++ head/sys/dev/ioat/ioat.cFri Oct 28 23:53:36 2016(r308069) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -951,8 +952,12 @@ ioat_release(bus_dmaengine_t dmaengine) struct ioat_softc *ioat; ioat = to_ioat_softc(dmaengine); - CTR3(KTR_IOAT, "%s channel=%u dispatch hw_head=%u", __func__, - ioat->chan_idx, ioat->hw_head & UINT16_MAX); + CTR4(KTR_IOAT, "%s channel=%u dispatch1 hw_head=%u head=%u", __func__, + ioat->chan_idx, ioat->hw_head & UINT16_MAX, ioat->head); + KFAIL_POINT_CODE(DEBUG_FP, ioat_release, /* do nothing */); + CTR4(KTR_IOAT, "%s channel=%u dispatch2 hw_head=%u head=%u", __func__, + ioat->chan_idx, ioat->hw_head & UINT16_MAX, ioat->head); + ioat_write_2(ioat, IOAT_DMACOUNT_OFFSET, (uint16_t)ioat->hw_head); if (!ioat->is_completion_pending) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r308067 - head/sys/dev/ioat
Author: cem Date: Fri Oct 28 23:53:33 2016 New Revision: 308067 URL: https://svnweb.freebsd.org/changeset/base/308067 Log: ioat(4): Add additional tracing These probes help track down driver bugs. Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cFri Oct 28 23:01:11 2016(r308066) +++ head/sys/dev/ioat/ioat.cFri Oct 28 23:53:33 2016(r308067) @@ -693,8 +693,8 @@ ioat_process_events(struct ioat_softc *i while (desc->hw_desc_bus_addr != status && ioat_get_active(ioat) > 0) { desc = ioat_get_ring_entry(ioat, ioat->tail); dmadesc = &desc->bus_dmadesc; - CTR4(KTR_IOAT, "channel=%u completing desc %u ok cb %p(%p)", - ioat->chan_idx, ioat->tail, dmadesc->callback_fn, + CTR5(KTR_IOAT, "channel=%u completing desc idx %u (%p) ok cb %p(%p)", + ioat->chan_idx, ioat->tail, dmadesc, dmadesc->callback_fn, dmadesc->callback_arg); if (dmadesc->callback_fn != NULL) @@ -703,6 +703,8 @@ ioat_process_events(struct ioat_softc *i completed++; ioat->tail++; } + CTR5(KTR_IOAT, "%s channel=%u head=%u tail=%u active=%u", __func__, + ioat->chan_idx, ioat->head, ioat->tail, ioat_get_active(ioat)); if (completed != 0) { ioat->last_seen = desc->hw_desc_bus_addr; @@ -760,8 +762,8 @@ out: while (ioat_get_active(ioat) > 0) { desc = ioat_get_ring_entry(ioat, ioat->tail); dmadesc = &desc->bus_dmadesc; - CTR4(KTR_IOAT, "channel=%u completing desc %u err cb %p(%p)", - ioat->chan_idx, ioat->tail, dmadesc->callback_fn, + CTR5(KTR_IOAT, "channel=%u completing desc idx %u (%p) err cb %p(%p)", + ioat->chan_idx, ioat->tail, dmadesc, dmadesc->callback_fn, dmadesc->callback_arg); if (dmadesc->callback_fn != NULL) @@ -773,6 +775,8 @@ out: ioat->stats.descriptors_processed++; ioat->stats.descriptors_error++; } + CTR5(KTR_IOAT, "%s channel=%u head=%u tail=%u active=%u", __func__, + ioat->chan_idx, ioat->head, ioat->tail, ioat_get_active(ioat)); if (ioat->is_completion_pending) { ioat->is_completion_pending = FALSE; @@ -947,7 +951,8 @@ ioat_release(bus_dmaengine_t dmaengine) struct ioat_softc *ioat; ioat = to_ioat_softc(dmaengine); - CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); + CTR3(KTR_IOAT, "%s channel=%u dispatch hw_head=%u", __func__, + ioat->chan_idx, ioat->hw_head & UINT16_MAX); ioat_write_2(ioat, IOAT_DMACOUNT_OFFSET, (uint16_t)ioat->hw_head); if (!ioat->is_completion_pending) { @@ -1040,7 +1045,6 @@ ioat_copy(bus_dmaengine_t dmaengine, bus struct ioat_softc *ioat; ioat = to_ioat_softc(dmaengine); - CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); if (((src | dst) & (0xull << 48)) != 0) { ioat_log_message(0, "%s: High 16 bits of src/dst invalid\n", @@ -1058,6 +1062,8 @@ ioat_copy(bus_dmaengine_t dmaengine, bus dump_descriptor(hw_desc); ioat_submit_single(ioat); + CTR6(KTR_IOAT, "%s channel=%u desc=%p dest=%lx src=%lx len=%lx", + __func__, ioat->chan_idx, &desc->bus_dmadesc, dst, src, len); return (&desc->bus_dmadesc); } @@ -1414,11 +1420,16 @@ ioat_reserve_space(struct ioat_softc *io if (ioat_get_ring_space(ioat) >= num_descs) goto out; + CTR3(KTR_IOAT, "%s channel=%u starved (%u)", __func__, + ioat->chan_idx, num_descs); + if (!dug && !ioat->is_submitter_processing && (1 << ioat->ring_size_order) > num_descs) { ioat->is_submitter_processing = TRUE; mtx_unlock(&ioat->submit_lock); + CTR2(KTR_IOAT, "%s channel=%u attempting to process events", + __func__, ioat->chan_idx); ioat_process_events(ioat); mtx_lock(&ioat->submit_lock); @@ -1433,6 +1444,8 @@ ioat_reserve_space(struct ioat_softc *io order = ioat->ring_size_order; if (ioat->is_resize_pending || order == IOAT_MAX_ORDER) { if ((mflags & M_WAITOK) != 0) { + CTR2(KTR_IOAT, "%s channel=%u blocking on completions", + __func__, ioat->chan_idx); msleep(&ioat->tail, &ioat->submit_lock, 0, "ioat_rsz", 0); cont
svn commit: r307946 - head/sys/dev/usb/net
Author: cem Date: Tue Oct 25 18:36:15 2016 New Revision: 307946 URL: https://svnweb.freebsd.org/changeset/base/307946 Log: uhso(4): Fix a null pointer dereference The directly following m_defrag() call can wait, so there is no reason this call can't as well. Reported by: Coverity CID: 1353551 Sponsored by: Dell EMC Isilon Modified: head/sys/dev/usb/net/uhso.c Modified: head/sys/dev/usb/net/uhso.c == --- head/sys/dev/usb/net/uhso.c Tue Oct 25 18:17:03 2016(r307945) +++ head/sys/dev/usb/net/uhso.c Tue Oct 25 18:36:15 2016(r307946) @@ -1752,7 +1752,7 @@ uhso_if_rxflush(void *arg) * Allocate a new mbuf for this IP packet and * copy the IP-packet into it. */ - m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); + m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR); memcpy(mtod(m, uint8_t *), mtod(m0, uint8_t *), iplen); m->m_pkthdr.len = m->m_len = iplen; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r307780 - head/sys/kern
Author: cem Date: Sat Oct 22 18:02:20 2016 New Revision: 307780 URL: https://svnweb.freebsd.org/changeset/base/307780 Log: ddb(4): Add sleepchains to "show allchains" Reported by: markj Reviewed by: markj Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8320 Modified: head/sys/kern/subr_turnstile.c Modified: head/sys/kern/subr_turnstile.c == --- head/sys/kern/subr_turnstile.c Sat Oct 22 17:21:21 2016 (r307779) +++ head/sys/kern/subr_turnstile.c Sat Oct 22 18:02:20 2016 (r307780) @@ -157,6 +157,9 @@ static void init_turnstile0(void *dummy) #ifdef TURNSTILE_PROFILING static voidinit_turnstile_profiling(void *arg); #endif +#ifdef DDB +static voidprint_sleepchain(struct thread *td, const char *prefix); +#endif static voidpropagate_priority(struct thread *td); static int turnstile_adjust_thread(struct turnstile *ts, struct thread *td); @@ -1169,6 +1172,10 @@ DB_SHOW_ALL_COMMAND(chains, db_show_allc db_printf("chain %d:\n", i++); print_lockchain(td, " "); } + if (TD_IS_INHIBITED(td) && TD_ON_SLEEPQ(td)) { + db_printf("chain %d:\n", i++); + print_sleepchain(td, " "); + } if (db_pager_quit) return; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r307660 - head/usr.bin/jot
Author: cem Date: Wed Oct 19 21:50:57 2016 New Revision: 307660 URL: https://svnweb.freebsd.org/changeset/base/307660 Log: Capsicum support for jot(1) Limit descriptors and enter capability mode in jot(1). Submitted by: brueffer (earlier version) Reviewed by: emaste, jonathan (earlier version) Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D1345 Modified: head/usr.bin/jot/jot.c Modified: head/usr.bin/jot/jot.c == --- head/usr.bin/jot/jot.c Wed Oct 19 21:25:59 2016(r307659) +++ head/usr.bin/jot/jot.c Wed Oct 19 21:50:57 2016(r307660) @@ -47,8 +47,11 @@ __FBSDID("$FreeBSD$"); * Author: John Kunze, Office of Comp. Affairs, UCB */ +#include +#include #include #include +#include #include #include #include @@ -89,6 +92,7 @@ static void usage(void); int main(int argc, char **argv) { + cap_rights_t rights; boolhave_format = false; boolinfinity = false; boolnofinalnl = false; @@ -105,6 +109,21 @@ main(int argc, char **argv) longi; longreps = REPS_DEF; + if (caph_limit_stdio() < 0) + err(1, "unable to limit rights for stdio"); + cap_rights_init(&rights); + if (cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for stdin"); + + /* +* Cache NLS data, for strerror, for err(3), before entering capability +* mode. +*/ + caph_cache_catpages(); + + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "unable to enter capability mode"); + while ((ch = getopt(argc, argv, "b:cnp:rs:w:")) != -1) switch (ch) { case 'b': ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r307163 - in head/sys: kern sys
Author: cem Date: Thu Oct 13 02:06:23 2016 New Revision: 307163 URL: https://svnweb.freebsd.org/changeset/base/307163 Log: kern_linker: Handle module-loading failures in preloaded .ko files The runtime kernel loader, linker_load_file, unloads kernel files that failed to load all of their modules. For consistency, treat preloaded (loader.conf loaded) kernel files in the same way. Reviewed by: kib Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8200 Modified: head/sys/kern/kern_linker.c head/sys/sys/linker.h Modified: head/sys/kern/kern_linker.c == --- head/sys/kern/kern_linker.c Thu Oct 13 01:58:49 2016(r307162) +++ head/sys/kern/kern_linker.c Thu Oct 13 02:06:23 2016(r307163) @@ -1599,7 +1599,6 @@ restart: if (error) panic("cannot add dependency"); } - lf->userrefs++; /* so we can (try to) kldunload it */ error = linker_file_lookup_set(lf, MDT_SETNAME, &start, &stop, NULL); if (!error) { @@ -1637,6 +1636,8 @@ restart: goto fail; } linker_file_register_modules(lf); + if (!TAILQ_EMPTY(&lf->modules)) + lf->flags |= LINKER_FILE_MODULES; if (linker_file_lookup_set(lf, "sysinit_set", &si_start, &si_stop, NULL) == 0) sysinit_add(si_start, si_stop); @@ -1654,6 +1655,41 @@ fail: SYSINIT(preload, SI_SUB_KLD, SI_ORDER_MIDDLE, linker_preload, 0); /* + * Handle preload files that failed to load any modules. + */ +static void +linker_preload_finish(void *arg) +{ + linker_file_t lf, nlf; + + sx_xlock(&kld_sx); + TAILQ_FOREACH_SAFE(lf, &linker_files, link, nlf) { + /* +* If all of the modules in this file failed to load, unload +* the file and return an error of ENOEXEC. (Parity with +* linker_load_file.) +*/ + if ((lf->flags & LINKER_FILE_MODULES) != 0 && + TAILQ_EMPTY(&lf->modules)) { + linker_file_unload(lf, LINKER_UNLOAD_FORCE); + continue; + } + + lf->flags &= ~LINKER_FILE_MODULES; + lf->userrefs++; /* so we can (try to) kldunload it */ + } + sx_xunlock(&kld_sx); +} + +/* + * Attempt to run after all DECLARE_MODULE SYSINITs. Unfortunately they can be + * scheduled at any subsystem and order, so run this as late as possible. init + * becomes runnable in SI_SUB_KTHREAD_INIT, so go slightly before that. + */ +SYSINIT(preload_finish, SI_SUB_KTHREAD_INIT - 100, SI_ORDER_MIDDLE, +linker_preload_finish, 0); + +/* * Search for a not-loaded module by name. * * Modules may be found in the following locations: Modified: head/sys/sys/linker.h == --- head/sys/sys/linker.h Thu Oct 13 01:58:49 2016(r307162) +++ head/sys/sys/linker.h Thu Oct 13 02:06:23 2016(r307163) @@ -73,6 +73,7 @@ struct linker_file { intuserrefs; /* kldload(2) count */ intflags; #define LINKER_FILE_LINKED 0x1 /* file has been fully linked */ +#define LINKER_FILE_MODULES0x2 /* file has >0 modules at preload */ TAILQ_ENTRY(linker_file) link; /* list of all loaded files */ char* filename; /* file which was loaded */ char* pathname; /* file name with full path */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r306874 - head/sys/sys
Author: cem Date: Sat Oct 8 19:40:58 2016 New Revision: 306874 URL: https://svnweb.freebsd.org/changeset/base/306874 Log: sys/module.h: Unbreak MOD_DPF printf MOD_DPF's args parameter already has parentheses around it. This was broken 14 years ago in r91472. Sponsored by: Dell EMC Isilon Modified: head/sys/sys/module.h Modified: head/sys/sys/module.h == --- head/sys/sys/module.h Sat Oct 8 19:32:17 2016(r306873) +++ head/sys/sys/module.h Sat Oct 8 19:40:58 2016(r306874) @@ -233,7 +233,7 @@ extern int mod_debug; #defineMOD_DPF(cat, args) do { \ if (mod_debug & MOD_DEBUG_##cat)\ - printf(args); \ + printf args;\ } while (0) #else /* !MOD_DEBUG */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r306761 - head/usr.bin/write
Author: cem Date: Thu Oct 6 14:55:15 2016 New Revision: 306761 URL: https://svnweb.freebsd.org/changeset/base/306761 Log: write(1): Capsicumify Enter Capsicum capability sandbox pretty early in this setuid program. Some minor modifications were needed to cache directory fds and use relative lookups. Rights restriction of the stdio descriptors is unfortunately pretty messy because we need an ioctl capability not present in the current libcapsicum helpers (FIODGNAME). Reviewed by: ed Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7999 Modified: head/usr.bin/write/write.c Modified: head/usr.bin/write/write.c == --- head/usr.bin/write/write.c Thu Oct 6 14:42:06 2016(r306760) +++ head/usr.bin/write/write.c Thu Oct 6 14:55:15 2016(r306761) @@ -46,12 +46,16 @@ static char sccsid[] = "@(#)write.c 8.1 __FBSDID("$FreeBSD$"); #include +#include +#include #include #include -#include #include + +#include #include #include +#include #include #include #include @@ -64,23 +68,76 @@ __FBSDID("$FreeBSD$"); #include void done(int); -void do_write(char *, char *, uid_t); +void do_write(int, char *, char *, const char *); static void usage(void); -int term_chk(char *, int *, time_t *, int); +int term_chk(int, char *, int *, time_t *, int); void wr_fputs(wchar_t *s); -void search_utmp(char *, char *, char *, uid_t); +void search_utmp(int, char *, char *, char *, uid_t); int utmp_chk(char *, char *); int main(int argc, char **argv) { + unsigned long cmds[] = { TIOCGETA, TIOCGWINSZ, FIODGNAME }; + cap_rights_t rights; + struct passwd *pwd; time_t atime; uid_t myuid; int msgsok, myttyfd; char tty[MAXPATHLEN], *mytty; + const char *login; + int devfd; (void)setlocale(LC_CTYPE, ""); + devfd = open(_PATH_DEV, O_RDONLY); + if (devfd < 0) + err(1, "open(/dev)"); + cap_rights_init(&rights, CAP_FCNTL, CAP_FSTAT, CAP_IOCTL, CAP_LOOKUP, + CAP_PWRITE); + if (cap_rights_limit(devfd, &rights) < 0 && errno != ENOSYS) + err(1, "can't limit devfd rights"); + + /* +* Can't use capsicum helpers here because we need the additional +* FIODGNAME ioctl. +*/ + cap_rights_init(&rights, CAP_FCNTL, CAP_FSTAT, CAP_IOCTL, CAP_READ, + CAP_WRITE); + if ((cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) || + (cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS) || + (cap_rights_limit(STDERR_FILENO, &rights) < 0 && errno != ENOSYS) || + (cap_ioctls_limit(STDIN_FILENO, cmds, nitems(cmds)) < 0 && errno != ENOSYS) || + (cap_ioctls_limit(STDOUT_FILENO, cmds, nitems(cmds)) < 0 && errno != ENOSYS) || + (cap_ioctls_limit(STDERR_FILENO, cmds, nitems(cmds)) < 0 && errno != ENOSYS) || + (cap_fcntls_limit(STDIN_FILENO, CAP_FCNTL_GETFL) < 0 && errno != ENOSYS) || + (cap_fcntls_limit(STDOUT_FILENO, CAP_FCNTL_GETFL) < 0 && errno != ENOSYS) || + (cap_fcntls_limit(STDERR_FILENO, CAP_FCNTL_GETFL) < 0 && errno != ENOSYS)) + err(1, "can't limit stdio rights"); + + caph_cache_catpages(); + caph_cache_tzdata(); + + /* +* Cache UTX database fds. +*/ + setutxent(); + + /* +* Determine our login name before we reopen() stdout +* and before entering capability sandbox. +*/ + myuid = getuid(); + if ((login = getlogin()) == NULL) { + if ((pwd = getpwuid(myuid))) + login = pwd->pw_name; + else + login = "???"; + } + + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "cap_enter"); + while (getopt(argc, argv, "") != -1) usage(); argc -= optind; @@ -99,29 +156,27 @@ main(int argc, char **argv) errx(1, "can't find your tty's name"); if (!strncmp(mytty, _PATH_DEV, strlen(_PATH_DEV))) mytty += strlen(_PATH_DEV); - if (term_chk(mytty, &msgsok, &atime, 1)) + if (term_chk(devfd, mytty, &msgsok, &atime, 1)) exit(1); if (!msgsok) errx(1, "you have write permission turned off"); - myuid = getuid(); - /* check args */ switch (argc) { case 1: - search_utmp(argv[0], tty, mytty, myuid); - do_write(tty, mytty, myuid); + search_utmp(devfd, argv[0], tty, mytty, myuid); + do_write(devfd, tty, mytty, login); break; case 2: if (!strncmp(argv[1], _PATH_DEV, strlen(_PATH_DEV))) argv[1] += strlen(_PATH_DEV); if (utmp_chk(argv[0],
svn commit: r306752 - head/sbin/savecore
Author: cem Date: Thu Oct 6 05:16:44 2016 New Revision: 306752 URL: https://svnweb.freebsd.org/changeset/base/306752 Log: savecore(8): Fix buffer overrun inspecting disks with varying sector size A premature optimization lead to caching a native-sector sized memory allocation. If the program examined a 512 byte sector disk, then a 4096 byte sector disk, the program would overrun the cached 512 byte buffer. Just remove the optimization to fix the bug. This was introduced with the 4Kn dump support in r298076. Reported by: markj Reviewed by: markj, rpokala Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8162 Modified: head/sbin/savecore/savecore.c Modified: head/sbin/savecore/savecore.c == --- head/sbin/savecore/savecore.c Thu Oct 6 03:32:30 2016 (r306751) +++ head/sbin/savecore/savecore.c Thu Oct 6 05:16:44 2016 (r306752) @@ -436,7 +436,8 @@ DoFile(const char *savedir, const char * { xo_handle_t *xostdout, *xoinfo; static char infoname[PATH_MAX], corename[PATH_MAX], linkname[PATH_MAX]; - static char *buf = NULL, *temp = NULL; + static char *buf = NULL; + char *temp = NULL; struct kerneldumpheader kdhf, kdhl; off_t mediasize, dumpsize, firsthd, lasthd; FILE *info, *fp; @@ -498,12 +499,10 @@ DoFile(const char *savedir, const char * } lasthd = mediasize - sectorsize; + temp = malloc(sectorsize); if (temp == NULL) { - temp = malloc(sectorsize); - if (temp == NULL) { - syslog(LOG_ERR, "%m"); - goto closefd; - } + syslog(LOG_ERR, "%m"); + goto closefd; } if (lseek(fd, lasthd, SEEK_SET) != lasthd || read(fd, temp, sectorsize) != (ssize_t)sectorsize) { @@ -749,6 +748,7 @@ nuke: } xo_close_container_h(xostdout, "crashdump"); xo_finish_h(xostdout); + free(temp); close(fd); return; @@ -756,6 +756,7 @@ closeall: fclose(fp); closefd: + free(temp); close(fd); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r306748 - head/share/man/man9
Author: cem Date: Thu Oct 6 01:52:00 2016 New Revision: 306748 URL: https://svnweb.freebsd.org/changeset/base/306748 Log: style(9): Some additional clarification Prompted by an email from bde@. Reviewed by: emaste, imp (earlier version) With input from: wblock Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7983 Modified: head/share/man/man9/style.9 Modified: head/share/man/man9/style.9 == --- head/share/man/man9/style.9 Thu Oct 6 01:14:10 2016(r306747) +++ head/share/man/man9/style.9 Thu Oct 6 01:52:00 2016(r306748) @@ -26,7 +26,7 @@ .\"From: @(#)style 1.14 (Berkeley) 4/28/95 .\" $FreeBSD$ .\" -.Dd December 5, 2015 +.Dd October 5, 2016 .Dt STYLE 9 .Os .Sh NAME @@ -114,20 +114,28 @@ static char sccsid[] = "@(#)style 1.14 ( __FBSDID("$FreeBSD$"); .Ed .Pp -Leave another blank line before the header files. +Leave one blank line before the header files. .Pp -Kernel include files (i.e.\& -.Pa sys/*.h ) -come first sorted alphabetically where possible. -Include -.In sys/types.h -OR -.In sys/param.h , -but not both and include it first. +Kernel include files +.Pa ( sys/*.h ) +come first. +If +.In sys/cdefs.h +is needed for +.Fn __FBSDID , +include it first. +If either .In sys/types.h +or +.In sys/param.h +is needed, include it before other include files. +.Po +.In sys/param.h includes -.In sys/cdefs.h , -and it is okay to depend on that. +.In sys/types.h ; +do not include both. +.Pc +The remaining kernel headers should be sorted alphabetically. .Bd -literal #include /* Non-local includes in angle brackets. */ #include @@ -144,9 +152,9 @@ For a network program, put the network i #include .Ed .Pp -Do not use files in +Do not include files from .Pa /usr/include -for files in the kernel. +in the kernel. .Pp Leave a blank line before the next group, the .Pa /usr/include @@ -166,7 +174,7 @@ in the local directory. #include .Ed .Pp -Leave another blank line before the user include files. +Leave another blank line before the local include files. .Bd -literal #include "pathnames.h" /* Local includes in double quotes. */ .Ed ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r306741 - head/sys/kern
Author: cem Date: Wed Oct 5 23:42:02 2016 New Revision: 306741 URL: https://svnweb.freebsd.org/changeset/base/306741 Log: vfs_bio: Remove a leading space (style) Introduced in r282085. Sponsored by: Dell EMC Isilon Modified: head/sys/kern/vfs_bio.c Modified: head/sys/kern/vfs_bio.c == --- head/sys/kern/vfs_bio.c Wed Oct 5 23:25:29 2016(r306740) +++ head/sys/kern/vfs_bio.c Wed Oct 5 23:42:02 2016(r306741) @@ -3113,7 +3113,7 @@ flushbufqueues(struct vnode *lvp, int ta if (bp->b_qindex == QUEUE_SENTINEL || (lvp != NULL && bp->b_vp != lvp)) { mtx_unlock(&bqlocks[queue]); - continue; + continue; } error = BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL); mtx_unlock(&bqlocks[queue]); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r306537 - head/lib/libc/sys
Author: cem Date: Fri Sep 30 23:01:37 2016 New Revision: 306537 URL: https://svnweb.freebsd.org/changeset/base/306537 Log: open.2: Document Capsicum behavior Document open(2) and openat(2) behavior in Capsicum capability mode. Reviewed by: ed (previous version), emaste, rwatson (previous version), wblock Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7947 Modified: head/lib/libc/sys/open.2 Modified: head/lib/libc/sys/open.2 == --- head/lib/libc/sys/open.2Fri Sep 30 22:40:58 2016(r306536) +++ head/lib/libc/sys/open.2Fri Sep 30 23:01:37 2016(r306537) @@ -28,7 +28,7 @@ .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" $FreeBSD$ .\" -.Dd April 2, 2015 +.Dd September 30, 2016 .Dt OPEN 2 .Os .Sh NAME @@ -95,6 +95,28 @@ parameter, the current working directory and the behavior is identical to a call to .Fn open . .Pp +In +.Xr capsicum 4 +capability mode, +.Fn open +is not permitted. +The +.Fa path +argument to +.Fn openat +must be strictly relative to a file descriptor +.Fa fd , +as defined in +.Pa sys/kern/vfs_lookup.c . +.Fa path +must not be an absolute path and must not contain ".." components. +Additionally, no symbolic link in +.Fa path +may contain ".." components either. +.Fa fd +must not be +.Dv AT_FDCWD . +.Pp The flags specified are formed by .Em or Ns 'ing the following values @@ -447,8 +469,18 @@ nor a file descriptor associated with a .It Bq Er ENOTDIR .Dv O_DIRECTORY is specified and the file is not a directory. +.It Bq Er ECAPMODE +.Dv AT_FDCWD +is specified and the process is in capability mode. +.It Bq Er ECAPMODE +.Fn open +was called and the process is in capability mode. +.It Bq Er ENOTCAPABLE +.Fa path +is an absolute path or contained "..". .El .Sh SEE ALSO +.Xr capsicum 4 , .Xr chmod 2 , .Xr close 2 , .Xr dup 2 , ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r306521 - in head/sys: amd64/amd64 amd64/include x86/include x86/x86
Author: cem Date: Fri Sep 30 18:58:50 2016 New Revision: 306521 URL: https://svnweb.freebsd.org/changeset/base/306521 Log: Revert r306516 for now, it is incomplete on i386 Noted by: kib Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/include/pcpu.h head/sys/x86/include/x86_smp.h head/sys/x86/x86/mp_x86.c Modified: head/sys/amd64/amd64/mp_machdep.c == --- head/sys/amd64/amd64/mp_machdep.c Fri Sep 30 18:47:34 2016 (r306520) +++ head/sys/amd64/amd64/mp_machdep.c Fri Sep 30 18:58:50 2016 (r306521) @@ -409,7 +409,6 @@ void invltlb_invpcid_handler(void) { struct invpcid_descr d; - uint64_t generation; #ifdef COUNT_XINVLTLB_HITS xhits_gbl[PCPU_GET(cpuid)]++; @@ -418,20 +417,17 @@ invltlb_invpcid_handler(void) (*ipi_invltlb_counts[PCPU_GET(cpuid)])++; #endif /* COUNT_IPIS */ - generation = smp_tlb_generation; d.pcid = smp_tlb_pmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid; d.pad = 0; d.addr = 0; invpcid(&d, smp_tlb_pmap == kernel_pmap ? INVPCID_CTXGLOB : INVPCID_CTX); - PCPU_SET(smp_tlb_done, generation); + atomic_add_int(&smp_tlb_wait, 1); } void invltlb_pcid_handler(void) { - uint64_t generation; - #ifdef COUNT_XINVLTLB_HITS xhits_gbl[PCPU_GET(cpuid)]++; #endif /* COUNT_XINVLTLB_HITS */ @@ -439,7 +435,6 @@ invltlb_pcid_handler(void) (*ipi_invltlb_counts[PCPU_GET(cpuid)])++; #endif /* COUNT_IPIS */ - generation = smp_tlb_generation; if (smp_tlb_pmap == kernel_pmap) { invltlb_glob(); } else { @@ -455,5 +450,5 @@ invltlb_pcid_handler(void) smp_tlb_pmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid); } } - PCPU_SET(smp_tlb_done, generation); + atomic_add_int(&smp_tlb_wait, 1); } Modified: head/sys/amd64/include/pcpu.h == --- head/sys/amd64/include/pcpu.h Fri Sep 30 18:47:34 2016 (r306520) +++ head/sys/amd64/include/pcpu.h Fri Sep 30 18:58:50 2016 (r306521) @@ -65,8 +65,7 @@ u_int pc_vcpu_id; /* Xen vCPU ID */ \ uint32_t pc_pcid_next; \ uint32_t pc_pcid_gen; \ - uint64_t pc_smp_tlb_done; /* TLB op acknowledgement */\ - char__pad[141] /* be divisor of PAGE_SIZE \ + char__pad[149] /* be divisor of PAGE_SIZE \ after cache alignment */ #definePC_DBREG_CMD_NONE 0 Modified: head/sys/x86/include/x86_smp.h == --- head/sys/x86/include/x86_smp.h Fri Sep 30 18:47:34 2016 (r306520) +++ head/sys/x86/include/x86_smp.h Fri Sep 30 18:58:50 2016 (r306521) @@ -35,7 +35,7 @@ extern volatile int aps_ready; extern struct mtx ap_boot_mtx; extern int cpu_logical; extern int cpu_cores; -extern volatile uint64_t smp_tlb_generation; +extern volatile int smp_tlb_wait; extern struct pmap *smp_tlb_pmap; extern u_int xhits_gbl[]; extern u_int xhits_pg[]; Modified: head/sys/x86/x86/mp_x86.c == --- head/sys/x86/x86/mp_x86.c Fri Sep 30 18:47:34 2016(r306520) +++ head/sys/x86/x86/mp_x86.c Fri Sep 30 18:58:50 2016(r306521) @@ -1304,15 +1304,12 @@ cpususpend_handler(void) void invlcache_handler(void) { - uint64_t generation; - #ifdef COUNT_IPIS (*ipi_invlcache_counts[PCPU_GET(cpuid)])++; #endif /* COUNT_IPIS */ - generation = smp_tlb_generation; wbinvd(); - PCPU_SET(smp_tlb_done, generation); + atomic_add_int(&smp_tlb_wait, 1); } /* @@ -1370,7 +1367,7 @@ SYSINIT(mp_ipi_intrcnt, SI_SUB_INTR, SI_ /* Variables needed for SMP tlb shootdown. */ static vm_offset_t smp_tlb_addr1, smp_tlb_addr2; pmap_t smp_tlb_pmap; -volatile uint64_t smp_tlb_generation; +volatile int smp_tlb_wait; #ifdef __amd64__ #defineread_eflags() read_rflags() @@ -1380,16 +1377,15 @@ static void smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, pmap_t pmap, vm_offset_t addr1, vm_offset_t addr2) { - cpuset_t other_cpus; - volatile uint64_t *p_cpudone; - uint64_t generation; - int cpu; + int cpu, ncpu, othercpus; + + othercpus = mp_ncpus - 1; /* does not shootdown self */ /* * Check for other cpus. Return if none. */ if (CPU_ISFULLSET(&mask)) { - if (mp_ncpus <= 1) + if (othercpus < 1) return; } else { CPU_CLR(PCPU_GET(cpuid), &mask); @@ -1403,28 +1
svn commit: r306516 - in head/sys: amd64/amd64 amd64/include x86/include x86/x86
Author: cem Date: Fri Sep 30 18:12:16 2016 New Revision: 306516 URL: https://svnweb.freebsd.org/changeset/base/306516 Log: Reduce the cost of TLB invalidation on x86 by using per-CPU completion flags Reduce contention during TLB invalidation operations by using a per-CPU completion flag, rather than a single atomically-updated variable. On a Westmere system (2 sockets x 4 cores x 1 threads), dtrace measurements show that smp_tlb_shootdown is about 50% faster with this patch; observations with VTune show that the percentage of time spent in invlrng_single_page on an interrupt (actually doing invalidation, rather than synchronization) increases from 31% with the old mechanism to 71% with the new one. (Running a basic file server workload.) Submitted by: Anton Rang Reviewed by: cem (earlier version), kib Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D8041 Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/include/pcpu.h head/sys/x86/include/x86_smp.h head/sys/x86/x86/mp_x86.c Modified: head/sys/amd64/amd64/mp_machdep.c == --- head/sys/amd64/amd64/mp_machdep.c Fri Sep 30 18:08:16 2016 (r306515) +++ head/sys/amd64/amd64/mp_machdep.c Fri Sep 30 18:12:16 2016 (r306516) @@ -409,6 +409,7 @@ void invltlb_invpcid_handler(void) { struct invpcid_descr d; + uint64_t generation; #ifdef COUNT_XINVLTLB_HITS xhits_gbl[PCPU_GET(cpuid)]++; @@ -417,17 +418,20 @@ invltlb_invpcid_handler(void) (*ipi_invltlb_counts[PCPU_GET(cpuid)])++; #endif /* COUNT_IPIS */ + generation = smp_tlb_generation; d.pcid = smp_tlb_pmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid; d.pad = 0; d.addr = 0; invpcid(&d, smp_tlb_pmap == kernel_pmap ? INVPCID_CTXGLOB : INVPCID_CTX); - atomic_add_int(&smp_tlb_wait, 1); + PCPU_SET(smp_tlb_done, generation); } void invltlb_pcid_handler(void) { + uint64_t generation; + #ifdef COUNT_XINVLTLB_HITS xhits_gbl[PCPU_GET(cpuid)]++; #endif /* COUNT_XINVLTLB_HITS */ @@ -435,6 +439,7 @@ invltlb_pcid_handler(void) (*ipi_invltlb_counts[PCPU_GET(cpuid)])++; #endif /* COUNT_IPIS */ + generation = smp_tlb_generation; if (smp_tlb_pmap == kernel_pmap) { invltlb_glob(); } else { @@ -450,5 +455,5 @@ invltlb_pcid_handler(void) smp_tlb_pmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid); } } - atomic_add_int(&smp_tlb_wait, 1); + PCPU_SET(smp_tlb_done, generation); } Modified: head/sys/amd64/include/pcpu.h == --- head/sys/amd64/include/pcpu.h Fri Sep 30 18:08:16 2016 (r306515) +++ head/sys/amd64/include/pcpu.h Fri Sep 30 18:12:16 2016 (r306516) @@ -65,7 +65,8 @@ u_int pc_vcpu_id; /* Xen vCPU ID */ \ uint32_t pc_pcid_next; \ uint32_t pc_pcid_gen; \ - char__pad[149] /* be divisor of PAGE_SIZE \ + uint64_t pc_smp_tlb_done; /* TLB op acknowledgement */\ + char__pad[141] /* be divisor of PAGE_SIZE \ after cache alignment */ #definePC_DBREG_CMD_NONE 0 Modified: head/sys/x86/include/x86_smp.h == --- head/sys/x86/include/x86_smp.h Fri Sep 30 18:08:16 2016 (r306515) +++ head/sys/x86/include/x86_smp.h Fri Sep 30 18:12:16 2016 (r306516) @@ -35,7 +35,7 @@ extern volatile int aps_ready; extern struct mtx ap_boot_mtx; extern int cpu_logical; extern int cpu_cores; -extern volatile int smp_tlb_wait; +extern volatile uint64_t smp_tlb_generation; extern struct pmap *smp_tlb_pmap; extern u_int xhits_gbl[]; extern u_int xhits_pg[]; Modified: head/sys/x86/x86/mp_x86.c == --- head/sys/x86/x86/mp_x86.c Fri Sep 30 18:08:16 2016(r306515) +++ head/sys/x86/x86/mp_x86.c Fri Sep 30 18:12:16 2016(r306516) @@ -1304,12 +1304,15 @@ cpususpend_handler(void) void invlcache_handler(void) { + uint64_t generation; + #ifdef COUNT_IPIS (*ipi_invlcache_counts[PCPU_GET(cpuid)])++; #endif /* COUNT_IPIS */ + generation = smp_tlb_generation; wbinvd(); - atomic_add_int(&smp_tlb_wait, 1); + PCPU_SET(smp_tlb_done, generation); } /* @@ -1367,7 +1370,7 @@ SYSINIT(mp_ipi_intrcnt, SI_SUB_INTR, SI_ /* Variables needed for SMP tlb shootdown. */ static vm_offset_t smp_tlb_addr1, smp_tlb_addr2; pmap_t smp_tlb_pmap; -volatile int smp_tlb_wait; +volatile uint64_t
svn commit: r306149 - head/sys/dev/oce
Author: cem Date: Thu Sep 22 00:25:23 2016 New Revision: 306149 URL: https://svnweb.freebsd.org/changeset/base/306149 Log: Revert r306148 to fix build Requested by: jpaetzel Reported by: Larry Rosenman , Jenkins Modified: head/sys/dev/oce/oce_hw.c head/sys/dev/oce/oce_hw.h head/sys/dev/oce/oce_if.c head/sys/dev/oce/oce_if.h head/sys/dev/oce/oce_mbox.c head/sys/dev/oce/oce_queue.c head/sys/dev/oce/oce_sysctl.c Modified: head/sys/dev/oce/oce_hw.c == --- head/sys/dev/oce/oce_hw.c Wed Sep 21 22:53:16 2016(r306148) +++ head/sys/dev/oce/oce_hw.c Thu Sep 22 00:25:23 2016(r306149) @@ -393,11 +393,6 @@ oce_create_nw_interface(POCE_SOFTC sc) if (IS_SH(sc) || IS_XE201(sc)) capab_flags |= MBX_RX_IFACE_FLAGS_MULTICAST; -if (sc->enable_hwlro) { -capab_flags |= MBX_RX_IFACE_FLAGS_LRO; -capab_en_flags |= MBX_RX_IFACE_FLAGS_LRO; -} - /* enable capabilities controlled via driver startup parameters */ if (is_rss_enabled(sc)) capab_en_flags |= MBX_RX_IFACE_FLAGS_RSS; Modified: head/sys/dev/oce/oce_hw.h == --- head/sys/dev/oce/oce_hw.h Wed Sep 21 22:53:16 2016(r306148) +++ head/sys/dev/oce/oce_hw.h Thu Sep 22 00:25:23 2016(r306149) @@ -111,9 +111,6 @@ #definePD_MPU_MBOX_DB 0x0160 #definePD_MQ_DB0x0140 -#define DB_OFFSET 0xc0 -#define DB_LRO_RQ_ID_MASK 0x7FF - /* EQE completion types */ #defineEQ_MINOR_CODE_COMPLETION0x00 #defineEQ_MINOR_CODE_OTHER 0x01 @@ -183,7 +180,6 @@ #define ASYNC_EVENT_GRP5 0x5 #define ASYNC_EVENT_CODE_DEBUG 0x6 #define ASYNC_EVENT_PVID_STATE 0x3 -#define ASYNC_EVENT_OS2BMC 0x5 #define ASYNC_EVENT_DEBUG_QNQ 0x1 #define ASYNC_EVENT_CODE_SLIPORT 0x11 #define VLAN_VID_MASK 0x0FFF @@ -726,34 +722,6 @@ struct oce_async_cqe_link_state { } u0; }; -/* OS2BMC async event */ -struct oce_async_evt_grp5_os2bmc { - union { - struct { - uint32_t lrn_enable:1; - uint32_t lrn_disable:1; - uint32_t mgmt_enable:1; - uint32_t mgmt_disable:1; - uint32_t rsvd0:12; - uint32_t vlan_tag:16; - uint32_t arp_filter:1; - uint32_t dhcp_client_filt:1; - uint32_t dhcp_server_filt:1; - uint32_t net_bios_filt:1; - uint32_t rsvd1:3; - uint32_t bcast_filt:1; - uint32_t ipv6_nbr_filt:1; - uint32_t ipv6_ra_filt:1; - uint32_t ipv6_ras_filt:1; - uint32_t rsvd2[4]; - uint32_t mcast_filt:1; - uint32_t rsvd3:16; - uint32_t evt_tag; - uint32_t dword3; - } s; - uint32_t dword[4]; - } u; -}; /* PVID aync event */ struct oce_async_event_grp5_pvid_state { @@ -1428,7 +1396,7 @@ typedef union oce_cq_ctx_u { uint32_t dw5rsvd3:1; uint32_t eventable:1; /* dw6 */ - uint32_t eq_id:16; + uint32_t eq_id:8; uint32_t dw6rsvd1:15; uint32_t armed:1; /* dw7 */ @@ -2435,8 +2403,8 @@ struct oce_nic_hdr_wqe { uint32_t tcpcs:1; uint32_t udpcs:1; uint32_t ipcs:1; - uint32_t mgmt:1; - uint32_t lso6:1; + uint32_t rsvd3:1; + uint32_t rsvd2:1; uint32_t forward:1; uint32_t crc:1; uint32_t event:1; @@ -2458,8 +2426,8 @@ struct oce_nic_hdr_wqe { uint32_t event:1; uint32_t crc:1; uint32_t forward:1; - uint32_t lso6:1; - uint32_t mgmt:1; + uint32_t rsvd2:1; + uint32_t rsvd3:1; uint32_t ipcs:1; uint32_t udpcs:1; uint32_t tcpcs:1; @@ -3042,53 +3010,6 @@ struct oce_rxf_stats_v0 { uint32_t rsvd1[6]; }; -struct oce_port_rxf_stats_v2 { -uint32_t rsvd0[10]; -uint32_t roce_bytes_received_lsd; -uint32_t roce_bytes_received_msd; -uint32_t rsvd1[5]; -uint32_t roce_frames_received; -uint32_t rx_crc_errors; -uint32_t rx
svn commit: r306127 - head/lib/libc/sys
Author: cem Date: Wed Sep 21 17:51:27 2016 New Revision: 306127 URL: https://svnweb.freebsd.org/changeset/base/306127 Log: posix_openpt.2: Sort includes per style(9) Sponsored by: Dell EMC Isilon Modified: head/lib/libc/sys/posix_openpt.2 Modified: head/lib/libc/sys/posix_openpt.2 == --- head/lib/libc/sys/posix_openpt.2Wed Sep 21 16:51:56 2016 (r306126) +++ head/lib/libc/sys/posix_openpt.2Wed Sep 21 17:51:27 2016 (r306127) @@ -37,7 +37,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 21, 2013 +.Dd September 21, 2016 .Dt POSIX_OPENPT 2 .Os .Sh NAME @@ -46,8 +46,8 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In stdlib.h .In fcntl.h +.In stdlib.h .Ft int .Fn posix_openpt "int oflag" .Sh DESCRIPTION ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r306053 - head/sbin/dhclient
Author: cem Date: Tue Sep 20 19:21:41 2016 New Revision: 306053 URL: https://svnweb.freebsd.org/changeset/base/306053 Log: dhclient(8): Enable numbered user class ID option By adding it to the option priorities table. PR: 184117 Submitted by: Lowell Gilbert Reported by: Tomek CEDRO Reviewed by: jhb Differential Revision:https://reviews.freebsd.org/D7911 Modified: head/sbin/dhclient/tables.c Modified: head/sbin/dhclient/tables.c == --- head/sbin/dhclient/tables.c Tue Sep 20 19:15:39 2016(r306052) +++ head/sbin/dhclient/tables.c Tue Sep 20 19:21:41 2016(r306053) @@ -400,6 +400,7 @@ unsigned char dhcp_option_default_priori DHO_IRC_SERVER, DHO_STREETTALK_SERVER, DHO_STREETTALK_DA_SERVER, + DHO_DHCP_USER_CLASS_ID, DHO_DOMAIN_SEARCH, /* Presently-undefined options... */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r305998 - in head/usr.bin: cmp indent tr
Author: cem Date: Mon Sep 19 20:43:03 2016 New Revision: 305998 URL: https://svnweb.freebsd.org/changeset/base/305998 Log: Move sys/capsicum.h includes after types.h or param.h This is not actually documented or even implied in style(9). Make the change to match convention. Someone should document this convention in style(9). Reported by: jhb Sponsored by: EMC Dell Isilon Modified: head/usr.bin/cmp/cmp.c head/usr.bin/indent/indent.c head/usr.bin/tr/tr.c Modified: head/usr.bin/cmp/cmp.c == --- head/usr.bin/cmp/cmp.c Mon Sep 19 19:18:40 2016(r305997) +++ head/usr.bin/cmp/cmp.c Mon Sep 19 20:43:03 2016(r305998) @@ -42,8 +42,8 @@ static char sccsid[] = "@(#)cmp.c 8.3 (B #include __FBSDID("$FreeBSD$"); -#include #include +#include #include #include Modified: head/usr.bin/indent/indent.c == --- head/usr.bin/indent/indent.cMon Sep 19 19:18:40 2016 (r305997) +++ head/usr.bin/indent/indent.cMon Sep 19 20:43:03 2016 (r305998) @@ -50,8 +50,8 @@ static char sccsid[] = "@(#)indent.c 5.1 #include __FBSDID("$FreeBSD$"); -#include #include +#include #include #include #include Modified: head/usr.bin/tr/tr.c == --- head/usr.bin/tr/tr.cMon Sep 19 19:18:40 2016(r305997) +++ head/usr.bin/tr/tr.cMon Sep 19 20:43:03 2016(r305998) @@ -41,8 +41,8 @@ static const char copyright[] = static const char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95"; #endif -#include #include +#include #include #include ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r305983 - head/usr.bin/indent
Author: cem Date: Mon Sep 19 16:16:14 2016 New Revision: 305983 URL: https://svnweb.freebsd.org/changeset/base/305983 Log: indent(1): Capsicumify This is a nice and trivial program for sandboxing. One input file, one output file. Reviewed by: pfg Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7920 Modified: head/usr.bin/indent/indent.c Modified: head/usr.bin/indent/indent.c == --- head/usr.bin/indent/indent.cMon Sep 19 16:14:38 2016 (r305982) +++ head/usr.bin/indent/indent.cMon Sep 19 16:16:14 2016 (r305983) @@ -50,8 +50,10 @@ static char sccsid[] = "@(#)indent.c 5.1 #include __FBSDID("$FreeBSD$"); +#include #include #include +#include #include #include #include @@ -74,6 +76,7 @@ charbakfile[MAXPATHLEN] = ""; int main(int argc, char **argv) { +cap_rights_t rights; int dec_ind; /* current indentation for declarations */ int di_stack[20]; /* a stack of structure indentation levels */ @@ -234,6 +237,17 @@ main(int argc, char **argv) bakcopy(); } } + +/* Restrict input/output descriptors and enter Capsicum sandbox. */ +cap_rights_init(&rights, CAP_FSTAT, CAP_WRITE); +if (cap_rights_limit(fileno(output), &rights) < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to limit rights for %s", out_name); +cap_rights_init(&rights, CAP_FSTAT, CAP_READ); +if (cap_rights_limit(fileno(input), &rights) < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to limit rights for %s", in_name); +if (cap_enter() < 0 && errno != ENOSYS) + err(EXIT_FAILURE, "unable to enter capability mode"); + if (ps.com_ind <= 1) ps.com_ind = 2; /* dont put normal comments before column 2 */ if (troff) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r305982 - head/usr.bin/tr
Author: cem Date: Mon Sep 19 16:14:38 2016 New Revision: 305982 URL: https://svnweb.freebsd.org/changeset/base/305982 Log: tr(1): Capsicumify This is a straightforward single input, single output program for capsicum. Reviewed by: bapt Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7928 Modified: head/usr.bin/tr/tr.c Modified: head/usr.bin/tr/tr.c == --- head/usr.bin/tr/tr.cMon Sep 19 16:13:00 2016(r305981) +++ head/usr.bin/tr/tr.cMon Sep 19 16:14:38 2016(r305982) @@ -41,16 +41,19 @@ static const char copyright[] = static const char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95"; #endif +#include #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -69,6 +72,8 @@ int main(int argc, char **argv) { static int carray[NCHARS_SB]; + cap_rights_t rights; + unsigned long cmd; struct cmap *map; struct cset *delete, *squeeze; int n, *p; @@ -77,6 +82,27 @@ main(int argc, char **argv) (void)setlocale(LC_ALL, ""); + cap_rights_init(&rights, CAP_FSTAT, CAP_IOCTL, CAP_READ); + if (cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for stdin"); + cap_rights_init(&rights, CAP_FSTAT, CAP_IOCTL, CAP_WRITE); + if (cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for stdout"); + if (cap_rights_limit(STDERR_FILENO, &rights) < 0 && errno != ENOSYS) + err(1, "unable to limit rights for stderr"); + + /* Required for isatty(3). */ + cmd = TIOCGETA; + if (cap_ioctls_limit(STDIN_FILENO, &cmd, 1) < 0 && errno != ENOSYS) + err(1, "unable to limit ioctls for stdin"); + if (cap_ioctls_limit(STDOUT_FILENO, &cmd, 1) < 0 && errno != ENOSYS) + err(1, "unable to limit ioctls for stdout"); + if (cap_ioctls_limit(STDERR_FILENO, &cmd, 1) < 0 && errno != ENOSYS) + err(1, "unable to limit ioctls for stderr"); + + if (cap_enter() < 0 && errno != ENOSYS) + err(1, "unable to enter capability mode"); + Cflag = cflag = dflag = sflag = 0; while ((ch = getopt(argc, argv, "Ccdsu")) != -1) switch((char)ch) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r305981 - head/usr.bin/cmp
Author: cem Date: Mon Sep 19 16:13:00 2016 New Revision: 305981 URL: https://svnweb.freebsd.org/changeset/base/305981 Log: cmp(1): Capsicumify Reviewed by: allanjude, bapt, oshogbo Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D7912 Modified: head/usr.bin/cmp/cmp.c Modified: head/usr.bin/cmp/cmp.c == --- head/usr.bin/cmp/cmp.c Mon Sep 19 16:07:32 2016(r305980) +++ head/usr.bin/cmp/cmp.c Mon Sep 19 16:13:00 2016(r305981) @@ -42,15 +42,18 @@ static char sccsid[] = "@(#)cmp.c 8.3 (B #include __FBSDID("$FreeBSD$"); +#include #include #include #include #include #include +#include #include #include #include +#include #include #include "extern.h" @@ -66,6 +69,9 @@ main(int argc, char *argv[]) off_t skip1, skip2; int ch, fd1, fd2, oflag, special; const char *file1, *file2; + cap_rights_t rights; + unsigned long cmd; + uint32_t fcntls; oflag = O_RDONLY; while ((ch = getopt(argc, argv, "hlsxz")) != -1) @@ -146,6 +152,37 @@ main(int argc, char *argv[]) exit(ERR_EXIT); } + cap_rights_init(&rights, CAP_FCNTL, CAP_FSTAT, CAP_MMAP_R); + if (cap_rights_limit(fd1, &rights) < 0 && errno != ENOSYS) + err(ERR_EXIT, "unable to limit rights for %s", file1); + if (cap_rights_limit(fd2, &rights) < 0 && errno != ENOSYS) + err(ERR_EXIT, "unable to limit rights for %s", file2); + + /* Required for fdopen(3). */ + fcntls = CAP_FCNTL_GETFL; + if (cap_fcntls_limit(fd1, fcntls) < 0 && errno != ENOSYS) + err(ERR_EXIT, "unable to limit fcntls for %s", file1); + if (cap_fcntls_limit(fd2, fcntls) < 0 && errno != ENOSYS) + err(ERR_EXIT, "unable to limit fcntls for %s", file2); + + cap_rights_init(&rights, CAP_FSTAT, CAP_WRITE, CAP_IOCTL); + if (cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS) + err(ERR_EXIT, "unable to limit rights for stdout"); + + /* Required for printf(3) via isatty(3). */ + cmd = TIOCGETA; + if (cap_ioctls_limit(STDOUT_FILENO, &cmd, 1) < 0 && errno != ENOSYS) + err(ERR_EXIT, "unable to limit ioctls for stdout"); + + /* +* Cache NLS data, for strerror, for err(3), before entering capability +* mode. +*/ + (void)catopen("libc", NL_CAT_LOCALE); + + if (cap_enter() < 0 && errno != ENOSYS) + err(ERR_EXIT, "unable to enter capability mode"); + if (!special) { if (fstat(fd1, &sb1)) { if (!sflag) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r305711 - head/sys/dev/ioat
Author: cem Date: Sun Sep 11 20:15:41 2016 New Revision: 305711 URL: https://svnweb.freebsd.org/changeset/base/305711 Log: ioat(4): Start poll timer when descriptors are released to HW Rather than when the software creates the descriptors. Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cSun Sep 11 20:14:19 2016(r305710) +++ head/sys/dev/ioat/ioat.cSun Sep 11 20:15:41 2016(r305711) @@ -949,6 +949,13 @@ ioat_release(bus_dmaengine_t dmaengine) ioat = to_ioat_softc(dmaengine); CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); ioat_write_2(ioat, IOAT_DMACOUNT_OFFSET, (uint16_t)ioat->hw_head); + + if (!ioat->is_completion_pending) { + ioat->is_completion_pending = TRUE; + callout_reset(&ioat->poll_timer, 1, ioat_poll_timer_callback, + ioat); + callout_stop(&ioat->shrink_timer); + } mtx_unlock(&ioat->submit_lock); } @@ -1788,13 +1795,6 @@ ioat_submit_single(struct ioat_softc *io atomic_add_rel_int(&ioat->head, 1); atomic_add_rel_int(&ioat->hw_head, 1); - if (!ioat->is_completion_pending) { - ioat->is_completion_pending = TRUE; - callout_reset(&ioat->poll_timer, 1, ioat_poll_timer_callback, - ioat); - callout_stop(&ioat->shrink_timer); - } - ioat->stats.descriptors_submitted++; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r305710 - head/sys/dev/ioat
Author: cem Date: Sun Sep 11 20:14:19 2016 New Revision: 305710 URL: https://svnweb.freebsd.org/changeset/base/305710 Log: ioat(4): De-spam ioat_process_events KTR logs Sponsored by: Dell EMC Isilon Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cSun Sep 11 19:51:32 2016(r305709) +++ head/sys/dev/ioat/ioat.cSun Sep 11 20:14:19 2016(r305710) @@ -663,8 +663,6 @@ ioat_process_events(struct ioat_softc *i boolean_t pending; int error; - CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); - mtx_lock(&ioat->cleanup_lock); /* @@ -679,8 +677,6 @@ ioat_process_events(struct ioat_softc *i completed = 0; comp_update = ioat_get_chansts(ioat); - CTR4(KTR_IOAT, "%s channel=%u hw_status=0x%lx last_seen=0x%lx", - __func__, ioat->chan_idx, comp_update, ioat->last_seen); status = comp_update & IOAT_CHANSTS_COMPLETED_DESCRIPTOR_MASK; if (status == ioat->last_seen) { @@ -690,6 +686,8 @@ ioat_process_events(struct ioat_softc *i */ goto out; } + CTR4(KTR_IOAT, "%s channel=%u hw_status=0x%lx last_seen=0x%lx", + __func__, ioat->chan_idx, comp_update, ioat->last_seen); desc = ioat_get_ring_entry(ioat, ioat->tail - 1); while (desc->hw_desc_bus_addr != status && ioat_get_active(ioat) > 0) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r305627 - in head: . share/man/man3 sys/sys
Author: cem Date: Thu Sep 8 21:20:01 2016 New Revision: 305627 URL: https://svnweb.freebsd.org/changeset/base/305627 Log: queue(3): Enhance queue debugging macros Split the QUEUE_MACRO_DEBUG into QUEUE_MACRO_DEBUG_TRACE and QUEUE_MACRO_DEBUG_TRASH. Add the debug macrso QMD_IS_TRASHED() and QMD_SLIST_CHECK_PREVPTR(). Document these in queue.3. Reviewed by: emaste Sponsored by: Dell EMC Isilon Differential Revision:https://reviews.freebsd.org/D3984 Modified: head/UPDATING head/share/man/man3/Makefile head/share/man/man3/queue.3 head/sys/sys/queue.h Modified: head/UPDATING == --- head/UPDATING Thu Sep 8 20:01:26 2016(r305626) +++ head/UPDATING Thu Sep 8 21:20:01 2016(r305627) @@ -31,6 +31,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12 disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20160908: + The queue(3) debugging macro, QUEUE_MACRO_DEBUG, has been split into + two separate components, QUEUE_MACRO_DEBUG_TRACE and + QUEUE_MACRO_DEBUG_TRASH. Define both for the original + QUEUE_MACRO_DEBUG behavior. + 20160824: r304787 changed some ioctl interfaces between the iSCSI userspace programs and the kernel. ctladm, ctld, iscsictl, and iscsid must be Modified: head/share/man/man3/Makefile == --- head/share/man/man3/MakefileThu Sep 8 20:01:26 2016 (r305626) +++ head/share/man/man3/MakefileThu Sep 8 21:20:01 2016 (r305627) @@ -106,6 +106,7 @@ MLINKS+=queue.3 LIST_CLASS_ENTRY.3 \ queue.3 SLIST_REMOVE.3 \ queue.3 SLIST_REMOVE_AFTER.3 \ queue.3 SLIST_REMOVE_HEAD.3 \ + queue.3 SLIST_REMOVE_PREVPTR.3 \ queue.3 SLIST_SWAP.3 \ queue.3 STAILQ_CLASS_ENTRY.3 \ queue.3 STAILQ_CLASS_HEAD.3 \ Modified: head/share/man/man3/queue.3 == --- head/share/man/man3/queue.3 Thu Sep 8 20:01:26 2016(r305626) +++ head/share/man/man3/queue.3 Thu Sep 8 21:20:01 2016(r305627) @@ -28,7 +28,7 @@ .\"@(#)queue.3 8.2 (Berkeley) 1/24/94 .\" $FreeBSD$ .\" -.Dd August 15, 2016 +.Dd September 8, 2016 .Dt QUEUE 3 .Os .Sh NAME @@ -1284,6 +1284,50 @@ while (n1 != NULL) { } TAILQ_INIT(&head); .Ed +.Sh DIAGNOSTICS +When debugging +.Nm queue(3) , +it can be useful to trace queue changes. +To enable tracing, define the macro +.Va QUEUE_MACRO_DEBUG_TRACE +at compile time. +.Pp +It can also be useful to trash pointers that have been unlinked from a queue, +to detect use after removal. +To enable pointer trashing, define the macro +.Va QUEUE_MACRO_DEBUG_TRASH +at compile time. +The macro +.Fn QMD_IS_TRASHED "void *ptr" +returns true if +.Fa ptr +has been trashed by the +.Va QUEUE_MACRO_DEBUG_TRASH +option. +.Pp +In the kernel (with +.Va INVARIANTS +enabled), the +.Fn SLIST_REMOVE_PREVPTR +macro is available to aid debugging: +.Bl -hang -offset indent +.It Fn SLIST_REMOVE_PREVPTR "TYPE **prev" "TYPE *elm" "SLIST_ENTRY NAME" +.Pp +Removes +.Fa elm , +which must directly follow the element whose +.Va &SLIST_NEXT() +is +.Fa prev , +from the SLIST. +This macro validates that +.Fa elm +follows +.Fa prev +in +.Va INVARIANTS +mode. +.El .Sh SEE ALSO .Xr tree 3 .Sh HISTORY Modified: head/sys/sys/queue.h == --- head/sys/sys/queue.hThu Sep 8 20:01:26 2016(r305626) +++ head/sys/sys/queue.hThu Sep 8 21:20:01 2016(r305627) @@ -113,6 +113,12 @@ * */ #ifdef QUEUE_MACRO_DEBUG +#warn Use QUEUE_MACRO_DEBUG_TRACE and/or QUEUE_MACRO_DEBUG_TRASH +#defineQUEUE_MACRO_DEBUG_TRACE +#defineQUEUE_MACRO_DEBUG_TRASH +#endif + +#ifdef QUEUE_MACRO_DEBUG_TRACE /* Store the last 2 places the queue element or head was altered */ struct qm_trace { unsigned longlastline; @@ -123,8 +129,6 @@ struct qm_trace { #defineTRACEBUFstruct qm_trace trace; #defineTRACEBUF_INITIALIZER{ __LINE__, 0, __FILE__, NULL } , -#defineTRASHIT(x) do {(x) = (void *)-1;} while (0) -#defineQMD_SAVELINK(name, link)void **name = (void *)&(link) #defineQMD_TRACE_HEAD(head) do { \ (head)->trace.prevline = (head)->trace.lastline;\ @@ -140,14 +144,26 @@ struct qm_trace { (elem)->trace.lastfile = __FILE__; \ } while (0) -#else +#else /* !QUEUE_MACRO_DEBUG_TRACE */ #defineQMD_TRACE_ELEM(elem) #defineQMD_TRACE_HEAD(head) -#defineQMD_SAVELINK(name, link) #defineTRACEBUF #define
svn commit: r305306 - head/sbin/dhclient
Author: cem Date: Fri Sep 2 21:14:29 2016 New Revision: 305306 URL: https://svnweb.freebsd.org/changeset/base/305306 Log: dhclient: add support for interface-mtu (26) Make dhclient set interface MTU if it was provided. This version implements MTU setting in dhclient itself before it runs dhclient-script. PR: 206721 Submitted by: novel@ Reported by: Jarrod Petz Reviewed by: cem, allanjude Differential Revision:https://reviews.freebsd.org/D5675 Modified: head/sbin/dhclient/clparse.c head/sbin/dhclient/dhclient.c head/sbin/dhclient/dhcpd.h head/sbin/dhclient/dispatch.c head/sbin/dhclient/privsep.c head/sbin/dhclient/privsep.h Modified: head/sbin/dhclient/clparse.c == --- head/sbin/dhclient/clparse.cFri Sep 2 21:13:46 2016 (r305305) +++ head/sbin/dhclient/clparse.cFri Sep 2 21:14:29 2016 (r305306) @@ -102,6 +102,8 @@ read_client_conf(void) [top_level_config.requested_option_count++] = DHO_HOST_NAME; top_level_config.requested_options [top_level_config.requested_option_count++] = DHO_DOMAIN_SEARCH; + top_level_config.requested_options + [top_level_config.requested_option_count++] = DHO_INTERFACE_MTU; if ((cfile = fopen(path_dhclient_conf, "r")) != NULL) { do { Modified: head/sbin/dhclient/dhclient.c == --- head/sbin/dhclient/dhclient.c Fri Sep 2 21:13:46 2016 (r305305) +++ head/sbin/dhclient/dhclient.c Fri Sep 2 21:14:29 2016 (r305306) @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include "privsep.h" #include +#include #include @@ -132,6 +133,9 @@ int fork_privchld(int, int); ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) #defineADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) +/* Minimum MTU is 68 as per RFC791, p. 24 */ +#define MIN_MTU 68 + static time_t scripttime; int @@ -798,9 +802,20 @@ dhcpack(struct packet *packet) void bind_lease(struct interface_info *ip) { + struct option_data *opt; + /* Remember the medium. */ ip->client->new->medium = ip->client->medium; + opt = &ip->client->new->options[DHO_INTERFACE_MTU]; + if (opt->len == sizeof(u_int16_t)) { + u_int16_t mtu = be16dec(opt->data); + if (mtu < MIN_MTU) + warning("mtu size %u < %d: ignored", (unsigned)mtu, MIN_MTU); + else + interface_set_mtu_unpriv(privfd, mtu); + } + /* Write out the new lease. */ write_client_lease(ip, ip->client->new, 0); Modified: head/sbin/dhclient/dhcpd.h == --- head/sbin/dhclient/dhcpd.h Fri Sep 2 21:13:46 2016(r305305) +++ head/sbin/dhclient/dhcpd.h Fri Sep 2 21:14:29 2016(r305306) @@ -319,6 +319,8 @@ void cancel_timeout(void (*)(void *), vo void add_protocol(char *, int, void (*)(struct protocol *), void *); void remove_protocol(struct protocol *); int interface_link_status(char *); +void interface_set_mtu_unpriv(int, u_int16_t); +void interface_set_mtu_priv(char *, u_int16_t); /* hash.c */ struct hash_table *new_hash(void); Modified: head/sbin/dhclient/dispatch.c == --- head/sbin/dhclient/dispatch.c Fri Sep 2 21:13:46 2016 (r305305) +++ head/sbin/dhclient/dispatch.c Fri Sep 2 21:14:29 2016 (r305306) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include "dhcpd.h" +#include "privsep.h" #include @@ -501,3 +502,46 @@ interface_link_status(char *ifname) } return (1); } + +void +interface_set_mtu_unpriv(int privfd, u_int16_t mtu) +{ + struct imsg_hdr hdr; + struct buf *buf; + int errs = 0; + + hdr.code = IMSG_SET_INTERFACE_MTU; + hdr.len = sizeof(hdr) + + sizeof(u_int16_t); + + if ((buf = buf_open(hdr.len)) == NULL) + error("buf_open: %m"); + + errs += buf_add(buf, &hdr, sizeof(hdr)); + errs += buf_add(buf, &mtu, sizeof(mtu)); + if (errs) + error("buf_add: %m"); + + if (buf_close(privfd, buf) == -1) + error("buf_close: %m"); +} + +void +interface_set_mtu_priv(char *ifname, u_int16_t mtu) +{ + struct ifreq ifr; + int sock; + + if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) + error("Can't create socket"); + + memset(&ifr, 0, sizeof(ifr)); + + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + ifr.ifr_mtu = mtu; + + if (ioctl(sock, SIOCSIFMTU, &ifr) == -1) + warning("SIOCSIFMTU failed (%d): %s", mtu, + strerror(errno)); +
svn commit: r305259 - head/sys/dev/ioat
Author: cem Date: Thu Sep 1 23:56:02 2016 New Revision: 305259 URL: https://svnweb.freebsd.org/changeset/base/305259 Log: ioat(4): Despam relatively common hardware reset messages Reported by: ngie@ Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cThu Sep 1 23:52:25 2016(r305258) +++ head/sys/dev/ioat/ioat.cThu Sep 1 23:56:02 2016(r305259) @@ -750,13 +750,13 @@ out: * Fatal programming error on this DMA channel. Flush any outstanding * work with error status and restart the engine. */ - ioat_log_message(0, "Channel halted due to fatal programming error\n"); mtx_lock(&ioat->submit_lock); mtx_lock(&ioat->cleanup_lock); ioat->quiescing = TRUE; chanerr = ioat_read_4(ioat, IOAT_CHANERR_OFFSET); - ioat_halted_debug(ioat, chanerr); + if (1 <= g_ioat_debug_level) + ioat_halted_debug(ioat, chanerr); ioat->stats.last_halt_chanerr = chanerr; while (ioat_get_active(ioat) > 0) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r305139 - head/bin/df
Author: cem Date: Wed Aug 31 18:10:41 2016 New Revision: 305139 URL: https://svnweb.freebsd.org/changeset/base/305139 Log: df(1): Allow duplicate -l flags gracefully Rather than producing a misleading error message when duplicate -l flags are provided to df(1), simply ignore extra flags and proceed as if only one was specified. This seems most reasonable given the usage for -l: -l Only display information about locally-mounted file systems. l and t flags still conflict, as before. PR: 208169 Reported by: by at reorigin.com Reviewed by: allanjude Modified: head/bin/df/df.c Modified: head/bin/df/df.c == --- head/bin/df/df.cWed Aug 31 18:00:41 2016(r305138) +++ head/bin/df/df.cWed Aug 31 18:10:41 2016(r305139) @@ -166,6 +166,9 @@ main(int argc, char *argv[]) hflag = 0; break; case 'l': + /* Ignore duplicate -l */ + if (lflag) + break; if (vfslist != NULL) xo_errx(1, "-l and -t are mutually exclusive."); vfslist = makevfslist(makenetvfslist()); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r305028 - head/sys/dev/ioat
Author: cem Date: Mon Aug 29 20:51:34 2016 New Revision: 305028 URL: https://svnweb.freebsd.org/changeset/base/305028 Log: ioat(4): Add additional CTR tracing during reset Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cMon Aug 29 20:46:33 2016(r305027) +++ head/sys/dev/ioat/ioat.cMon Aug 29 20:51:34 2016(r305028) @@ -1831,6 +1831,9 @@ ioat_reset_hw(struct ioat_softc *ioat) ioat->resetting_cleanup = TRUE; mtx_unlock(&ioat->cleanup_lock); + CTR2(KTR_IOAT, "%s channel=%u quiesced and drained", __func__, + ioat->chan_idx); + status = ioat_get_chansts(ioat); if (is_ioat_active(status) || is_ioat_idle(status)) ioat_suspend(ioat); @@ -1851,6 +1854,9 @@ ioat_reset_hw(struct ioat_softc *ioat) chanerr = ioat_read_4(ioat, IOAT_CHANERR_OFFSET); ioat_write_4(ioat, IOAT_CHANERR_OFFSET, chanerr); + CTR2(KTR_IOAT, "%s channel=%u hardware suspended", __func__, + ioat->chan_idx); + /* * IOAT v3 workaround - CHANERRMSK_INT with 3E07h to masks out errors * that can cause stability issues for IOAT v3. @@ -1870,6 +1876,8 @@ ioat_reset_hw(struct ioat_softc *ioat) } ioat_reset(ioat); + CTR2(KTR_IOAT, "%s channel=%u hardware reset", __func__, + ioat->chan_idx); /* Wait at most 20 ms */ for (timeout = 0; ioat_reset_pending(ioat) && timeout < 20; timeout++) @@ -1919,11 +1927,16 @@ ioat_reset_hw(struct ioat_softc *ioat) ioat_write_chancmp(ioat, ioat->comp_update_bus_addr); ioat_write_chainaddr(ioat, ioat->ring[0]->hw_desc_bus_addr); error = 0; + CTR2(KTR_IOAT, "%s channel=%u configured channel", __func__, + ioat->chan_idx); out: /* Enqueues a null operation and ensures it completes. */ - if (error == 0) + if (error == 0) { error = ioat_start_channel(ioat); + CTR2(KTR_IOAT, "%s channel=%u started channel", __func__, + ioat->chan_idx); + } /* * Resume completions now that ring state is consistent. @@ -1943,6 +1956,7 @@ out: if (ioat->is_completion_pending) callout_reset(&ioat->poll_timer, 1, ioat_poll_timer_callback, ioat); + CTR2(KTR_IOAT, "%s channel=%u reset done", __func__, ioat->chan_idx); mtx_unlock(IOAT_REFLK); return (error); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r305027 - head/sys/dev/ioat
Author: cem Date: Mon Aug 29 20:46:33 2016 New Revision: 305027 URL: https://svnweb.freebsd.org/changeset/base/305027 Log: ioat(4): Don't "complete" DMA descriptors prematurely In r304602, I mistakenly removed the ioat_process_events check that we weren't processing events before the hardware had completed the descriptor ("last_seen"). Reinstate that logic. Keep the defensive loop condition and additionally make sure we've actually completed a descriptor before blindly chasing the ring around. In reset, queue and finish the startup command before allowing any event processing or submission to occur. Avoid potential missed callouts by requeueing the poll later. Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cMon Aug 29 20:01:53 2016(r305026) +++ head/sys/dev/ioat/ioat.cMon Aug 29 20:46:33 2016(r305027) @@ -683,7 +683,16 @@ ioat_process_events(struct ioat_softc *i __func__, ioat->chan_idx, comp_update, ioat->last_seen); status = comp_update & IOAT_CHANSTS_COMPLETED_DESCRIPTOR_MASK; - while (ioat_get_active(ioat) > 0) { + if (status == ioat->last_seen) { + /* +* If we landed in process_events and nothing has been +* completed, check for a timeout due to channel halt. +*/ + goto out; + } + + desc = ioat_get_ring_entry(ioat, ioat->tail - 1); + while (desc->hw_desc_bus_addr != status && ioat_get_active(ioat) > 0) { desc = ioat_get_ring_entry(ioat, ioat->tail); dmadesc = &desc->bus_dmadesc; CTR4(KTR_IOAT, "channel=%u completing desc %u ok cb %p(%p)", @@ -695,8 +704,6 @@ ioat_process_events(struct ioat_softc *i completed++; ioat->tail++; - if (desc->hw_desc_bus_addr == status) - break; } if (completed != 0) { @@ -704,6 +711,7 @@ ioat_process_events(struct ioat_softc *i ioat->stats.descriptors_processed += completed; } +out: ioat_write_chanctrl(ioat, IOAT_CHANCTRL_RUN); /* Perform a racy check first; only take the locks if it passes. */ @@ -1913,19 +1921,17 @@ ioat_reset_hw(struct ioat_softc *ioat) error = 0; out: + /* Enqueues a null operation and ensures it completes. */ + if (error == 0) + error = ioat_start_channel(ioat); + /* * Resume completions now that ring state is consistent. -* ioat_start_channel will add a pending completion and if we are still -* blocking completions, we may livelock. */ mtx_lock(&ioat->cleanup_lock); ioat->resetting_cleanup = FALSE; mtx_unlock(&ioat->cleanup_lock); - /* Enqueues a null operation and ensures it completes. */ - if (error == 0) - error = ioat_start_channel(ioat); - /* Unblock submission of new work */ mtx_lock(IOAT_REFLK); ioat->quiescing = FALSE; @@ -1933,6 +1939,10 @@ out: ioat->resetting = FALSE; wakeup(&ioat->resetting); + + if (ioat->is_completion_pending) + callout_reset(&ioat->poll_timer, 1, ioat_poll_timer_callback, + ioat); mtx_unlock(IOAT_REFLK); return (error); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r304828 - head/sys/ddb
Author: cem Date: Fri Aug 26 02:46:47 2016 New Revision: 304828 URL: https://svnweb.freebsd.org/changeset/base/304828 Log: ddb: Add 'show active trace' command 'show active trace', or 'acttrace' for short, prints backtraces from running threads only. Reviewed by: mjg Differential Revision:https://reviews.freebsd.org/D7646 Modified: head/sys/ddb/db_command.c Modified: head/sys/ddb/db_command.c == --- head/sys/ddb/db_command.c Fri Aug 26 01:28:31 2016(r304827) +++ head/sys/ddb/db_command.c Fri Aug 26 02:46:47 2016(r304828) @@ -72,6 +72,7 @@ static db_cmdfcn_tdb_halt; static db_cmdfcn_t db_kill; static db_cmdfcn_t db_reset; static db_cmdfcn_t db_stack_trace; +static db_cmdfcn_t db_stack_trace_active; static db_cmdfcn_t db_stack_trace_all; static db_cmdfcn_t db_watchdog; @@ -79,6 +80,12 @@ static db_cmdfcn_t db_watchdog; * 'show' commands */ +static struct command db_show_active_cmds[] = { + { "trace", db_stack_trace_active, 0, NULL }, +}; +struct command_table db_show_active_table = +LIST_HEAD_INITIALIZER(db_show_active_table); + static struct command db_show_all_cmds[] = { { "trace", db_stack_trace_all, 0, NULL }, }; @@ -86,6 +93,7 @@ struct command_table db_show_all_table = LIST_HEAD_INITIALIZER(db_show_all_table); static struct command db_show_cmds[] = { + { "active", 0, 0, &db_show_active_table }, { "all",0, 0, &db_show_all_table }, { "registers", db_show_regs, 0, NULL }, { "breaks", db_listbreak_cmd, 0, NULL }, @@ -120,6 +128,8 @@ static struct command db_cmds[] = { { "match", db_trace_until_matching_cmd,0, NULL }, { "trace", db_stack_trace, CS_OWN, NULL }, { "t", db_stack_trace, CS_OWN, NULL }, + /* XXX alias for active trace */ + { "acttrace", db_stack_trace_active, 0, NULL }, /* XXX alias for all trace */ { "alltrace", db_stack_trace_all, 0, NULL }, { "where", db_stack_trace, CS_OWN, NULL }, @@ -195,6 +205,9 @@ db_command_init(void) db_command_register(&db_cmd_table, &db_cmds[i]); for (i = 0; i < N(db_show_cmds); i++) db_command_register(&db_show_table, &db_show_cmds[i]); + for (i = 0; i < N(db_show_active_cmds); i++) + db_command_register(&db_show_active_table, + &db_show_active_cmds[i]); for (i = 0; i < N(db_show_all_cmds); i++) db_command_register(&db_show_all_table, &db_show_all_cmds[i]); #undef N @@ -799,8 +812,7 @@ db_stack_trace(db_expr_t tid, bool hasti } static void -db_stack_trace_all(db_expr_t dummy, bool dummy2, db_expr_t dummy3, -char *dummy4) +_db_stack_trace_all(bool active_only) { struct proc *p; struct thread *td; @@ -811,8 +823,18 @@ db_stack_trace_all(db_expr_t dummy, bool prev_jb = kdb_jmpbuf(jb); if (setjmp(jb) == 0) { FOREACH_THREAD_IN_PROC(p, td) { - db_printf("\nTracing command %s pid %d tid %ld td %p\n", - p->p_comm, p->p_pid, (long)td->td_tid, td); + if (td->td_state == TDS_RUNNING) + db_printf("\nTracing command %s pid %d" + " tid %ld td %p (CPU %d)\n", + p->p_comm, p->p_pid, + (long)td->td_tid, td, + td->td_oncpu); + else if (active_only) + continue; + else + db_printf("\nTracing command %s pid %d" + " tid %ld td %p\n", p->p_comm, + p->p_pid, (long)td->td_tid, td); db_trace_thread(td, -1); if (db_pager_quit) { kdb_jmpbuf(prev_jb); @@ -824,6 +846,22 @@ db_stack_trace_all(db_expr_t dummy, bool } } +static void +db_stack_trace_active(db_expr_t dummy, bool dummy2, db_expr_t dummy3, +char *dummy4) +{ + + _db_stack_trace_all(true); +} + +static void +db_stack_trace_all(db_expr_t dummy, bool dummy2, db_expr_t dummy3, +char *dummy4) +{ + + _db_stack_trace_all(false); +} + /* * Take the parsed expression value from the command line that was parsed * as a hexadecimal value and convert it as if the expression was parsed ___ svn-src-head@fre
svn commit: r304602 - head/sys/dev/ioat
Author: cem Date: Mon Aug 22 14:51:07 2016 New Revision: 304602 URL: https://svnweb.freebsd.org/changeset/base/304602 Log: ioat(4): Don't process events past queue head Fix a race where the completion routine could overrun the active ring area in some situations. Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cMon Aug 22 13:43:25 2016(r304601) +++ head/sys/dev/ioat/ioat.cMon Aug 22 14:51:07 2016(r304602) @@ -678,19 +678,12 @@ ioat_process_events(struct ioat_softc *i } completed = 0; - comp_update = *ioat->comp_update; + comp_update = ioat_get_chansts(ioat); + CTR4(KTR_IOAT, "%s channel=%u hw_status=0x%lx last_seen=0x%lx", + __func__, ioat->chan_idx, comp_update, ioat->last_seen); status = comp_update & IOAT_CHANSTS_COMPLETED_DESCRIPTOR_MASK; - if (status == ioat->last_seen) { - /* -* If we landed in process_events and nothing has been -* completed, check for a timeout due to channel halt. -*/ - comp_update = ioat_get_chansts(ioat); - goto out; - } - - while (1) { + while (ioat_get_active(ioat) > 0) { desc = ioat_get_ring_entry(ioat, ioat->tail); dmadesc = &desc->bus_dmadesc; CTR4(KTR_IOAT, "channel=%u completing desc %u ok cb %p(%p)", @@ -704,17 +697,13 @@ ioat_process_events(struct ioat_softc *i ioat->tail++; if (desc->hw_desc_bus_addr == status) break; - - KASSERT(ioat_get_active(ioat) > 0, ("overrunning ring t:%u " - "h:%u st:0x%016lx last_seen:%016lx completed:%u\n", - ioat->tail, ioat->head, comp_update, ioat->last_seen, - completed)); } - ioat->last_seen = desc->hw_desc_bus_addr; - ioat->stats.descriptors_processed += completed; + if (completed != 0) { + ioat->last_seen = desc->hw_desc_bus_addr; + ioat->stats.descriptors_processed += completed; + } -out: ioat_write_chanctrl(ioat, IOAT_CHANCTRL_RUN); /* Perform a racy check first; only take the locks if it passes. */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r304603 - head/sys/dev/ioat
Author: cem Date: Mon Aug 22 14:51:09 2016 New Revision: 304603 URL: https://svnweb.freebsd.org/changeset/base/304603 Log: ioat(4): Allow callouts to be scheduled after hw reset is_completion_pending governs whether or not a callout will be scheduled when new work is queued on the IOAT device. If true, a callout is already scheduled, so we do not need a new one. If false, we schedule one and set it true. Because resetting the hardware completed all outstanding work but failed to clear is_completion_pending, no new callout could be scheduled after a reset with pending work. This resulted in a driver hang for polled-only work. Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cMon Aug 22 14:51:07 2016(r304602) +++ head/sys/dev/ioat/ioat.cMon Aug 22 14:51:09 2016(r304603) @@ -768,6 +768,13 @@ ioat_process_events(struct ioat_softc *i ioat->stats.descriptors_error++; } + if (ioat->is_completion_pending) { + ioat->is_completion_pending = FALSE; + callout_reset(&ioat->shrink_timer, IOAT_SHRINK_PERIOD, + ioat_shrink_timer_callback, ioat); + callout_stop(&ioat->poll_timer); + } + /* Clear error status */ ioat_write_4(ioat, IOAT_CHANERR_OFFSET, chanerr); @@ -1898,6 +1905,7 @@ ioat_reset_hw(struct ioat_softc *ioat) ioat->tail = ioat->head = ioat->hw_head = 0; ioat->last_seen = 0; *ioat->comp_update = 0; + KASSERT(!ioat->is_completion_pending, ("bogus completion_pending")); ioat_write_chanctrl(ioat, IOAT_CHANCTRL_RUN); ioat_write_chancmp(ioat, ioat->comp_update_bus_addr); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r303761 - head/sys/dev/ioat
Author: cem Date: Fri Aug 5 02:56:31 2016 New Revision: 303761 URL: https://svnweb.freebsd.org/changeset/base/303761 Log: ioat(4): Log channel number in CTR events Modified: head/sys/dev/ioat/ioat.c Modified: head/sys/dev/ioat/ioat.c == --- head/sys/dev/ioat/ioat.cFri Aug 5 02:19:03 2016(r303760) +++ head/sys/dev/ioat/ioat.cFri Aug 5 02:56:31 2016(r303761) @@ -663,7 +663,7 @@ ioat_process_events(struct ioat_softc *i boolean_t pending; int error; - CTR0(KTR_IOAT, __func__); + CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); mtx_lock(&ioat->cleanup_lock); @@ -693,8 +693,9 @@ ioat_process_events(struct ioat_softc *i while (1) { desc = ioat_get_ring_entry(ioat, ioat->tail); dmadesc = &desc->bus_dmadesc; - CTR3(KTR_IOAT, "completing desc %u ok cb %p(%p)", ioat->tail, - dmadesc->callback_fn, dmadesc->callback_arg); + CTR4(KTR_IOAT, "channel=%u completing desc %u ok cb %p(%p)", + ioat->chan_idx, ioat->tail, dmadesc->callback_fn, + dmadesc->callback_arg); if (dmadesc->callback_fn != NULL) dmadesc->callback_fn(dmadesc->callback_arg, 0); @@ -764,8 +765,9 @@ out: while (ioat_get_active(ioat) > 0) { desc = ioat_get_ring_entry(ioat, ioat->tail); dmadesc = &desc->bus_dmadesc; - CTR3(KTR_IOAT, "completing desc %u err cb %p(%p)", ioat->tail, - dmadesc->callback_fn, dmadesc->callback_arg); + CTR4(KTR_IOAT, "channel=%u completing desc %u err cb %p(%p)", + ioat->chan_idx, ioat->tail, dmadesc->callback_fn, + dmadesc->callback_arg); if (dmadesc->callback_fn != NULL) dmadesc->callback_fn(dmadesc->callback_arg, @@ -919,7 +921,7 @@ ioat_acquire(bus_dmaengine_t dmaengine) ioat = to_ioat_softc(dmaengine); mtx_lock(&ioat->submit_lock); - CTR0(KTR_IOAT, __func__); + CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); } int @@ -943,7 +945,7 @@ ioat_release(bus_dmaengine_t dmaengine) struct ioat_softc *ioat; ioat = to_ioat_softc(dmaengine); - CTR0(KTR_IOAT, __func__); + CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); ioat_write_2(ioat, IOAT_DMACOUNT_OFFSET, (uint16_t)ioat->hw_head); mtx_unlock(&ioat->submit_lock); } @@ -1005,8 +1007,8 @@ ioat_null(bus_dmaengine_t dmaengine, bus struct ioat_descriptor *desc; struct ioat_softc *ioat; - CTR0(KTR_IOAT, __func__); ioat = to_ioat_softc(dmaengine); + CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); desc = ioat_op_generic(ioat, IOAT_OP_COPY, 8, 0, 0, callback_fn, callback_arg, flags); @@ -1028,8 +1030,8 @@ ioat_copy(bus_dmaengine_t dmaengine, bus struct ioat_descriptor *desc; struct ioat_softc *ioat; - CTR0(KTR_IOAT, __func__); ioat = to_ioat_softc(dmaengine); + CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); if (((src | dst) & (0xull << 48)) != 0) { ioat_log_message(0, "%s: High 16 bits of src/dst invalid\n", @@ -1059,8 +1061,8 @@ ioat_copy_8k_aligned(bus_dmaengine_t dma struct ioat_descriptor *desc; struct ioat_softc *ioat; - CTR0(KTR_IOAT, __func__); ioat = to_ioat_softc(dmaengine); + CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); if (((src1 | src2 | dst1 | dst2) & (0xull << 48)) != 0) { ioat_log_message(0, "%s: High 16 bits of src/dst invalid\n", @@ -1106,8 +1108,8 @@ ioat_copy_crc(bus_dmaengine_t dmaengine, uint32_t teststore; uint8_t op; - CTR0(KTR_IOAT, __func__); ioat = to_ioat_softc(dmaengine); + CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); if ((ioat->capabilities & IOAT_DMACAP_MOVECRC) == 0) { ioat_log_message(0, "%s: Device lacks MOVECRC capability\n", @@ -1185,8 +1187,8 @@ ioat_crc(bus_dmaengine_t dmaengine, bus_ uint32_t teststore; uint8_t op; - CTR0(KTR_IOAT, __func__); ioat = to_ioat_softc(dmaengine); + CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); if ((ioat->capabilities & IOAT_DMACAP_CRC) == 0) { ioat_log_message(0, "%s: Device lacks CRC capability\n", @@ -1262,8 +1264,8 @@ ioat_blockfill(bus_dmaengine_t dmaengine struct ioat_descriptor *desc; struct ioat_softc *ioat; - CTR0(KTR_IOAT, __func__); ioat = to_ioat_softc(dmaengine); + CTR2(KTR_IOAT, "%s channel=%u", __func__, ioat->chan_idx); if ((ioat->capabilities & IOAT_DMACAP_BFILL) == 0) { ioat_log_message(0
svn commit: r303669 - head/lib/libproc
Author: cem Date: Tue Aug 2 18:13:50 2016 New Revision: 303669 URL: https://svnweb.freebsd.org/changeset/base/303669 Log: proc_init: Fix a few memory leaks of 'phdl' In the normal case and correct failure cases, the 'phdl' pointer is passed to callers to use or clean up as needed. However, some failure cases returned early, failing to export the phdl pointer. This was introduced in the restructuring of r303533. Reported by: Coverity CID: 1361070 Reviewed by: markj Sponsored by: EMC / Isilon Storage Division Modified: head/lib/libproc/proc_create.c Modified: head/lib/libproc/proc_create.c == --- head/lib/libproc/proc_create.c Tue Aug 2 17:23:45 2016 (r303668) +++ head/lib/libproc/proc_create.c Tue Aug 2 18:13:50 2016 (r303669) @@ -73,9 +73,9 @@ proc_init(pid_t pid, int flags, int stat struct proc_handle *phdl; int error, class, count, fd; - *pphdl = NULL; + error = ENOMEM; if ((phdl = malloc(sizeof(*phdl))) == NULL) - return (ENOMEM); + goto out; memset(phdl, 0, sizeof(*phdl)); phdl->pid = pid; @@ -83,17 +83,17 @@ proc_init(pid_t pid, int flags, int stat phdl->status = status; phdl->procstat = procstat_open_sysctl(); if (phdl->procstat == NULL) - return (ENOMEM); + goto out; /* Obtain a path to the executable. */ if ((kp = procstat_getprocs(phdl->procstat, KERN_PROC_PID, pid, &count)) == NULL) - return (ENOMEM); + goto out; error = procstat_getpathname(phdl->procstat, kp, phdl->execpath, sizeof(phdl->execpath)); procstat_freeprocs(phdl->procstat, kp); if (error != 0) - return (error); + goto out; /* Use it to determine the data model for the process. */ if ((fd = open(phdl->execpath, O_RDONLY)) < 0) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r303651 - head/sys/net
Author: cem Date: Mon Aug 1 23:07:31 2016 New Revision: 303651 URL: https://svnweb.freebsd.org/changeset/base/303651 Log: rtentry: Initialize rt_mtx with MTX_NEW The "rtentry" zone does not use UMA_ZONE_ZINIT, so it is invalid to assume the mutex's memory will be zero. Without MTX_NEW, garbage backing memory may trigger the "re-initializing a mutex" assertion. PR: 200991 Submitted by: Chang-Hsien Tsai Modified: head/sys/net/route.h Modified: head/sys/net/route.h == --- head/sys/net/route.hMon Aug 1 22:57:03 2016(r303650) +++ head/sys/net/route.hMon Aug 1 23:07:31 2016(r303651) @@ -360,7 +360,7 @@ struct rt_addrinfo { || (ifp)->if_link_state == LINK_STATE_UP) #defineRT_LOCK_INIT(_rt) \ - mtx_init(&(_rt)->rt_mtx, "rtentry", NULL, MTX_DEF | MTX_DUPOK) + mtx_init(&(_rt)->rt_mtx, "rtentry", NULL, MTX_DEF | MTX_DUPOK | MTX_NEW) #defineRT_LOCK(_rt)mtx_lock(&(_rt)->rt_mtx) #defineRT_UNLOCK(_rt) mtx_unlock(&(_rt)->rt_mtx) #defineRT_LOCK_DESTROY(_rt)mtx_destroy(&(_rt)->rt_mtx) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"