From owner-freebsd-current@FreeBSD.ORG Sun Apr 19 23:06:53 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03ADA106567B for ; Sun, 19 Apr 2009 23:06:53 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.30]) by mx1.freebsd.org (Postfix) with ESMTP id B53438FC2A for ; Sun, 19 Apr 2009 23:06:52 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: by yx-out-2324.google.com with SMTP id 31so508515yxl.13 for ; Sun, 19 Apr 2009 16:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=C3AyIhSs5h0ly4QDs3rA2oWPXm3lbuUbxT2+z03snuo=; b=EHvYEuG8bAPYJCi8Sn+TXSbKyHuSLup4GTUJsdqXsKeS+/r3Akr1FwdBstbQr4tiBe JETPI8RwTR8drK+beizTHCKO+KJiFpUbv61H5S3R3sRkg3/eqmUx8QoHeCVtV7o0AZTL GQzvpXuqkVWtM76EV66+P/w432nKxhCHPjNoU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=a8HP1OU9zTte9qhRMOLFc4Z0VJ0fTQuIBdHvFcotos92luSGA/9q8RRcidMpTiottd B5Xp8sBFcKcey71Re6T6kmZnDQxe3a4Qrmti/WS/xEGKl7H7yU3f976CFmPpOeiWnk/U cWDw3JJXSRXVIO9Kx4/4oWvcR6pG+PsqIm6Sw= MIME-Version: 1.0 Received: by 10.90.106.4 with SMTP id e4mr2626253agc.88.1240182411358; Sun, 19 Apr 2009 16:06:51 -0700 (PDT) Date: Sun, 19 Apr 2009 16:06:51 -0700 Message-ID: From: Maksim Yevmenkin To: FreeBSD Current Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: sb_mbtail is not set in sbappendrecord_locked() X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Apr 2009 23:06:53 -0000 hello, i'm fairly certain that sbappendrecord_locked() has bug in it. the bug is triggered by the kernel SOCKBUF_DEBUG option. the easiest way to trigger the bug is to 1) compile kernel with the SOCKBUF_DEBUG option enabled; 2) call sbappendrecord_locked() and try to append mbuf chain with exactly one mbuf (i.e. m0->m_next is NULL) to an empty sockbuf; there is a kern/126742 pr that basically shows the problem and stack traces. initial investigation was done by "pluknet" < pluknet -at- gmail -dot- com >, who confirmed the bug. see http://lists.freebsd.org/pipermail/freebsd-net/2008-August/019345.html for more details. i'm proposing the following patch. please review. == > svn diff Index: uipc_sockbuf.c =================================================================== --- uipc_sockbuf.c (revision 191012) +++ uipc_sockbuf.c (working copy) @@ -577,10 +577,6 @@ if (m0 == 0) return; - m = sb->sb_mb; - if (m) - while (m->m_nextpkt) - m = m->m_nextpkt; /* * Put the first mbuf on the queue. Note this permits zero length * records. @@ -588,17 +584,17 @@ sballoc(sb, m0); SBLASTRECORDCHK(sb); SBLINKRECORD(sb, m0); - if (m) - m->m_nextpkt = m0; - else - sb->sb_mb = m0; + sb->sb_mbtail = m0; m = m0->m_next; m0->m_next = 0; - if (m && (m0->m_flags & M_EOR)) { - m0->m_flags &= ~M_EOR; - m->m_flags |= M_EOR; + if (m != NULL) { + if (m0->m_flags & M_EOR) { + m0->m_flags &= ~M_EOR; + m->m_flags |= M_EOR; + } + + sbcompress(sb, m, m0); } - sbcompress(sb, m, m0); } /* == thanks, max