Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7157946ybi; Mon, 8 Jul 2019 15:49:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAgg3T5bBiqoRiHyRrQPSB2CZ+YfmEA7hVfecyUxn9W9COjYV07NVLiEM1eiZOlr5yxusg X-Received: by 2002:a17:902:b196:: with SMTP id s22mr26029345plr.245.1562626180300; Mon, 08 Jul 2019 15:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562626180; cv=none; d=google.com; s=arc-20160816; b=NtbuBgcZZDQvLIdpcwtKrqCyRUMjT+5IAuou87AAiXUuyIbl3GnRjbjt1fQ4s4tYVB tEVQ4xiQLeawa+efzeWkmYGutLZzWCh/wQy0ugRQnpDCwHdpXqOVey+pLOyeJcKAMova IsrvyFyQW351MSRg28tQVsClg5HzsA3Tt/MLiX8nWnnCqhbsa+Tg2KAj7rb61lXM+w6Z efRosDGAy1fDJY8e7ncuKpjgGPBVYsQ9aCBhnharZJSvjMaoHhur50QsfGhehoufXDPX I9ujpW8kP9pMBa2Qn7l9qRuxcMP+5iCmuXJdSjBL46iR685Rpx4NL4qNwCvZdc/XaMkj 7xrw== 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=TylGuspNeCUoW8nua4Sr0QWN1QxRHrGILCPTzFyGjF4=; b=NSjEkq4n1DIglQ7xk+7QhsK7obTqK5cfBq0RaA3JU4lMxcf4687Gj/7CwZ/Aj3/UO+ tx1JmuAto4RdZUGMeE8+ogwItWFM7WxuS5C7b2wHk7ahOQnEOnh8aNRq9SI6dTreUVe7 AhUxID9ZZxrbaKNjXPyZXZwPSLf1Kirke55zrfYKnf6LzphLHMMf9FWWflFadw3KyW5A XmI9YjJTCveZCEbUpFJyft/3xHrVUM8n/bJFuEliQ6mxPSD2FfGEopVfnKTVJ5XWY8qB NQoD0MnhC1op1H5UepaR5YEmwt7hSoZxzSUs+KkVwG7FxPzqx6Xvd1/4bMPQsGY/hfIS HsOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b="PcWw+/z2"; 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 6si20236836pgb.201.2019.07.08.15.49.26; Mon, 08 Jul 2019 15:49:40 -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="PcWw+/z2"; 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 S1731693AbfGHTiQ (ORCPT + 99 others); Mon, 8 Jul 2019 15:38:16 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:44093 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731628AbfGHTiQ (ORCPT ); Mon, 8 Jul 2019 15:38:16 -0400 Received: by mail-qk1-f193.google.com with SMTP id d79so9959659qke.11 for ; Mon, 08 Jul 2019 12:38:16 -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=TylGuspNeCUoW8nua4Sr0QWN1QxRHrGILCPTzFyGjF4=; b=PcWw+/z2WHLQiOeNrbXf/1WeVVGWBkKKh4TOwzFaP3xI1R52FemdlSxUyfeSEGKHRG BR4TQ+KjWlm1+fndB0979LrQAHfyEKQDrp4GPMXvH4+ezBUZaPcFsSWdlsOz7QLU+drT 2rh3GD3k+eXKyfnpI44JzhUYTULeEtssA011xCfOkqx4OECoy4VbWXbvlRFcCvdLeMMD G5nDmtJ1HlcXNgweqYcWf+akG7KG3x/lPOSu71NqC0AOD7a9mbf4hCmW4Tca+fiFhVqF KNF8tWiHmTz2C6af/yTHJY3M5fsUKArdwpE8YScZKt8zEFhsFMircsg2A2XYFAIKGAtJ HnxA== 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=TylGuspNeCUoW8nua4Sr0QWN1QxRHrGILCPTzFyGjF4=; b=eSgxmrFlYt+Np6hkk3yx0mtlWPwMfKwPeD8Luwo9Ww4R67o0g5jaeXNYq5G07GmQUK Hwe539HwD/PLY+3H6xv5arXOSrOoI92nbvKmMjIiT/zTY0xOgNumQGiPyqLskRBG1+2r Ib/jhVGaKvDob3vJvOmxT/nZEWDbuXR5v0uK3UU/9LFGnfKkKcC8KmeRMU5aNxqYuouE qIlbWpof7xgVd+tWaPkQYnY15DB11bwRfrhd5Hvz6PgjMnS8AzcgeiTQrSNQEP7xCzQ3 yFqpvmOujSrZyWO2rg76IHUrPsG5gq9XQwu7W5kFQaXljGFvId0x6d4QtIkQbeFlECGo +NyQ== X-Gm-Message-State: APjAAAX67+e+D7upF4YdT5Xzf7FG/N/TH7bPohbFGB+zw7rS0JWspaUQ TRltc2Fh8WPUC9wTS5uUM1LRBA== X-Received: by 2002:a37:62ca:: with SMTP id w193mr14360785qkb.363.1562614695570; Mon, 08 Jul 2019 12:38:15 -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 t2sm10048103qth.33.2019.07.08.12.38.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 12:38:15 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hkZSo-0006yC-Dz; Mon, 08 Jul 2019 16:38:14 -0300 Date: Mon, 8 Jul 2019 16:38:14 -0300 From: Jason Gunthorpe To: Mark Bloch Cc: Dag Moxnes , "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: <20190708193814.GF23996@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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <63b9d2cb-f69c-d77c-7803-f08e2a6f755d@mellanox.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 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 Thanks, Jason