Date: Tue, 9 Dec 2003 15:10:37 -0800 (PST) From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 43699 for review Message-ID: <200312092310.hB9NAboH034461@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=43699 Change 43699 by sam@sam_ebb on 2003/12/09 15:10:01 o correct SOCK_ASSERT definition and renmae to SOCK_LOCK_ASSERT for consistency o change sorele and sotryfree to assume(+assert) a held lock and to zero the parameter to insure no use-after-free problems Affected files ... .. //depot/projects/netperf+sockets/sys/sys/socketvar.h#4 edit Differences ... ==== //depot/projects/netperf+sockets/sys/sys/socketvar.h#4 (text+ko) ==== @@ -148,7 +148,7 @@ #define SOCK_LOCK(_so) SOCKBUF_LOCK(&(_so)->so_rcv) #define SOCK_OWNED(_so) SOCKBUF_OWNED(&(_so)->so_rcv) #define SOCK_UNLOCK(_so) SOCKBUF_UNLOCK(&(_so)->so_rcv) -#define SOCK_ASSERT(_so) SOCKBUF_ASSERT(&(_so)->so_rcv) +#define SOCK_LOCK_ASSERT(_so) SOCKBUF_LOCK_ASSERT(&(_so)->so_rcv) /* * Socket state bits. @@ -289,15 +289,24 @@ } while (0) #define sorele(so) do { \ + SOCK_LOCK_ASSERT(so); \ if ((so)->so_count <= 0) \ panic("sorele"); \ if (--(so)->so_count == 0) \ sofree(so); \ + else { \ + SOCK_UNLOCK(so); \ + so = NULL; \ + } \ } while (0) #define sotryfree(so) do { \ + SOCK_LOCK_ASSERT(so); \ if ((so)->so_count == 0) \ sofree(so); \ + else \ + SOCK_UNLOCK(so); \ + so = NULL; \ } while (0) #define sorwakeup(so) do { \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200312092310.hB9NAboH034461>