From owner-svn-src-all@FreeBSD.ORG Tue Aug 25 12:32:16 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 81029106568C; Tue, 25 Aug 2009 12:32:16 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6E6E98FC1A; Tue, 25 Aug 2009 12:32:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7PCWGON027750; Tue, 25 Aug 2009 12:32:16 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7PCWGt1027748; Tue, 25 Aug 2009 12:32:16 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <200908251232.n7PCWGt1027748@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Tue, 25 Aug 2009 12:32:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196538 - in stable/7/sys: . contrib/pf kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Aug 2009 12:32:16 -0000 Author: bz Date: Tue Aug 25 12:32:16 2009 New Revision: 196538 URL: http://svn.freebsd.org/changeset/base/196538 Log: MFC r182842: Catch a possible NULL pointer deref in case the offsets got mangled somehow. As a consequence we may now get an unexpected result(*). Catch that error cases with a well defined panic giving appropriate pointers to ease debugging. (*) While the concensus was that the case should never happen unless there was a bug, noone was definitively sure. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/kern/uipc_sockbuf.c Modified: stable/7/sys/kern/uipc_sockbuf.c ============================================================================== --- stable/7/sys/kern/uipc_sockbuf.c Tue Aug 25 11:44:17 2009 (r196537) +++ stable/7/sys/kern/uipc_sockbuf.c Tue Aug 25 12:32:16 2009 (r196538) @@ -930,11 +930,13 @@ sbsndptr(struct sockbuf *sb, u_int off, /* Advance by len to be as close as possible for the next transmit. */ for (off = off - sb->sb_sndptroff + len - 1; - off > 0 && off >= m->m_len; + off > 0 && m != NULL && off >= m->m_len; m = m->m_next) { sb->sb_sndptroff += m->m_len; off -= m->m_len; } + if (off > 0 && m == NULL) + panic("%s: sockbuf %p and mbuf %p clashing", __func__, sb, ret); sb->sb_sndptr = m; return (ret);