From owner-freebsd-net@FreeBSD.ORG Thu Oct 30 19:39:42 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D1F3B34A; Thu, 30 Oct 2014 19:39:42 +0000 (UTC) Received: from mail-yh0-x236.google.com (mail-yh0-x236.google.com [IPv6:2607:f8b0:4002:c01::236]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8C15C94B; Thu, 30 Oct 2014 19:39:42 +0000 (UTC) Received: by mail-yh0-f54.google.com with SMTP id 29so2119855yhl.41 for ; Thu, 30 Oct 2014 12:39:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=4XNdPwyB2tfjCIHfH2vkgq9PtZ+pgGA+PapNli5mkYU=; b=L4zd1dbjAlLb/LveqOLXxre9QPLsCG841PTQ7WySa5L8oo/70zBqCS2ZnUYb7YSwhI XyZFlqzb9+UfCzQTn9ym0dh2CoRdCdLg8HQrULNyr3KgzC0xe0yyUt6uHD1GF5ztZSZF DM3fAyQhIeJkV+LXHtO56H2dhzgp6SUFp8AYy9nKG5Jc0+f7Ke9yjw/bAIWfSPd6ulVK fAtoA2Lsq+5wPbvqMuC3b5rrZbxcAz6lLcgwbJMlOe1A2uniJThJCREagI6ei7WRoeVI cfl5u63QKsEnxtproENpTuMaZ2uRaxKLYrYTwTxA7mfB9+zviTt4AdZzisiVYqwfKVBC Tmsg== MIME-Version: 1.0 X-Received: by 10.170.221.193 with SMTP id n184mr19703505ykf.25.1414697981658; Thu, 30 Oct 2014 12:39:41 -0700 (PDT) Sender: kmacybsd@gmail.com Received: by 10.170.82.197 with HTTP; Thu, 30 Oct 2014 12:39:41 -0700 (PDT) In-Reply-To: References: <20131226175410.GA15332@lath.rinet.ru> Date: Thu, 30 Oct 2014 12:39:41 -0700 X-Google-Sender-Auth: roAY8z0yHtwL8LHtJsljj2CKXUM Message-ID: Subject: Re: buf_ring in HEAD is racy From: "K. Macy" To: "De La Gueronniere, Marc" Content-Type: text/plain; charset=UTF-8 Cc: Ryan Stone , Oleg Bulyzhin , "Charbon, Julien" , freebsd-net X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2014 19:39:42 -0000 > > I also suspect there are further problems with buf_ring. A full wrap > around of the atomically swapped value is possible. I.e. the code thinks > it just atomically updated a head/tail index when in fact a full wrap > around occurred leading to undefined land. A relatively simple way to > avoid this is to only mask on ring array access, and to let the > head/tail/prod/cons indices overflow the array. > Up until Rui Paulo complained to me of packet drops with buf_ring a couple of days ago I had thought that this patch had been committed. This patch (now 273866) fixes the problem for him. Without further scrutiny and testing I won't provide the UL guarantee for buf_ring_enqueue, but this is a clear improvement. -K