From owner-svn-src-stable-11@freebsd.org Sun Jan 5 21:32:42 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6E38B1E78A4; Sun, 5 Jan 2020 21:32:42 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47rX1632Dfz3JpT; Sun, 5 Jan 2020 21:32:42 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 631233FF8; Sun, 5 Jan 2020 21:32:42 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 005LWgOU079961; Sun, 5 Jan 2020 21:32:42 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 005LWfCW079957; Sun, 5 Jan 2020 21:32:41 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001052132.005LWfCW079957@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 5 Jan 2020 21:32:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356387 - stable/11/usr.sbin/inetd X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.sbin/inetd X-SVN-Commit-Revision: 356387 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jan 2020 21:32:42 -0000 Author: kevans Date: Sun Jan 5 21:32:41 2020 New Revision: 356387 URL: https://svnweb.freebsd.org/changeset/base/356387 Log: MFC r310921, r311354, r315644: Light inetd(8) cleanup r310921: - Add static for symbols which need not to be exported. - Clean up warnings to the WARNS=6 level. r311354: Fix build when WITHOUT_INET6 is defined. r315644: Simplify a pipe for signal handling. Modified: stable/11/usr.sbin/inetd/builtins.c stable/11/usr.sbin/inetd/inetd.c stable/11/usr.sbin/inetd/inetd.h Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/inetd/builtins.c ============================================================================== --- stable/11/usr.sbin/inetd/builtins.c Sun Jan 5 19:14:16 2020 (r356386) +++ stable/11/usr.sbin/inetd/builtins.c Sun Jan 5 21:32:41 2020 (r356387) @@ -54,26 +54,25 @@ __FBSDID("$FreeBSD$"); #include "inetd.h" -void chargen_dg(int, struct servtab *); -void chargen_stream(int, struct servtab *); -void daytime_dg(int, struct servtab *); -void daytime_stream(int, struct servtab *); -void discard_dg(int, struct servtab *); -void discard_stream(int, struct servtab *); -void echo_dg(int, struct servtab *); -void echo_stream(int, struct servtab *); +static void chargen_dg(int, struct servtab *); +static void chargen_stream(int, struct servtab *); +static void daytime_dg(int, struct servtab *); +static void daytime_stream(int, struct servtab *); +static void discard_dg(int, struct servtab *); +static void discard_stream(int, struct servtab *); +static void echo_dg(int, struct servtab *); +static void echo_stream(int, struct servtab *); static int get_line(int, char *, int); -void iderror(int, int, int, const char *); -void ident_stream(int, struct servtab *); -void initring(void); -uint32_t machtime(void); -void machtime_dg(int, struct servtab *); -void machtime_stream(int, struct servtab *); +static void iderror(int, int, int, const char *); +static void ident_stream(int, struct servtab *); +static void initring(void); +static uint32_t machtime(void); +static void machtime_dg(int, struct servtab *); +static void machtime_stream(int, struct servtab *); -char ring[128]; -char *endring; +static char ring[128]; +static char *endring; - struct biltin biltins[] = { /* Echo received data */ { "echo", SOCK_STREAM, 1, -1, echo_stream }, @@ -107,7 +106,7 @@ struct biltin biltins[] = { * any regard for input. */ -void +static void initring(void) { int i; @@ -124,7 +123,7 @@ initring(void) * characters chosen from the range 0 to 512. We send LINESIZ+2. */ /* ARGSUSED */ -void +static void chargen_dg(int s, struct servtab *sep) { struct sockaddr_storage ss; @@ -161,7 +160,7 @@ chargen_dg(int s, struct servtab *sep) /* Character generator */ /* ARGSUSED */ -void +static void chargen_stream(int s, struct servtab *sep) { int len; @@ -196,7 +195,7 @@ chargen_stream(int s, struct servtab *sep) /* Return human-readable time of day */ /* ARGSUSED */ -void +static void daytime_dg(int s, struct servtab *sep) { char buffer[256]; @@ -221,7 +220,7 @@ daytime_dg(int s, struct servtab *sep) /* Return human-readable time of day */ /* ARGSUSED */ -void +static void daytime_stream(int s, struct servtab *sep __unused) { char buffer[256]; @@ -240,7 +239,7 @@ daytime_stream(int s, struct servtab *sep __unused) /* Discard service -- ignore data */ /* ARGSUSED */ -void +static void discard_dg(int s, struct servtab *sep __unused) { char buffer[BUFSIZE]; @@ -250,7 +249,7 @@ discard_dg(int s, struct servtab *sep __unused) /* Discard service -- ignore data */ /* ARGSUSED */ -void +static void discard_stream(int s, struct servtab *sep) { int ret; @@ -273,7 +272,7 @@ discard_stream(int s, struct servtab *sep) /* Echo service -- echo data back */ /* ARGSUSED */ -void +static void echo_dg(int s, struct servtab *sep) { char buffer[65536]; /* Should be sizeof(max datagram). */ @@ -294,7 +293,7 @@ echo_dg(int s, struct servtab *sep) /* Echo service -- echo data back */ /* ARGSUSED */ -void +static void echo_stream(int s, struct servtab *sep) { char buffer[BUFSIZE]; @@ -322,7 +321,7 @@ echo_stream(int s, struct servtab *sep) /* Generic ident_stream error-sending func */ /* ARGSUSED */ -void +static void iderror(int lport, int fport, int s, const char *er) { char *p; @@ -340,7 +339,7 @@ iderror(int lport, int fport, int s, const char *er) /* Ident service (AKA "auth") */ /* ARGSUSED */ -void +static void ident_stream(int s, struct servtab *sep) { struct utsname un; @@ -688,7 +687,7 @@ printit: * some seventy years Bell Labs was asleep. */ -uint32_t +static uint32_t machtime(void) { @@ -698,7 +697,7 @@ machtime(void) } /* ARGSUSED */ -void +static void machtime_dg(int s, struct servtab *sep) { uint32_t result; @@ -719,7 +718,7 @@ machtime_dg(int s, struct servtab *sep) } /* ARGSUSED */ -void +static void machtime_stream(int s, struct servtab *sep __unused) { uint32_t result; Modified: stable/11/usr.sbin/inetd/inetd.c ============================================================================== --- stable/11/usr.sbin/inetd/inetd.c Sun Jan 5 19:14:16 2020 (r356386) +++ stable/11/usr.sbin/inetd/inetd.c Sun Jan 5 21:32:41 2020 (r356387) @@ -206,30 +206,33 @@ __FBSDID("$FreeBSD$"); #define SIGBLOCK (sigmask(SIGCHLD)|sigmask(SIGHUP)|sigmask(SIGALRM)) -void close_sep(struct servtab *); -void flag_signal(int); -void flag_config(int); -void config(void); -int cpmip(const struct servtab *, int); -void endconfig(void); -struct servtab *enter(struct servtab *); -void freeconfig(struct servtab *); -struct servtab *getconfigent(void); -int matchservent(const char *, const char *, const char *); -char *nextline(FILE *); -void addchild(struct servtab *, int); -void flag_reapchild(int); -void reapchild(void); -void enable(struct servtab *); -void disable(struct servtab *); -void flag_retry(int); -void retry(void); -int setconfig(void); -void setup(struct servtab *); +#define satosin(sa) ((struct sockaddr_in *)(void *)sa) +#define csatosin(sa) ((const struct sockaddr_in *)(const void *)sa) +#ifdef INET6 +#define satosin6(sa) ((struct sockaddr_in6 *)(void *)sa) +#define csatosin6(sa) ((const struct sockaddr_in6 *)(const void *)sa) +#endif +static void close_sep(struct servtab *); +static void flag_signal(int); +static void config(void); +static int cpmip(const struct servtab *, int); +static void endconfig(void); +static struct servtab *enter(struct servtab *); +static void freeconfig(struct servtab *); +static struct servtab *getconfigent(void); +static int matchservent(const char *, const char *, const char *); +static char *nextline(FILE *); +static void addchild(struct servtab *, int); +static void reapchild(void); +static void enable(struct servtab *); +static void disable(struct servtab *); +static void retry(void); +static int setconfig(void); +static void setup(struct servtab *); #ifdef IPSEC -void ipsecsetup(struct servtab *); +static void ipsecsetup(struct servtab *); #endif -void unregisterrpc(register struct servtab *sep); +static void unregisterrpc(register struct servtab *sep); static struct conninfo *search_conn(struct servtab *sep, int ctrl); static int room_conn(struct servtab *sep, struct conninfo *conn); static void addchild_conn(struct conninfo *conn, pid_t pid); @@ -240,51 +243,55 @@ static void free_connlist(struct servtab *sep); static void free_proc(struct procinfo *); static struct procinfo *search_proc(pid_t pid, int add); static int hashval(char *p, int len); +static char *skip(char **); +static char *sskip(char **); +static char *newstr(const char *); +static void print_service(const char *, const struct servtab *); +/* tcpd.h */ int allow_severity; int deny_severity; -int wrap_ex = 0; -int wrap_bi = 0; + +static int wrap_ex = 0; +static int wrap_bi = 0; int debug = 0; -int dolog = 0; -int maxsock; /* highest-numbered descriptor */ -fd_set allsock; -int options; -int timingout; -int toomany = TOOMANY; -int maxchild = MAXCHILD; -int maxcpm = MAXCPM; -int maxperip = MAXPERIP; -struct servent *sp; -struct rpcent *rpc; -char *hostname = NULL; -struct sockaddr_in *bind_sa4; -int v4bind_ok = 0; +static int dolog = 0; +static int maxsock; /* highest-numbered descriptor */ +static fd_set allsock; +static int options; +static int timingout; +static int toomany = TOOMANY; +static int maxchild = MAXCHILD; +static int maxcpm = MAXCPM; +static int maxperip = MAXPERIP; +static struct servent *sp; +static struct rpcent *rpc; +static char *hostname = NULL; +static struct sockaddr_in *bind_sa4; +static int v4bind_ok = 0; #ifdef INET6 -struct sockaddr_in6 *bind_sa6; -int v6bind_ok = 0; +static struct sockaddr_in6 *bind_sa6; +static int v6bind_ok = 0; #endif -int signalpipe[2]; +static int signalpipe[2]; #ifdef SANITY_CHECK -int nsock; +static int nsock; #endif -uid_t euid; -gid_t egid; -mode_t mask; +static uid_t euid; +static gid_t egid; +static mode_t mask; -struct servtab *servtab; +struct servtab *servtab; -extern struct biltin biltins[]; +static const char *CONFIG = _PATH_INETDCONF; +static const char *pid_file = _PATH_INETDPID; +static struct pidfh *pfh = NULL; -const char *CONFIG = _PATH_INETDCONF; -const char *pid_file = _PATH_INETDPID; -struct pidfh *pfh = NULL; +static struct netconfig *udpconf, *tcpconf, *udp6conf, *tcp6conf; -struct netconfig *udpconf, *tcpconf, *udp6conf, *tcp6conf; - static LIST_HEAD(, procinfo) proctable[PERIPSIZE]; -int +static int getvalue(const char *arg, int *value, const char *whine) { int tmp; @@ -308,9 +315,11 @@ whichaf(struct request_info *req) sa = (struct sockaddr *)req->client->sin; if (sa == NULL) return AF_UNSPEC; +#ifdef INET6 if (sa->sa_family == AF_INET6 && - IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)sa)->sin6_addr)) + IN6_IS_ADDR_V4MAPPED(&satosin6(sa)->sin6_addr)) return AF_INET; +#endif return sa->sa_family; } #endif @@ -419,7 +428,7 @@ main(int argc, char **argv) case AF_INET: if (v4bind_ok) continue; - bind_sa4 = (struct sockaddr_in *)res->ai_addr; + bind_sa4 = satosin(res->ai_addr); /* init port num in case servname is dummy */ bind_sa4->sin_port = 0; v4bind_ok = 1; @@ -428,7 +437,7 @@ main(int argc, char **argv) case AF_INET6: if (v6bind_ok) continue; - bind_sa6 = (struct sockaddr_in6 *)res->ai_addr; + bind_sa6 = satosin6(res->ai_addr); /* init port num in case servname is dummy */ bind_sa6->sin6_port = 0; v6bind_ok = 1; @@ -520,17 +529,17 @@ main(int argc, char **argv) } #endif - sa.sa_flags = 0; + sa = (struct sigaction){ + .sa_flags = 0, + .sa_handler = flag_signal, + }; sigemptyset(&sa.sa_mask); sigaddset(&sa.sa_mask, SIGALRM); sigaddset(&sa.sa_mask, SIGCHLD); sigaddset(&sa.sa_mask, SIGHUP); - sa.sa_handler = flag_retry; sigaction(SIGALRM, &sa, &saalrm); config(); - sa.sa_handler = flag_config; sigaction(SIGHUP, &sa, &sahup); - sa.sa_handler = flag_reapchild; sigaction(SIGCHLD, &sa, &sachld); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, &sapipe); @@ -579,30 +588,34 @@ main(int argc, char **argv) } /* handle any queued signal flags */ if (FD_ISSET(signalpipe[0], &readable)) { - int nsig; + int nsig, signo; + if (ioctl(signalpipe[0], FIONREAD, &nsig) != 0) { - syslog(LOG_ERR, "ioctl: %m"); - exit(EX_OSERR); + syslog(LOG_ERR, "ioctl: %m"); + exit(EX_OSERR); } + nsig /= sizeof(signo); while (--nsig >= 0) { - char c; - if (read(signalpipe[0], &c, 1) != 1) { - syslog(LOG_ERR, "read: %m"); - exit(EX_OSERR); - } - if (debug) - warnx("handling signal flag %c", c); - switch(c) { - case 'A': /* sigalrm */ - retry(); - break; - case 'C': /* sigchld */ - reapchild(); - break; - case 'H': /* sighup */ - config(); - break; - } + size_t len; + + len = read(signalpipe[0], &signo, sizeof(signo)); + if (len != sizeof(signo)) { + syslog(LOG_ERR, "read: %m"); + exit(EX_OSERR); + } + if (debug) + warnx("handling signal flag %d", signo); + switch (signo) { + case SIGALRM: + retry(); + break; + case SIGCHLD: + reapchild(); + break; + case SIGHUP: + config(); + break; + } } } for (sep = servtab; n && sep; sep = sep->se_next) @@ -887,12 +900,13 @@ main(int argc, char **argv) * Add a signal flag to the signal flag queue for later handling */ -void -flag_signal(int c) +static void +flag_signal(int signo) { - char ch = c; + size_t len; - if (write(signalpipe[1], &ch, 1) != 1) { + len = write(signalpipe[1], &signo, sizeof(signo)); + if (len != sizeof(signo)) { syslog(LOG_ERR, "write: %m"); _exit(EX_OSERR); } @@ -903,7 +917,7 @@ flag_signal(int c) * limit on children, then stop accepting incoming requests. */ -void +static void addchild(struct servtab *sep, pid_t pid) { if (sep->se_maxchild <= 0) @@ -920,17 +934,7 @@ addchild(struct servtab *sep, pid_t pid) disable(sep); } -/* - * Some child process has exited. See if it's on somebody's list. - */ - -void -flag_reapchild(int signo __unused) -{ - flag_signal('C'); -} - -void +static void reapchild(void) { int k, status; @@ -968,13 +972,7 @@ reapchild(void) } } -void -flag_config(int signo __unused) -{ - flag_signal('H'); -} - -void +static void config(void) { struct servtab *sep, *new, **sepp; @@ -1182,7 +1180,7 @@ config(void) (void) sigsetmask(omask); } -void +static void unregisterrpc(struct servtab *sep) { u_int i; @@ -1237,13 +1235,7 @@ unregisterrpc(struct servtab *sep) (void) sigsetmask(omask); } -void -flag_retry(int signo __unused) -{ - flag_signal('A'); -} - -void +static void retry(void) { struct servtab *sep; @@ -1254,7 +1246,7 @@ retry(void) setup(sep); } -void +static void setup(struct servtab *sep) { int on = 1; @@ -1281,6 +1273,7 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (o syslog(LOG_ERR, "setsockopt (SO_PRIVSTATE): %m"); #endif /* tftpd opens a new connection then needs more infos */ +#ifdef INET6 if ((sep->se_family == AF_INET6) && (strcmp(sep->se_proto, "udp") == 0) && (sep->se_accept == 0) && @@ -1293,6 +1286,7 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (o (char *)&flag, sizeof (flag)) < 0) syslog(LOG_ERR, "setsockopt (IPV6_V6ONLY): %m"); } +#endif #undef turnon #ifdef IPSEC ipsecsetup(sep); @@ -1330,7 +1324,9 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (o u_int i; socklen_t len = sep->se_ctrladdr_size; struct netconfig *netid, *netid2 = NULL; +#ifdef INET6 struct sockaddr_in sock; +#endif struct netbuf nbuf, nbuf2; if (getsockname(sep->se_fd, @@ -1345,6 +1341,7 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (o nbuf.len = sep->se_ctrladdr.sa_len; if (sep->se_family == AF_INET) netid = sep->se_socktype==SOCK_DGRAM? udpconf:tcpconf; +#ifdef INET6 else { netid = sep->se_socktype==SOCK_DGRAM? udp6conf:tcp6conf; if (!sep->se_nomapped) { /* INET and INET6 */ @@ -1356,6 +1353,7 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (o sock.sin_port = sep->se_ctrladdr6.sin6_port; } } +#endif if (debug) print_service("REG ", sep); for (i = sep->se_rpc_lowvers; i <= sep->se_rpc_highvers; i++) { @@ -1377,7 +1375,7 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (o } #ifdef IPSEC -void +static void ipsecsetup(struct servtab *sep) { char *buf; @@ -1451,7 +1449,7 @@ ipsecsetup(struct servtab *sep) /* * Finish with a service and its socket. */ -void +static void close_sep(struct servtab *sep) { if (sep->se_fd >= 0) { @@ -1464,7 +1462,7 @@ close_sep(struct servtab *sep) sep->se_numchild = 0; /* forget about any existing children */ } -int +static int matchservent(const char *name1, const char *name2, const char *proto) { char **alias, *p; @@ -1488,7 +1486,7 @@ matchservent(const char *name1, const char *name2, con return(0); } -struct servtab * +static struct servtab * enter(struct servtab *cp) { struct servtab *sep; @@ -1508,7 +1506,7 @@ enter(struct servtab *cp) return (sep); } -void +static void enable(struct servtab *sep) { if (debug) @@ -1537,7 +1535,7 @@ enable(struct servtab *sep) maxsock = sep->se_fd; } -void +static void disable(struct servtab *sep) { if (debug) @@ -1570,11 +1568,11 @@ disable(struct servtab *sep) maxsock--; } -FILE *fconfig = NULL; -struct servtab serv; -char line[LINE_MAX]; +static FILE *fconfig = NULL; +static struct servtab serv; +static char line[LINE_MAX]; -int +static int setconfig(void) { @@ -1586,7 +1584,7 @@ setconfig(void) return (fconfig != NULL); } -void +static void endconfig(void) { if (fconfig) { @@ -1595,7 +1593,7 @@ endconfig(void) } } -struct servtab * +static struct servtab * getconfigent(void) { struct servtab *sep = &serv; @@ -1973,7 +1971,7 @@ more: return (sep); } -void +static void freeconfig(struct servtab *cp) { int i; @@ -2009,7 +2007,7 @@ freeconfig(struct servtab *cp) * Safe skip - if skip returns null, log a syntax error in the * configuration file and exit. */ -char * +static char * sskip(char **cpp) { char *cp; @@ -2022,7 +2020,7 @@ sskip(char **cpp) return (cp); } -char * +static char * skip(char **cpp) { char *cp = *cpp; @@ -2058,7 +2056,7 @@ again: return (start); } -char * +static char * nextline(FILE *fd) { char *cp; @@ -2071,7 +2069,7 @@ nextline(FILE *fd) return (line); } -char * +static char * newstr(const char *cp) { char *cr; @@ -2111,13 +2109,13 @@ check_loop(const struct sockaddr *sa, const struct ser switch (se2->se_family) { case AF_INET: - if (((const struct sockaddr_in *)sa)->sin_port == + if (csatosin(sa)->sin_port == se2->se_ctrladdr4.sin_port) goto isloop; continue; #ifdef INET6 case AF_INET6: - if (((const struct sockaddr_in6 *)sa)->sin6_port == + if (csatosin6(sa)->sin6_port == se2->se_ctrladdr6.sin6_port) goto isloop; continue; @@ -2141,7 +2139,7 @@ check_loop(const struct sockaddr *sa, const struct ser * print_service: * Dump relevant information to stderr */ -void +static void print_service(const char *action, const struct servtab *sep) { fprintf(stderr, @@ -2189,9 +2187,9 @@ typedef struct CHash { CTime ch_Times[CHTSIZE]; } CHash; -CHash CHashAry[CPMHSIZE]; +static CHash CHashAry[CPMHSIZE]; -int +static int cpmip(const struct servtab *sep, int ctrl) { struct sockaddr_storage rss; Modified: stable/11/usr.sbin/inetd/inetd.h ============================================================================== --- stable/11/usr.sbin/inetd/inetd.h Sun Jan 5 19:14:16 2020 (r356386) +++ stable/11/usr.sbin/inetd/inetd.h Sun Jan 5 21:32:41 2020 (r356387) @@ -123,12 +123,7 @@ struct servtab { #define se_reset se_flags.se_reset int check_loop(const struct sockaddr *, const struct servtab *sep); -int getvalue(const char *, int *, const char *); -char *newstr(const char *); void inetd_setproctitle(const char *, int); -void print_service(const char *, const struct servtab *); -char *sskip(char **); -char *skip(char **); struct servtab *tcpmux(int); extern int debug; @@ -143,3 +138,4 @@ struct biltin { int bi_maxchild; /* max number of children, -1=default */ bi_fn_t *bi_fn; /* function which performs it */ }; +extern struct biltin biltins[]; From owner-svn-src-stable-11@freebsd.org Sun Jan 5 21:35:04 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0C7261E794B; Sun, 5 Jan 2020 21:35:04 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47rX3r09NYz3Jwt; Sun, 5 Jan 2020 21:35:04 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F09203FFD; Sun, 5 Jan 2020 21:35:03 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 005LZ3Lh080163; Sun, 5 Jan 2020 21:35:03 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 005LZ3xp080159; Sun, 5 Jan 2020 21:35:03 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001052135.005LZ3xp080159@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 5 Jan 2020 21:35:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356388 - in stable: 11/usr.sbin/inetd 12/usr.sbin/inetd X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/usr.sbin/inetd 12/usr.sbin/inetd X-SVN-Commit-Revision: 356388 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jan 2020 21:35:04 -0000 Author: kevans Date: Sun Jan 5 21:35:02 2020 New Revision: 356388 URL: https://svnweb.freebsd.org/changeset/base/356388 Log: MFC further inetd(8) cleanup: r356204, r356215, r356217-r356218, r356246-r356248, r356254, r356318 r356204: inetd: don't leak `policy` on return sep->se_policy gets a strdup'd version of policy, so we don't need it to stick around afterwards. While here, remove a couple of NULL checks prior to free(policy). r356215: inetd: knock out some clang analyze warnings chargen_dg: clang-analyze is convinced that endring could be non-NULL at entry, and thus wants to assume that rs == NULL. Just independently initialize rs if it's NULL to appease the analyzer. getconfigent: policy leaks on return free_connlist: reorganize the loop to make it clear that we're not going to access `conn` after it's been freed. cpmip/hashval: left-shifts performed will result in UB as we take signed 0xABC3D20F and left shift it by 5. r356217: inetd: prefer strtonum(3) to strspn(3)+atoi(3), NFC strtonum(3) does effectively the same validation as we had, but it's more concise. r356218: inetd: prefer strlcpy to strlen(3) check + strcpy(3), NFC This is again functionally equivalent but more concise. r356246: inetd: add some macros for checking child limits, NFC The main point here is capturing the maxchild > 0 check. A future change to inetd will start tracking all of the child pids so that it can give proper and consistent notification of process exit/signalling. r356247: inetd: track all child pids, regardless of maxchild spec Currently, child pids are only tracked if maxchildren is specified. As a consequence, without a maxchild limit we do not get a notice in syslog on children aborting abnormally. This turns out to be a great debugging aide at times. Children are now tracked in a LIST; the management interface is decidedly less painful when there's no upper bound on the number of entries we may have at the cost of one small allocation per connection. r356248: inetd: convert remaining bzero(3) to memset(3), NFC This change is purely in the name of noise reduction from static analyzers that want to complain that bzero(3) is obsolete in favor of memset(3). With this, clang-analyze at least is now noise free. WARNS= 6 also appears to have been OK for some time now, so drop the current setting and opt for the default. r356254: inetd: final round of trivial cleanup, NFC Highlights: - Use MAX() for maxsock raising; small readability improvement IMO - malloc(3) + memset(3) -> calloc(3) where appropriate - stop casting the return value of malloc(3) - mallloc(3) -> reallocarray(3) where appropriate A future change may enter capability mode when forking for some of the built-in handlers. r356318: inetd: fix WITHOUT_TCP_WRAPPERS build after r356248 After increasing WARNS, building WITHOUT_TCP_WRAPPERS failed because of some unused variables. Modified: stable/11/usr.sbin/inetd/Makefile stable/11/usr.sbin/inetd/builtins.c stable/11/usr.sbin/inetd/inetd.c stable/11/usr.sbin/inetd/inetd.h Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/usr.sbin/inetd/Makefile stable/12/usr.sbin/inetd/builtins.c stable/12/usr.sbin/inetd/inetd.c stable/12/usr.sbin/inetd/inetd.h Directory Properties: stable/12/ (props changed) Modified: stable/11/usr.sbin/inetd/Makefile ============================================================================== --- stable/11/usr.sbin/inetd/Makefile Sun Jan 5 21:32:41 2020 (r356387) +++ stable/11/usr.sbin/inetd/Makefile Sun Jan 5 21:35:02 2020 (r356388) @@ -8,7 +8,6 @@ MAN= inetd.8 MLINKS= inetd.8 inetd.conf.5 SRCS= inetd.c builtins.c -WARNS?= 3 CFLAGS+= -DLOGIN_CAP #CFLAGS+= -DSANITY_CHECK Modified: stable/11/usr.sbin/inetd/builtins.c ============================================================================== --- stable/11/usr.sbin/inetd/builtins.c Sun Jan 5 21:32:41 2020 (r356387) +++ stable/11/usr.sbin/inetd/builtins.c Sun Jan 5 21:35:02 2020 (r356388) @@ -132,10 +132,10 @@ chargen_dg(int s, struct servtab *sep) socklen_t size; char text[LINESIZ+2]; - if (endring == 0) { + if (endring == NULL) initring(); + if (rs == NULL) rs = ring; - } size = sizeof(ss); if (recvfrom(s, text, sizeof(text), 0, @@ -649,8 +649,14 @@ ident_stream(int s, struct servtab *sep) goto fakeid_fail; if (!Fflag) { if (iflag) { - if (p[strspn(p, "0123456789")] == '\0' && - getpwuid(atoi(p)) != NULL) + const char *errstr; + uid_t uid; + + uid = strtonum(p, 0, UID_MAX, &errstr); + if (errstr != NULL) + goto fakeid_fail; + + if (getpwuid(uid) != NULL) goto fakeid_fail; } else { if (getpwnam(p) != NULL) Modified: stable/11/usr.sbin/inetd/inetd.c ============================================================================== --- stable/11/usr.sbin/inetd/inetd.c Sun Jan 5 21:32:41 2020 (r356387) +++ stable/11/usr.sbin/inetd/inetd.c Sun Jan 5 21:35:02 2020 (r356388) @@ -248,9 +248,11 @@ static char *sskip(char **); static char *newstr(const char *); static void print_service(const char *, const struct servtab *); +#ifdef LIBWRAP /* tcpd.h */ int allow_severity; int deny_severity; +#endif static int wrap_ex = 0; static int wrap_bi = 0; @@ -408,7 +410,7 @@ main(int argc, char **argv) */ servname = (hostname == NULL) ? "0" /* dummy */ : NULL; - bzero(&hints, sizeof(struct addrinfo)); + memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_flags = AI_PASSIVE; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; /* dummy */ @@ -562,10 +564,7 @@ main(int argc, char **argv) #ifdef SANITY_CHECK nsock++; #endif - if (signalpipe[0] > maxsock) - maxsock = signalpipe[0]; - if (signalpipe[1] > maxsock) - maxsock = signalpipe[1]; + maxsock = MAX(MAX(maxsock, signalpipe[0]), signalpipe[1]); for (;;) { int n, ctrl; @@ -920,25 +919,33 @@ flag_signal(int signo) static void addchild(struct servtab *sep, pid_t pid) { - if (sep->se_maxchild <= 0) - return; + struct stabchild *sc; + #ifdef SANITY_CHECK - if (sep->se_numchild >= sep->se_maxchild) { + if (SERVTAB_EXCEEDS_LIMIT(sep)) { syslog(LOG_ERR, "%s: %d >= %d", __func__, sep->se_numchild, sep->se_maxchild); exit(EX_SOFTWARE); } #endif - sep->se_pids[sep->se_numchild++] = pid; - if (sep->se_numchild == sep->se_maxchild) + sc = calloc(1, sizeof(*sc)); + if (sc == NULL) { + syslog(LOG_ERR, "calloc: %m"); + exit(EX_OSERR); + } + sc->sc_pid = pid; + LIST_INSERT_HEAD(&sep->se_children, sc, sc_link); + ++sep->se_numchild; + if (SERVTAB_AT_LIMIT(sep)) disable(sep); } static void reapchild(void) { - int k, status; + int status; pid_t pid; + struct stabchild *sc; struct servtab *sep; for (;;) { @@ -951,14 +958,17 @@ reapchild(void) WIFEXITED(status) ? WEXITSTATUS(status) : WTERMSIG(status)); for (sep = servtab; sep; sep = sep->se_next) { - for (k = 0; k < sep->se_numchild; k++) - if (sep->se_pids[k] == pid) + LIST_FOREACH(sc, &sep->se_children, sc_link) { + if (sc->sc_pid == pid) break; - if (k == sep->se_numchild) + } + if (sc == NULL) continue; - if (sep->se_numchild == sep->se_maxchild) + if (SERVTAB_AT_LIMIT(sep)) enable(sep); - sep->se_pids[k] = sep->se_pids[--sep->se_numchild]; + LIST_REMOVE(sc, sc_link); + free(sc); + --sep->se_numchild; if (WIFSIGNALED(status) || WEXITSTATUS(status)) syslog(LOG_WARNING, "%s[%d]: exited, %s %u", @@ -1030,25 +1040,20 @@ config(void) sep->se_nomapped = new->se_nomapped; sep->se_reset = 1; } - /* copy over outstanding child pids */ - if (sep->se_maxchild > 0 && new->se_maxchild > 0) { - new->se_numchild = sep->se_numchild; - if (new->se_numchild > new->se_maxchild) - new->se_numchild = new->se_maxchild; - memcpy(new->se_pids, sep->se_pids, - new->se_numchild * sizeof(*new->se_pids)); - } - SWAP(pid_t *, sep->se_pids, new->se_pids); - sep->se_maxchild = new->se_maxchild; - sep->se_numchild = new->se_numchild; + + /* + * The children tracked remain; we want numchild to + * still reflect how many jobs are running so we don't + * throw off our accounting. + */ sep->se_maxcpm = new->se_maxcpm; + sep->se_maxchild = new->se_maxchild; resize_conn(sep, new->se_maxperip); sep->se_maxperip = new->se_maxperip; sep->se_bi = new->se_bi; /* might need to turn on or off service now */ if (sep->se_fd >= 0) { - if (sep->se_maxchild > 0 - && sep->se_numchild == sep->se_maxchild) { + if (SERVTAB_EXCEEDS_LIMIT(sep)) { if (FD_ISSET(sep->se_fd, &allsock)) disable(sep); } else { @@ -1492,8 +1497,8 @@ enter(struct servtab *cp) struct servtab *sep; long omask; - sep = (struct servtab *)malloc(sizeof (*sep)); - if (sep == (struct servtab *)0) { + sep = malloc(sizeof(*sep)); + if (sep == NULL) { syslog(LOG_ERR, "malloc: %m"); exit(EX_OSERR); } @@ -1531,8 +1536,7 @@ enable(struct servtab *sep) nsock++; #endif FD_SET(sep->se_fd, &allsock); - if (sep->se_fd > maxsock) - maxsock = sep->se_fd; + maxsock = MAX(maxsock, sep->se_fd); } static void @@ -1610,6 +1614,7 @@ getconfigent(void) int v6bind; #endif int i; + size_t unsz; #ifdef IPSEC policy = NULL; @@ -1627,12 +1632,10 @@ more: for (p = cp + 2; p && *p && isspace(*p); p++) ; if (*p == '\0') { - if (policy) - free(policy); + free(policy); policy = NULL; } else if (ipsec_get_policylen(p) >= 0) { - if (policy) - free(policy); + free(policy); policy = newstr(p); } else { syslog(LOG_ERR, @@ -1646,8 +1649,11 @@ more: continue; break; } - if (cp == NULL) - return ((struct servtab *)0); + if (cp == NULL) { + free(policy); + return (NULL); + } + /* * clear the static buffer, since some fields (se_ctrladdr, * for example) don't get initialized here. @@ -1829,16 +1835,18 @@ more: break; #endif case AF_UNIX: - if (strlen(sep->se_service) >= sizeof(sep->se_ctrladdr_un.sun_path)) { - syslog(LOG_ERR, +#define SUN_PATH_MAXSIZE sizeof(sep->se_ctrladdr_un.sun_path) + memset(&sep->se_ctrladdr, 0, sizeof(sep->se_ctrladdr)); + sep->se_ctrladdr_un.sun_family = sep->se_family; + if ((unsz = strlcpy(sep->se_ctrladdr_un.sun_path, + sep->se_service, SUN_PATH_MAXSIZE) >= SUN_PATH_MAXSIZE)) { + syslog(LOG_ERR, "domain socket pathname too long for service %s", sep->se_service); goto more; } - memset(&sep->se_ctrladdr, 0, sizeof(sep->se_ctrladdr)); - sep->se_ctrladdr_un.sun_family = sep->se_family; - sep->se_ctrladdr_un.sun_len = strlen(sep->se_service); - strcpy(sep->se_ctrladdr_un.sun_path, sep->se_service); + sep->se_ctrladdr_un.sun_len = unsz; +#undef SUN_PATH_MAXSIZE sep->se_ctrladdr_size = SUN_LEN(&sep->se_ctrladdr_un); } arg = sskip(&cp); @@ -1944,13 +1952,7 @@ more: else sep->se_maxchild = 1; } - if (sep->se_maxchild > 0) { - sep->se_pids = malloc(sep->se_maxchild * sizeof(*sep->se_pids)); - if (sep->se_pids == NULL) { - syslog(LOG_ERR, "malloc: %m"); - exit(EX_OSERR); - } - } + LIST_INIT(&sep->se_children); argc = 0; for (arg = skip(&cp); cp; arg = skip(&cp)) if (argc < MAXARGV) { @@ -1967,6 +1969,7 @@ more: LIST_INIT(&sep->se_conn[i]); #ifdef IPSEC sep->se_policy = policy ? newstr(policy) : NULL; + free(policy); #endif return (sep); } @@ -1974,31 +1977,28 @@ more: static void freeconfig(struct servtab *cp) { + struct stabchild *sc; int i; - if (cp->se_service) - free(cp->se_service); - if (cp->se_proto) - free(cp->se_proto); - if (cp->se_user) - free(cp->se_user); - if (cp->se_group) - free(cp->se_group); + free(cp->se_service); + free(cp->se_proto); + free(cp->se_user); + free(cp->se_group); #ifdef LOGIN_CAP - if (cp->se_class) - free(cp->se_class); + free(cp->se_class); #endif - if (cp->se_server) - free(cp->se_server); - if (cp->se_pids) - free(cp->se_pids); + free(cp->se_server); + while (!LIST_EMPTY(&cp->se_children)) { + sc = LIST_FIRST(&cp->se_children); + LIST_REMOVE(sc, sc_link); + free(sc); + } for (i = 0; i < MAXARGV; i++) if (cp->se_argv[i]) free(cp->se_argv[i]); free_connlist(cp); #ifdef IPSEC - if (cp->se_policy) - free(cp->se_policy); + free(cp->se_policy); #endif } @@ -2205,7 +2205,7 @@ cpmip(const struct servtab *sep, int ctrl) (sep->se_family == AF_INET || sep->se_family == AF_INET6) && getpeername(ctrl, (struct sockaddr *)&rss, &rssLen) == 0 ) { time_t t = time(NULL); - int hv = 0xABC3D20F; + unsigned int hv = 0xABC3D20F; int i; int cnt = 0; CHash *chBest = NULL; @@ -2278,10 +2278,9 @@ cpmip(const struct servtab *sep, int ctrl) strcmp(sep->se_service, chBest->ch_Service) != 0) { chBest->ch_Family = sin4->sin_family; chBest->ch_Addr4 = sin4->sin_addr; - if (chBest->ch_Service) - free(chBest->ch_Service); + free(chBest->ch_Service); chBest->ch_Service = strdup(sep->se_service); - bzero(chBest->ch_Times, sizeof(chBest->ch_Times)); + memset(chBest->ch_Times, 0, sizeof(chBest->ch_Times)); } #ifdef INET6 if ((rss.ss_family == AF_INET6 && @@ -2292,10 +2291,9 @@ cpmip(const struct servtab *sep, int ctrl) strcmp(sep->se_service, chBest->ch_Service) != 0) { chBest->ch_Family = sin6->sin6_family; chBest->ch_Addr6 = sin6->sin6_addr; - if (chBest->ch_Service) - free(chBest->ch_Service); + free(chBest->ch_Service); chBest->ch_Service = strdup(sep->se_service); - bzero(chBest->ch_Times, sizeof(chBest->ch_Times)); + memset(chBest->ch_Times, 0, sizeof(chBest->ch_Times)); } #endif chBest->ch_LTime = t; @@ -2386,9 +2384,10 @@ search_conn(struct servtab *sep, int ctrl) syslog(LOG_ERR, "malloc: %m"); exit(EX_OSERR); } - conn->co_proc = malloc(sep->se_maxperip * sizeof(*conn->co_proc)); + conn->co_proc = reallocarray(NULL, sep->se_maxperip, + sizeof(*conn->co_proc)); if (conn->co_proc == NULL) { - syslog(LOG_ERR, "malloc: %m"); + syslog(LOG_ERR, "reallocarray: %m"); exit(EX_OSERR); } memcpy(&conn->co_addr, (struct sockaddr *)&ss, sslen); @@ -2477,10 +2476,10 @@ resize_conn(struct servtab *sep, int maxpip) LIST_FOREACH(conn, &sep->se_conn[i], co_link) { for (j = maxpip; j < conn->co_numchild; ++j) free_proc(conn->co_proc[j]); - conn->co_proc = realloc(conn->co_proc, - maxpip * sizeof(*conn->co_proc)); + conn->co_proc = reallocarray(conn->co_proc, maxpip, + sizeof(*conn->co_proc)); if (conn->co_proc == NULL) { - syslog(LOG_ERR, "realloc: %m"); + syslog(LOG_ERR, "reallocarray: %m"); exit(EX_OSERR); } if (conn->co_numchild > maxpip) @@ -2492,11 +2491,15 @@ resize_conn(struct servtab *sep, int maxpip) static void free_connlist(struct servtab *sep) { - struct conninfo *conn; + struct conninfo *conn, *conn_temp; int i, j; for (i = 0; i < PERIPSIZE; ++i) { - while ((conn = LIST_FIRST(&sep->se_conn[i])) != NULL) { + LIST_FOREACH_SAFE(conn, &sep->se_conn[i], co_link, conn_temp) { + if (conn == NULL) { + LIST_REMOVE(conn, co_link); + continue; + } for (j = 0; j < conn->co_numchild; ++j) free_proc(conn->co_proc[j]); conn->co_numchild = 0; @@ -2552,7 +2555,8 @@ free_proc(struct procinfo *proc) static int hashval(char *p, int len) { - int i, hv = 0xABC3D20F; + unsigned int hv = 0xABC3D20F; + int i; for (i = 0; i < len; ++i, ++p) hv = (hv << 5) ^ (hv >> 23) ^ *p; Modified: stable/11/usr.sbin/inetd/inetd.h ============================================================================== --- stable/11/usr.sbin/inetd/inetd.h Sun Jan 5 21:32:41 2020 (r356387) +++ stable/11/usr.sbin/inetd/inetd.h Sun Jan 5 21:35:02 2020 (r356388) @@ -64,6 +64,11 @@ struct conninfo { #define PERIPSIZE 256 +struct stabchild { + LIST_ENTRY(stabchild) sc_link; + pid_t sc_pid; +}; + struct servtab { char *se_service; /* name of service */ int se_socktype; /* type of socket to use */ @@ -72,7 +77,6 @@ struct servtab { int se_maxchild; /* max number of children */ int se_maxcpm; /* max connects per IP per minute */ int se_numchild; /* current number of children */ - pid_t *se_pids; /* array of child pids */ char *se_user; /* user name to run as */ char *se_group; /* group name to run as */ #ifdef LOGIN_CAP @@ -117,10 +121,16 @@ struct servtab { } se_flags; int se_maxperip; /* max number of children per src */ LIST_HEAD(, conninfo) se_conn[PERIPSIZE]; + LIST_HEAD(, stabchild) se_children; }; #define se_nomapped se_flags.se_nomapped #define se_reset se_flags.se_reset + +#define SERVTAB_AT_LIMIT(sep) \ + ((sep)->se_maxchild > 0 && (sep)->se_numchild == (sep)->se_maxchild) +#define SERVTAB_EXCEEDS_LIMIT(sep) \ + ((sep)->se_maxchild > 0 && (sep)->se_numchild >= (sep)->se_maxchild) int check_loop(const struct sockaddr *, const struct servtab *sep); void inetd_setproctitle(const char *, int); From owner-svn-src-stable-11@freebsd.org Mon Jan 6 01:15:36 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5F08F1ECA53; Mon, 6 Jan 2020 01:15:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47rcyJ1q0Zz415v; Mon, 6 Jan 2020 01:15:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 20B856932; Mon, 6 Jan 2020 01:15:36 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0061FaW0011777; Mon, 6 Jan 2020 01:15:36 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0061Fasi011776; Mon, 6 Jan 2020 01:15:36 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202001060115.0061Fasi011776@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 6 Jan 2020 01:15:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356391 - stable/11/sys/cam X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cam X-SVN-Commit-Revision: 356391 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jan 2020 01:15:36 -0000 Author: mav Date: Mon Jan 6 01:15:35 2020 New Revision: 356391 URL: https://svnweb.freebsd.org/changeset/base/356391 Log: MFC r356042: Make pass(4) handle misaligned buffers of MAXPHYS size. Since we are already using malloc()+copyin()/copyout() for smaller data blocks, and since new asynchronous API does it always, I see no reason to keep this ugly artificial size/alignment limitation in old API. Tape applications suffer enough from the MAXPHYS limitations by itself, and additional alignment requirement, often halving effectively usable block size, does not help. It would be good to use unmapped I/O here instead, but it require some HBA drivers polishing first to support non-BIO unmapped buffers. Modified: stable/11/sys/cam/cam_periph.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cam/cam_periph.c ============================================================================== --- stable/11/sys/cam/cam_periph.c Mon Jan 6 01:12:15 2020 (r356390) +++ stable/11/sys/cam/cam_periph.c Mon Jan 6 01:15:35 2020 (r356391) @@ -770,6 +770,7 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma u_int8_t **data_ptrs[CAM_PERIPH_MAXMAPS]; u_int32_t lengths[CAM_PERIPH_MAXMAPS]; u_int32_t dirs[CAM_PERIPH_MAXMAPS]; + bool misaligned[CAM_PERIPH_MAXMAPS]; bzero(mapinfo, sizeof(*mapinfo)); if (maxmap == 0) @@ -869,6 +870,12 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma * have to unmap any previously mapped buffers. */ for (i = 0; i < numbufs; i++) { + if (lengths[i] > maxmap) { + printf("cam_periph_mapmem: attempt to map %lu bytes, " + "which is greater than %lu\n", + (long)(lengths[i]), (u_long)maxmap); + return (E2BIG); + } /* * The userland data pointer passed in may not be page @@ -878,15 +885,8 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma * whatever extra space is necessary to make it to the page * boundary. */ - if ((lengths[i] + - (((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK)) > maxmap){ - printf("cam_periph_mapmem: attempt to map %lu bytes, " - "which is greater than %lu\n", - (long)(lengths[i] + - (((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK)), - (u_long)maxmap); - return(E2BIG); - } + misaligned[i] = (lengths[i] + + (((vm_offset_t)(*data_ptrs[i])) & PAGE_MASK) > MAXPHYS); } /* @@ -910,7 +910,7 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_ma * small allocations malloc is backed by UMA, and so much * cheaper on SMP systems. */ - if (lengths[i] <= periph_mapmem_thresh) { + if (lengths[i] <= periph_mapmem_thresh || misaligned[i]) { *data_ptrs[i] = malloc(lengths[i], M_CAMPERIPH, M_WAITOK); if (dirs[i] != CAM_DIR_IN) { From owner-svn-src-stable-11@freebsd.org Mon Jan 6 09:10:15 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 433AF1FDED3; Mon, 6 Jan 2020 09:10:15 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47rqTz14nvz4QbK; Mon, 6 Jan 2020 09:10:15 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2032CC037; Mon, 6 Jan 2020 09:10:15 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0069AEvG095490; Mon, 6 Jan 2020 09:10:14 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0069AERf095485; Mon, 6 Jan 2020 09:10:14 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202001060910.0069AERf095485@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 6 Jan 2020 09:10:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356395 - in stable/11/sys: dev/usb sys X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/11/sys: dev/usb sys X-SVN-Commit-Revision: 356395 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jan 2020 09:10:15 -0000 Author: hselasky Date: Mon Jan 6 09:10:13 2020 New Revision: 356395 URL: https://svnweb.freebsd.org/changeset/base/356395 Log: MFC r356135: Make USB statistics per device instead of per bus. Bump the FreeBSD version due to structure change to force recompilation of external USB modules. Sponsored by: Mellanox Technologies Modified: stable/11/sys/dev/usb/usb_bus.h stable/11/sys/dev/usb/usb_device.h stable/11/sys/dev/usb/usb_generic.c stable/11/sys/dev/usb/usb_transfer.c stable/11/sys/sys/param.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/usb_bus.h ============================================================================== --- stable/11/sys/dev/usb/usb_bus.h Mon Jan 6 09:07:57 2020 (r356394) +++ stable/11/sys/dev/usb/usb_bus.h Mon Jan 6 09:10:13 2020 (r356395) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. + * Copyright (c) 2008-2019 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -40,19 +40,10 @@ struct usb_bus_msg { }; /* - * The following structure defines the USB statistics structure. - */ -struct usb_bus_stat { - uint32_t uds_requests[4]; -}; - -/* * The following structure defines an USB BUS. There is one USB BUS * for every Host or Device controller. */ struct usb_bus { - struct usb_bus_stat stats_err; - struct usb_bus_stat stats_ok; #if USB_HAVE_ROOT_MOUNT_HOLD struct root_hold_token *bus_roothold; #endif Modified: stable/11/sys/dev/usb/usb_device.h ============================================================================== --- stable/11/sys/dev/usb/usb_device.h Mon Jan 6 09:07:57 2020 (r356394) +++ stable/11/sys/dev/usb/usb_device.h Mon Jan 6 09:10:13 2020 (r356395) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. + * Copyright (c) 2008-2019 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -175,10 +175,21 @@ union usb_device_scratch { }; /* + * Helper structure to keep track of USB device statistics. + */ +struct usb_device_statistics { + uint32_t uds_requests[4]; +}; + +/* * The following structure defines an USB device. There exists one of * these structures for every USB device. */ struct usb_device { + /* statistics */ + struct usb_device_statistics stats_err; + struct usb_device_statistics stats_ok; + /* generic clear stall message */ struct usb_udev_msg cs_msg[2]; struct sx enum_sx; Modified: stable/11/sys/dev/usb/usb_generic.c ============================================================================== --- stable/11/sys/dev/usb/usb_generic.c Mon Jan 6 09:07:57 2020 (r356394) +++ stable/11/sys/dev/usb/usb_generic.c Mon Jan 6 09:10:13 2020 (r356395) @@ -2221,10 +2221,9 @@ ugen_ioctl_post(struct usb_fifo *f, u_long cmd, void * for (n = 0; n != 4; n++) { u.stat->uds_requests_fail[n] = - f->udev->bus->stats_err.uds_requests[n]; - + f->udev->stats_err.uds_requests[n]; u.stat->uds_requests_ok[n] = - f->udev->bus->stats_ok.uds_requests[n]; + f->udev->stats_ok.uds_requests[n]; } break; Modified: stable/11/sys/dev/usb/usb_transfer.c ============================================================================== --- stable/11/sys/dev/usb/usb_transfer.c Mon Jan 6 09:07:57 2020 (r356394) +++ stable/11/sys/dev/usb/usb_transfer.c Mon Jan 6 09:10:13 2020 (r356395) @@ -2593,10 +2593,10 @@ usbd_transfer_done(struct usb_xfer *xfer, usb_error_t #endif /* keep some statistics */ if (xfer->error) { - info->bus->stats_err.uds_requests + info->udev->stats_err.uds_requests [xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE]++; } else { - info->bus->stats_ok.uds_requests + info->udev->stats_ok.uds_requests [xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE]++; } Modified: stable/11/sys/sys/param.h ============================================================================== --- stable/11/sys/sys/param.h Mon Jan 6 09:07:57 2020 (r356394) +++ stable/11/sys/sys/param.h Mon Jan 6 09:10:13 2020 (r356395) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1103505 /* Master, propagated to newvers */ +#define __FreeBSD_version 1103506 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable-11@freebsd.org Mon Jan 6 09:21:17 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8B6A41FE3A9; Mon, 6 Jan 2020 09:21:17 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47rqkj3BjXz4RTx; Mon, 6 Jan 2020 09:21:17 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 68E03C398; Mon, 6 Jan 2020 09:21:17 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0069LHp3003162; Mon, 6 Jan 2020 09:21:17 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0069LGOj003154; Mon, 6 Jan 2020 09:21:16 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202001060921.0069LGOj003154@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 6 Jan 2020 09:21:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356398 - stable/11/lib/libusb X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/lib/libusb X-SVN-Commit-Revision: 356398 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jan 2020 09:21:17 -0000 Author: hselasky Date: Mon Jan 6 09:21:15 2020 New Revision: 356398 URL: https://svnweb.freebsd.org/changeset/base/356398 Log: MFC r356136: Implement new libusb v2.0 API function, libusb20_dev_get_stats(). This function is useful when debugging USB device issues. Sponsored by: Mellanox Technologies Modified: stable/11/lib/libusb/Makefile stable/11/lib/libusb/libusb20.3 stable/11/lib/libusb/libusb20.c stable/11/lib/libusb/libusb20.h stable/11/lib/libusb/libusb20_int.h stable/11/lib/libusb/libusb20_ugen20.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libusb/Makefile ============================================================================== --- stable/11/lib/libusb/Makefile Mon Jan 6 09:20:04 2020 (r356397) +++ stable/11/lib/libusb/Makefile Mon Jan 6 09:21:15 2020 (r356398) @@ -220,6 +220,7 @@ MLINKS += libusb20.3 libusb20_dev_get_backend_name.3 MLINKS += libusb20.3 libusb20_dev_get_info.3 MLINKS += libusb20.3 libusb20_dev_get_iface_desc.3 MLINKS += libusb20.3 libusb20_dev_get_desc.3 +MLINKS += libusb20.3 libusb20_dev_get_stats.3 MLINKS += libusb20.3 libusb20_dev_close.3 MLINKS += libusb20.3 libusb20_dev_detach_kernel_driver.3 MLINKS += libusb20.3 libusb20_dev_set_config_index.3 Modified: stable/11/lib/libusb/libusb20.3 ============================================================================== --- stable/11/lib/libusb/libusb20.3 Mon Jan 6 09:20:04 2020 (r356397) +++ stable/11/lib/libusb/libusb20.3 Mon Jan 6 09:21:15 2020 (r356398) @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2008 Hans Petter Selasky +.\" Copyright (c) 2008-2019 Hans Petter Selasky .\" .\" All rights reserved. .\" @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 3, 2013 +.Dd December 27, 2019 .Dt LIBUSB20 3 .Os .Sh NAME @@ -122,6 +122,8 @@ USB access library (libusb -lusb) .Ft const char * .Fn libusb20_dev_get_desc "struct libusb20_device *pdev" .Ft int +.Fn libusb20_dev_get_stats "struct libusb20_device *pdev" "struct libusb20_device_stats *pstats" +.Ft int .Fn libusb20_dev_close "struct libusb20_device *pdev" .Ft int .Fn libusb20_dev_detach_kernel_driver "struct libusb20_device *pdev" "uint8_t iface_index" @@ -594,6 +596,14 @@ This function returns zero on success else a LIBUSB20_ .Fn libusb20_dev_get_desc returns a zero terminated string describing the given USB device. The format of the string is: "drivername: " +. +.Pp +. +.Fn libusb20_dev_get_stats +retrieves the device statistics into the structure pointed to by the +.Fa pstats +argument. +This function returns zero on success else a LIBUSB20_ERROR value is returned. . .Pp . Modified: stable/11/lib/libusb/libusb20.c ============================================================================== --- stable/11/lib/libusb/libusb20.c Mon Jan 6 09:20:04 2020 (r356397) +++ stable/11/lib/libusb/libusb20.c Mon Jan 6 09:21:15 2020 (r356398) @@ -76,6 +76,7 @@ dummy_callback(struct libusb20_transfer *xfer) #define dummy_set_power_mode (void *)dummy_int #define dummy_get_power_mode (void *)dummy_int #define dummy_get_power_usage (void *)dummy_int +#define dummy_get_stats (void *)dummy_int #define dummy_kernel_driver_active (void *)dummy_int #define dummy_detach_kernel_driver (void *)dummy_int #define dummy_do_request_sync (void *)dummy_int @@ -1045,6 +1046,31 @@ uint8_t libusb20_dev_get_speed(struct libusb20_device *pdev) { return (pdev->usb_speed); +} + +int +libusb20_dev_get_stats(struct libusb20_device *pdev, struct libusb20_device_stats *pstats) +{ + uint8_t do_close; + int error; + + if (!pdev->is_opened) { + error = libusb20_dev_open(pdev, 0); + if (error == 0) { + do_close = 1; + } else { + do_close = 0; + } + } else { + do_close = 0; + } + + error = pdev->methods->get_stats(pdev, pstats); + + if (do_close) + (void) libusb20_dev_close(pdev); + + return (error); } /* if this function returns an error, the device is gone */ Modified: stable/11/lib/libusb/libusb20.h ============================================================================== --- stable/11/lib/libusb/libusb20.h Mon Jan 6 09:20:04 2020 (r356397) +++ stable/11/lib/libusb/libusb20.h Mon Jan 6 09:21:15 2020 (r356398) @@ -193,6 +193,12 @@ struct libusb20_quirk { char quirkname[64 - 12]; }; +struct libusb20_device_stats { + uint64_t xfer_ok[4]; /* sorted by USB transfer type, UE_XXX */ + uint64_t xfer_fail[4]; /* sorted by USB transfer type, UE_XXX */ + uint64_t xfer_reserved[24]; /* reserved */ +}; + #define LIBUSB20_MAX_FRAME_PRE_SCALE (1U << 31) /* USB transfer operations */ @@ -241,6 +247,7 @@ int libusb20_dev_detach_kernel_driver(struct libusb20_ int libusb20_dev_set_config_index(struct libusb20_device *pdev, uint8_t configIndex); int libusb20_dev_get_debug(struct libusb20_device *pdev); int libusb20_dev_get_fd(struct libusb20_device *pdev); +int libusb20_dev_get_stats(struct libusb20_device *pdev, struct libusb20_device_stats *pstat); int libusb20_dev_kernel_driver_active(struct libusb20_device *pdev, uint8_t iface_index); int libusb20_dev_open(struct libusb20_device *pdev, uint16_t transfer_max); int libusb20_dev_process(struct libusb20_device *pdev); Modified: stable/11/lib/libusb/libusb20_int.h ============================================================================== --- stable/11/lib/libusb/libusb20_int.h Mon Jan 6 09:20:04 2020 (r356397) +++ stable/11/lib/libusb/libusb20_int.h Mon Jan 6 09:21:15 2020 (r356398) @@ -106,10 +106,12 @@ typedef int (libusb20_reset_device_t)(struct libusb20_ typedef int (libusb20_set_power_mode_t)(struct libusb20_device *pdev, uint8_t power_mode); typedef int (libusb20_get_power_mode_t)(struct libusb20_device *pdev, uint8_t *power_mode); typedef int (libusb20_get_power_usage_t)(struct libusb20_device *pdev, uint16_t *power_usage); +typedef int (libusb20_get_stats_t)(struct libusb20_device *pdev, struct libusb20_device_stats *pstats); typedef int (libusb20_set_alt_index_t)(struct libusb20_device *pdev, uint8_t iface_index, uint8_t alt_index); typedef int (libusb20_set_config_index_t)(struct libusb20_device *pdev, uint8_t index); typedef int (libusb20_check_connected_t)(struct libusb20_device *pdev); + /* USB transfer specific */ typedef int (libusb20_tr_open_t)(struct libusb20_transfer *xfer, uint32_t MaxBufSize, uint32_t MaxFrameCount, uint8_t ep_no, uint16_t stream_id, uint8_t pre_scale); typedef int (libusb20_tr_close_t)(struct libusb20_transfer *xfer); @@ -129,6 +131,7 @@ typedef void (libusb20_tr_cancel_async_t)(struct libus m(n, set_power_mode) \ m(n, get_power_mode) \ m(n, get_power_usage) \ + m(n, get_stats) \ m(n, set_alt_index) \ m(n, set_config_index) \ m(n, tr_cancel_async) \ Modified: stable/11/lib/libusb/libusb20_ugen20.c ============================================================================== --- stable/11/lib/libusb/libusb20_ugen20.c Mon Jan 6 09:20:04 2020 (r356397) +++ stable/11/lib/libusb/libusb20_ugen20.c Mon Jan 6 09:21:15 2020 (r356398) @@ -78,6 +78,7 @@ static libusb20_check_connected_t ugen20_check_connect static libusb20_set_power_mode_t ugen20_set_power_mode; static libusb20_get_power_mode_t ugen20_get_power_mode; static libusb20_get_power_usage_t ugen20_get_power_usage; +static libusb20_get_stats_t ugen20_get_stats; static libusb20_kernel_driver_active_t ugen20_kernel_driver_active; static libusb20_detach_kernel_driver_t ugen20_detach_kernel_driver; static libusb20_do_request_sync_t ugen20_do_request_sync; @@ -664,6 +665,29 @@ ugen20_get_power_usage(struct libusb20_device *pdev, u return (LIBUSB20_ERROR_OTHER); } *power_usage = temp; + return (0); /* success */ +} + +static int +ugen20_get_stats(struct libusb20_device *pdev, struct libusb20_device_stats *pstats) +{ + struct usb_device_stats st; + + if (ioctl(pdev->file_ctrl, IOUSB(USB_DEVICESTATS), &st)) + return (LIBUSB20_ERROR_OTHER); + + memset(pstats, 0, sizeof(*pstats)); + + pstats->xfer_ok[0] = st.uds_requests_ok[0]; + pstats->xfer_ok[1] = st.uds_requests_ok[1]; + pstats->xfer_ok[2] = st.uds_requests_ok[2]; + pstats->xfer_ok[3] = st.uds_requests_ok[3]; + + pstats->xfer_fail[0] = st.uds_requests_fail[0]; + pstats->xfer_fail[1] = st.uds_requests_fail[1]; + pstats->xfer_fail[2] = st.uds_requests_fail[2]; + pstats->xfer_fail[3] = st.uds_requests_fail[3]; + return (0); /* success */ } From owner-svn-src-stable-11@freebsd.org Mon Jan 6 09:24:49 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0A6B71FE57A; Mon, 6 Jan 2020 09:24:49 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47rqpm6TsVz4S3W; Mon, 6 Jan 2020 09:24:48 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D9D96C410; Mon, 6 Jan 2020 09:24:48 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0069OmVq007461; Mon, 6 Jan 2020 09:24:48 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0069Om3W007458; Mon, 6 Jan 2020 09:24:48 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202001060924.0069Om3W007458@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 6 Jan 2020 09:24:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356401 - stable/11/usr.sbin/usbconfig X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/usr.sbin/usbconfig X-SVN-Commit-Revision: 356401 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jan 2020 09:24:49 -0000 Author: hselasky Date: Mon Jan 6 09:24:47 2020 New Revision: 356401 URL: https://svnweb.freebsd.org/changeset/base/356401 Log: MFC r356137: Implement dump_stats command for usbconfig(8). This command is useful when debugging USB device issues. Sponsored by: Mellanox Technologies Modified: stable/11/usr.sbin/usbconfig/dump.c stable/11/usr.sbin/usbconfig/dump.h stable/11/usr.sbin/usbconfig/usbconfig.8 stable/11/usr.sbin/usbconfig/usbconfig.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/usbconfig/dump.c ============================================================================== --- stable/11/usr.sbin/usbconfig/dump.c Mon Jan 6 09:23:54 2020 (r356400) +++ stable/11/usr.sbin/usbconfig/dump.c Mon Jan 6 09:24:47 2020 (r356401) @@ -483,3 +483,32 @@ dump_string_by_index(struct libusb20_device *pdev, uin } free(pbuf); } + +void +dump_device_stats(struct libusb20_device *pdev) +{ + struct libusb20_device_stats st; + + if (libusb20_dev_get_stats(pdev, &st)) { + printf("{}\n"); + } else { + printf("{\n" + " UE_CONTROL_OK : %llu\n" + " UE_ISOCHRONOUS_OK : %llu\n" + " UE_BULK_OK : %llu\n" + " UE_INTERRUPT_OK : %llu\n" + " UE_CONTROL_FAIL : %llu\n" + " UE_ISOCHRONOUS_FAIL : %llu\n" + " UE_BULK_FAIL : %llu\n" + " UE_INTERRUPT_FAIL : %llu\n" + "}\n", + (unsigned long long)st.xfer_ok[0], + (unsigned long long)st.xfer_ok[1], + (unsigned long long)st.xfer_ok[2], + (unsigned long long)st.xfer_ok[3], + (unsigned long long)st.xfer_fail[0], + (unsigned long long)st.xfer_fail[1], + (unsigned long long)st.xfer_fail[2], + (unsigned long long)st.xfer_fail[3]); + } +} Modified: stable/11/usr.sbin/usbconfig/dump.h ============================================================================== --- stable/11/usr.sbin/usbconfig/dump.h Mon Jan 6 09:23:54 2020 (r356400) +++ stable/11/usr.sbin/usbconfig/dump.h Mon Jan 6 09:24:47 2020 (r356401) @@ -37,6 +37,7 @@ void dump_device_info(struct libusb20_device *pdev, ui void dump_be_quirk_names(struct libusb20_backend *pbe); void dump_be_dev_quirks(struct libusb20_backend *pbe); void dump_device_desc(struct libusb20_device *pdev); +void dump_device_stats(struct libusb20_device *pdev); void dump_config(struct libusb20_device *pdev, uint8_t all_cfg); #endif /* _DUMP_H_ */ Modified: stable/11/usr.sbin/usbconfig/usbconfig.8 ============================================================================== --- stable/11/usr.sbin/usbconfig/usbconfig.8 Mon Jan 6 09:23:54 2020 (r356400) +++ stable/11/usr.sbin/usbconfig/usbconfig.8 Mon Jan 6 09:24:47 2020 (r356401) @@ -1,6 +1,6 @@ .\" $FreeBSD$ .\" -.\" Copyright (c) 2008-2010 Hans Petter Selasky. All rights reserved. +.\" Copyright (c) 2008-2019 Hans Petter Selasky. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 16, 2019 +.Dd December 27, 2019 .Dt USBCONFIG 8 .Os .Sh NAME @@ -116,6 +116,8 @@ Display all the configuration descriptors. Display string descriptor at selected index. .It Cm dump_info Display summary information about the device. +.It Cm dump_stats +Display USB transfer statistics. .It Cm show_ifdrv Display the list of interface drivers (such as .Xr ukbd 4 Modified: stable/11/usr.sbin/usbconfig/usbconfig.c ============================================================================== --- stable/11/usr.sbin/usbconfig/usbconfig.c Mon Jan 6 09:23:54 2020 (r356400) +++ stable/11/usr.sbin/usbconfig/usbconfig.c Mon Jan 6 09:24:47 2020 (r356401) @@ -82,6 +82,7 @@ struct options { uint8_t got_dump_curr_config:1; uint8_t got_dump_all_config:1; uint8_t got_dump_info:1; + uint8_t got_dump_stats:1; uint8_t got_show_iface_driver:1; uint8_t got_remove_device_quirk:1; uint8_t got_add_device_quirk:1; @@ -121,6 +122,7 @@ enum { T_DUMP_ALL_CONFIG_DESC, T_DUMP_STRING, T_DUMP_INFO, + T_DUMP_STATS, T_SUSPEND, T_RESUME, T_POWER_OFF, @@ -155,6 +157,7 @@ static const struct token token[] = { {"dump_all_config_desc", T_DUMP_ALL_CONFIG_DESC, 0}, {"dump_string", T_DUMP_STRING, 1}, {"dump_info", T_DUMP_INFO, 0}, + {"dump_stats", T_DUMP_STATS, 0}, {"show_ifdrv", T_SHOW_IFACE_DRIVER, 0}, {"suspend", T_SUSPEND, 0}, {"resume", T_RESUME, 0}, @@ -296,6 +299,7 @@ usage(void) " dump_all_config_desc" "\n" " dump_string " "\n" " dump_info" "\n" + " dump_stats" "\n" " show_ifdrv" "\n" " suspend" "\n" " resume" "\n" @@ -506,7 +510,8 @@ flush_command(struct libusb20_backend *pbe, struct opt opt->got_dump_device_desc || opt->got_dump_curr_config || opt->got_dump_all_config || - opt->got_dump_info); + opt->got_dump_info || + opt->got_dump_stats); if (opt->got_list || dump_any) { dump_device_info(pdev, @@ -527,6 +532,10 @@ flush_command(struct libusb20_backend *pbe, struct opt dump_device_desc(pdev); dump_config(pdev, 1); } + if (opt->got_dump_stats) { + printf("\n"); + dump_device_stats(pdev); + } if (dump_any) { printf("\n"); } @@ -749,6 +758,12 @@ main(int argc, char **argv) if (opt->got_dump_info) duplicate_option(argv[n]); opt->got_dump_info = 1; + opt->got_any++; + break; + case T_DUMP_STATS: + if (opt->got_dump_stats) + duplicate_option(argv[n]); + opt->got_dump_stats = 1; opt->got_any++; break; case T_DUMP_STRING: From owner-svn-src-stable-11@freebsd.org Mon Jan 6 09:51:22 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C3CFB1FF1DC; Mon, 6 Jan 2020 09:51:22 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47rrPQ4sSfz4VPb; Mon, 6 Jan 2020 09:51:22 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A1BBDC984; Mon, 6 Jan 2020 09:51:22 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0069pMXX021532; Mon, 6 Jan 2020 09:51:22 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0069pMuq021531; Mon, 6 Jan 2020 09:51:22 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202001060951.0069pMuq021531@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 6 Jan 2020 09:51:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356411 - stable/11/sys/dev/hyperv/netvsc X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/dev/hyperv/netvsc X-SVN-Commit-Revision: 356411 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jan 2020 09:51:22 -0000 Author: hselasky Date: Mon Jan 6 09:51:22 2020 New Revision: 356411 URL: https://svnweb.freebsd.org/changeset/base/356411 Log: MFC r356201: Fix spelling. PR: 242891 Sponsored by: Mellanox Technologies Modified: stable/11/sys/dev/hyperv/netvsc/if_hn.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/hyperv/netvsc/if_hn.c ============================================================================== --- stable/11/sys/dev/hyperv/netvsc/if_hn.c Mon Jan 6 09:50:44 2020 (r356410) +++ stable/11/sys/dev/hyperv/netvsc/if_hn.c Mon Jan 6 09:51:22 2020 (r356411) @@ -1506,7 +1506,7 @@ hn_vf_rss_fixup(struct hn_softc *sc, bool reconf) strlcpy(ifrk.ifrk_name, vf_ifp->if_xname, sizeof(ifrk.ifrk_name)); error = vf_ifp->if_ioctl(vf_ifp, SIOCGIFRSSKEY, (caddr_t)&ifrk); if (error) { - if_printf(ifp, "%s SIOCGRSSKEY failed: %d\n", + if_printf(ifp, "%s SIOCGIFRSSKEY failed: %d\n", vf_ifp->if_xname, error); goto done; } From owner-svn-src-stable-11@freebsd.org Mon Jan 6 21:23:15 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D4A851F0942; Mon, 6 Jan 2020 21:23:15 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47s7ll4cN8z4F5b; Mon, 6 Jan 2020 21:23:15 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 98FBA1C88D; Mon, 6 Jan 2020 21:23:15 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 006LNFxo076240; Mon, 6 Jan 2020 21:23:15 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 006LNF4W076234; Mon, 6 Jan 2020 21:23:15 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <202001062123.006LNF4W076234@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Mon, 6 Jan 2020 21:23:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356428 - stable/11/sbin/fsck_ffs X-SVN-Group: stable-11 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/11/sbin/fsck_ffs X-SVN-Commit-Revision: 356428 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jan 2020 21:23:15 -0000 Author: mckusick Date: Mon Jan 6 21:23:14 2020 New Revision: 356428 URL: https://svnweb.freebsd.org/changeset/base/356428 Log: MFC of 356063 Do not ask to use journal in fsck_ffs if journal is out of date Modified: stable/11/sbin/fsck_ffs/main.c stable/11/sbin/fsck_ffs/suj.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fsck_ffs/main.c ============================================================================== --- stable/11/sbin/fsck_ffs/main.c Mon Jan 6 21:14:27 2020 (r356427) +++ stable/11/sbin/fsck_ffs/main.c Mon Jan 6 21:23:14 2020 (r356428) @@ -420,13 +420,11 @@ checkfilesys(char *filesys) */ if ((sblock.fs_flags & FS_SUJ) == FS_SUJ) { if ((sblock.fs_flags & FS_NEEDSFSCK) != FS_NEEDSFSCK && skipclean) { - if (preen || reply("USE JOURNAL")) { - if (suj_check(filesys) == 0) { - printf("\n***** FILE SYSTEM MARKED CLEAN *****\n"); - if (chkdoreload(mntp) == 0) - exit(0); - exit(4); - } + if (suj_check(filesys) == 0) { + printf("\n***** FILE SYSTEM MARKED CLEAN *****\n"); + if (chkdoreload(mntp) == 0) + exit(0); + exit(4); } printf("** Skipping journal, falling through to full fsck\n\n"); } Modified: stable/11/sbin/fsck_ffs/suj.c ============================================================================== --- stable/11/sbin/fsck_ffs/suj.c Mon Jan 6 21:14:27 2020 (r356427) +++ stable/11/sbin/fsck_ffs/suj.c Mon Jan 6 21:23:14 2020 (r356428) @@ -2726,6 +2726,8 @@ suj_check(const char *filesys) printf("** SU+J Recovering %s\n", filesys); if (suj_verifyino(jip) != 0) return (-1); + if (!preen && !reply("USE JOURNAL")) + return (-1); /* * Build a list of journal blocks in jblocks before parsing the * available journal blocks in with suj_read(). From owner-svn-src-stable-11@freebsd.org Tue Jan 7 00:54:45 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C38431DD0CF; Tue, 7 Jan 2020 00:54:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47sDRn4rWRz4TSl; Tue, 7 Jan 2020 00:54:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A18E01EEEC; Tue, 7 Jan 2020 00:54:45 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0070sjE2005280; Tue, 7 Jan 2020 00:54:45 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0070sjZN005279; Tue, 7 Jan 2020 00:54:45 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202001070054.0070sjZN005279@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 7 Jan 2020 00:54:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356430 - stable/11/sys/dev/ioat X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/dev/ioat X-SVN-Commit-Revision: 356430 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jan 2020 00:54:45 -0000 Author: mav Date: Tue Jan 7 00:54:45 2020 New Revision: 356430 URL: https://svnweb.freebsd.org/changeset/base/356430 Log: MFC r356216: Don't spin on cleanup_lock if we are not interrupt. If somebody else holds that lock, it will likely do the work for us. If it won't, then we return here later and retry. Under heavy load it allows to avoid lock congestion between interrupt and polling threads. Modified: stable/11/sys/dev/ioat/ioat.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/ioat/ioat.c ============================================================================== --- stable/11/sys/dev/ioat/ioat.c Tue Jan 7 00:54:23 2020 (r356429) +++ stable/11/sys/dev/ioat/ioat.c Tue Jan 7 00:54:45 2020 (r356430) @@ -682,7 +682,12 @@ ioat_process_events(struct ioat_softc *ioat, boolean_t uint32_t completed, chanerr; int error; - mtx_lock(&ioat->cleanup_lock); + if (intr) { + mtx_lock(&ioat->cleanup_lock); + } else { + if (!mtx_trylock(&ioat->cleanup_lock)) + return; + } /* * Don't run while the hardware is being reset. Reset is responsible From owner-svn-src-stable-11@freebsd.org Tue Jan 7 16:49:57 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5E0BA1ECA88; Tue, 7 Jan 2020 16:49:57 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47sddx1xL7z4Kw9; Tue, 7 Jan 2020 16:49:57 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3B98D1DBA; Tue, 7 Jan 2020 16:49:57 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 007Gnv6k080744; Tue, 7 Jan 2020 16:49:57 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 007GnvS1080743; Tue, 7 Jan 2020 16:49:57 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202001071649.007GnvS1080743@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Tue, 7 Jan 2020 16:49:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356449 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: bz X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 356449 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jan 2020 16:49:57 -0000 Author: bz Date: Tue Jan 7 16:49:56 2020 New Revision: 356449 URL: https://svnweb.freebsd.org/changeset/base/356449 Log: MFC r354416: m_pulldown(): Change an if () panic() into a KASSERT(). If we pass in a NULL mbuf to m_pulldown() we are in a bad situation already. There is no point in doing that check for production code. Change the if () panic() into a KASSERT. Modified: stable/11/sys/kern/uipc_mbuf2.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/uipc_mbuf2.c ============================================================================== --- stable/11/sys/kern/uipc_mbuf2.c Tue Jan 7 16:49:50 2020 (r356448) +++ stable/11/sys/kern/uipc_mbuf2.c Tue Jan 7 16:49:56 2020 (r356449) @@ -99,8 +99,8 @@ m_pulldown(struct mbuf *m, int off, int len, int *offp int writable; /* check invalid arguments. */ - if (m == NULL) - panic("m == NULL in m_pulldown()"); + KASSERT(m != NULL, ("%s: fix caller: m is NULL off %d len %d offp %p\n", + __func__, off, len, offp)); if (len > MCLBYTES) { m_freem(m); return NULL; /* impossible */ From owner-svn-src-stable-11@freebsd.org Tue Jan 7 16:52:16 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 931441ECC66; Tue, 7 Jan 2020 16:52:16 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47sdhc3SWtz4LRH; Tue, 7 Jan 2020 16:52:16 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 71CD21F5F; Tue, 7 Jan 2020 16:52:16 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 007GqGVx086260; Tue, 7 Jan 2020 16:52:16 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 007GqG4C086259; Tue, 7 Jan 2020 16:52:16 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202001071652.007GqG4C086259@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Tue, 7 Jan 2020 16:52:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356451 - stable/11/lib/libipsec X-SVN-Group: stable-11 X-SVN-Commit-Author: bz X-SVN-Commit-Paths: stable/11/lib/libipsec X-SVN-Commit-Revision: 356451 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jan 2020 16:52:16 -0000 Author: bz Date: Tue Jan 7 16:52:15 2020 New Revision: 356451 URL: https://svnweb.freebsd.org/changeset/base/356451 Log: MFC r354572: libipsec: correct a typo Correct a typo in the ipsec_errlist and replicated in a comment. No functional changes. Modified: stable/11/lib/libipsec/ipsec_strerror.c stable/11/lib/libipsec/ipsec_strerror.h Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libipsec/ipsec_strerror.c ============================================================================== --- stable/11/lib/libipsec/ipsec_strerror.c Tue Jan 7 16:52:05 2020 (r356450) +++ stable/11/lib/libipsec/ipsec_strerror.c Tue Jan 7 16:52:15 2020 (r356451) @@ -60,7 +60,7 @@ static const char *ipsec_errlist[] = { "Invalid key length", /*EIPSEC_INVAL_KEYLEN*/ "Invalid address family", /*EIPSEC_INVAL_FAMILY*/ "Invalid prefix length", /*EIPSEC_INVAL_PREFIXLEN*/ -"Invalid direciton", /*EIPSEC_INVAL_DIR*/ +"Invalid direction", /*EIPSEC_INVAL_DIR*/ "SPI range violation", /*EIPSEC_INVAL_SPI*/ "No protocol specified", /*EIPSEC_NO_PROTO*/ "No algorithm specified", /*EIPSEC_NO_ALGS*/ Modified: stable/11/lib/libipsec/ipsec_strerror.h ============================================================================== --- stable/11/lib/libipsec/ipsec_strerror.h Tue Jan 7 16:52:05 2020 (r356450) +++ stable/11/lib/libipsec/ipsec_strerror.h Tue Jan 7 16:52:15 2020 (r356451) @@ -50,7 +50,7 @@ extern void __ipsec_set_strerror(const char *); #define EIPSEC_INVAL_KEYLEN 14 /*invalid key length*/ #define EIPSEC_INVAL_FAMILY 15 /*invalid address family*/ #define EIPSEC_INVAL_PREFIXLEN 16 /*SPI range violation*/ -#define EIPSEC_INVAL_DIR 17 /*Invalid direciton*/ +#define EIPSEC_INVAL_DIR 17 /*Invalid direction*/ #define EIPSEC_INVAL_SPI 18 /*invalid prefixlen*/ #define EIPSEC_NO_PROTO 19 /*no protocol specified*/ #define EIPSEC_NO_ALGS 20 /*No algorithm specified*/ From owner-svn-src-stable-11@freebsd.org Tue Jan 7 16:54:54 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 02DFB1ECF7E; Tue, 7 Jan 2020 16:54:54 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47sdld6GLRz4LrH; Tue, 7 Jan 2020 16:54:53 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D208F1F82; Tue, 7 Jan 2020 16:54:53 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 007GsrZD086551; Tue, 7 Jan 2020 16:54:53 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 007GsrHq086550; Tue, 7 Jan 2020 16:54:53 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202001071654.007GsrHq086550@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Tue, 7 Jan 2020 16:54:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356454 - stable/11/usr.bin/netstat X-SVN-Group: stable-11 X-SVN-Commit-Author: bz X-SVN-Commit-Paths: stable/11/usr.bin/netstat X-SVN-Commit-Revision: 356454 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jan 2020 16:54:54 -0000 Author: bz Date: Tue Jan 7 16:54:53 2020 New Revision: 356454 URL: https://svnweb.freebsd.org/changeset/base/356454 Log: MFC r354639: netstat: igmp stats, error on unexpected information, not only warn The igmp stats tend to print two lines of warning for an unexpected version and length. Despite an invalid version and struct size it continues to try to do something with the data. Do not try to parse the remainder of the struct and error on warning. Note the underlying issue of the data not being available properly is still there and needs to be fixed seperately. Reported by: test cases, lwhsu Modified: stable/11/usr.bin/netstat/inet.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/netstat/inet.c ============================================================================== --- stable/11/usr.bin/netstat/inet.c Tue Jan 7 16:54:43 2020 (r356453) +++ stable/11/usr.bin/netstat/inet.c Tue Jan 7 16:54:53 2020 (r356454) @@ -1330,10 +1330,12 @@ igmp_stats(u_long off, const char *name, int af1 __unu if (igmpstat.igps_version != IGPS_VERSION_3) { xo_warnx("%s: version mismatch (%d != %d)", __func__, igmpstat.igps_version, IGPS_VERSION_3); + return; } if (igmpstat.igps_len != IGPS_VERSION3_LEN) { xo_warnx("%s: size mismatch (%d != %d)", __func__, igmpstat.igps_len, IGPS_VERSION3_LEN); + return; } xo_open_container(name); From owner-svn-src-stable-11@freebsd.org Tue Jan 7 17:02:50 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4C7B41ED35A; Tue, 7 Jan 2020 17:02:50 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47sdwp1LPyz4MWb; Tue, 7 Jan 2020 17:02:50 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 29595218F; Tue, 7 Jan 2020 17:02:50 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 007H2oLE092416; Tue, 7 Jan 2020 17:02:50 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 007H2ol8092415; Tue, 7 Jan 2020 17:02:50 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202001071702.007H2ol8092415@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Tue, 7 Jan 2020 17:02:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356456 - stable/11/sys/net X-SVN-Group: stable-11 X-SVN-Commit-Author: bz X-SVN-Commit-Paths: stable/11/sys/net X-SVN-Commit-Revision: 356456 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jan 2020 17:02:50 -0000 Author: bz Date: Tue Jan 7 17:02:49 2020 New Revision: 356456 URL: https://svnweb.freebsd.org/changeset/base/356456 Log: MFC r355070: Allow kernel to compile without BPF. r297816 added some bpf magic for VIMAGE unconditionally which no longer allows kernels to compile without bpf (but with other networking). Add the missing ifdef checks and allow a kernel to compile without bpf again. PR: 242136 Reported by: dave mischler.com MFC after: 2 weeks Modified: stable/11/sys/net/if.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/if.c ============================================================================== --- stable/11/sys/net/if.c Tue Jan 7 16:58:39 2020 (r356455) +++ stable/11/sys/net/if.c Tue Jan 7 17:02:49 2020 (r356456) @@ -31,6 +31,7 @@ */ #include "opt_compat.h" +#include "opt_bpf.h" #include "opt_inet6.h" #include "opt_inet.h" @@ -1201,15 +1202,19 @@ static void if_vmove(struct ifnet *ifp, struct vnet *new_vnet) { struct if_clone *ifc; +#ifdef DEV_BPF u_int bif_dlt, bif_hdrlen; +#endif int rc; +#ifdef DEV_BPF /* * if_detach_internal() will call the eventhandler to notify * interface departure. That will detach if_bpf. We need to * safe the dlt and hdrlen so we can re-attach it later. */ bpf_get_bp_params(ifp->if_bpf, &bif_dlt, &bif_hdrlen); +#endif /* * Detach from current vnet, but preserve LLADDR info, do not @@ -1250,8 +1255,10 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet) if_attach_internal(ifp, 1, ifc); +#ifdef DEV_BPF if (ifp->if_bpf == NULL) bpfattach(ifp, bif_dlt, bif_hdrlen); +#endif CURVNET_RESTORE(); } From owner-svn-src-stable-11@freebsd.org Tue Jan 7 18:42:55 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9AC751EF4F4; Tue, 7 Jan 2020 18:42:55 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47sh8H3dZYz4SWW; Tue, 7 Jan 2020 18:42:55 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 77C623479; Tue, 7 Jan 2020 18:42:55 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 007IgtlW054736; Tue, 7 Jan 2020 18:42:55 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 007IgrB1054727; Tue, 7 Jan 2020 18:42:53 GMT (envelope-from ian@FreeBSD.org) Message-Id: <202001071842.007IgrB1054727@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Tue, 7 Jan 2020 18:42:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356461 - in stable/11/lib: libc/gen libutil X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11/lib: libc/gen libutil X-SVN-Commit-Revision: 356461 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jan 2020 18:42:55 -0000 Author: ian Date: Tue Jan 7 18:42:53 2020 New Revision: 356461 URL: https://svnweb.freebsd.org/changeset/base/356461 Log: MFC r336746, r336779 r336746: Make pw_scan(3) more compatible with getpwent(3) et. al. when processing data from /etc/passwd rather than /etc/master.passwd. The libc getpwent(3) and related functions automatically read master.passwd when run by root, or passwd when run by a non-root user. When run by non- root, getpwent() copes with the missing data by setting the corresponding fields in the passwd struct to known values (zeroes for numbers, or a pointer to an empty string for literals). When libutil's pw_scan(3) was used to parse a line without the root-accessible data, it was leaving garbage in the corresponding fields. These changes rename the static pw_init() function used by getpwent() and friends to __pw_initpwd(), and move it into pw_scan.c so that common init code can be shared between libc and libutil. pw_scan(3) now calls __pw_initpwd() before __pw_scan(), just like the getpwent() family does, so that reading an arbitrary passwd file in either format and parsing it with pw_scan(3) returns the same results as getpwent(3) would. This also adds a new pw_initpwd(3) function to libutil, so that code which creates passwd structs from scratch in some manner that doesn't involve pw_scan() can initialize the struct to the values expected by lots of existing code, which doesn't expect to encounter NULL pointers or garbage values in some fields. r336779: Stop exporting __pw_scan and __pw_initpwd as freebsd-private libc functions for use in libutil, and instead compile the small amount of common code directly into libutil with a .PATH reachover. Modified: stable/11/lib/libc/gen/Symbol.map stable/11/lib/libc/gen/getpwent.c stable/11/lib/libc/gen/pw_scan.c stable/11/lib/libc/gen/pw_scan.h stable/11/lib/libutil/Makefile stable/11/lib/libutil/libutil.h stable/11/lib/libutil/pw_util.3 stable/11/lib/libutil/pw_util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/Symbol.map ============================================================================== --- stable/11/lib/libc/gen/Symbol.map Tue Jan 7 18:08:09 2020 (r356460) +++ stable/11/lib/libc/gen/Symbol.map Tue Jan 7 18:42:53 2020 (r356461) @@ -518,7 +518,6 @@ FBSDprivate_1.0 { __opendir2; __pause; _pause; - __pw_scan; /* Used by (at least) libutil */ __raise; _raise; __sleep; Modified: stable/11/lib/libc/gen/getpwent.c ============================================================================== --- stable/11/lib/libc/gen/getpwent.c Tue Jan 7 18:08:09 2020 (r356460) +++ stable/11/lib/libc/gen/getpwent.c Tue Jan 7 18:42:53 2020 (r356461) @@ -94,8 +94,6 @@ int __pw_match_entry(const char *, size_t, enum nss_lo const char *, uid_t); int __pw_parse_entry(char *, size_t, struct passwd *, int, int *errnop); -static void pwd_init(struct passwd *); - union key { const char *name; uid_t uid; @@ -525,7 +523,7 @@ getpwent_r(struct passwd *pwd, char *buffer, size_t bu }; int rv, ret_errno; - pwd_init(pwd); + __pw_initpwd(pwd); ret_errno = 0; *result = NULL; rv = _nsdispatch(result, dtab, NSDB_PASSWD, "getpwent_r", defaultsrc, @@ -564,7 +562,7 @@ getpwnam_r(const char *name, struct passwd *pwd, char }; int rv, ret_errno; - pwd_init(pwd); + __pw_initpwd(pwd); ret_errno = 0; *result = NULL; rv = _nsdispatch(result, dtab, NSDB_PASSWD, "getpwnam_r", defaultsrc, @@ -603,7 +601,7 @@ getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer }; int rv, ret_errno; - pwd_init(pwd); + __pw_initpwd(pwd); ret_errno = 0; *result = NULL; rv = _nsdispatch(result, dtab, NSDB_PASSWD, "getpwuid_r", defaultsrc, @@ -615,23 +613,6 @@ getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer } -static void -pwd_init(struct passwd *pwd) -{ - static char nul[] = ""; - - memset(pwd, 0, sizeof(*pwd)); - pwd->pw_uid = (uid_t)-1; /* Considered least likely to lead to */ - pwd->pw_gid = (gid_t)-1; /* a security issue. */ - pwd->pw_name = nul; - pwd->pw_passwd = nul; - pwd->pw_class = nul; - pwd->pw_gecos = nul; - pwd->pw_dir = nul; - pwd->pw_shell = nul; -} - - static struct passwd pwd; static char *pwd_storage; static size_t pwd_storage_size; @@ -1612,7 +1593,7 @@ compat_redispatch(struct compat_state *st, enum nss_lo for (i = 0; i < (int)(nitems(dtab) - 1); i++) dtab[i].mdata = (void *)lookup_how; more: - pwd_init(pwd); + __pw_initpwd(pwd); switch (lookup_how) { case nss_lt_all: rv = _nsdispatch(&discard, dtab, NSDB_PASSWD_COMPAT, Modified: stable/11/lib/libc/gen/pw_scan.c ============================================================================== --- stable/11/lib/libc/gen/pw_scan.c Tue Jan 7 18:08:09 2020 (r356460) +++ stable/11/lib/libc/gen/pw_scan.c Tue Jan 7 18:42:53 2020 (r356461) @@ -27,10 +27,10 @@ * SUCH DAMAGE. */ +#include #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)pw_scan.c 8.3 (Berkeley) 4/2/94"; +static char sccsid[] __unused = "@(#)pw_scan.c 8.3 (Berkeley) 4/2/94"; #endif /* LIBC_SCCS and not lint */ -#include __FBSDID("$FreeBSD$"); /* @@ -66,6 +66,22 @@ __FBSDID("$FreeBSD$"); * system lag behind. */ static int pw_big_ids_warning = 0; + +void +__pw_initpwd(struct passwd *pwd) +{ + static char nul[] = ""; + + memset(pwd, 0, sizeof(*pwd)); + pwd->pw_uid = (uid_t)-1; /* Considered least likely to lead to */ + pwd->pw_gid = (gid_t)-1; /* a security issue. */ + pwd->pw_name = nul; + pwd->pw_passwd = nul; + pwd->pw_class = nul; + pwd->pw_gecos = nul; + pwd->pw_dir = nul; + pwd->pw_shell = nul; +} int __pw_scan(char *bp, struct passwd *pw, int flags) Modified: stable/11/lib/libc/gen/pw_scan.h ============================================================================== --- stable/11/lib/libc/gen/pw_scan.h Tue Jan 7 18:08:09 2020 (r356460) +++ stable/11/lib/libc/gen/pw_scan.h Tue Jan 7 18:42:53 2020 (r356461) @@ -33,4 +33,5 @@ #define _PWSCAN_MASTER 0x01 #define _PWSCAN_WARN 0x02 +extern void __pw_initpwd(struct passwd *); extern int __pw_scan(char *, struct passwd *, int); Modified: stable/11/lib/libutil/Makefile ============================================================================== --- stable/11/lib/libutil/Makefile Tue Jan 7 18:08:09 2020 (r356460) +++ stable/11/lib/libutil/Makefile Tue Jan 7 18:42:53 2020 (r356461) @@ -6,6 +6,8 @@ SHLIBDIR?= /lib .include +.PATH: ${SRCTOP}/lib/libc/gen # for pw_scan.c + LIB= util SHLIB_MAJOR= 9 @@ -15,8 +17,8 @@ SRCS= _secure_path.c auth.c expand_number.c flopen.c f kinfo_getvmobject.c kld.c \ login_auth.c login_cap.c \ login_class.c login_crypt.c login_ok.c login_times.c login_tty.c \ - pidfile.c property.c pty.c pw_util.c quotafile.c realhostname.c \ - stub.c trimdomain.c uucplock.c + pidfile.c property.c pty.c pw_scan.c pw_util.c quotafile.c \ + realhostname.c stub.c trimdomain.c uucplock.c INCS= libutil.h login_cap.h CFLAGS+= -DLIBC_SCCS Modified: stable/11/lib/libutil/libutil.h ============================================================================== --- stable/11/lib/libutil/libutil.h Tue Jan 7 18:08:09 2020 (r356460) +++ stable/11/lib/libutil/libutil.h Tue Jan 7 18:42:53 2020 (r356461) @@ -152,6 +152,7 @@ int pw_edit(int _notsetuid); int pw_equal(const struct passwd *_pw1, const struct passwd *_pw2); void pw_fini(void); int pw_init(const char *_dir, const char *_master); +void pw_initpwd(struct passwd *_pw); char *pw_make(const struct passwd *_pw); char *pw_make_v7(const struct passwd *_pw); int pw_mkdb(const char *_user); Modified: stable/11/lib/libutil/pw_util.3 ============================================================================== --- stable/11/lib/libutil/pw_util.3 Tue Jan 7 18:08:09 2020 (r356460) +++ stable/11/lib/libutil/pw_util.3 Tue Jan 7 18:42:53 2020 (r356461) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 02, 2015 +.Dd July 26, 2018 .Dt PW_UTIL 3 .Os .Sh NAME @@ -59,6 +59,8 @@ .Fn pw_fini "void" .Ft int .Fn pw_init "const char *dir" const char *master" +.Ft void +.Fn pw_initpwd "struct passwd *pw" .Ft "char *" .Fn pw_make "const struct passwd *pw" .Ft "char *" @@ -179,7 +181,7 @@ if any. .Pp The .Fn pw_init -initialize the static variable representing the path a password file. +initializes the static variable representing the path to a password file. .Fa dir is the directory where the password file is located. If set to @@ -192,6 +194,18 @@ If set to .Dv NULL? it will default to .Pa master.passwd +.Pp +The +.Fn pw_initpwd +function initializes the +.Vt passwd +struct to canonical values. +The entire structure is zeroed, then +.Va pw_uid +and +.Va pw_gid +are set to -1, and all string pointers are set to point at +an internally-defined zero-length string. .Pp The .Fn pw_make Modified: stable/11/lib/libutil/pw_util.c ============================================================================== --- stable/11/lib/libutil/pw_util.c Tue Jan 7 18:08:09 2020 (r356460) +++ stable/11/lib/libutil/pw_util.c Tue Jan 7 18:42:53 2020 (r356461) @@ -654,8 +654,16 @@ pw_dup(const struct passwd *pw) #include "pw_scan.h" /* - * Wrapper around an internal libc function + * Wrapper around some internal libc functions. */ + +void +pw_initpwd(struct passwd *pw) +{ + + __pw_initpwd(pw); +} + struct passwd * pw_scan(const char *line, int flags) { @@ -664,6 +672,7 @@ pw_scan(const char *line, int flags) if ((bp = strdup(line)) == NULL) return (NULL); + __pw_initpwd(&pw); if (!__pw_scan(bp, &pw, flags)) { free(bp); return (NULL); From owner-svn-src-stable-11@freebsd.org Thu Jan 9 01:17:03 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08243222C79; Thu, 9 Jan 2020 01:17:03 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47tSrZ6RvFz4QCl; Thu, 9 Jan 2020 01:17:02 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D858720F49; Thu, 9 Jan 2020 01:17:02 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0091H2qa057099; Thu, 9 Jan 2020 01:17:02 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0091H1Wk057094; Thu, 9 Jan 2020 01:17:01 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <202001090117.0091H1Wk057094@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Thu, 9 Jan 2020 01:17:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356533 - in stable/11: contrib/mtree contrib/netbsd-tests/usr.sbin/mtree usr.sbin/fmtree X-SVN-Group: stable-11 X-SVN-Commit-Author: bdrewery X-SVN-Commit-Paths: in stable/11: contrib/mtree contrib/netbsd-tests/usr.sbin/mtree usr.sbin/fmtree X-SVN-Commit-Revision: 356533 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jan 2020 01:17:03 -0000 Author: bdrewery Date: Thu Jan 9 01:17:01 2020 New Revision: 356533 URL: https://svnweb.freebsd.org/changeset/base/356533 Log: MFC r352261,r352262,r352265: r352261: mtree: Fix -f -f not considering type changes. r352262: mtree -c: Fix username logic when getlogin(3) fails. r352265: mtree -O: Fix not descending on hash collisions Relnotes: yes Modified: stable/11/contrib/mtree/create.c stable/11/contrib/mtree/only.c stable/11/contrib/mtree/specspec.c stable/11/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh stable/11/usr.sbin/fmtree/specspec.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/mtree/create.c ============================================================================== --- stable/11/contrib/mtree/create.c Thu Jan 9 01:14:26 2020 (r356532) +++ stable/11/contrib/mtree/create.c Thu Jan 9 01:17:01 2020 (r356533) @@ -117,7 +117,7 @@ cwalk(FILE *fp) host[sizeof(host) - 1] = '\0'; if ((user = getlogin()) == NULL) { struct passwd *pw; - user = (pw = getpwuid(getuid())) == NULL ? pw->pw_name : + user = (pw = getpwuid(getuid())) != NULL ? pw->pw_name : ""; } Modified: stable/11/contrib/mtree/only.c ============================================================================== --- stable/11/contrib/mtree/only.c Thu Jan 9 01:14:26 2020 (r356532) +++ stable/11/contrib/mtree/only.c Thu Jan 9 01:17:01 2020 (r356533) @@ -1,4 +1,4 @@ -/* $NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $ */ +/* $NetBSD: only.c,v 1.3 2017/09/07 04:04:13 nakayama Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $"); +__RCSID("$NetBSD: only.c,v 1.3 2017/09/07 04:04:13 nakayama Exp $"); #endif #include @@ -89,11 +89,14 @@ static void hash_insert(char *str, uint32_t h) { struct hentry *e; + char *x; if ((e = malloc(sizeof(*e))) == NULL) mtree_err("memory allocation error"); + if ((x = strdup(str)) == NULL) + mtree_err("memory allocation error"); - e->str = str; + e->str = x; e->hash = h; e->next = table[h]; table[h] = e; @@ -110,10 +113,7 @@ fill(char *str) *ptr = '\0'; if (!hash_find(str, &h)) { - char *x = strdup(str); - if (x == NULL) - mtree_err("memory allocation error"); - hash_insert(x, h); + hash_insert(str, h); fill(str); } *ptr = '/'; @@ -135,6 +135,7 @@ load_only(const char *fname) err(1, "Duplicate entry %s", line); hash_insert(line, h); fill(line); + free(line); } fclose(fp); Modified: stable/11/contrib/mtree/specspec.c ============================================================================== --- stable/11/contrib/mtree/specspec.c Thu Jan 9 01:14:26 2020 (r356532) +++ stable/11/contrib/mtree/specspec.c Thu Jan 9 01:17:01 2020 (r356533) @@ -145,7 +145,7 @@ compare_nodes(NODE *n1, NODE *n2, char const *path) return (1); } if (n1->type != n2->type) { - differs = 0; + differs = F_TYPE; mismatch(n1, n2, differs, path); return (1); } Modified: stable/11/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh Thu Jan 9 01:14:26 2020 (r356532) +++ stable/11/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh Thu Jan 9 01:17:01 2020 (r356533) @@ -411,7 +411,42 @@ netbsd6_nonemptydir_body() FLAVOR=netbsd6 nonemptydir_body } +atf_test_case mtree_specspec_type +mtree_specspec_type_head() +{ + atf_set "descr" "Test that spec comparisons detect type changes" +} +mtree_specspec_type_body() +{ + mkdir testdir + + touch testdir/bar + mtree -c -p testdir > mtree1.spec + + if [ ! -f mtree1.spec ]; then + atf_fail "mtree failed" + fi + + rm -f testdir/bar + ln -s foo testdir/bar + # uid change is expected to be ignored as done in -C + chown -h operator testdir/bar + mtree -c -p testdir > mtree2.spec + + if [ ! -f mtree2.spec ]; then + atf_fail "mtree failed" + fi + + atf_check -s ignore -o save:output \ + -x "mtree -f mtree1.spec -f mtree2.spec" + + if ! cut -f 3 output | egrep -q "bar file" || \ + ! cut -f 3 output | egrep -q "bar link"; then + atf_fail "mtree did not detect type change" + fi +} + atf_init_test_cases() { atf_add_test_case mtree_create @@ -423,6 +458,7 @@ atf_init_test_cases() atf_add_test_case mtree_ignore atf_add_test_case mtree_merge atf_add_test_case mtree_nonemptydir + atf_add_test_case mtree_specspec_type atf_add_test_case netbsd6_create atf_add_test_case netbsd6_check Modified: stable/11/usr.sbin/fmtree/specspec.c ============================================================================== --- stable/11/usr.sbin/fmtree/specspec.c Thu Jan 9 01:14:26 2020 (r356532) +++ stable/11/usr.sbin/fmtree/specspec.c Thu Jan 9 01:17:01 2020 (r356533) @@ -132,7 +132,7 @@ compare_nodes(NODE *n1, NODE *n2, char const *path) return (1); } if (n1->type != n2->type) { - differs = 0; + differs = F_TYPE; mismatch(n1, n2, differs, path); return (1); } From owner-svn-src-stable-11@freebsd.org Thu Jan 9 09:30:14 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C77B522EFCD; Thu, 9 Jan 2020 09:30:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47tgnf4zD4z3MKH; Thu, 9 Jan 2020 09:30:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A435526A18; Thu, 9 Jan 2020 09:30:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0099UEal050401; Thu, 9 Jan 2020 09:30:14 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0099UEug050400; Thu, 9 Jan 2020 09:30:14 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202001090930.0099UEug050400@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 9 Jan 2020 09:30:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356546 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 356546 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jan 2020 09:30:14 -0000 Author: kib Date: Thu Jan 9 09:30:14 2020 New Revision: 356546 URL: https://svnweb.freebsd.org/changeset/base/356546 Log: MFC r356292: Style: remove trailing spaces/tabs. Modified: stable/11/sys/kern/kern_umtx.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_umtx.c ============================================================================== --- stable/11/sys/kern/kern_umtx.c Thu Jan 9 09:29:24 2020 (r356545) +++ stable/11/sys/kern/kern_umtx.c Thu Jan 9 09:30:14 2020 (r356546) @@ -94,7 +94,7 @@ struct umtx_pi { /* Reference count */ int pi_refcount; - /* List entry to link umtx holding by thread */ + /* List entry to link umtx holding by thread */ TAILQ_ENTRY(umtx_pi) pi_link; /* List entry in hash */ @@ -137,7 +137,7 @@ struct umtx_q { /* Inherited priority from PP mutex */ u_char uq_inherited_pri; - + /* Spare queue ready to be reused */ struct umtxq_queue *uq_spare_queue; @@ -179,7 +179,7 @@ struct umtxq_chain { TAILQ_HEAD(,umtx_pi) uc_pi_list; #ifdef UMTX_PROFILING - u_int length; + u_int length; u_int max_length; #endif }; @@ -289,7 +289,7 @@ static struct mtx umtx_lock; #ifdef UMTX_PROFILING static void -umtx_init_profiling(void) +umtx_init_profiling(void) { struct sysctl_oid *chain_oid; char chain_name[10]; @@ -297,8 +297,8 @@ umtx_init_profiling(void) for (i = 0; i < UMTX_CHAINS; ++i) { snprintf(chain_name, sizeof(chain_name), "%d", i); - chain_oid = SYSCTL_ADD_NODE(NULL, - SYSCTL_STATIC_CHILDREN(_debug_umtx_chains), OID_AUTO, + chain_oid = SYSCTL_ADD_NODE(NULL, + SYSCTL_STATIC_CHILDREN(_debug_umtx_chains), OID_AUTO, chain_name, CTLFLAG_RD, NULL, "umtx hash stats"); SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(chain_oid), OID_AUTO, "max_length0", CTLFLAG_RD, &umtxq_chains[0][i].max_length, 0, NULL); @@ -403,7 +403,7 @@ sysctl_debug_umtx_chains_clear(SYSCTL_HANDLER_ARGS) uc = &umtxq_chains[i][j]; mtx_lock(&uc->uc_lock); uc->length = 0; - uc->max_length = 0; + uc->max_length = 0; mtx_unlock(&uc->uc_lock); } } @@ -438,7 +438,7 @@ umtxq_sysinit(void *arg __unused) umtxq_chains[i][j].uc_waiters = 0; #ifdef UMTX_PROFILING umtxq_chains[i][j].length = 0; - umtxq_chains[i][j].max_length = 0; + umtxq_chains[i][j].max_length = 0; #endif } } @@ -610,7 +610,7 @@ umtxq_insert_queue(struct umtx_q *uq, int q) if (uc->length > uc->max_length) { uc->max_length = uc->length; if (uc->max_length > max_length) - max_length = uc->max_length; + max_length = uc->max_length; } #endif } @@ -759,7 +759,7 @@ umtxq_signal_thread(struct umtx_q *uq) wakeup(uq); } -static inline int +static inline int tstohz(const struct timespec *tsp) { struct timeval tv; @@ -815,7 +815,7 @@ abs_timeout_gethz(struct abs_timeout *timo) struct timespec tts; if (timespeccmp(&timo->end, &timo->cur, <=)) - return (-1); + return (-1); tts = timo->end; timespecsub(&tts, &timo->cur); return (tstohz(&tts)); @@ -1000,7 +1000,7 @@ kern_umtx_wake(struct thread *td, void *uaddr, int n_w { struct umtx_key key; int ret; - + if ((ret = umtx_key_get(uaddr, TYPE_SIMPLE_WAIT, is_private ? THREAD_SHARE : AUTO_SHARE, &key)) != 0) return (ret); @@ -1483,7 +1483,7 @@ umtx_pi_check_loop(struct umtx_pi *pi) /* * Propagate priority when a thread is blocked on POSIX * PI mutex. - */ + */ static void umtx_propagate_priority(struct thread *td) { @@ -1734,7 +1734,7 @@ umtx_pi_ref(struct umtx_pi *pi) /* * Decrease reference count for a PI mutex, if the counter * is decreased to zero, its memory space is freed. - */ + */ static void umtx_pi_unref(struct umtx_pi *pi) { @@ -1919,7 +1919,7 @@ do_lock_pi(struct thread *td, struct umutex *m, uint32 */ if (error != 0) break; - + umtxq_lock(&uq->uq_key); umtxq_busy(&uq->uq_key); umtxq_unlock(&uq->uq_key); @@ -2033,7 +2033,7 @@ do_unlock_pi(struct thread *td, struct umutex *m, uint umtx_pi_disown(pi); /* get highest priority thread which is still sleeping. */ uq_first = TAILQ_FIRST(&pi->pi_blocked); - while (uq_first != NULL && + while (uq_first != NULL && (uq_first->uq_flags & UQF_UMTXQ) == 0) { uq_first = TAILQ_NEXT(uq_first, uq_lockq); } @@ -2534,7 +2534,7 @@ do_cv_wait(struct thread *td, struct ucond *cv, struct if (timeout != NULL) abs_timeout_init(&timo, clockid, (wflags & CVWAIT_ABSTIME) != 0, timeout); - + umtxq_lock(&uq->uq_key); if (error == 0) { error = umtxq_sleep(uq, "ucond", timeout == NULL ? @@ -2583,7 +2583,7 @@ do_cv_signal(struct thread *td, struct ucond *cv) if (error == -1) return (EFAULT); if ((error = umtx_key_get(cv, TYPE_CV, GET_SHARE(flags), &key)) != 0) - return (error); + return (error); umtxq_lock(&key); umtxq_busy(&key); cnt = umtxq_count(&key); @@ -2612,7 +2612,7 @@ do_cv_broadcast(struct thread *td, struct ucond *cv) if (error == -1) return (EFAULT); if ((error = umtx_key_get(cv, TYPE_CV, GET_SHARE(flags), &key)) != 0) - return (error); + return (error); umtxq_lock(&key); umtxq_busy(&key); @@ -3022,7 +3022,7 @@ do_rw_unlock(struct thread *td, struct urwlock *rwlock } if (state & URWLOCK_WRITE_OWNER) { for (;;) { - rv = casueword32(&rwlock->rw_state, state, + rv = casueword32(&rwlock->rw_state, state, &oldstate, state & ~URWLOCK_WRITE_OWNER); if (rv == -1) { error = EFAULT; @@ -3165,7 +3165,7 @@ do_sem_wake(struct thread *td, struct _usem *sem) if (error == -1) return (EFAULT); if ((error = umtx_key_get(sem, TYPE_SEM, GET_SHARE(flags), &key)) != 0) - return (error); + return (error); umtxq_lock(&key); umtxq_busy(&key); cnt = umtxq_count(&key); @@ -3283,7 +3283,7 @@ do_sem2_wake(struct thread *td, struct _usem2 *sem) if (rv == -1) return (EFAULT); if ((error = umtx_key_get(sem, TYPE_SEM, GET_SHARE(flags), &key)) != 0) - return (error); + return (error); umtxq_lock(&key); umtxq_busy(&key); cnt = umtxq_count(&key); @@ -3330,12 +3330,12 @@ static inline int umtx_copyin_umtx_time(const void *addr, size_t size, struct _umtx_time *tp) { int error; - + if (size <= sizeof(struct timespec)) { tp->_clockid = CLOCK_REALTIME; tp->_flags = 0; error = copyin(addr, &tp->_timeout, sizeof(struct timespec)); - } else + } else error = copyin(addr, tp, sizeof(struct _umtx_time)); if (error != 0) return (error); @@ -3569,7 +3569,7 @@ __umtx_op_rw_wrlock(struct thread *td, struct _umtx_op if (uap->uaddr2 == NULL) { error = do_rw_wrlock(td, uap->obj, 0); } else { - error = umtx_copyin_umtx_time(uap->uaddr2, + error = umtx_copyin_umtx_time(uap->uaddr2, (size_t)uap->uaddr1, &timeout); if (error != 0) return (error); @@ -4074,12 +4074,12 @@ umtx_copyin_umtx_time32(const void *addr, size_t size, { struct umtx_time32 t32; int error; - + t32.clockid = CLOCK_REALTIME; t32.flags = 0; if (size <= sizeof(struct timespec32)) error = copyin(addr, &t32.timeout, sizeof(struct timespec32)); - else + else error = copyin(addr, &t32, sizeof(struct umtx_time32)); if (error != 0) return (error); @@ -4140,7 +4140,7 @@ __umtx_op_wait_umutex_compat32(struct thread *td, stru if (uap->uaddr2 == NULL) tm_p = NULL; else { - error = umtx_copyin_umtx_time32(uap->uaddr2, + error = umtx_copyin_umtx_time32(uap->uaddr2, (size_t)uap->uaddr1, &timeout); if (error != 0) return (error); From owner-svn-src-stable-11@freebsd.org Thu Jan 9 09:47:24 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8905E22F5D7; Thu, 9 Jan 2020 09:47:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47th9S2d7vz3NCM; Thu, 9 Jan 2020 09:47:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 555FF26DBF; Thu, 9 Jan 2020 09:47:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0099lOH1062337; Thu, 9 Jan 2020 09:47:24 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0099lOPa062336; Thu, 9 Jan 2020 09:47:24 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202001090947.0099lOPa062336@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 9 Jan 2020 09:47:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356547 - stable/11/libexec/rtld-elf X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/libexec/rtld-elf X-SVN-Commit-Revision: 356547 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jan 2020 09:47:24 -0000 Author: kib Date: Thu Jan 9 09:47:23 2020 New Revision: 356547 URL: https://svnweb.freebsd.org/changeset/base/356547 Log: MFC r356300, r356503: Fix AT_EXECPATH for direct exec mode. Modified: stable/11/libexec/rtld-elf/rtld.c Directory Properties: stable/11/ (props changed) Modified: stable/11/libexec/rtld-elf/rtld.c ============================================================================== --- stable/11/libexec/rtld-elf/rtld.c Thu Jan 9 09:30:14 2020 (r356546) +++ stable/11/libexec/rtld-elf/rtld.c Thu Jan 9 09:47:23 2020 (r356547) @@ -123,7 +123,8 @@ static void objlist_push_head(Objlist *, Obj_Entry *); static void objlist_push_tail(Objlist *, Obj_Entry *); static void objlist_put_after(Objlist *, Obj_Entry *, Obj_Entry *); static void objlist_remove(Objlist *, Obj_Entry *); -static int open_binary_fd(const char *argv0, bool search_in_path); +static int open_binary_fd(const char *argv0, bool search_in_path, + const char **binpath_res); static int parse_args(char* argv[], int argc, bool *use_pathp, int *fdp); static int parse_integer(const char *); static void *path_enumerate(const char *, path_enum_proc, const char *, void *); @@ -362,6 +363,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entr struct stat st; Elf_Addr *argcp; char **argv, *argv0, **env, **envp, *kexecpath, *library_path_rpath; + const char *binpath; caddr_t imgentry; char buf[MAXPATHLEN]; int argc, fd, i, mib[2], phnum, rtld_argc; @@ -445,8 +447,9 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entr rtld_argc = parse_args(argv, argc, &search_in_path, &fd); argv0 = argv[rtld_argc]; explicit_fd = (fd != -1); + binpath = NULL; if (!explicit_fd) - fd = open_binary_fd(argv0, search_in_path); + fd = open_binary_fd(argv0, search_in_path, &binpath); if (fstat(fd, &st) == -1) { _rtld_error("failed to fstat FD %d (%s): %s", fd, explicit_fd ? "user-provided descriptor" : argv0, @@ -499,11 +502,24 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entr } while (*envp != NULL); aux = auxp = (Elf_Auxinfo *)envp; auxpf = (Elf_Auxinfo *)(envp + rtld_argc); + /* XXXKIB insert place for AT_EXECPATH if not present */ for (;; auxp++, auxpf++) { *auxp = *auxpf; if (auxp->a_type == AT_NULL) break; } + + /* Point AT_EXECPATH auxv and aux_info to the binary path. */ + if (binpath == NULL) { + aux_info[AT_EXECPATH] = NULL; + } else { + if (aux_info[AT_EXECPATH] == NULL) { + aux_info[AT_EXECPATH] = xmalloc(sizeof(Elf_Auxinfo)); + aux_info[AT_EXECPATH]->a_type = AT_EXECPATH; + } + aux_info[AT_EXECPATH]->a_un.a_ptr = __DECONST(void *, + binpath); + } } else { rtld_printf("no binary\n"); rtld_die(); @@ -5392,12 +5408,14 @@ symlook_init_from_req(SymLook *dst, const SymLook *src } static int -open_binary_fd(const char *argv0, bool search_in_path) +open_binary_fd(const char *argv0, bool search_in_path, + const char **binpath_res) { - char *pathenv, *pe, binpath[PATH_MAX]; + char *pathenv, *pe, *binpath; int fd; if (search_in_path && strchr(argv0, '/') == NULL) { + binpath = xmalloc(PATH_MAX); pathenv = getenv("PATH"); if (pathenv == NULL) { rtld_printf("-p and no PATH environment variable\n"); @@ -5411,24 +5429,25 @@ open_binary_fd(const char *argv0, bool search_in_path) fd = -1; errno = ENOENT; while ((pe = strsep(&pathenv, ":")) != NULL) { - if (strlcpy(binpath, pe, sizeof(binpath)) >= - sizeof(binpath)) + if (strlcpy(binpath, pe, PATH_MAX) >= PATH_MAX) continue; if (binpath[0] != '\0' && - strlcat(binpath, "/", sizeof(binpath)) >= - sizeof(binpath)) + strlcat(binpath, "/", PATH_MAX) >= PATH_MAX) continue; - if (strlcat(binpath, argv0, sizeof(binpath)) >= - sizeof(binpath)) + if (strlcat(binpath, argv0, PATH_MAX) >= PATH_MAX) continue; fd = open(binpath, O_RDONLY | O_CLOEXEC | O_VERIFY); - if (fd != -1 || errno != ENOENT) + if (fd != -1 || errno != ENOENT) { + *binpath_res = binpath; break; + } } free(pathenv); } else { fd = open(argv0, O_RDONLY | O_CLOEXEC | O_VERIFY); + *binpath_res = argv0; } + /* XXXKIB Use getcwd() to resolve relative binpath to absolute. */ if (fd == -1) { rtld_printf("Opening %s: %s\n", argv0, From owner-svn-src-stable-11@freebsd.org Thu Jan 9 19:58:05 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ABEF41F78BD; Thu, 9 Jan 2020 19:58:05 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47txk542Wfz4ch0; Thu, 9 Jan 2020 19:58:05 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 85C8964CD; Thu, 9 Jan 2020 19:58:05 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 009Jw5Kt037445; Thu, 9 Jan 2020 19:58:05 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 009Jw56r037444; Thu, 9 Jan 2020 19:58:05 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <202001091958.009Jw56r037444@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Thu, 9 Jan 2020 19:58:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356566 - stable/11/contrib/smbfs/lib/smb X-SVN-Group: stable-11 X-SVN-Commit-Author: bapt X-SVN-Commit-Paths: stable/11/contrib/smbfs/lib/smb X-SVN-Commit-Revision: 356566 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jan 2020 19:58:05 -0000 Author: bapt Date: Thu Jan 9 19:58:05 2020 New Revision: 356566 URL: https://svnweb.freebsd.org/changeset/base/356566 Log: MFC r356317 (by arrowd): mount_smbfs: Issue a warning when .nsmbrc section name contains lowercase characters. PR: 231656 Approved by: bapt Differential Revision: https://reviews.freebsd.org/D22289 Modified: stable/11/contrib/smbfs/lib/smb/rcfile.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/smbfs/lib/smb/rcfile.c ============================================================================== --- stable/11/contrib/smbfs/lib/smb/rcfile.c Thu Jan 9 19:56:25 2020 (r356565) +++ stable/11/contrib/smbfs/lib/smb/rcfile.c Thu Jan 9 19:58:05 2020 (r356566) @@ -156,11 +156,19 @@ static struct rcsection * rc_addsect(struct rcfile *rcp, const char *sectname) { struct rcsection *p; + const char* sectletter = sectname; p = rc_findsect(rcp, sectname); if (p) return p; p = malloc(sizeof(*p)); if (!p) return NULL; + for(sectletter = sectname; *sectletter; sectletter++) { + if (islower(*sectletter)) { + if (strcmp(sectname, "default")) + dprintf(STDERR_FILENO, "warning: section name [%s] contains lower-case letters\n", sectname); + break; + } + } p->rs_name = strdup(sectname); SLIST_INIT(&p->rs_keys); SLIST_INSERT_HEAD(&rcp->rf_sect, p, rs_next); From owner-svn-src-stable-11@freebsd.org Thu Jan 9 21:40:59 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E70601FA5EE; Thu, 9 Jan 2020 21:40:59 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47v00q5wBMz3GlV; Thu, 9 Jan 2020 21:40:59 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C33A378C9; Thu, 9 Jan 2020 21:40:59 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 009LexXI099092; Thu, 9 Jan 2020 21:40:59 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 009Lexqh099091; Thu, 9 Jan 2020 21:40:59 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <202001092140.009Lexqh099091@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Thu, 9 Jan 2020 21:40:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356572 - stable/11/stand/i386/libi386 X-SVN-Group: stable-11 X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: stable/11/stand/i386/libi386 X-SVN-Commit-Revision: 356572 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jan 2020 21:41:00 -0000 Author: tsoome Date: Thu Jan 9 21:40:59 2020 New Revision: 356572 URL: https://svnweb.freebsd.org/changeset/base/356572 Log: MFC r356570: loader: bioscd probe can get sector size 0 With buggy BIOS, it may happen we get sector size reported 0 for cd, and then the default 512 is used, which is quite wrong. PR: 238749 Modified: stable/11/stand/i386/libi386/biosdisk.c Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/i386/libi386/biosdisk.c ============================================================================== --- stable/11/stand/i386/libi386/biosdisk.c Thu Jan 9 21:37:50 2020 (r356571) +++ stable/11/stand/i386/libi386/biosdisk.c Thu Jan 9 21:40:59 2020 (r356572) @@ -380,7 +380,8 @@ bc_add(int biosdev) return (-1); bd->bd_flags = BD_CDROM; - bd->bd_unit = biosdev; + bd->bd_unit = biosdev; + bd->bd_sectorsize = 2048; /* * Ignore result from bd_int13probe(), we will use local @@ -548,7 +549,8 @@ bd_int13probe(bdinfo_t *bd) bd->bd_flags |= BD_MODEEDD3; /* Default sector size */ - bd->bd_sectorsize = BIOSDISK_SECSIZE; + if (bd->bd_sectorsize == 0) + bd->bd_sectorsize = BIOSDISK_SECSIZE; /* * Test if the floppy device is present, so we can avoid receiving From owner-svn-src-stable-11@freebsd.org Thu Jan 9 21:50:16 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 092191FAA4E; Thu, 9 Jan 2020 21:50:16 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47v0CW6MzQz3HNx; Thu, 9 Jan 2020 21:50:15 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D13227AA4; Thu, 9 Jan 2020 21:50:15 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 009LoF3S005434; Thu, 9 Jan 2020 21:50:15 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 009LoFoC005433; Thu, 9 Jan 2020 21:50:15 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <202001092150.009LoFoC005433@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Thu, 9 Jan 2020 21:50:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356573 - in stable: 11/release 12/release X-SVN-Group: stable-11 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: in stable: 11/release 12/release X-SVN-Commit-Revision: 356573 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jan 2020 21:50:16 -0000 Author: gjb Date: Thu Jan 9 21:50:15 2020 New Revision: 356573 URL: https://svnweb.freebsd.org/changeset/base/356573 Log: MFC r353440: Increase the default VMSIZE for raw, qcow2, vhd, and vmdk virtual machine images due to 'filesystem full' failures. Sponsored by: Rubicon Communications, LLC (netgate.com) Modified: stable/11/release/Makefile.vm Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/release/Makefile.vm Directory Properties: stable/12/ (props changed) Modified: stable/11/release/Makefile.vm ============================================================================== --- stable/11/release/Makefile.vm Thu Jan 9 21:40:59 2020 (r356572) +++ stable/11/release/Makefile.vm Thu Jan 9 21:50:15 2020 (r356573) @@ -7,7 +7,7 @@ VMTARGETS= vm-image VMFORMATS?= vhd vmdk qcow2 raw -VMSIZE?= 3072M +VMSIZE?= 4096M SWAPSIZE?= 1G VMBASE?= vm From owner-svn-src-stable-11@freebsd.org Fri Jan 10 00:42:07 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 850561FDE9C; Fri, 10 Jan 2020 00:42:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47v41q2ZGDz3whZ; Fri, 10 Jan 2020 00:42:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 533E09CA2; Fri, 10 Jan 2020 00:42:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00A0g7v7016546; Fri, 10 Jan 2020 00:42:07 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00A0g6qj016540; Fri, 10 Jan 2020 00:42:06 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202001100042.00A0g6qj016540@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 10 Jan 2020 00:42:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356577 - stable/11/sys/geom/vinum X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/geom/vinum X-SVN-Commit-Revision: 356577 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 00:42:07 -0000 Author: mav Date: Fri Jan 10 00:42:05 2020 New Revision: 356577 URL: https://svnweb.freebsd.org/changeset/base/356577 Log: MFC r356138: Reimplement gvinum orphanization. gvinum was the only GEOM class, using consumer nstart/nend fields. Making it do its own accounting for orphanization purposes allows in perspective to remove burden of that expensive for SMP accounting from GEOM. Also the previous implementation spinned in a tight event loop, waiting for all active BIOs to complete, while the new one knows exactly when it is possible to close the consumer. Modified: stable/11/sys/geom/vinum/geom_vinum.h stable/11/sys/geom/vinum/geom_vinum_events.c stable/11/sys/geom/vinum/geom_vinum_plex.c stable/11/sys/geom/vinum/geom_vinum_raid5.c stable/11/sys/geom/vinum/geom_vinum_var.h stable/11/sys/geom/vinum/geom_vinum_volume.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/vinum/geom_vinum.h ============================================================================== --- stable/11/sys/geom/vinum/geom_vinum.h Fri Jan 10 00:41:15 2020 (r356576) +++ stable/11/sys/geom/vinum/geom_vinum.h Fri Jan 10 00:42:05 2020 (r356577) @@ -125,6 +125,7 @@ void gv_post_event(struct gv_softc *, int, void *, voi void gv_worker_exit(struct gv_softc *); struct gv_event *gv_get_event(struct gv_softc *); void gv_remove_event(struct gv_softc *, struct gv_event *); +void gv_drive_done(struct gv_drive *); void gv_drive_tasted(struct gv_softc *, struct g_provider *); void gv_drive_lost(struct gv_softc *, struct gv_drive *); void gv_setup_objects(struct gv_softc *); Modified: stable/11/sys/geom/vinum/geom_vinum_events.c ============================================================================== --- stable/11/sys/geom/vinum/geom_vinum_events.c Fri Jan 10 00:41:15 2020 (r356576) +++ stable/11/sys/geom/vinum/geom_vinum_events.c Fri Jan 10 00:42:05 2020 (r356577) @@ -192,6 +192,20 @@ failed: } /* + * Count completed BIOs and handle orphanization when all are done. + */ +void +gv_drive_done(struct gv_drive *d) +{ + + KASSERT(d->active >= 0, ("Negative number of BIOs (%d)", d->active)); + if (--d->active == 0 && (d->flags & GV_DRIVE_ORPHANED)) { + d->flags &= ~GV_DRIVE_ORPHANED; + gv_post_event(d->vinumconf, GV_EVENT_DRIVE_LOST, d, NULL, 0, 0); + } +} + +/* * When losing a drive (e.g. hardware failure), we cut down the consumer * attached to the underlying device and bring the drive itself to a * "referenced" state so that normal tasting could bring it up cleanly if it @@ -211,10 +225,10 @@ gv_drive_lost(struct gv_softc *sc, struct gv_drive *d) cp = d->consumer; if (cp != NULL) { - if (cp->nstart != cp->nend) { - G_VINUM_DEBUG(0, "dead drive '%s' has still active " + if (d->active > 0) { + G_VINUM_DEBUG(2, "dead drive '%s' has still active " "requests, unable to detach consumer", d->name); - gv_post_event(sc, GV_EVENT_DRIVE_LOST, d, NULL, 0, 0); + d->flags |= GV_DRIVE_ORPHANED; return; } g_topology_lock(); Modified: stable/11/sys/geom/vinum/geom_vinum_plex.c ============================================================================== --- stable/11/sys/geom/vinum/geom_vinum_plex.c Fri Jan 10 00:41:15 2020 (r356576) +++ stable/11/sys/geom/vinum/geom_vinum_plex.c Fri Jan 10 00:42:05 2020 (r356577) @@ -275,6 +275,7 @@ gv_plex_normal_request(struct gv_plex *p, struct bio * cbp->bio_data = addr; cbp->bio_done = gv_done; cbp->bio_caller1 = s; + s->drive_sc->active++; /* Store the sub-requests now and let others issue them. */ bioq_insert_tail(p->bqueue, cbp); @@ -577,10 +578,10 @@ gv_sync_request(struct gv_plex *from, struct gv_plex * return (ENOMEM); } bp->bio_length = length; - bp->bio_done = gv_done; + bp->bio_done = NULL; bp->bio_pflags |= GV_BIO_SYNCREQ; bp->bio_offset = offset; - bp->bio_caller1 = from; + bp->bio_caller1 = from; bp->bio_caller2 = to; bp->bio_cmd = type; if (data == NULL) @@ -691,7 +692,7 @@ gv_grow_request(struct gv_plex *p, off_t offset, off_t } bp->bio_cmd = type; - bp->bio_done = gv_done; + bp->bio_done = NULL; bp->bio_error = 0; bp->bio_caller1 = p; bp->bio_offset = offset; @@ -799,7 +800,7 @@ gv_init_request(struct gv_sd *s, off_t start, caddr_t } bp->bio_cmd = BIO_WRITE; bp->bio_data = data; - bp->bio_done = gv_done; + bp->bio_done = NULL; bp->bio_error = 0; bp->bio_length = length; bp->bio_pflags |= GV_BIO_INIT; @@ -816,6 +817,7 @@ gv_init_request(struct gv_sd *s, off_t start, caddr_t } cbp->bio_done = gv_done; cbp->bio_caller1 = s; + d->active++; /* Send it off to the consumer. */ g_io_request(cbp, cp); } @@ -902,7 +904,7 @@ gv_parity_request(struct gv_plex *p, int flags, off_t } bp->bio_cmd = BIO_WRITE; - bp->bio_done = gv_done; + bp->bio_done = NULL; bp->bio_error = 0; bp->bio_length = p->stripesize; bp->bio_caller1 = p; Modified: stable/11/sys/geom/vinum/geom_vinum_raid5.c ============================================================================== --- stable/11/sys/geom/vinum/geom_vinum_raid5.c Fri Jan 10 00:41:15 2020 (r356576) +++ stable/11/sys/geom/vinum/geom_vinum_raid5.c Fri Jan 10 00:42:05 2020 (r356577) @@ -90,11 +90,13 @@ gv_raid5_start(struct gv_plex *p, struct bio *bp, cadd if (wp->waiting != NULL) { if (wp->waiting->bio_cflags & GV_BIO_MALLOC) g_free(wp->waiting->bio_data); + gv_drive_done(wp->waiting->bio_caller1); g_destroy_bio(wp->waiting); } if (wp->parity != NULL) { if (wp->parity->bio_cflags & GV_BIO_MALLOC) g_free(wp->parity->bio_data); + gv_drive_done(wp->parity->bio_caller1); g_destroy_bio(wp->parity); } g_free(wp); @@ -115,6 +117,7 @@ gv_raid5_start(struct gv_plex *p, struct bio *bp, cadd while (cbp != NULL) { if (cbp->bio_cflags & GV_BIO_MALLOC) g_free(cbp->bio_data); + gv_drive_done(cbp->bio_caller1); g_destroy_bio(cbp); cbp = bioq_takefirst(p->bqueue); } @@ -654,6 +657,7 @@ gv_raid5_clone_bio(struct bio *bp, struct gv_sd *s, st cbp->bio_length = wp->length; cbp->bio_done = gv_done; cbp->bio_caller1 = s; + s->drive_sc->active++; if (use_wp) cbp->bio_caller2 = wp; Modified: stable/11/sys/geom/vinum/geom_vinum_var.h ============================================================================== --- stable/11/sys/geom/vinum/geom_vinum_var.h Fri Jan 10 00:41:15 2020 (r356576) +++ stable/11/sys/geom/vinum/geom_vinum_var.h Fri Jan 10 00:42:05 2020 (r356577) @@ -258,10 +258,12 @@ struct gv_drive { #define GV_DRIVE_REFERENCED 0x01 /* The drive isn't really existing, but was referenced by a subdisk during taste. */ +#define GV_DRIVE_ORPHANED 0x02 /* The drive was orphaned. */ struct gv_hdr *hdr; /* The drive header. */ struct g_consumer *consumer; /* Consumer attached to this drive. */ + int active; /* Number of active requests. */ int freelist_entries; /* Count of freelist entries. */ LIST_HEAD(,gv_freelist) freelist; /* List of freelist entries. */ Modified: stable/11/sys/geom/vinum/geom_vinum_volume.c ============================================================================== --- stable/11/sys/geom/vinum/geom_vinum_volume.c Fri Jan 10 00:41:15 2020 (r356576) +++ stable/11/sys/geom/vinum/geom_vinum_volume.c Fri Jan 10 00:42:05 2020 (r356577) @@ -161,4 +161,6 @@ gv_bio_done(struct gv_softc *sc, struct bio *bp) gv_plex_raid5_done(p, bp); break; } + + gv_drive_done(s->drive_sc); } From owner-svn-src-stable-11@freebsd.org Fri Jan 10 00:43:08 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F36E11FDF75; Fri, 10 Jan 2020 00:43:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47v4306FC2z3wxR; Fri, 10 Jan 2020 00:43:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D186E9CCA; Fri, 10 Jan 2020 00:43:08 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00A0h8TG016712; Fri, 10 Jan 2020 00:43:08 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00A0h8mm016711; Fri, 10 Jan 2020 00:43:08 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202001100043.00A0h8mm016711@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 10 Jan 2020 00:43:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356579 - stable/11/sys/geom/uzip X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/geom/uzip X-SVN-Commit-Revision: 356579 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 00:43:09 -0000 Author: mav Date: Fri Jan 10 00:43:08 2020 New Revision: 356579 URL: https://svnweb.freebsd.org/changeset/base/356579 Log: MFC r356138: Fix GEOM_UZIP orphanization. Previous code destroyed softc even with provider still open, that resulted in panic under load. This change postpones the free till the final close, when we know for sure there will be no more I/O requests. Modified: stable/11/sys/geom/uzip/g_uzip.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/uzip/g_uzip.c ============================================================================== --- stable/11/sys/geom/uzip/g_uzip.c Fri Jan 10 00:42:39 2020 (r356578) +++ stable/11/sys/geom/uzip/g_uzip.c Fri Jan 10 00:43:08 2020 (r356579) @@ -137,13 +137,12 @@ static void g_uzip_read_done(struct bio *bp); static void g_uzip_do(struct g_uzip_softc *, struct bio *bp); static void -g_uzip_softc_free(struct g_uzip_softc *sc, struct g_geom *gp) +g_uzip_softc_free(struct g_geom *gp) { + struct g_uzip_softc *sc = gp->softc; - if (gp != NULL) { - DPRINTF(GUZ_DBG_INFO, ("%s: %d requests, %d cached\n", - gp->name, sc->req_total, sc->req_cached)); - } + DPRINTF(GUZ_DBG_INFO, ("%s: %d requests, %d cached\n", + gp->name, sc->req_total, sc->req_cached)); mtx_lock(&sc->queue_mtx); sc->wrkthr_flags |= GUZ_SHUTDOWN; @@ -160,6 +159,7 @@ g_uzip_softc_free(struct g_uzip_softc *sc, struct g_ge mtx_destroy(&sc->last_mtx); free(sc->last_buf, M_GEOM_UZIP); free(sc, M_GEOM_UZIP); + gp->softc = NULL; } static int @@ -480,20 +480,35 @@ g_uzip_orphan(struct g_consumer *cp) { struct g_geom *gp; - g_trace(G_T_TOPOLOGY, "%s(%p/%s)", __func__, cp, cp->provider->name); g_topology_assert(); - + G_VALID_CONSUMER(cp); gp = cp->geom; - g_uzip_softc_free(gp->softc, gp); - gp->softc = NULL; + g_trace(G_T_TOPOLOGY, "%s(%p/%s)", __func__, cp, gp->name); g_wither_geom(gp, ENXIO); + + /* + * We can safely free the softc now if there are no accesses, + * otherwise g_uzip_access() will do that after the last close. + */ + if ((cp->acr + cp->acw + cp->ace) == 0) + g_uzip_softc_free(gp); } +static void +g_uzip_spoiled(struct g_consumer *cp) +{ + + g_trace(G_T_TOPOLOGY, "%s(%p/%s)", __func__, cp, cp->geom->name); + cp->flags |= G_CF_ORPHAN; + g_uzip_orphan(cp); +} + static int g_uzip_access(struct g_provider *pp, int dr, int dw, int de) { struct g_geom *gp; struct g_consumer *cp; + int error; gp = pp->geom; cp = LIST_FIRST(&gp->consumer); @@ -502,22 +517,17 @@ g_uzip_access(struct g_provider *pp, int dr, int dw, i if (cp->acw + dw > 0) return (EROFS); - return (g_access(cp, dr, dw, de)); -} + error = g_access(cp, dr, dw, de); -static void -g_uzip_spoiled(struct g_consumer *cp) -{ - struct g_geom *gp; + /* + * Free the softc if all providers have been closed and this geom + * is being removed. + */ + if (error == 0 && (gp->flags & G_GEOM_WITHER) != 0 && + (cp->acr + cp->acw + cp->ace) == 0) + g_uzip_softc_free(gp); - G_VALID_CONSUMER(cp); - gp = cp->geom; - g_trace(G_T_TOPOLOGY, "%s(%p/%s)", __func__, cp, gp->name); - g_topology_assert(); - - g_uzip_softc_free(gp->softc, gp); - gp->softc = NULL; - g_wither_geom(gp, ENXIO); + return (error); } static int @@ -878,10 +888,8 @@ g_uzip_destroy_geom(struct gctl_req *req, struct g_cla if (pp->acr > 0 || pp->acw > 0 || pp->ace > 0) return (EBUSY); - g_uzip_softc_free(gp->softc, gp); - gp->softc = NULL; g_wither_geom(gp, ENXIO); - + g_uzip_softc_free(gp); return (0); } From owner-svn-src-stable-11@freebsd.org Fri Jan 10 00:44:07 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E98831FE056; Fri, 10 Jan 2020 00:44:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47v4475v7Xz3xBQ; Fri, 10 Jan 2020 00:44:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C57829CCC; Fri, 10 Jan 2020 00:44:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00A0i7ZW016902; Fri, 10 Jan 2020 00:44:07 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00A0i7XN016900; Fri, 10 Jan 2020 00:44:07 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202001100044.00A0i7XN016900@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 10 Jan 2020 00:44:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356581 - stable/11/sys/geom/gate X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/geom/gate X-SVN-Commit-Revision: 356581 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 00:44:08 -0000 Author: mav Date: Fri Jan 10 00:44:07 2020 New Revision: 356581 URL: https://svnweb.freebsd.org/changeset/base/356581 Log: MFC r356151: Fix GEOM_GATE orphanization. Previous code closed and destroyed direct read consumer even with I/O still in progress. This patch adds locking and request counting to postpone the close till the last of running requests completes. Modified: stable/11/sys/geom/gate/g_gate.c stable/11/sys/geom/gate/g_gate.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/gate/g_gate.c ============================================================================== --- stable/11/sys/geom/gate/g_gate.c Fri Jan 10 00:43:40 2020 (r356580) +++ stable/11/sys/geom/gate/g_gate.c Fri Jan 10 00:44:07 2020 (r356581) @@ -86,6 +86,19 @@ static struct g_gate_softc **g_gate_units; static u_int g_gate_nunits; static struct mtx g_gate_units_lock; +static void +g_gate_detach(void *arg, int flags __unused) +{ + struct g_consumer *cp = arg; + + g_topology_assert(); + G_GATE_DEBUG(1, "Destroying read consumer on provider %s orphan.", + cp->provider->name); + (void)g_access(cp, -1, 0, 0); + g_detach(cp); + g_destroy_consumer(cp); +} + static int g_gate_destroy(struct g_gate_softc *sc, boolean_t force) { @@ -137,6 +150,7 @@ g_gate_destroy(struct g_gate_softc *sc, boolean_t forc g_gate_nunits--; mtx_unlock(&g_gate_units_lock); mtx_destroy(&sc->sc_queue_mtx); + mtx_destroy(&sc->sc_read_mtx); g_topology_lock(); if ((cp = sc->sc_readcons) != NULL) { sc->sc_readcons = NULL; @@ -205,8 +219,11 @@ g_gate_queue_io(struct bio *bp) static void g_gate_done(struct bio *cbp) { + struct g_gate_softc *sc; struct bio *pbp; + struct g_consumer *cp; + cp = cbp->bio_from; pbp = cbp->bio_parent; if (cbp->bio_error == 0) { pbp->bio_completed = cbp->bio_completed; @@ -219,12 +236,20 @@ g_gate_done(struct bio *cbp) pbp->bio_children--; g_gate_queue_io(pbp); } + + sc = cp->geom->softc; + mtx_lock(&sc->sc_read_mtx); + if (--cp->index == 0 && sc->sc_readcons != cp) + g_post_event(g_gate_detach, cp, M_NOWAIT, NULL); + mtx_unlock(&sc->sc_read_mtx); } static void g_gate_start(struct bio *pbp) { struct g_gate_softc *sc; + struct g_consumer *cp; + struct bio *cbp; sc = pbp->bio_to->geom->softc; if (sc == NULL || (sc->sc_flags & G_GATE_FLAG_DESTROY) != 0) { @@ -234,21 +259,26 @@ g_gate_start(struct bio *pbp) G_GATE_LOGREQ(2, pbp, "Request received."); switch (pbp->bio_cmd) { case BIO_READ: - if (sc->sc_readcons != NULL) { - struct bio *cbp; - - cbp = g_clone_bio(pbp); - if (cbp == NULL) { - g_io_deliver(pbp, ENOMEM); - return; - } - cbp->bio_done = g_gate_done; - cbp->bio_offset = pbp->bio_offset + sc->sc_readoffset; - cbp->bio_to = sc->sc_readcons->provider; - g_io_request(cbp, sc->sc_readcons); + if (sc->sc_readcons == NULL) + break; + cbp = g_clone_bio(pbp); + if (cbp == NULL) { + g_io_deliver(pbp, ENOMEM); return; } - break; + mtx_lock(&sc->sc_read_mtx); + if ((cp = sc->sc_readcons) == NULL) { + mtx_unlock(&sc->sc_read_mtx); + g_destroy_bio(cbp); + pbp->bio_children--; + break; + } + cp->index++; + cbp->bio_offset = pbp->bio_offset + sc->sc_readoffset; + mtx_unlock(&sc->sc_read_mtx); + cbp->bio_done = g_gate_done; + g_io_request(cbp, cp); + return; case BIO_DELETE: case BIO_WRITE: case BIO_FLUSH: @@ -374,20 +404,18 @@ g_gate_orphan(struct g_consumer *cp) { struct g_gate_softc *sc; struct g_geom *gp; + int done; g_topology_assert(); gp = cp->geom; sc = gp->softc; - if (sc == NULL) - return; - KASSERT(cp == sc->sc_readcons, ("cp=%p sc_readcons=%p", cp, - sc->sc_readcons)); - sc->sc_readcons = NULL; - G_GATE_DEBUG(1, "Destroying read consumer on provider %s orphan.", - cp->provider->name); - (void)g_access(cp, -1, 0, 0); - g_detach(cp); - g_destroy_consumer(cp); + mtx_lock(&sc->sc_read_mtx); + if (sc->sc_readcons == cp) + sc->sc_readcons = NULL; + done = (cp->index == 0); + mtx_unlock(&sc->sc_read_mtx); + if (done) + g_gate_detach(cp, 0); } static void @@ -480,6 +508,7 @@ g_gate_create(struct g_gate_ctl_create *ggio) bioq_init(&sc->sc_inqueue); bioq_init(&sc->sc_outqueue); mtx_init(&sc->sc_queue_mtx, "gg:queue", NULL, MTX_DEF); + mtx_init(&sc->sc_read_mtx, "gg:read", NULL, MTX_DEF); sc->sc_queue_count = 0; sc->sc_queue_size = ggio->gctl_maxcount; if (sc->sc_queue_size > G_GATE_MAX_QUEUE_SIZE) @@ -593,6 +622,7 @@ fail2: fail1: mtx_unlock(&g_gate_units_lock); mtx_destroy(&sc->sc_queue_mtx); + mtx_destroy(&sc->sc_read_mtx); free(sc, M_GATE); return (error); } @@ -602,7 +632,7 @@ g_gate_modify(struct g_gate_softc *sc, struct g_gate_c { struct g_provider *pp; struct g_consumer *cp; - int error; + int done, error; if ((ggio->gctl_modify & GG_MODIFY_MEDIASIZE) != 0) { if (ggio->gctl_mediasize <= 0) { @@ -625,13 +655,15 @@ g_gate_modify(struct g_gate_softc *sc, struct g_gate_c if ((ggio->gctl_modify & GG_MODIFY_READPROV) != 0) { g_topology_lock(); - if (sc->sc_readcons != NULL) { - cp = sc->sc_readcons; + mtx_lock(&sc->sc_read_mtx); + if ((cp = sc->sc_readcons) != NULL) { sc->sc_readcons = NULL; - (void)g_access(cp, -1, 0, 0); - g_detach(cp); - g_destroy_consumer(cp); - } + done = (cp->index == 0); + mtx_unlock(&sc->sc_read_mtx); + if (done) + g_gate_detach(cp, 0); + } else + mtx_unlock(&sc->sc_read_mtx); if (ggio->gctl_readprov[0] != '\0') { pp = g_provider_by_name(ggio->gctl_readprov); if (pp == NULL) { Modified: stable/11/sys/geom/gate/g_gate.h ============================================================================== --- stable/11/sys/geom/gate/g_gate.h Fri Jan 10 00:43:40 2020 (r356580) +++ stable/11/sys/geom/gate/g_gate.h Fri Jan 10 00:44:07 2020 (r356581) @@ -89,16 +89,15 @@ struct g_gate_softc { uint32_t sc_queue_count; /* P: sc_queue_mtx */ uint32_t sc_queue_size; /* P: (read-only) */ u_int sc_timeout; /* P: (read-only) */ - struct g_consumer *sc_readcons; /* P: XXX */ - off_t sc_readoffset; /* P: XXX */ + struct g_consumer *sc_readcons; /* P: sc_read_mtx */ + off_t sc_readoffset; /* P: sc_read_mtx */ struct callout sc_callout; /* P: (modified only from callout thread) */ - uintptr_t sc_seq; /* P: (modified only - from g_down - thread) */ + uintptr_t sc_seq; /* P: sc_queue_mtx */ LIST_ENTRY(g_gate_softc) sc_next; /* P: g_gate_list_mtx */ char sc_info[G_GATE_INFOSIZE]; /* P: (read-only) */ + struct mtx sc_read_mtx; }; #define G_GATE_DEBUG(lvl, ...) do { \ From owner-svn-src-stable-11@freebsd.org Fri Jan 10 00:45:53 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2079C1FE164; Fri, 10 Jan 2020 00:45:53 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47v46900t6z3xQg; Fri, 10 Jan 2020 00:45:53 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EEDEE9CCF; Fri, 10 Jan 2020 00:45:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00A0jqMm017099; Fri, 10 Jan 2020 00:45:52 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00A0jqbN017098; Fri, 10 Jan 2020 00:45:52 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202001100045.00A0jqbN017098@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 10 Jan 2020 00:45:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356583 - stable/11/sys/geom/shsec X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/geom/shsec X-SVN-Commit-Revision: 356583 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 00:45:53 -0000 Author: mav Date: Fri Jan 10 00:45:52 2020 New Revision: 356583 URL: https://svnweb.freebsd.org/changeset/base/356583 Log: MFC r356162, r356182: Fix GEOM_SHSEC orphanization. Previous code closed and destroyed consumer even with I/O in progress. This patch postpones the destruction till the last close, identical to GEOM_STRIPE, since they seem to have common origin. Modified: stable/11/sys/geom/shsec/g_shsec.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/shsec/g_shsec.c ============================================================================== --- stable/11/sys/geom/shsec/g_shsec.c Fri Jan 10 00:45:27 2020 (r356582) +++ stable/11/sys/geom/shsec/g_shsec.c Fri Jan 10 00:45:52 2020 (r356583) @@ -162,7 +162,7 @@ g_shsec_remove_disk(struct g_consumer *cp) } if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0) - g_access(cp, -cp->acr, -cp->acw, -cp->ace); + return; g_detach(cp); g_destroy_consumer(cp); } @@ -181,14 +181,14 @@ g_shsec_orphan(struct g_consumer *cp) g_shsec_remove_disk(cp); /* If there are no valid disks anymore, remove device. */ - if (g_shsec_nvalid(sc) == 0) + if (LIST_EMPTY(&gp->consumer)) g_shsec_destroy(sc, 1); } static int g_shsec_access(struct g_provider *pp, int dr, int dw, int de) { - struct g_consumer *cp1, *cp2; + struct g_consumer *cp1, *cp2, *tmp; struct g_shsec_softc *sc; struct g_geom *gp; int error; @@ -196,21 +196,6 @@ g_shsec_access(struct g_provider *pp, int dr, int dw, gp = pp->geom; sc = gp->softc; - if (sc == NULL) { - /* - * It looks like geom is being withered. - * In that case we allow only negative requests. - */ - KASSERT(dr <= 0 && dw <= 0 && de <= 0, - ("Positive access request (device=%s).", pp->name)); - if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && - (pp->ace + de) == 0) { - G_SHSEC_DEBUG(0, "Device %s definitely destroyed.", - gp->name); - } - return (0); - } - /* On first open, grab an extra "exclusive" bit */ if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) de++; @@ -219,21 +204,30 @@ g_shsec_access(struct g_provider *pp, int dr, int dw, de--; error = ENXIO; - LIST_FOREACH(cp1, &gp->consumer, consumer) { + LIST_FOREACH_SAFE(cp1, &gp->consumer, consumer, tmp) { error = g_access(cp1, dr, dw, de); - if (error == 0) - continue; - /* - * If we fail here, backout all previous changes. - */ - LIST_FOREACH(cp2, &gp->consumer, consumer) { - if (cp1 == cp2) - return (error); - g_access(cp2, -dr, -dw, -de); + if (error != 0) + goto fail; + if (cp1->acr == 0 && cp1->acw == 0 && cp1->ace == 0 && + cp1->flags & G_CF_ORPHAN) { + g_detach(cp1); + g_destroy_consumer(cp1); } - /* NOTREACHED */ } + /* If there are no valid disks anymore, remove device. */ + if (LIST_EMPTY(&gp->consumer)) + g_shsec_destroy(sc, 1); + + return (error); + +fail: + /* If we fail here, backout all previous changes. */ + LIST_FOREACH(cp2, &gp->consumer, consumer) { + if (cp1 == cp2) + break; + g_access(cp2, -dr, -dw, -de); + } return (error); } From owner-svn-src-stable-11@freebsd.org Fri Jan 10 00:46:59 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A0F721FE260; Fri, 10 Jan 2020 00:46:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47v47R3sPZz3xfs; Fri, 10 Jan 2020 00:46:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7FBC59CD2; Fri, 10 Jan 2020 00:46:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00A0kxcn017267; Fri, 10 Jan 2020 00:46:59 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00A0kx33017266; Fri, 10 Jan 2020 00:46:59 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202001100046.00A0kx33017266@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 10 Jan 2020 00:46:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356585 - stable/11/sys/geom/mountver X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/geom/mountver X-SVN-Commit-Revision: 356585 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 00:46:59 -0000 Author: mav Date: Fri Jan 10 00:46:59 2020 New Revision: 356585 URL: https://svnweb.freebsd.org/changeset/base/356585 Log: MFC r356178: Fix GEOM_MOUNTVER orphanization. Previous code closed and detached consumer even with I/O still in progress. This patch adds locking and request counting to postpone the close till the last of running requests completes. Modified: stable/11/sys/geom/mountver/g_mountver.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/mountver/g_mountver.c ============================================================================== --- stable/11/sys/geom/mountver/g_mountver.c Fri Jan 10 00:46:33 2020 (r356584) +++ stable/11/sys/geom/mountver/g_mountver.c Fri Jan 10 00:46:59 2020 (r356585) @@ -82,14 +82,29 @@ struct g_class g_mountver_class = { }; static void +g_mountver_detach(void *arg, int flags __unused) +{ + struct g_consumer *cp = arg; + + g_topology_assert(); + if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0) + g_access(cp, -cp->acr, -cp->acw, -cp->ace); + g_detach(cp); +} + +static void g_mountver_done(struct bio *bp) { + struct g_mountver_softc *sc; struct g_geom *gp; + struct g_consumer *cp; struct bio *pbp; + cp = bp->bio_from; + gp = cp->geom; if (bp->bio_error != ENXIO) { g_std_done(bp); - return; + goto done; } /* @@ -98,32 +113,45 @@ g_mountver_done(struct bio *bp) * gets called. To work around that, we have to queue requests * that failed with ENXIO, in order to send them later. */ - gp = bp->bio_from->geom; - pbp = bp->bio_parent; KASSERT(pbp->bio_to == LIST_FIRST(&gp->provider), ("parent request was for someone else")); g_destroy_bio(bp); pbp->bio_inbed++; g_mountver_queue(pbp); + +done: + sc = gp->softc; + mtx_lock(&sc->sc_mtx); + if (--cp->index == 0 && sc->sc_orphaned) + g_post_event(g_mountver_detach, cp, M_NOWAIT, NULL); + mtx_unlock(&sc->sc_mtx); } +/* + * Send the BIO down. The function is called with sc_mtx held to cover + * the race with orphan, but drops it before external calls. + */ static void -g_mountver_send(struct bio *bp) +g_mountver_send(struct g_geom *gp, struct bio *bp) { - struct g_geom *gp; + struct g_mountver_softc *sc = gp->softc; + struct g_consumer *cp; struct bio *cbp; - gp = bp->bio_to->geom; - + mtx_assert(&sc->sc_mtx, MA_OWNED); cbp = g_clone_bio(bp); if (cbp == NULL) { + mtx_unlock(&sc->sc_mtx); g_io_deliver(bp, ENOMEM); return; } + cp = LIST_FIRST(&gp->consumer); + cp->index++; + mtx_unlock(&sc->sc_mtx); cbp->bio_done = g_mountver_done; - g_io_request(cbp, LIST_FIRST(&gp->consumer)); + g_io_request(cbp, cp); } static void @@ -149,10 +177,12 @@ g_mountver_send_queued(struct g_geom *gp) sc = gp->softc; mtx_lock(&sc->sc_mtx); - while ((bp = TAILQ_FIRST(&sc->sc_queue)) != NULL) { + while ((bp = TAILQ_FIRST(&sc->sc_queue)) != NULL && !sc->sc_orphaned) { TAILQ_REMOVE(&sc->sc_queue, bp, bio_queue); G_MOUNTVER_LOGREQ(bp, "Sending queued request."); - g_mountver_send(bp); + /* sc_mtx is dropped inside */ + g_mountver_send(gp, bp); + mtx_lock(&sc->sc_mtx); } mtx_unlock(&sc->sc_mtx); } @@ -168,8 +198,10 @@ g_mountver_discard_queued(struct g_geom *gp) mtx_lock(&sc->sc_mtx); while ((bp = TAILQ_FIRST(&sc->sc_queue)) != NULL) { TAILQ_REMOVE(&sc->sc_queue, bp, bio_queue); + mtx_unlock(&sc->sc_mtx); G_MOUNTVER_LOGREQ(bp, "Discarding queued request."); g_io_deliver(bp, ENXIO); + mtx_lock(&sc->sc_mtx); } mtx_unlock(&sc->sc_mtx); } @@ -189,7 +221,9 @@ g_mountver_start(struct bio *bp) * orphaning didn't happen yet. In that case, queue all subsequent * requests in order to maintain ordering. */ + mtx_lock(&sc->sc_mtx); if (sc->sc_orphaned || !TAILQ_EMPTY(&sc->sc_queue)) { + mtx_unlock(&sc->sc_mtx); if (sc->sc_shutting_down) { G_MOUNTVER_LOGREQ(bp, "Discarding request due to shutdown."); g_io_deliver(bp, ENXIO); @@ -201,7 +235,8 @@ g_mountver_start(struct bio *bp) g_mountver_send_queued(gp); } else { G_MOUNTVER_LOGREQ(bp, "Sending request."); - g_mountver_send(bp); + /* sc_mtx is dropped inside */ + g_mountver_send(gp, bp); } } @@ -463,14 +498,17 @@ static void g_mountver_orphan(struct g_consumer *cp) { struct g_mountver_softc *sc; + int done; g_topology_assert(); sc = cp->geom->softc; + mtx_lock(&sc->sc_mtx); sc->sc_orphaned = 1; - if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0) - g_access(cp, -cp->acr, -cp->acw, -cp->ace); - g_detach(cp); + done = (cp->index == 0); + mtx_unlock(&sc->sc_mtx); + if (done) + g_mountver_detach(cp, 0); G_MOUNTVER_DEBUG(0, "%s is offline. Mount verification in progress.", sc->sc_provider_name); } @@ -568,8 +606,8 @@ g_mountver_taste(struct g_class *mp, struct g_provider return (NULL); } } - g_mountver_send_queued(gp); sc->sc_orphaned = 0; + g_mountver_send_queued(gp); G_MOUNTVER_DEBUG(0, "%s has completed mount verification.", sc->sc_provider_name); return (gp); From owner-svn-src-stable-11@freebsd.org Fri Jan 10 00:48:01 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 947631FE37F; Fri, 10 Jan 2020 00:48:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47v48d2xCnz3xvL; Fri, 10 Jan 2020 00:48:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5FB089CD6; Fri, 10 Jan 2020 00:48:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00A0m1Eu017433; Fri, 10 Jan 2020 00:48:01 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00A0m1rF017432; Fri, 10 Jan 2020 00:48:01 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202001100048.00A0m1rF017432@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 10 Jan 2020 00:48:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356587 - stable/11/sys/geom/virstor X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/geom/virstor X-SVN-Commit-Revision: 356587 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 00:48:01 -0000 Author: mav Date: Fri Jan 10 00:48:00 2020 New Revision: 356587 URL: https://svnweb.freebsd.org/changeset/base/356587 Log: MFC r356181: Fix GEOM_VIRSTOR orphanization. Previous code closed and destroyed consumer even with I/O in progress. This patch postpones the destruction till the last close. Modified: stable/11/sys/geom/virstor/g_virstor.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/virstor/g_virstor.c ============================================================================== --- stable/11/sys/geom/virstor/g_virstor.c Fri Jan 10 00:47:37 2020 (r356586) +++ stable/11/sys/geom/virstor/g_virstor.c Fri Jan 10 00:48:00 2020 (r356587) @@ -906,7 +906,7 @@ remove_component(struct g_virstor_softc *sc, struct g_ } if (c->acr > 0 || c->acw > 0 || c->ace > 0) - g_access(c, -c->acr, -c->acw, -c->ace); + return; if (delay) { /* Destroy consumer after it's tasted */ g_post_event(delay_destroy_consumer, c, M_WAITOK, NULL); @@ -1397,7 +1397,7 @@ g_virstor_orphan(struct g_consumer *cp) KASSERT(comp != NULL, ("%s: No component in private part of consumer", __func__)); remove_component(sc, comp, FALSE); - if (virstor_valid_components(sc) == 0) + if (LIST_EMPTY(&gp->consumer)) virstor_geom_destroy(sc, TRUE, FALSE); } @@ -1407,7 +1407,7 @@ g_virstor_orphan(struct g_consumer *cp) static int g_virstor_access(struct g_provider *pp, int dr, int dw, int de) { - struct g_consumer *c; + struct g_consumer *c, *c2, *tmp; struct g_virstor_softc *sc; struct g_geom *gp; int error; @@ -1417,46 +1417,40 @@ g_virstor_access(struct g_provider *pp, int dr, int dw KASSERT(gp != NULL, ("%s: NULL geom", __func__)); sc = gp->softc; - if (sc == NULL) { - /* It seems that .access can be called with negative dr,dw,dx - * in this case but I want to check for myself */ - LOG_MSG(LVL_WARNING, "access(%d, %d, %d) for %s", - dr, dw, de, pp->name); - /* This should only happen when geom is withered so - * allow only negative requests */ - KASSERT(dr <= 0 && dw <= 0 && de <= 0, - ("%s: Positive access for %s", __func__, pp->name)); - if (pp->acr + dr == 0 && pp->acw + dw == 0 && pp->ace + de == 0) - LOG_MSG(LVL_DEBUG, "Device %s definitely destroyed", - pp->name); - return (0); - } - /* Grab an exclusive bit to propagate on our consumers on first open */ if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) de++; /* ... drop it on close */ if (pp->acr + dr == 0 && pp->acw + dw == 0 && pp->ace + de == 0) { de--; - update_metadata(sc); /* Writes statistical information */ + if (sc != NULL) + update_metadata(sc); } error = ENXIO; - LIST_FOREACH(c, &gp->consumer, consumer) { - KASSERT(c != NULL, ("%s: consumer is NULL", __func__)); + LIST_FOREACH_SAFE(c, &gp->consumer, consumer, tmp) { error = g_access(c, dr, dw, de); - if (error != 0) { - struct g_consumer *c2; - - /* Backout earlier changes */ - LIST_FOREACH(c2, &gp->consumer, consumer) { - if (c2 == c) /* all eariler components fixed */ - return (error); - g_access(c2, -dr, -dw, -de); - } + if (error != 0) + goto fail; + if (c->acr == 0 && c->acw == 0 && c->ace == 0 && + c->flags & G_CF_ORPHAN) { + g_detach(c); + g_destroy_consumer(c); } } + if (sc != NULL && LIST_EMPTY(&gp->consumer)) + virstor_geom_destroy(sc, TRUE, FALSE); + + return (error); + +fail: + /* Backout earlier changes */ + LIST_FOREACH(c2, &gp->consumer, consumer) { + if (c2 == c) + break; + g_access(c2, -dr, -dw, -de); + } return (error); } From owner-svn-src-stable-11@freebsd.org Fri Jan 10 00:55:38 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1EA661FE71F; Fri, 10 Jan 2020 00:55:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47v4KQ04Nyz3yTv; Fri, 10 Jan 2020 00:55:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F1F0A9EA5; Fri, 10 Jan 2020 00:55:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00A0tbl1023632; Fri, 10 Jan 2020 00:55:37 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00A0tbxv023631; Fri, 10 Jan 2020 00:55:37 GMT (envelope-from mav@FreeBSD.org) Message-Id: <202001100055.00A0tbxv023631@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 10 Jan 2020 00:55:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356589 - stable/11/sys/geom X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/geom X-SVN-Commit-Revision: 356589 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 00:55:38 -0000 Author: mav Date: Fri Jan 10 00:55:37 2020 New Revision: 356589 URL: https://svnweb.freebsd.org/changeset/base/356589 Log: MFC r356214: Avoid few memory accesses in g_disk_done(). Modified: stable/11/sys/geom/geom_disk.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/geom/geom_disk.c ============================================================================== --- stable/11/sys/geom/geom_disk.c Fri Jan 10 00:53:20 2020 (r356588) +++ stable/11/sys/geom/geom_disk.c Fri Jan 10 00:55:37 2020 (r356589) @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); struct g_disk_softc { struct mtx done_mtx; struct disk *dp; + struct devstat *d_devstat; struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; char led[64]; @@ -228,15 +229,13 @@ g_disk_done(struct bio *bp) struct g_disk_softc *sc; /* See "notes" for why we need a mutex here */ - /* XXX: will witness accept a mix of Giant/unGiant drivers here ? */ + sc = bp->bio_caller1; bp2 = bp->bio_parent; - sc = bp2->bio_to->private; - bp->bio_completed = bp->bio_length - bp->bio_resid; binuptime(&now); mtx_lock(&sc->done_mtx); if (bp2->bio_error == 0) bp2->bio_error = bp->bio_error; - bp2->bio_completed += bp->bio_completed; + bp2->bio_completed += bp->bio_length - bp->bio_resid; switch (bp->bio_cmd) { case BIO_ZONE: @@ -246,7 +245,7 @@ g_disk_done(struct bio *bp) case BIO_WRITE: case BIO_DELETE: case BIO_FLUSH: - devstat_end_transaction_bio_bt(sc->dp->d_devstat, bp, &now); + devstat_end_transaction_bio_bt(sc->d_devstat, bp, &now); break; default: break; @@ -463,6 +462,7 @@ g_disk_start(struct bio *bp) bp->bio_error = ENOMEM; } bp2->bio_done = g_disk_done; + bp2->bio_caller1 = sc; bp2->bio_pblkno = bp2->bio_offset / dp->d_sectorsize; bp2->bio_bcount = bp2->bio_length; bp2->bio_disk = dp; @@ -548,6 +548,7 @@ g_disk_start(struct bio *bp) return; } bp2->bio_done = g_disk_done; + bp2->bio_caller1 = sc; bp2->bio_disk = dp; mtx_lock(&sc->start_mtx); devstat_start_transaction_bio(dp->d_devstat, bp2); @@ -702,6 +703,7 @@ g_disk_create(void *arg, int flag) mtx_init(&sc->start_mtx, "g_disk_start", NULL, MTX_DEF); mtx_init(&sc->done_mtx, "g_disk_done", NULL, MTX_DEF); sc->dp = dp; + sc->d_devstat = dp->d_devstat; gp = g_new_geomf(&g_disk_class, "%s%d", dp->d_name, dp->d_unit); gp->softc = sc; pp = g_new_providerf(gp, "%s", gp->name); From owner-svn-src-stable-11@freebsd.org Fri Jan 10 03:37:53 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6993822267D; Fri, 10 Jan 2020 03:37:53 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47v7wd2bm2z46fL; Fri, 10 Jan 2020 03:37:53 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5457EBDBF; Fri, 10 Jan 2020 03:37:53 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00A3braF020400; Fri, 10 Jan 2020 03:37:53 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00A3bq5u020396; Fri, 10 Jan 2020 03:37:52 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001100337.00A3bq5u020396@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 10 Jan 2020 03:37:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356593 - in stable: 11/lib/libbe 11/sbin/bectl/tests 12/lib/libbe 12/sbin/bectl/tests X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/lib/libbe 11/sbin/bectl/tests 12/lib/libbe 12/sbin/bectl/tests X-SVN-Commit-Revision: 356593 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 03:37:53 -0000 Author: kevans Date: Fri Jan 10 03:37:52 2020 New Revision: 356593 URL: https://svnweb.freebsd.org/changeset/base/356593 Log: MFC r356279: libbe(3): promote dependent clones when destroying a BE When removing a boot environment iterate over the dependents and process the snapshots by grabbing any clones. Promote the clones we found and then remove the target environment. This fixes the ability to destroy a boot environment when it has been used to spawn one or more other boot environments. PR: 242592 Modified: stable/11/lib/libbe/be.c stable/11/lib/libbe/be.h stable/11/lib/libbe/be_error.c stable/11/sbin/bectl/tests/bectl_test.sh Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/lib/libbe/be.c stable/12/lib/libbe/be.h stable/12/lib/libbe/be_error.c stable/12/sbin/bectl/tests/bectl_test.sh Directory Properties: stable/12/ (props changed) Modified: stable/11/lib/libbe/be.c ============================================================================== --- stable/11/lib/libbe/be.c Fri Jan 10 03:17:28 2020 (r356592) +++ stable/11/lib/libbe/be.c Fri Jan 10 03:37:52 2020 (r356593) @@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include - +#include #include #include @@ -48,9 +48,16 @@ __FBSDID("$FreeBSD$"); #include "be.h" #include "be_impl.h" +struct promote_entry { + char name[BE_MAXPATHLEN]; + SLIST_ENTRY(promote_entry) link; +}; + struct be_destroy_data { - libbe_handle_t *lbh; - char *snapname; + libbe_handle_t *lbh; + char target_name[BE_MAXPATHLEN]; + char *snapname; + SLIST_HEAD(, promote_entry) promotelist; }; #if SOON @@ -194,7 +201,153 @@ be_nicenum(uint64_t num, char *buf, size_t buflen) zfs_nicenum(num, buf, buflen); } +static bool +be_should_promote_clones(zfs_handle_t *zfs_hdl, struct be_destroy_data *bdd) +{ + char *atpos; + + if (zfs_get_type(zfs_hdl) != ZFS_TYPE_SNAPSHOT) + return (false); + + /* + * If we're deleting a snapshot, we need to make sure we only promote + * clones that are derived from one of the snapshots we're deleting, + * rather than that of a snapshot we're not touching. This keeps stuff + * in a consistent state, making sure that we don't error out unless + * we really need to. + */ + if (bdd->snapname == NULL) + return (true); + + atpos = strchr(zfs_get_name(zfs_hdl), '@'); + return (strcmp(atpos + 1, bdd->snapname) == 0); +} + +/* + * This is executed from be_promote_dependent_clones via zfs_iter_dependents, + * It checks if the dependent type is a snapshot then attempts to find any + * clones associated with it. Any clones not related to the destroy target are + * added to the promote list. + */ static int +be_dependent_clone_cb(zfs_handle_t *zfs_hdl, void *data) +{ + int err; + bool found; + char *name; + struct nvlist *nvl; + struct nvpair *nvp; + struct be_destroy_data *bdd; + struct promote_entry *entry, *newentry; + + nvp = NULL; + err = 0; + bdd = (struct be_destroy_data *)data; + + if (be_should_promote_clones(zfs_hdl, bdd) && + (nvl = zfs_get_clones_nvl(zfs_hdl)) != NULL) { + while ((nvp = nvlist_next_nvpair(nvl, nvp)) != NULL) { + name = nvpair_name(nvp); + + /* + * Skip if the clone is equal to, or a child of, the + * destroy target. + */ + if (strncmp(name, bdd->target_name, + strlen(bdd->target_name)) == 0 || + strstr(name, bdd->target_name) == name) { + continue; + } + + found = false; + SLIST_FOREACH(entry, &bdd->promotelist, link) { + if (strcmp(entry->name, name) == 0) { + found = true; + break; + } + } + + if (found) + continue; + + newentry = malloc(sizeof(struct promote_entry)); + if (newentry == NULL) { + err = ENOMEM; + break; + } + +#define BE_COPY_NAME(entry, src) \ + strlcpy((entry)->name, (src), sizeof((entry)->name)) + if (BE_COPY_NAME(newentry, name) >= + sizeof(newentry->name)) { + /* Shouldn't happen. */ + free(newentry); + err = ENAMETOOLONG; + break; + } +#undef BE_COPY_NAME + + /* + * We're building up a SLIST here to make sure both that + * we get the order right and so that we don't + * inadvertently observe the wrong state by promoting + * datasets while we're still walking the tree. The + * latter can lead to situations where we promote a BE + * then effectively demote it again. + */ + SLIST_INSERT_HEAD(&bdd->promotelist, newentry, link); + } + nvlist_free(nvl); + } + zfs_close(zfs_hdl); + return (err); +} + +/* + * This is called before a destroy, so that any datasets(environments) that are + * dependent on this one get promoted before destroying the target. + */ +static int +be_promote_dependent_clones(zfs_handle_t *zfs_hdl, struct be_destroy_data *bdd) +{ + int err; + zfs_handle_t *clone; + struct promote_entry *entry; + + snprintf(bdd->target_name, BE_MAXPATHLEN, "%s/", zfs_get_name(zfs_hdl)); + err = zfs_iter_dependents(zfs_hdl, true, be_dependent_clone_cb, bdd); + + /* + * Drain the list and walk away from it if we're only deleting a + * snapshot. + */ + if (bdd->snapname != NULL && !SLIST_EMPTY(&bdd->promotelist)) + err = BE_ERR_HASCLONES; + while (!SLIST_EMPTY(&bdd->promotelist)) { + entry = SLIST_FIRST(&bdd->promotelist); + SLIST_REMOVE_HEAD(&bdd->promotelist, link); + +#define ZFS_GRAB_CLONE() \ + zfs_open(bdd->lbh->lzh, entry->name, ZFS_TYPE_FILESYSTEM) + /* + * Just skip this part on error, we still want to clean up the + * promotion list after the first error. We'll then preserve it + * all the way back. + */ + if (err == 0 && (clone = ZFS_GRAB_CLONE()) != NULL) { + err = zfs_promote(clone); + if (err != 0) + err = BE_ERR_DESTROYMNT; + zfs_close(clone); + } +#undef ZFS_GRAB_CLONE + free(entry); + } + + return (err); +} + +static int be_destroy_cb(zfs_handle_t *zfs_hdl, void *data) { char path[BE_MAXPATHLEN]; @@ -239,8 +392,9 @@ be_destroy_cb(zfs_handle_t *zfs_hdl, void *data) * BE_DESTROY_FORCE : forces operation on mounted datasets * BE_DESTROY_ORIGIN: destroy the origin snapshot as well */ -int -be_destroy(libbe_handle_t *lbh, const char *name, int options) +static int +be_destroy_internal(libbe_handle_t *lbh, const char *name, int options, + bool odestroyer) { struct be_destroy_data bdd; char origin[BE_MAXPATHLEN], path[BE_MAXPATHLEN]; @@ -251,6 +405,7 @@ be_destroy(libbe_handle_t *lbh, const char *name, int bdd.lbh = lbh; bdd.snapname = NULL; + SLIST_INIT(&bdd.promotelist); force = options & BE_DESTROY_FORCE; *origin = '\0'; @@ -268,25 +423,6 @@ be_destroy(libbe_handle_t *lbh, const char *name, int if (fs == NULL) return (set_error(lbh, BE_ERR_ZFSOPEN)); - if ((options & BE_DESTROY_WANTORIGIN) != 0 && - zfs_prop_get(fs, ZFS_PROP_ORIGIN, origin, sizeof(origin), - NULL, NULL, 0, 1) != 0 && - (options & BE_DESTROY_ORIGIN) != 0) - return (set_error(lbh, BE_ERR_NOORIGIN)); - - /* - * If the caller wants auto-origin destruction and the origin - * name matches one of our automatically created snapshot names - * (i.e. strftime("%F-%T") with a serial at the end), then - * we'll set the DESTROY_ORIGIN flag and nuke it - * be_is_auto_snapshot_name is exported from libbe(3) so that - * the caller can determine if it needs to warn about the origin - * not being destroyed or not. - */ - if ((options & BE_DESTROY_AUTOORIGIN) != 0 && *origin != '\0' && - be_is_auto_snapshot_name(lbh, origin)) - options |= BE_DESTROY_ORIGIN; - /* Don't destroy a mounted dataset unless force is specified */ if ((mounted = zfs_is_mounted(fs, NULL)) != 0) { if (force) { @@ -297,6 +433,14 @@ be_destroy(libbe_handle_t *lbh, const char *name, int } } } else { + /* + * If we're initially destroying a snapshot, origin options do + * not make sense. If we're destroying the origin snapshot of + * a BE, we want to maintain the options in case we need to + * fake success after failing to promote. + */ + if (!odestroyer) + options &= ~BE_DESTROY_WANTORIGIN; if (!zfs_dataset_exists(lbh->lzh, path, ZFS_TYPE_SNAPSHOT)) return (set_error(lbh, BE_ERR_NOENT)); @@ -311,6 +455,49 @@ be_destroy(libbe_handle_t *lbh, const char *name, int } } + /* + * Whether we're destroying a BE or a single snapshot, we need to walk + * the tree of what we're going to destroy and promote everything in our + * path so that we can make it happen. + */ + if ((err = be_promote_dependent_clones(fs, &bdd)) != 0) { + free(bdd.snapname); + + /* + * If we're just destroying the origin of some other dataset + * we were invoked to destroy, then we just ignore + * BE_ERR_HASCLONES and return success unless the caller wanted + * to force the issue. + */ + if (odestroyer && err == BE_ERR_HASCLONES && + (options & BE_DESTROY_AUTOORIGIN) != 0) + return (0); + return (set_error(lbh, err)); + } + + /* + * This was deferred until after we promote all of the derivatives so + * that we grab the new origin after everything's settled down. + */ + if ((options & BE_DESTROY_WANTORIGIN) != 0 && + zfs_prop_get(fs, ZFS_PROP_ORIGIN, origin, sizeof(origin), + NULL, NULL, 0, 1) != 0 && + (options & BE_DESTROY_ORIGIN) != 0) + return (set_error(lbh, BE_ERR_NOORIGIN)); + + /* + * If the caller wants auto-origin destruction and the origin + * name matches one of our automatically created snapshot names + * (i.e. strftime("%F-%T") with a serial at the end), then + * we'll set the DESTROY_ORIGIN flag and nuke it + * be_is_auto_snapshot_name is exported from libbe(3) so that + * the caller can determine if it needs to warn about the origin + * not being destroyed or not. + */ + if ((options & BE_DESTROY_AUTOORIGIN) != 0 && *origin != '\0' && + be_is_auto_snapshot_name(lbh, origin)) + options |= BE_DESTROY_ORIGIN; + err = be_destroy_cb(fs, &bdd); zfs_close(fs); free(bdd.snapname); @@ -337,8 +524,23 @@ be_destroy(libbe_handle_t *lbh, const char *name, int if (strncmp(origin, lbh->root, rootlen) != 0 || origin[rootlen] != '/') return (0); - return (be_destroy(lbh, origin + rootlen + 1, - options & ~BE_DESTROY_ORIGIN)); + return (be_destroy_internal(lbh, origin + rootlen + 1, + options & ~BE_DESTROY_ORIGIN, true)); +} + +int +be_destroy(libbe_handle_t *lbh, const char *name, int options) +{ + + /* + * The consumer must not set both BE_DESTROY_AUTOORIGIN and + * BE_DESTROY_ORIGIN. Internally, we'll set the latter from the former. + * The latter should imply that we must succeed at destroying the + * origin, or complain otherwise. + */ + if ((options & BE_DESTROY_WANTORIGIN) == BE_DESTROY_WANTORIGIN) + return (set_error(lbh, BE_ERR_UNKNOWN)); + return (be_destroy_internal(lbh, name, options, false)); } static void Modified: stable/11/lib/libbe/be.h ============================================================================== --- stable/11/lib/libbe/be.h Fri Jan 10 03:17:28 2020 (r356592) +++ stable/11/lib/libbe/be.h Fri Jan 10 03:37:52 2020 (r356593) @@ -60,6 +60,7 @@ typedef enum be_error { BE_ERR_NOMEM, /* insufficient memory */ BE_ERR_UNKNOWN, /* unknown error */ BE_ERR_INVORIGIN, /* invalid origin */ + BE_ERR_HASCLONES, /* snapshot has clones */ } be_error_t; Modified: stable/11/lib/libbe/be_error.c ============================================================================== --- stable/11/lib/libbe/be_error.c Fri Jan 10 03:17:28 2020 (r356592) +++ stable/11/lib/libbe/be_error.c Fri Jan 10 03:37:52 2020 (r356593) @@ -108,6 +108,9 @@ libbe_error_description(libbe_handle_t *lbh) case BE_ERR_INVORIGIN: return ("invalid origin"); + case BE_ERR_HASCLONES: + return ("snapshot has clones"); + default: assert(lbh->error == BE_ERR_SUCCESS); return ("no error"); Modified: stable/11/sbin/bectl/tests/bectl_test.sh ============================================================================== --- stable/11/sbin/bectl/tests/bectl_test.sh Fri Jan 10 03:17:28 2020 (r356592) +++ stable/11/sbin/bectl/tests/bectl_test.sh Fri Jan 10 03:37:52 2020 (r356593) @@ -162,6 +162,51 @@ bectl_destroy_body() atf_check bectl -r ${zpool}/ROOT create -e default default3 atf_check bectl -r ${zpool}/ROOT destroy -o default3 atf_check bectl -r ${zpool}/ROOT unmount default + + # create two be from the same parent and destroy the parent + atf_check bectl -r ${zpool}/ROOT create -e default default2 + atf_check bectl -r ${zpool}/ROOT create -e default default3 + atf_check bectl -r ${zpool}/ROOT destroy default + atf_check bectl -r ${zpool}/ROOT destroy default2 + atf_check bectl -r ${zpool}/ROOT rename default3 default + + # Create a BE, have it be the parent for another and repeat, then start + # deleting environments. Arbitrarily chose default3 as the first. + # Sleeps are required to prevent conflicting snapshots- libbe will + # use the time with a serial at the end as needed to prevent collisions, + # but as BEs get promoted the snapshot names will convert and conflict + # anyways. libbe should perhaps consider adding something extra to the + # default name to prevent collisions like this, but the default name + # includes down to the second and creating BEs this rapidly is perhaps + # uncommon enough. + atf_check bectl -r ${zpool}/ROOT create -e default default2 + sleep 1 + atf_check bectl -r ${zpool}/ROOT create -e default2 default3 + sleep 1 + atf_check bectl -r ${zpool}/ROOT create -e default3 default4 + atf_check bectl -r ${zpool}/ROOT destroy default3 + atf_check bectl -r ${zpool}/ROOT destroy default2 + atf_check bectl -r ${zpool}/ROOT destroy default4 + + # Create two BEs, then create an unrelated snapshot on the originating + # BE and destroy it. We shouldn't have promoted the second BE, and it's + # only possible to tell if we promoted it by making sure we didn't + # demote the first BE at some point -- if we did, it's origin will no + # longer be empty. + atf_check bectl -r ${zpool}/ROOT create -e default default2 + atf_check bectl -r ${zpool}/ROOT create default@test + + atf_check bectl -r ${zpool}/ROOT destroy default@test + atf_check -o inline:"-\n" zfs get -Ho value origin ${zpool}/ROOT/default + atf_check bectl -r ${zpool}/ROOT destroy default2 + + # As observed by beadm, if we explicitly try to destroy a snapshot that + # leads to clones, we shouldn't have allowed it. + atf_check bectl -r ${zpool}/ROOT create default@test + atf_check bectl -r ${zpool}/ROOT create -e default@test default2 + + atf_check -e not-empty -s not-exit:0 bectl -r ${zpool}/ROOT destroy \ + default@test } bectl_destroy_cleanup() { From owner-svn-src-stable-11@freebsd.org Fri Jan 10 09:50:45 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 09BD51E2264; Fri, 10 Jan 2020 09:50:45 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from hz.grosbein.net (hz.grosbein.net [IPv6:2a01:4f8:c2c:26d8::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "hz.grosbein.net", Issuer "hz.grosbein.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 47vJBq5XXmz4Q7F; Fri, 10 Jan 2020 09:50:43 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from eg.sd.rdtc.ru (eg.sd.rdtc.ru [IPv6:2a03:3100:c:13:0:0:0:5]) by hz.grosbein.net (8.15.2/8.15.2) with ESMTPS id 00A9oVXv019251 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Jan 2020 09:50:35 GMT (envelope-from eugen@grosbein.net) X-Envelope-From: eugen@grosbein.net X-Envelope-To: bapt@FreeBSD.org Received: from [10.58.0.4] (dadv@[10.58.0.4]) by eg.sd.rdtc.ru (8.15.2/8.15.2) with ESMTPS id 00A9oOGq005792 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Fri, 10 Jan 2020 16:50:24 +0700 (+07) (envelope-from eugen@grosbein.net) Subject: Re: svn commit: r356566 - stable/11/contrib/smbfs/lib/smb To: Baptiste Daroussin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org References: <202001091958.009Jw56r037444@repo.freebsd.org> From: Eugene Grosbein Message-ID: <02858bb2-f5aa-bca3-bfea-60f91465e733@grosbein.net> Date: Fri, 10 Jan 2020 16:50:24 +0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <202001091958.009Jw56r037444@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00,LOCAL_FROM, SPF_HELO_NONE,SPF_PASS,T_DATE_IN_FUTURE_Q_PLUS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Report: * -2.3 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record * 0.0 T_DATE_IN_FUTURE_Q_PLUS Date: is over 4 months after Received: * date * -0.0 SPF_PASS SPF: sender matches SPF record * 2.6 LOCAL_FROM From my domains X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on hz.grosbein.net X-Rspamd-Queue-Id: 47vJBq5XXmz4Q7F X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=permerror (mx1.freebsd.org: domain of eugen@grosbein.net uses mechanism not recognized by this client) smtp.mailfrom=eugen@grosbein.net X-Spamd-Result: default: False [-3.85 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[grosbein.net]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; IP_SCORE(-1.75)[ip: (-4.78), ipnet: 2a01:4f8::/29(-2.45), asn: 24940(-1.50), country: DE(-0.02)]; R_SPF_PERMFAIL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:2a01:4f8::/29, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 09:50:45 -0000 10.01.2020 2:58, Baptiste Daroussin wrote: > Author: bapt > Date: Thu Jan 9 19:58:05 2020 > New Revision: 356566 > URL: https://svnweb.freebsd.org/changeset/base/356566 > > Log: > MFC r356317 (by arrowd): > > mount_smbfs: Issue a warning when .nsmbrc section name contains lowercase characters. > > PR: 231656 > Approved by: bapt > Differential Revision: https://reviews.freebsd.org/D22289 > > Modified: > stable/11/contrib/smbfs/lib/smb/rcfile.c > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/contrib/smbfs/lib/smb/rcfile.c > ============================================================================== > --- stable/11/contrib/smbfs/lib/smb/rcfile.c Thu Jan 9 19:56:25 2020 (r356565) > +++ stable/11/contrib/smbfs/lib/smb/rcfile.c Thu Jan 9 19:58:05 2020 (r356566) > @@ -156,11 +156,19 @@ static struct rcsection * > rc_addsect(struct rcfile *rcp, const char *sectname) > { > struct rcsection *p; > + const char* sectletter = sectname; > > p = rc_findsect(rcp, sectname); > if (p) return p; > p = malloc(sizeof(*p)); > if (!p) return NULL; > + for(sectletter = sectname; *sectletter; sectletter++) { > + if (islower(*sectletter)) { > + if (strcmp(sectname, "default")) > + dprintf(STDERR_FILENO, "warning: section name [%s] contains lower-case letters\n", sectname); > + break; > + } > + } > p->rs_name = strdup(sectname); > SLIST_INIT(&p->rs_keys); > SLIST_INSERT_HEAD(&rcp->rf_sect, p, rs_next); This commit broke source upgrade path from 10.4-STABLE to stable/11: rcfile.c:168:5: error: implicit declaration of function 'dprintf' is invalid in C99 [-Werror,-Wimplicit-function-declaration] dprintf(STDERR_FILENO, "warning: section name [%s] contains lower-case letters\n", sectname); ^ 1 error generated. From owner-svn-src-stable-11@freebsd.org Fri Jan 10 11:43:12 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 35ECA1E4693; Fri, 10 Jan 2020 11:43:12 +0000 (UTC) (envelope-from david@catwhisker.org) Received: from mx.catwhisker.org (107-204-234-170.lightspeed.sntcca.sbcglobal.net [107.204.234.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47vLhb0HCCz4VnV; Fri, 10 Jan 2020 11:43:10 +0000 (UTC) (envelope-from david@catwhisker.org) Received: from albert.catwhisker.org (localhost [127.0.0.1]) by albert.catwhisker.org (8.15.2/8.15.2) with ESMTP id 00ABh9kP075477; Fri, 10 Jan 2020 11:43:09 GMT (envelope-from david@albert.catwhisker.org) Received: (from david@localhost) by albert.catwhisker.org (8.15.2/8.15.2/Submit) id 00ABh9Sf075476; Fri, 10 Jan 2020 03:43:09 -0800 (PST) (envelope-from david) Date: Fri, 10 Jan 2020 03:43:09 -0800 From: David Wolfskill To: Baptiste Daroussin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r356566 - stable/11/contrib/smbfs/lib/smb Message-ID: <20200110114309.GA75442@albert.catwhisker.org> Mail-Followup-To: David Wolfskill , Baptiste Daroussin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org References: <202001091958.009Jw56r037444@repo.freebsd.org> <02858bb2-f5aa-bca3-bfea-60f91465e733@grosbein.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BXVAT5kNtrzKuDFl" Content-Disposition: inline In-Reply-To: <02858bb2-f5aa-bca3-bfea-60f91465e733@grosbein.net> X-Rspamd-Queue-Id: 47vLhb0HCCz4VnV X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of david@catwhisker.org designates 107.204.234.170 as permitted sender) smtp.mailfrom=david@catwhisker.org X-Spamd-Result: default: False [-6.81 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:107.204.234.170]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[catwhisker.org]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE(-2.41)[ip: (-9.39), ipnet: 107.192.0.0/12(-4.70), asn: 7018(2.10), country: US(-0.05)]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:7018, ipnet:107.192.0.0/12, country:US]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 11:43:12 -0000 --BXVAT5kNtrzKuDFl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 10, 2020 at 04:50:24PM +0700, Eugene Grosbein wrote: > 10.01.2020 2:58, Baptiste Daroussin wrote: >=20 > > Author: bapt > > Date: Thu Jan 9 19:58:05 2020 > > New Revision: 356566 > > URL: https://svnweb.freebsd.org/changeset/base/356566 > > ...=20 > This commit broke source upgrade path from 10.4-STABLE to stable/11: >=20 > rcfile.c:168:5: error: implicit declaration of function 'dprintf' is inva= lid in C99 [-Werror,-Wimplicit-function-declaration] > dprintf(STDERR_FILENO, "warning: section = name [%s] contains lower-case letters\n", sectname); > ^ > 1 error generated. > .... I got the same error (on two separate machines) attempting an in-place src update from stable/11 @r356547 to r356593. Peace, david --=20 David H. Wolfskill david@catwhisker.org At least Trump can count on McConnell and Putin to "have his back." And the rest of us can consider what that means about each of them. See http://www.catwhisker.org/~david/publickey.gpg for my public key. --BXVAT5kNtrzKuDFl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGTBAEBCgB9FiEE4owz2QxMJyaxAefyQLJg+bY2PckFAl4YY01fFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEUy OEMzM0Q5MEM0QzI3MjZCMTAxRTdGMjQwQjI2MEY5QjYzNjNEQzkACgkQQLJg+bY2 PclEKgf9EKs2AdjaEkIRfkqFjbKW1jXXX7IZo54zFFV2LiDmFXx3aShPVvB1gWxz OA+eCEPrPuwX7QQkPXebV9YP/xZuwsxphXzxcc44DLSlhSRdVJJD1VYOz6EKZgSl ppDfNl0wv6nHKKPnOgj9EGd6goboOD8fixKnVmgxy1FIrzDquTRDQaRcXTerX3Tf 7VKszMJUz5gNUHSNS47xOrcGI59UVoc4iuerStktcWv35qNNl7bSjbvLX1lRRGbn zvSg7nZTDrP7pb4HCWu47Wmb7zZWKZ8lhgQY4Fji0vrv/vxb46iT5HyyYTduF/AK X2JvEFO89RcqZHeZi96PAaJ3MroFAA== =AuaK -----END PGP SIGNATURE----- --BXVAT5kNtrzKuDFl-- From owner-svn-src-stable-11@freebsd.org Fri Jan 10 11:57:28 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 317501E49D8; Fri, 10 Jan 2020 11:57:28 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-ua1-x92e.google.com (mail-ua1-x92e.google.com [IPv6:2607:f8b0:4864:20::92e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47vM130jN8z4WGb; Fri, 10 Jan 2020 11:57:26 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: by mail-ua1-x92e.google.com with SMTP id 1so623855uao.1; Fri, 10 Jan 2020 03:57:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=H82LhaWb/w+1acWIgSJGPzDwXhN7UKkvJq274jti26U=; b=UKv4102vxJ+hUKtYnFQfq4yOlTL63xbHRz//XIzWvOsjDBlX/l/QC58txJm2bkkcEK DyXHCqrYmInYSPCHS55ij9g4c7Xp6TzxdsdYLUsPmTE1zS3MnJLYyEvVimoh5QImrD1J 4NnDuPFMJDlKl98NBaunzUEIt3JTXNrKVbGb29J1Xq1qTMswmuXD2WP61FHJVLbSOUYE GiSWlIlkChoHp1EZqL9O1Krt457DU2hZjo58HjyA2VsUDSCY0nKQWafZJF8nuHxzLDjP Dl4hDwPnhPzi748IiNVNK0sCySbjwYK1pRiaXFpXonBd3YLmqHpiWgGlBJyVGNkTe3iQ bSkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=H82LhaWb/w+1acWIgSJGPzDwXhN7UKkvJq274jti26U=; b=JkBzZ4MyIUlPKJlRJg5xeLkE2sbe1VBVofz1OnxcjQonfFOS2SCDZLuHc1uFUFddix EpmP0tWJBo16X2dAozclpC1mw60cpKQ+JgsXuo68pHclKFepU+h8ELXN0fv2U6j1cxMq XtE5L0VWOEdghluIBX2gvlWaGamIu+ZPhSG9hJ/bbnwtQ6wTbzqIg0qJIkAC4GgaTkxZ CWiknUtlkWwq9lPVaQ62c4R5GWp5tOlR9uTYXra6aYAKImS3ylAOTV72sX/4cjOehNdL 0Emgef/LyAzXzW6eL001/pq1Yn0ZFYRpbjlh8VukUMsytwUhyHUo90s9fo9RyZeMwVm/ s+0w== X-Gm-Message-State: APjAAAWdqE+1nCqvGZMMkBrQvnjwJH594JY6gzZeG+4r9M4UcZzfvDHN 5VliGT5D5W/0GON7j0bz2ylXP7GnYZA1mTG0liWvtmNz X-Google-Smtp-Source: APXvYqyDmxyfRWoGQU05BLWO1Fbctov+1sMKmH9PZ0TG2sfe2CXq8PRhA11z+XZ19aztpsAC3AOzEcXBkZ5VKq5scSs= X-Received: by 2002:ab0:2b85:: with SMTP id q5mr1651846uar.24.1578657445545; Fri, 10 Jan 2020 03:57:25 -0800 (PST) MIME-Version: 1.0 References: <202001091958.009Jw56r037444@repo.freebsd.org> <02858bb2-f5aa-bca3-bfea-60f91465e733@grosbein.net> <20200110114309.GA75442@albert.catwhisker.org> In-Reply-To: <20200110114309.GA75442@albert.catwhisker.org> From: Sergey Kandaurov Date: Fri, 10 Jan 2020 14:57:14 +0300 Message-ID: Subject: Re: svn commit: r356566 - stable/11/contrib/smbfs/lib/smb To: David Wolfskill , Baptiste Daroussin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org X-Rspamd-Queue-Id: 47vM130jN8z4WGb X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=UKv4102v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of pluknet@gmail.com designates 2607:f8b0:4864:20::92e as permitted sender) smtp.mailfrom=pluknet@gmail.com X-Spamd-Result: default: False [-2.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; IP_SCORE(0.00)[ip: (-9.38), ipnet: 2607:f8b0::/32(-2.11), asn: 15169(-1.84), country: US(-0.05)]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE_FREEMAIL(0.00)[]; URI_COUNT_ODD(1.00)[3]; RCPT_COUNT_FIVE(0.00)[6]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[e.2.9.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 11:57:28 -0000 On Fri, 10 Jan 2020 at 14:43, David Wolfskill wrote: > On Fri, Jan 10, 2020 at 04:50:24PM +0700, Eugene Grosbein wrote: > > 10.01.2020 2:58, Baptiste Daroussin wrote: > > > > > Author: bapt > > > Date: Thu Jan 9 19:58:05 2020 > > > New Revision: 356566 > > > URL: https://svnweb.freebsd.org/changeset/base/356566 > > > ... > > This commit broke source upgrade path from 10.4-STABLE to stable/11: > > > > rcfile.c:168:5: error: implicit declaration of function 'dprintf' is > invalid in C99 [-Werror,-Wimplicit-function-declaration] > > dprintf(STDERR_FILENO, "warning: section > name [%s] contains lower-case letters\n", sectname); > > ^ > > 1 error generated. > > .... > > I got the same error (on two separate machines) attempting an in-place > src update from stable/11 @r356547 to r356593. > In FreeBSD 11, dprintf() needs #define _WITH_DPRINTF "prior to the inclusion of <*stdio.h*>" From owner-svn-src-stable-11@freebsd.org Fri Jan 10 12:20:25 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CE3D31E5D02; Fri, 10 Jan 2020 12:20:25 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47vMWY55Gdz4XQR; Fri, 10 Jan 2020 12:20:25 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A15A719DDC; Fri, 10 Jan 2020 12:20:25 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00ACKPYn029556; Fri, 10 Jan 2020 12:20:25 GMT (envelope-from pluknet@FreeBSD.org) Received: (from pluknet@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00ACKP5G029555; Fri, 10 Jan 2020 12:20:25 GMT (envelope-from pluknet@FreeBSD.org) Message-Id: <202001101220.00ACKP5G029555@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pluknet set sender to pluknet@FreeBSD.org using -f From: Sergey Kandaurov Date: Fri, 10 Jan 2020 12:20:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356599 - stable/11/contrib/smbfs/lib/smb X-SVN-Group: stable-11 X-SVN-Commit-Author: pluknet X-SVN-Commit-Paths: stable/11/contrib/smbfs/lib/smb X-SVN-Commit-Revision: 356599 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 12:20:25 -0000 Author: pluknet Date: Fri Jan 10 12:20:25 2020 New Revision: 356599 URL: https://svnweb.freebsd.org/changeset/base/356599 Log: Fixed build after r356566 (MFC of r356317). This is a direct change. Modified: stable/11/contrib/smbfs/lib/smb/rcfile.c Modified: stable/11/contrib/smbfs/lib/smb/rcfile.c ============================================================================== --- stable/11/contrib/smbfs/lib/smb/rcfile.c Fri Jan 10 09:32:44 2020 (r356598) +++ stable/11/contrib/smbfs/lib/smb/rcfile.c Fri Jan 10 12:20:25 2020 (r356599) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#define _WITH_DPRINTF #include #include #include From owner-svn-src-stable-11@freebsd.org Fri Jan 10 14:46:30 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 042541E9853; Fri, 10 Jan 2020 14:46:30 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47vQm56JrMz3Byd; Fri, 10 Jan 2020 14:46:29 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from ivaldir.etoilebsd.net (etoilebsd.net [178.32.217.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: bapt) by smtp.freebsd.org (Postfix) with ESMTPSA id BB3F51075; Fri, 10 Jan 2020 14:46:29 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: by ivaldir.etoilebsd.net (Postfix, from userid 1001) id 06D06E83A6; Fri, 10 Jan 2020 15:46:28 +0100 (CET) Date: Fri, 10 Jan 2020 15:46:28 +0100 From: Baptiste Daroussin To: Sergey Kandaurov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r356599 - stable/11/contrib/smbfs/lib/smb Message-ID: <20200110144628.tkd7yp7bt54eyrog@ivaldir.net> References: <202001101220.00ACKP5G029555@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5qs7ivxvap4vsrxa" Content-Disposition: inline In-Reply-To: <202001101220.00ACKP5G029555@repo.freebsd.org> X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2020 14:46:30 -0000 --5qs7ivxvap4vsrxa Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 10, 2020 at 12:20:25PM +0000, Sergey Kandaurov wrote: > Author: pluknet > Date: Fri Jan 10 12:20:25 2020 > New Revision: 356599 > URL: https://svnweb.freebsd.org/changeset/base/356599 >=20 > Log: > Fixed build after r356566 (MFC of r356317). > =20 > This is a direct change. >=20 Thanks a lot, you have been faster than me to do it. And sorry about the breakage. Best regards, Bapt --5qs7ivxvap4vsrxa Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEgOTj3suS2urGXVU3Y4mL3PG3PloFAl4YjkEACgkQY4mL3PG3 Plq7fg//UP4uxINa7bakYM9rsmnKkeEjdi8v1v/2pHHp/MY0LfhnktaQaiEIbSFZ TCVGi5C17x1rlaFtskuLzyai4gPQo0ALAgkK9K+7nhWieThAjDcCcAphsgs3FVHL iJoKb1M5ipWTtHa3dcrZp8zX36gb078ETcQP1HG4B+NAml0uSAxgBgDZorPn51rZ RkmY/shT91ebpyUPyZI8+/Z0VfYK1ION1u+41ejimyTgfA5cPjuNN559qeb7o4uY 63nXFw5Jb20wWQhtNkY3Hanrev7SASYnYin45nXncDpmWSmkwvp+QugZpdnCG8al gumZ8SglNGDXkncxf/GLud1b1cHIQbkaoCJriG7J0b8hGfDKusLHT8r3achldr7v r0++e1EPlVqbcASC3Ypl0idHr9zqrj4rM5OhaCuqxN+DlcihSP6TFj1/8mlKK+QC F73AMl3zS4wn3/dnsFBKMh1Du9wDQs4MIu57+0Kg90j9IF2QGiZbxxTagTFsUPT6 yXQmibvUlzoAKlGa1+yMRvUIlruMhAQQSQq+cidw/CnLl4YZE8KC9dDQNKFjYaue 1ZgNf3lsqoNSImWDrZ8lo4LUXOQ6efMiTmaveJTx0ELcfp2IVcJNITk20Z9Wfqoy CDpgsIFIiuz3BeDpyl46/hdFPusFlLKBkQgDOcLB3PmPYp9qmpY= =8hek -----END PGP SIGNATURE----- --5qs7ivxvap4vsrxa-- From owner-svn-src-stable-11@freebsd.org Sat Jan 11 01:15:40 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 22CED1F882B; Sat, 11 Jan 2020 01:15:40 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47vhk40BFCz4NCL; Sat, 11 Jan 2020 01:15:40 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 016BB22D81; Sat, 11 Jan 2020 01:15:40 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00B1FdC0002618; Sat, 11 Jan 2020 01:15:39 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00B1FdjY002614; Sat, 11 Jan 2020 01:15:39 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202001110115.00B1FdjY002614@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Sat, 11 Jan 2020 01:15:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356623 - in stable/11/sys: netinet netinet6 X-SVN-Group: stable-11 X-SVN-Commit-Author: bz X-SVN-Commit-Paths: in stable/11/sys: netinet netinet6 X-SVN-Commit-Revision: 356623 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Jan 2020 01:15:40 -0000 Author: bz Date: Sat Jan 11 01:15:38 2020 New Revision: 356623 URL: https://svnweb.freebsd.org/changeset/base/356623 Log: MFC r354643: netinet*: update *mp to pass the proper value back In ip6_[direct_]input() we are looping over the extension headers to deal with the next header. We pass a pointer to an mbuf pointer to the handling functions. In certain cases the mbuf can be updated there and we need to pass the new one back. That missing in dest6_input() and route6_input(). In tcp6_input() we should also update it before we call tcp_input(). The merge is extracted of a larger change in head. PR: 240135 Reported by: prabhakar.lakhera gmail.com Modified: stable/11/sys/netinet/tcp_input.c stable/11/sys/netinet6/dest6.c stable/11/sys/netinet6/icmp6.c stable/11/sys/netinet6/route6.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet/tcp_input.c ============================================================================== --- stable/11/sys/netinet/tcp_input.c Sat Jan 11 00:11:29 2020 (r356622) +++ stable/11/sys/netinet/tcp_input.c Sat Jan 11 01:15:38 2020 (r356623) @@ -558,6 +558,7 @@ tcp6_input(struct mbuf **mp, int *offp, int proto) if (ia6) ifa_free(&ia6->ia_ifa); + *mp = m; return (tcp_input(mp, offp, proto)); } #endif /* INET6 */ Modified: stable/11/sys/netinet6/dest6.c ============================================================================== --- stable/11/sys/netinet6/dest6.c Sat Jan 11 00:11:29 2020 (r356622) +++ stable/11/sys/netinet6/dest6.c Sat Jan 11 01:15:38 2020 (r356623) @@ -116,6 +116,7 @@ dest6_input(struct mbuf **mp, int *offp, int proto) } *offp = off; + *mp = m; return (dstopts->ip6d_nxt); bad: Modified: stable/11/sys/netinet6/icmp6.c ============================================================================== --- stable/11/sys/netinet6/icmp6.c Sat Jan 11 00:11:29 2020 (r356622) +++ stable/11/sys/netinet6/icmp6.c Sat Jan 11 01:15:38 2020 (r356623) @@ -861,6 +861,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) /* deliver the packet to appropriate sockets */ icmp6_rip6_input(&m, *offp); + *mp = m; return IPPROTO_DONE; freeit: Modified: stable/11/sys/netinet6/route6.c ============================================================================== --- stable/11/sys/netinet6/route6.c Sat Jan 11 00:11:29 2020 (r356622) +++ stable/11/sys/netinet6/route6.c Sat Jan 11 01:15:38 2020 (r356623) @@ -108,5 +108,6 @@ route6_input(struct mbuf **mp, int *offp, int proto) } *offp += rhlen; + *mp = m; return (rh->ip6r_nxt); } From owner-svn-src-stable-11@freebsd.org Sat Jan 11 03:15:13 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 230791FBE78; Sat, 11 Jan 2020 03:15:13 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47vlN071WYz4TVV; Sat, 11 Jan 2020 03:15:12 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EC3002444F; Sat, 11 Jan 2020 03:15:12 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00B3FCad075101; Sat, 11 Jan 2020 03:15:12 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00B3FCCP075100; Sat, 11 Jan 2020 03:15:12 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001110315.00B3FCCP075100@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 11 Jan 2020 03:15:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356626 - in stable: 11/lib/libc/secure 12/lib/libc/secure X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/lib/libc/secure 12/lib/libc/secure X-SVN-Commit-Revision: 356626 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Jan 2020 03:15:13 -0000 Author: kevans Date: Sat Jan 11 03:15:12 2020 New Revision: 356626 URL: https://svnweb.freebsd.org/changeset/base/356626 Log: MFC r356355: ssp: knock out some trivial warnings that come up with WARNS=6 A future commit will rebuild this as part of libssp. The exact warnings are fairly trivially fixed: - No previous declaration for __stack_chk_guard - idx is the wrong type, nitems yields a size_t - Casting away volatile on the tmp_stack_chk_guard directly is a no-no. Modified: stable/11/lib/libc/secure/stack_protector.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/lib/libc/secure/stack_protector.c Directory Properties: stable/12/ (props changed) Modified: stable/11/lib/libc/secure/stack_protector.c ============================================================================== --- stable/11/lib/libc/secure/stack_protector.c Sat Jan 11 01:56:57 2020 (r356625) +++ stable/11/lib/libc/secure/stack_protector.c Sat Jan 11 03:15:12 2020 (r356626) @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); __attribute__((__constructor__, __used__)); #endif +extern long __stack_chk_guard[8]; extern int __sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen); @@ -73,8 +74,8 @@ __guard_setup(void) { static const int mib[2] = { CTL_KERN, KERN_ARND }; volatile long tmp_stack_chk_guard[nitems(__stack_chk_guard)]; - size_t len; - int error, idx; + size_t idx, len; + int error; if (__stack_chk_guard[0] != 0) return; @@ -84,7 +85,8 @@ __guard_setup(void) * data into a temporal array, then do manual volatile copy to * not allow optimizer to call memcpy() behind us. */ - error = _elf_aux_info(AT_CANARY, (void *)tmp_stack_chk_guard, + error = _elf_aux_info(AT_CANARY, + __DEQUALIFY(void *, tmp_stack_chk_guard), sizeof(tmp_stack_chk_guard)); if (error == 0 && tmp_stack_chk_guard[0] != 0) { for (idx = 0; idx < nitems(__stack_chk_guard); idx++) { From owner-svn-src-stable-11@freebsd.org Sat Jan 11 15:06:07 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8AAA1ED1DF; Sat, 11 Jan 2020 15:06:07 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47w38H4Sf9z49X2; Sat, 11 Jan 2020 15:06:07 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 935DD4B72; Sat, 11 Jan 2020 15:06:07 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00BF67EF004763; Sat, 11 Jan 2020 15:06:07 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00BF67tN004761; Sat, 11 Jan 2020 15:06:07 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001111506.00BF67tN004761@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 11 Jan 2020 15:06:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356634 - in stable: 11/sys/compat/linux 11/sys/sys 11/sys/vm 12/sys/compat/linux 12/sys/sys 12/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/compat/linux 11/sys/sys 11/sys/vm 12/sys/compat/linux 12/sys/sys 12/sys/vm X-SVN-Commit-Revision: 356634 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Jan 2020 15:06:07 -0000 Author: kevans Date: Sat Jan 11 15:06:06 2020 New Revision: 356634 URL: https://svnweb.freebsd.org/changeset/base/356634 Log: MFC r356359-r356360: kern_mmap: add fpcheck invariant for linux_mmap r356359: kern_mmap: add a variant that allows caller to inspect fp Linux mmap rejects mmap() on a write-only file with EACCES. linux_mmap_common currently does a fun dance to grab the fp associated with the passed in fd, validates it, then drops the reference and calls into kern_mmap(). Doing so is perhaps both fragile and premature; there's still plenty of chance for the request to get rejected with a more appropriate error, and it's prone to a race where the file we ultimately mmap has changed after it drops its referenced. This change alleviates the need to do this by providing a kern_mmap variant that allows the caller to inspect the fp just before calling into the fileop layer. The callback takes flags, prot, and maxprot as one could imagine scenarios where any of these, in conjunction with the file itself, may influence a caller's decision. The file type check in the linux compat layer has been removed; EINVAL is seemingly not an appropriate response to the file not being a vnode or device. The fileop layer will reject the operation with ENODEV if it's not supported, which more closely matches the common linux description of mmap(2) return values. If we discover that we're allowing an mmap() on a file type that Linux normally wouldn't, we should restrict those explicitly. r356360: kern_mmap: restore character deleted in transit Modified: stable/11/sys/compat/linux/linux_mmap.c stable/11/sys/sys/syscallsubr.h stable/11/sys/vm/vm_mmap.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/compat/linux/linux_mmap.c stable/12/sys/sys/syscallsubr.h stable/12/sys/vm/vm_mmap.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/compat/linux/linux_mmap.c ============================================================================== --- stable/11/sys/compat/linux/linux_mmap.c Sat Jan 11 12:02:16 2020 (r356633) +++ stable/11/sys/compat/linux/linux_mmap.c Sat Jan 11 15:06:06 2020 (r356634) @@ -62,7 +62,17 @@ __FBSDID("$FreeBSD$"); static void linux_fixup_prot(struct thread *td, int *prot); #endif +static int +linux_mmap_check_fp(struct file *fp, int flags, int prot, int maxprot) +{ + /* Linux mmap() just fails for O_WRONLY files */ + if ((fp->f_flag & FREAD) == 0) + return (EACCES); + + return (0); +} + int linux_mmap_common(struct thread *td, uintptr_t addr, size_t len, int prot, int flags, int fd, off_t pos) @@ -118,31 +128,6 @@ linux_mmap_common(struct thread *td, uintptr_t addr, s /* Linux does not check file descriptor when MAP_ANONYMOUS is set. */ fd = (bsd_flags & MAP_ANON) ? -1 : fd; - if (fd != -1) { - /* - * Linux follows Solaris mmap(2) description: - * The file descriptor fildes is opened with - * read permission, regardless of the - * protection options specified. - */ - - error = fget(td, fd, cap_rights_init(&rights, CAP_MMAP), &fp); - if (error != 0) - return (error); - if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_DEV) { - fdrop(fp, td); - return (EINVAL); - } - - /* Linux mmap() just fails for O_WRONLY files */ - if (!(fp->f_flag & FREAD)) { - fdrop(fp, td); - return (EACCES); - } - - fdrop(fp, td); - } - if (flags & LINUX_MAP_GROWSDOWN) { /* * The Linux MAP_GROWSDOWN option does not limit auto @@ -212,13 +197,15 @@ linux_mmap_common(struct thread *td, uintptr_t addr, s */ if (addr != 0 && (bsd_flags & MAP_FIXED) == 0 && (bsd_flags & MAP_EXCL) == 0) { - error = kern_mmap(td, addr, len, prot, - bsd_flags | MAP_FIXED | MAP_EXCL, fd, pos); + error = kern_mmap_fpcheck(td, addr, len, prot, + bsd_flags | MAP_FIXED | MAP_EXCL, fd, pos, + linux_mmap_check_fp); if (error == 0) goto out; } - error = kern_mmap(td, addr, len, prot, bsd_flags, fd, pos); + error = kern_mmap_fpcheck(td, addr, len, prot, bsd_flags, fd, pos, + linux_mmap_check_fp); out: LINUX_CTR2(mmap2, "return: %d (%p)", error, td->td_retval[0]); Modified: stable/11/sys/sys/syscallsubr.h ============================================================================== --- stable/11/sys/sys/syscallsubr.h Sat Jan 11 12:02:16 2020 (r356633) +++ stable/11/sys/sys/syscallsubr.h Sat Jan 11 15:06:06 2020 (r356634) @@ -60,6 +60,8 @@ struct thr_param; struct sched_param; struct __wrusage; +typedef int (*mmap_check_fp_fn)(struct file *, int, int, int); + int kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, u_int buflen, u_int path_max); int kern_accept(struct thread *td, int s, struct sockaddr **name, @@ -165,6 +167,9 @@ int kern_mlock(struct proc *proc, struct ucred *cred, size_t len); int kern_mmap(struct thread *td, uintptr_t addr, size_t size, int prot, int flags, int fd, off_t pos); +int kern_mmap_fpcheck(struct thread *td, uintptr_t addr, size_t len, + int prot, int flags, int fd, off_t pos, + mmap_check_fp_fn check_fp_fn); int kern_mprotect(struct thread *td, uintptr_t addr, size_t size, int prot); int kern_msgctl(struct thread *, int, int, struct msqid_ds *); int kern_msgrcv(struct thread *, int, void *, size_t, long, int, long *); Modified: stable/11/sys/vm/vm_mmap.c ============================================================================== --- stable/11/sys/vm/vm_mmap.c Sat Jan 11 12:02:16 2020 (r356633) +++ stable/11/sys/vm/vm_mmap.c Sat Jan 11 15:06:06 2020 (r356634) @@ -184,6 +184,18 @@ int kern_mmap(struct thread *td, uintptr_t addr0, size_t size, int prot, int flags, int fd, off_t pos) { + + return (kern_mmap_fpcheck(td, addr0, size, prot, flags, fd, pos, NULL)); +} + +/* + * When mmap'ing a file, check_fp_fn may be used for the caller to do any + * last-minute validation based on the referenced file in a non-racy way. + */ +int +kern_mmap_fpcheck(struct thread *td, uintptr_t addr0, size_t size, int prot, + int flags, int fd, off_t pos, mmap_check_fp_fn check_fp_fn) +{ struct vmspace *vms; struct file *fp; vm_offset_t addr; @@ -356,7 +368,11 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t s error = EINVAL; goto done; } - + if (check_fp_fn != NULL) { + error = check_fp_fn(fp, prot, cap_maxprot, flags); + if (error != 0) + goto done; + } /* This relies on VM_PROT_* matching PROT_*. */ error = fo_mmap(fp, &vms->vm_map, &addr, size, prot, cap_maxprot, flags, pos, td); From owner-svn-src-stable-11@freebsd.org Sat Jan 11 16:28:36 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0BFE51EEFC8; Sat, 11 Jan 2020 16:28:36 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47w4zR6DnSz4FTK; Sat, 11 Jan 2020 16:28:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D0AD65A55; Sat, 11 Jan 2020 16:28:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00BGSZIq053382; Sat, 11 Jan 2020 16:28:35 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00BGSZjQ053381; Sat, 11 Jan 2020 16:28:35 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001111628.00BGSZjQ053381@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 11 Jan 2020 16:28:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356635 - stable/11/sys/compat/linux X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/sys/compat/linux X-SVN-Commit-Revision: 356635 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Jan 2020 16:28:36 -0000 Author: kevans Date: Sat Jan 11 16:28:35 2020 New Revision: 356635 URL: https://svnweb.freebsd.org/changeset/base/356635 Log: Fix warning after r356634 This is a direct commit to stable/11, because stable/12 and head no longer used this local 'rights' variable. It is no longer needed now that grabbing fp was moved into mmap. Modified: stable/11/sys/compat/linux/linux_mmap.c Modified: stable/11/sys/compat/linux/linux_mmap.c ============================================================================== --- stable/11/sys/compat/linux/linux_mmap.c Sat Jan 11 15:06:06 2020 (r356634) +++ stable/11/sys/compat/linux/linux_mmap.c Sat Jan 11 16:28:35 2020 (r356635) @@ -82,7 +82,6 @@ linux_mmap_common(struct thread *td, uintptr_t addr, s int bsd_flags, error; struct file *fp; - cap_rights_t rights; LINUX_CTR6(mmap2, "0x%lx, %ld, %ld, 0x%08lx, %ld, 0x%lx", addr, len, prot, flags, fd, pos);