Date: Wed, 21 Nov 2018 22:25:05 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r340749 - head/sys/kern Message-ID: <201811212225.wALMP5uh018191@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Wed Nov 21 22:25:05 2018 New Revision: 340749 URL: https://svnweb.freebsd.org/changeset/base/340749 Log: uipc_usrreq: fix inode number assignment The code was incrementing a global variable in an unsafe manner. Two different threads stating two different sockets could have resulted in the same inode numbers assigned to both. Creation is protected with a global lock, move the assigment there. Since inode numbers are 64-bit now drop the check for overflows. Sponsored by: The FreeBSD Foundation Modified: head/sys/kern/uipc_usrreq.c Modified: head/sys/kern/uipc_usrreq.c ============================================================================== --- head/sys/kern/uipc_usrreq.c Wed Nov 21 22:16:10 2018 (r340748) +++ head/sys/kern/uipc_usrreq.c Wed Nov 21 22:25:05 2018 (r340749) @@ -530,6 +530,7 @@ uipc_attach(struct socket *so, int proto, struct threa UNP_LINK_WLOCK(); unp->unp_gencnt = ++unp_gencnt; + unp->unp_ino = ++unp_ino; unp_count++; switch (so->so_type) { case SOCK_STREAM: @@ -1302,12 +1303,8 @@ uipc_sense(struct socket *so, struct stat *sb) KASSERT(unp != NULL, ("uipc_sense: unp == NULL")); sb->st_blksize = so->so_snd.sb_hiwat; - UNP_PCB_LOCK(unp); sb->st_dev = NODEV; - if (unp->unp_ino == 0) - unp->unp_ino = (++unp_ino == 0) ? ++unp_ino : unp_ino; sb->st_ino = unp->unp_ino; - UNP_PCB_UNLOCK(unp); return (0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811212225.wALMP5uh018191>