Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7199364ybi; Mon, 8 Jul 2019 16:45:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1mmOCcJ3VMztTg3HmViTlHCAJWOtKG+9Fc7nw5N8UXTkdzOSos1RtcBrV53xw1ZRYc5lT X-Received: by 2002:a63:494d:: with SMTP id y13mr27298379pgk.109.1562629542794; Mon, 08 Jul 2019 16:45:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562629542; cv=none; d=google.com; s=arc-20160816; b=KEFt5YA6W+16Rkxf+T3rxdbkZ6Puo9N4Lzj0rBnRVl4TzOpAs5lfSm7knwXgVgxeT1 9m5hZQggG/OruEL+2c9Iyb48/S2EgJbOvItQmupjfKSah8jj49yQhEj3cEqASe247Dlm PifagXFbHhTEWqoROOeMv9v1aiPqRYuotf2ojuQTlmqbhAdXypGnVkQsUplP5fE2Z+aM XVGbMMTradygjE8XrseD1PWi2P/TDXw3HsAcrkWNwX42Vil4f3KQHzdU0+FpvZEknCfp HAH22s6Tb4FRKYhZu1NYhdkpDPLTz5ighc6pfzfdpQy5gzbRDPcdo0JAJptMxw2IfRaT 0gcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vUmFyAFJP6D1L/Z0W6cwED3cSN9zX28O4rJsev7br/g=; b=fV70AY5spmAm9rGtHnKVOFzsllgpl8BcFKPFYrTtKsBaG2WV33uVkrX/QxmGDax+TF XJnm2xkAsQsGl6pp45ZFflkZoyOlJMw1m8HCy8dr2wzWdEiOFr4J5ONiiauBr93mCYbd fUuUjt0S1m23Bm2/7GLxnHjPteGzF6zwuH2XmTYq6k9pggcIvaFBJfgmcqb0hSGh06Rt tWUDZ0JIbglNoY3ZUVhDcDrcFrPIWRxCkSZfn6aNIvmvbHQl8agbwxasQcPny5qjXK3s htAxEq8BA19u+8QmL206rjqj8uUoe49wsyBiKFft61k+O7g+T58U+AIPOHM4gIr31uC1 vnkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=bRb1UyQh; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t36si22312888pga.32.2019.07.08.16.45.28; Mon, 08 Jul 2019 16:45:42 -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=@ziepe.ca header.s=google header.b=bRb1UyQh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727702AbfGHXF1 (ORCPT + 99 others); Mon, 8 Jul 2019 19:05:27 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:42356 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726820AbfGHXF0 (ORCPT ); Mon, 8 Jul 2019 19:05:26 -0400 Received: by mail-qk1-f196.google.com with SMTP id 201so12496203qkm.9 for ; Mon, 08 Jul 2019 16:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=vUmFyAFJP6D1L/Z0W6cwED3cSN9zX28O4rJsev7br/g=; b=bRb1UyQhhgptjB7bucYZcRSjz7loj+ef0exzrWdJceIFhJpq/ZGrTeJsuiTUbRjroa aJayTI1PkJi8ioYjoL/VHfat/F5mvH41SZ7dbFxzqTtvvrNgvV47jI76ojZiwJGR2L+/ ahWrBvONpF7I/fr8NfFXBSxdriirqw50fa72LoU93WaVIddjpip6lYsQMcx15Qdv5zOP 8cV3tOvz5SIL4f09W7ylbhvTtKx9hNbN3T7HkP5SZOrX/7toWC/L9MYyZG+I/VJChfSv sUxeQ69hhBNm5XuOCaUWpyfRRBTcSyS0cqiXTBOWnomJoqK3JbnlulECHr3ikn1pR7Ci B+Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=vUmFyAFJP6D1L/Z0W6cwED3cSN9zX28O4rJsev7br/g=; b=Dh21kE3KsUA1z/vAhSDnJcDJgt2GtrTk8VldoGVKaH9qdaNWaa1WM63pHs6Q5d+zqp YcX01Vnj93/cAHxOqwlkHSMaIZhk2ayvE4RPDBmLgpDE4ugcrwnPTcDG9Hyiu65YRJub B/XFwaLsRTvfkTP0rnLVpxTf24XJiGcoeb7ni8swRlAjjp8Tl+YiCKykDa6RiJNkCSA3 mjCusI9DqDAbtpdiyWfvJle/9uVtWp75cv/ha7cP3PzZ8R+iy3A9p3q2hKBtqKgkwUc9 1k7aEWjK9Lb0+LFtdX7uR1e9lmDWLjdGyepJX/M80Os+eBlsx3SukssqHShrwBvdoMqo KkCw== X-Gm-Message-State: APjAAAXWLqOQV5SAI9lzBuQhxSps6DsL3bc5LDRoRBWivVhnrHB5ahWB G7IacdmHLnc/gh4EvuXPV1gTVg== X-Received: by 2002:a37:a744:: with SMTP id q65mr16071533qke.151.1562627125887; Mon, 08 Jul 2019 16:05:25 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-55-100.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.55.100]) by smtp.gmail.com with ESMTPSA id t29sm9359131qtt.42.2019.07.08.16.05.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 16:05:25 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hkchJ-0003CJ-2J; Mon, 08 Jul 2019 20:05:25 -0300 Date: Mon, 8 Jul 2019 20:05:25 -0300 From: Jason Gunthorpe To: Dag Moxnes Cc: Mark Bloch , "dledford@redhat.com" , "leon@kernel.org" , Parav Pandit , "linux-rdma@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3] RDMA/core: Fix race when resolving IP address Message-ID: <20190708230525.GI23996@ziepe.ca> References: <1562584584-13132-1-git-send-email-dag.moxnes@oracle.com> <20190708175025.GA6976@ziepe.ca> <4b9ae7b8-310c-e0b6-7a8e-33e6d5bef83d@oracle.com> <63b9d2cb-f69c-d77c-7803-f08e2a6f755d@mellanox.com> <20190708193814.GF23996@ziepe.ca> <424b75d7-90ea-8d07-42b9-de9d507b0f85@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <424b75d7-90ea-8d07-42b9-de9d507b0f85@oracle.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 08, 2019 at 10:11:29PM +0200, Dag Moxnes wrote: > > > Den 08.07.2019 21:38, skrev Jason Gunthorpe: > > On Mon, Jul 08, 2019 at 07:22:45PM +0000, Mark Bloch wrote: > > > > > > On 7/8/19 11:47 AM, Dag Moxnes wrote: > > > > Thanks Jason, > > > > > > > > Regards, > > > > Dag > > > > > > > > Den 08.07.2019 19:50, skrev Jason Gunthorpe: > > > > > On Mon, Jul 08, 2019 at 01:16:24PM +0200, Dag Moxnes wrote: > > > > > > Use neighbour lock when copying MAC address from neighbour data struct > > > > > > in dst_fetch_ha. > > > > > > > > > > > > When not using the lock, it is possible for the function to race with > > > > > > neigh_update, causing it to copy an invalid MAC address. > > > > > > > > > > > > It is possible to provoke this error by calling rdma_resolve_addr in a > > > > > > tight loop, while deleting the corresponding ARP entry in another tight > > > > > > loop. > > > > > > > > > > > > This will cause the race shown it the following sample trace: > > > > > > > > > > > > rdma_resolve_addr() > > > > > >    rdma_resolve_ip() > > > > > >      addr_resolve() > > > > > >        addr_resolve_neigh() > > > > > >          fetch_ha() > > > > > >            dst_fetch_ha() > > > > > >              n->nud_state == NUD_VALID > > > > > It isn't nud_state that is the problem here, it is the parallel > > > > > memcpy's onto ha. I fixed the commit message > > > > > > > > > > This could also have been solved by using the ha_lock, but I don't > > > > > think we have a reason to particularly over-optimize this. > > > Sorry I'm late to the party, but why not just use: neigh_ha_snapshot()? > > Yes, that is much better, please respin this > OK, will do! > Can I still post it as a v4? Or should I do it differently as you already > applied it? post a v4 Jason