Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2865143ybi; Thu, 4 Jul 2019 21:14:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwN+PJQ4hFgzFDiGLkwEoPVuxeTkJIBhMTnUAamCB+dYkYgjEi4qn3LnUvFFUVS1mfwgDS/ X-Received: by 2002:a63:c84d:: with SMTP id l13mr2339084pgi.154.1562300055757; Thu, 04 Jul 2019 21:14:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562300055; cv=none; d=google.com; s=arc-20160816; b=BR+umyKiYEcuUpH0Xn6jd1IsFVxh8UcydBcNfe+aoYNjF6WzeW0YRiPXVB+KcTVS0/ EKEekJwVjXhWEEu38LO+f7RFavyGSPB6nidyeykmuIUBY6KxUxtL5gBzozmA5MHx4nIk ooRjZpuWwN0ITfoom81KnKYo4uhrLwsaZ6NoCFa3xuVXd7wBQPgCTTwcBkWuzZ2pNKSs NT4STe0iDHnqcfpGhtqPtavaF5L6tUi9MsAnA+Kbk0tF3aggedHTl2bRBpr2W8yMvLss BgpZ0pCqdtPyM5hdsGOfGc78NYQsTW1g/jX0Kk5hY8Zl0JpCElljHve7Pxw2IvjoA2O1 xqUg== 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=z5zR7lfHvJTSj3RgrmDYufYnbc0qIgwbFCtIgFMRCIs=; b=T8C1aBo44s6h4U48BZMJMf3ycN76saqctqSCQfEcpDrixQ0Wsdfp4h+Rq4R4Hi9EUa 64LBoXbA8o649fBaKXfrRKZMFuoyW5282ClkxBD5FVzx77yyvhz9k3g2FQ89Z0Vf+ocd aWYpVBtGm1ACV9midCMVdX5WiX00XJsbQyfnvnPCJtV44SsXmq/GNyLpcDYlAT7GSH49 BG/eCU7jkGknLGvB6vJvKm7/6HhaszUpjRvUXK5p9+f1qsZL0AyQtzdBJLxv9oGsZUoz lrC0c3eV6QaKIARK/XuFV9b8SSk4ZSOduwfeHzfZjBhzun+s6xoOcyNz8WS5Rxmg/RqL iMrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="uxQMNM/A"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8si6365026pjp.61.2019.07.04.21.14.00; Thu, 04 Jul 2019 21:14:15 -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=@kernel.org header.s=default header.b="uxQMNM/A"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725926AbfGEEKI (ORCPT + 99 others); Fri, 5 Jul 2019 00:10:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:51550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725280AbfGEEKI (ORCPT ); Fri, 5 Jul 2019 00:10:08 -0400 Received: from localhost (unknown [37.142.3.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EC53A21852; Fri, 5 Jul 2019 04:10:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562299807; bh=o3nJicTy+Qjp7G09STgRNAO/lzLw5iVeuJIFKu6cNw0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uxQMNM/AZcsCbdxpbp3iTVv59AZe9WzAV267s8w8FeqzB4qpzHnMfsWwyvaylHTxS NTFaOoU3gAihbyOE8cqchTWA8I7Bfbt7lMA7ZGrY3eAv8ZxfFZXUQbN9ovcR3HRCx/ JTNiGdwc1QRvZv5pPJodfrmIIzWPs1nBVeWpJHO4= Date: Fri, 5 Jul 2019 07:09:50 +0300 From: Leon Romanovsky To: Parav Pandit Cc: Dag Moxnes , Doug Ledford , Jason Gunthorpe , Parav Pandit , linux-rdma , Linux Kernel Mailing List Subject: Re: [PATCH v2] RDMA/core: Fix race when resolving IP address Message-ID: <20190705040950.GO7212@mtr-leonro.mtl.com> References: <1561711763-24705-1-git-send-email-dag.moxnes@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 05, 2019 at 07:49:06AM +0530, Parav Pandit wrote: > On Fri, Jun 28, 2019 at 2:20 PM 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. > > > > Signed-off-by: Dag Moxnes > > Signed-off-by: H?kon Bugge > > > > --- > > v1 -> v2: > > * Modified implementation to improve readability > > --- > > drivers/infiniband/core/addr.c | 9 ++++++--- > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c > > index 2f7d141598..51323ffbc5 100644 > > --- a/drivers/infiniband/core/addr.c > > +++ b/drivers/infiniband/core/addr.c > > @@ -333,11 +333,14 @@ static int dst_fetch_ha(const struct dst_entry *dst, > > if (!n) > > return -ENODATA; > > > > - if (!(n->nud_state & NUD_VALID)) { > > + read_lock_bh(&n->lock); > > + if (n->nud_state & NUD_VALID) { > > + memcpy(dev_addr->dst_dev_addr, n->ha, MAX_ADDR_LEN); > > + read_unlock_bh(&n->lock); > > + } else { > > + read_unlock_bh(&n->lock); > > neigh_event_send(n, NULL); > > ret = -ENODATA; > > - } else { > > - memcpy(dev_addr->dst_dev_addr, n->ha, MAX_ADDR_LEN); > > } > > > > neigh_release(n); > > -- > > 2.20.1 > > > Reviewed-by: Parav Pandit > > A sample trace such as below in commit message would be good to have. > Or the similar one that you noticed with ARP delete sequence. > > neigh_changeaddr() > neigh_flush_dev() > n->nud_state = NUD_NOARP; > > Having some issues with office outlook, so replying via gmail. Your replies from gmail looks much better when you used Outlook - proper spacing between quoted text and your reply. Thanks