Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7946537ybi; Tue, 9 Jul 2019 06:46:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqx71DRi5mFLFRc9ZPdWWjnYvd6fE5p4PQHkJ8QUZ0UCK9D6aUTSf4B3xQkjlhQjOtkJJViv X-Received: by 2002:a63:34c3:: with SMTP id b186mr30706203pga.294.1562679974621; Tue, 09 Jul 2019 06:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562679974; cv=none; d=google.com; s=arc-20160816; b=Z3sLz8U9SZA+85cp2nlZo3L6vW+JHv+13VEQADyTkb724I8S6mlJzQ+c80fsgAg6ww kHBWx7O2rDBe6NZ/MKP1cNcBKQOcciF47IYpcJLStIwMPdnjVbugyUqBI6GuxiioJiZ9 gh8dL03htjUOPST+PT7q1nt5sHMZa6hcxroV1UIEWK4tylhSCDhRq8QE7Mj2RI+hjmAh qyX/4raUs0tQ0NkHmhSSd8O2Zy3Us9nD4HzjQ/sIxVxBsJeZEgchDWAEPk/2csEs92zZ 1n65sRxWUJgslyIbQwN0+3wuIvEMltIKPBcvAnPNh7/PPGuETA+I7tkTqeoZ9d8bE1sO hm1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=WoOafQCA+SKQoC197BJQPKhoNGwN0GTGPnMhrXbSqsY=; b=cU6Du76bGkyvDP/fxPameQRjkuqvTkuGJATDL1sQUkZKc5dDU1LmhJp7j0VaCf2KRC C9z9PTgjpw6cztrCFxWFuo+PN8Tq/ALHhUYRx1kXWWnGSDMFmiAXKyFFhvytDfepiTbD c6YnzKDtkqlXftMYC0JYIhCy27QS1Ml1Ic/iHiX3kKcxSQUtGgyMDFyFRV6M3AqaQx1u 9mtp5oxELYfsJ78KKMB0AnWxgfy+mZdPCGFESRaZf6t/xuJvCZ8l+OnuJanIkge2OOGT 59SQoCZXElw+bb5VMB+7iRuajb+siAVahD4ODdAtXPTbiOEloRWxHAZqVY88M1vO009V qE4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JqrLe8hL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g13si22558924pgr.577.2019.07.09.06.45.56; Tue, 09 Jul 2019 06:46:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JqrLe8hL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726660AbfGINpg (ORCPT + 99 others); Tue, 9 Jul 2019 09:45:36 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44477 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbfGINpg (ORCPT ); Tue, 9 Jul 2019 09:45:36 -0400 Received: by mail-wr1-f68.google.com with SMTP id p17so9939845wrf.11; Tue, 09 Jul 2019 06:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=WoOafQCA+SKQoC197BJQPKhoNGwN0GTGPnMhrXbSqsY=; b=JqrLe8hLX3vXecb9fN+lSl3VceukltpW7iONEOWHMfWuvftTwnQTzDrRtpIq86BnTo 6oUWzHhWA6iSgm/Ua+Cpz0dncARYLe04rUP4rPAXvVCtY28zKRQGW6QZRzG2ZGpEPeUS NeCBhT3XMXIFoICUd5tUZqJlxZKWj/Xy1DHIMHzF+3jwxiXbf5qbY4+zKO+6Sg+0n+Uk 1Vo7xMFx/U2pDIaUEbV4XCMHa0IzrvkYbTzOGquArrNNSsoSbrz9hzNdYzbv41/34J4Z WwpGLLId/AUGjV9IzE/CAYkoO9v5Ta5V7My/gTq81TZvLSRdL5HluZpPkeOtGe1mlF5k XEZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WoOafQCA+SKQoC197BJQPKhoNGwN0GTGPnMhrXbSqsY=; b=sokIQLqXkLQ30MqVf8wbWzjXGtMIWdPSDjwGptrILIG0g/a0TAhpWMgjIsRyGSFpiE i3lJq7X+ovvWLqji/VCvBcDcunyL+ieCBnUpDmDBquxT3QoiiQ5OSgdCdXEJhiQyn7m9 rdKK8KUktcHAM+APloaabzYod3pySygNQVYkvr7DkVSW15hO5iWzDKW+JpCURbjjWv33 50RoFj6yovU7ogRL8fUcGPruvIhJxS26FjfnvE5YkT8vVL/v9xCy8YPTV2MZw3zWGFGx I+sRt4glOlCYD+mkKQoE1mvyP3t/YuwXoVeWlT+f6rWhPcDoQpXF8dqTMkJIb5CraF3n zUeQ== X-Gm-Message-State: APjAAAUVEK4wbyQNv/77eRyKHsoWgS37NXhtkm1jo3P72CQxWYNIsdOu SclStVv3uFyGbBh33rodWmIo+ztt X-Received: by 2002:adf:f591:: with SMTP id f17mr26252881wro.119.1562679933912; Tue, 09 Jul 2019 06:45:33 -0700 (PDT) Received: from [192.168.8.147] (179.162.185.81.rev.sfr.net. [81.185.162.179]) by smtp.gmail.com with ESMTPSA id x6sm20911824wrt.63.2019.07.09.06.45.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jul 2019 06:45:33 -0700 (PDT) Subject: Re: [PATCH] tipc: ensure skb->lock is initialised To: Jon Maloy , Eric Dumazet , Chris Packham , "ying.xue@windriver.com" , "davem@davemloft.net" Cc: "netdev@vger.kernel.org" , "tipc-discussion@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" References: <20190707225328.15852-1-chris.packham@alliedtelesis.co.nz> <2298b9eb-100f-6130-60c4-0e5e2c7b84d1@gmail.com> <361940337b0d4833a5634ddd1e1896a9@svr-chch-ex1.atlnz.lc> <87fd2150548041219fc42bce80b63c9c@svr-chch-ex1.atlnz.lc> From: Eric Dumazet Message-ID: Date: Tue, 9 Jul 2019 15:45:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/9/19 3:25 PM, Jon Maloy wrote: > > >> -----Original Message----- >> From: Eric Dumazet >> Sent: 9-Jul-19 03:31 >> To: Chris Packham ; Eric Dumazet >> ; Jon Maloy ; >> ying.xue@windriver.com; davem@davemloft.net >> Cc: netdev@vger.kernel.org; tipc-discussion@lists.sourceforge.net; linux- >> kernel@vger.kernel.org >> Subject: Re: [PATCH] tipc: ensure skb->lock is initialised >> >> >> >> On 7/8/19 11:13 PM, Chris Packham wrote: >>> On 9/07/19 8:43 AM, Chris Packham wrote: >>>> On 8/07/19 8:18 PM, Eric Dumazet wrote: >>>>> >>>>> >>>>> On 7/8/19 12:53 AM, Chris Packham wrote: >>>>>> tipc_named_node_up() creates a skb list. It passes the list to >>>>>> tipc_node_xmit() which has some code paths that can call >>>>>> skb_queue_purge() which relies on the list->lock being initialised. >>>>>> Ensure tipc_named_node_up() uses skb_queue_head_init() so that the >>>>>> lock is explicitly initialised. >>>>>> >>>>>> Signed-off-by: Chris Packham >>>>> >>>>> I would rather change the faulty skb_queue_purge() to >>>>> __skb_queue_purge() >>>>> >>>> >>>> Makes sense. I'll look at that for v2. >>>> >>> >>> Actually maybe not. tipc_rcast_xmit(), tipc_node_xmit_skb(), >>> tipc_send_group_msg(), __tipc_sendmsg(), __tipc_sendstream(), and >>> tipc_sk_timeout() all use skb_queue_head_init(). So my original change >>> brings tipc_named_node_up() into line with them. >>> >>> I think it should be safe for tipc_node_xmit() to use >>> __skb_queue_purge() since all the callers seem to have exclusive >>> access to the list of skbs. It still seems that the callers should all >>> use >>> skb_queue_head_init() for consistency. > > I agree with that. > >>> >> >> No, tipc does not use the list lock (it relies on the socket lock) and therefore >> should consistently use __skb_queue_head_init() instead of >> skb_queue_head_init() > > TIPC is using the list lock at message reception within the scope of tipc_sk_rcv()/tipc_skb_peek_port(), so it is fundamental that the lock always is correctly initialized. Where is the lock acquired, why was it only acquired by queue purge and not normal dequeues ??? > >> > [...] >> >> tipc_link_xmit() for example never acquires the spinlock, yet uses skb_peek() >> and __skb_dequeue() > > > You should look at tipc_node_xmit instead. Node local messages are sent directly to tipc_sk_rcv(), and never go through tipc_link_xmit() tipc_node_xmit() calls tipc_link_xmit() eventually, right ? Please show me where the head->lock is acquired, and why it needed. If this is mandatory, then more fixes are needed than just initializing the lock for lockdep purposes.