From patchwork Sat Jun 11 05:04:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ronny Meeus X-Patchwork-Id: 104273 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C92D0B6F7B for ; Tue, 12 Jul 2011 05:44:23 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757394Ab1GKToS (ORCPT ); Mon, 11 Jul 2011 15:44:18 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:52155 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757251Ab1GKToR (ORCPT ); Mon, 11 Jul 2011 15:44:17 -0400 Received: by wyg8 with SMTP id 8so2815799wyg.19 for ; Mon, 11 Jul 2011 12:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=content-type:mime-version:content-transfer-encoding:subject :x-mercurial-node:message-id:user-agent:date:from:to; bh=Q8deTNK173Ghq52++vhHXd4DwnVQXx1tcflYWXoeVoM=; b=Lwx6S8Zmfy++4PJf2Nv49rduW8RbmYFYobrGjr84Bl7P1NhzqjNF1ihZw6HLYptJbv mtmjKhSk4PKZLGv9LyMoNOprIQq6AIqFKrM0uuKKN4YSlQ6GVlia/qJMG1CG5rBenPPF EukAKrfT4ebWN2pwJqCjBqafJ3RN1oa6dZAI4= Received: by 10.227.10.210 with SMTP id q18mr4651420wbq.44.1310413456035; Mon, 11 Jul 2011 12:44:16 -0700 (PDT) Received: from [127.0.1.1] ([109.132.85.139]) by mx.google.com with ESMTPS id gb1sm10281161wbb.37.2011.07.11.12.44.14 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Jul 2011 12:44:15 -0700 (PDT) MIME-Version: 1.0 Subject: [PATCH] [PATCH] Fix deadlock in af_packet while stressing raw ethernet socket interface X-Mercurial-Node: 78567a0a1d2999f06d8ff7ebee33658c09344f45 Message-Id: <78567a0a1d2999f06d8f.1307768649@meeusr-laptop> User-Agent: Mercurial-patchbomb/1.6.3 Date: Sat, 11 Jun 2011 07:04:09 +0200 From: Ronny Meeus To: netdev@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org I was running a test: 1 application was sending raw Ethernet packets on a physical looped interface while a second application was receiving packets, so the latter application receives each packet 2 times (once while sending from the context of the first application and a second time while receiving from the hardware). After some time, the test blocks due to a spinlock reentrance issue in af_packet. Both the sending application and the softIRQ receiving packets enter the spinlock code. After applying the patch below, the issue is resolved. Signed-off-by: Ronny Meeus --- net/packet/af_packet.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff -r ab5136256418 -r 78567a0a1d29 net/packet/af_packet.c --- a/net/packet/af_packet.c Fri Jun 10 20:31:07 2011 +0200 +++ b/net/packet/af_packet.c Sat Jun 11 07:03:55 2011 +0200 @@ -618,11 +618,11 @@ /* drop conntrack reference */ nf_reset(skb); - spin_lock(&sk->sk_receive_queue.lock); + spin_lock_bh(&sk->sk_receive_queue.lock); po->stats.tp_packets++; skb->dropcount = atomic_read(&sk->sk_drops); __skb_queue_tail(&sk->sk_receive_queue, skb); - spin_unlock(&sk->sk_receive_queue.lock); + spin_unlock_bh(&sk->sk_receive_queue.lock); sk->sk_data_ready(sk, skb->len); return 0; @@ -718,7 +718,7 @@ snaplen = 0; } - spin_lock(&sk->sk_receive_queue.lock); + spin_lock_bh(&sk->sk_receive_queue.lock); h.raw = packet_current_frame(po, &po->rx_ring, TP_STATUS_KERNEL); if (!h.raw) goto ring_is_full; @@ -730,7 +730,7 @@ } if (!po->stats.tp_drops) status &= ~TP_STATUS_LOSING; - spin_unlock(&sk->sk_receive_queue.lock); + spin_unlock_bh(&sk->sk_receive_queue.lock); skb_copy_bits(skb, 0, h.raw + macoff, snaplen); @@ -816,7 +816,7 @@ ring_is_full: po->stats.tp_drops++; - spin_unlock(&sk->sk_receive_queue.lock); + spin_unlock_bh(&sk->sk_receive_queue.lock); sk->sk_data_ready(sk, 0); kfree_skb(copy_skb);