Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3108997ybi; Fri, 5 Jul 2019 02:04:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbvwn7THwnGjMbnkM9upKOFVTDQ4D87qr5Iwxgy/S+lJqSLqXk4eZgfY8n61mkvQcGK4se X-Received: by 2002:a17:902:aa0a:: with SMTP id be10mr3878185plb.293.1562317483655; Fri, 05 Jul 2019 02:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562317483; cv=none; d=google.com; s=arc-20160816; b=o6P9u7Z4N7TEBmgLJO9sLk72iJahvaY1+CxjKpiimI8ASqcfFM6RLXhtcXe0X2tt3i BAfhfkY0LxCdZbxu2Tnpm/YVvye/v3uk/p5WFDqgWhbOnt86ny35c5d1jip0XHsS1eDQ MUvGoLxDuTSbIEAyqjDM503QLrdGEfmMGjegn3FQqmqXH7keDHHWCgMymTC5NLgRJr7d 08Hcx6Eq4FUm9eQeA+mPyf/jPfjyIenmvbnSXLS6BMzJdWob4tcPAQmEiaIrseDCVlaB 68Y2lGF3bm/ZDrbUqyAdweFFHSt9UZMcB7nsex3PNWCi8fThrA4iDk4e3iIs75HkXC7z mwGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=1g1pDf5Otmvxw/VYPR3CC5244T59MboONzYhSU/S7LA=; b=JLaLXaCx3kPtE/63t5IyX0EwAFp96YHs76tXOwhI3/t8aX6HLBdHfFKlpHewfeJ4Rp kXwIx3qVY1uq6luj3wTVXcpPRtRrxXqYgD/Q+QbtqYuwcKI4bYqcXAdUKMPG3eB9fKjJ m5rogbZx49xxuaN+IcEnIC7V7EoCz7VH1mRx+dIPSU8xQvx+0jyQtqV+saipLbMKbrEj aka48Oy6njb9xbDvdNfjbOHMYSxrEQtwjd2owh6uO8y6PrPKXE7K7I/2wqxt7mwxLtu1 orShBQ3pmcSqg2v1vXchjHhreqy6k9FpPr0d5cVSiFWth44AWmCowKHYAeh75z3PuF4/ QlNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=QpX6MdG+; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y92si8161369plb.209.2019.07.05.02.04.28; Fri, 05 Jul 2019 02:04:43 -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=@oracle.com header.s=corp-2018-07-02 header.b=QpX6MdG+; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728201AbfGEJDm (ORCPT + 99 others); Fri, 5 Jul 2019 05:03:42 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45520 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728003AbfGEJDl (ORCPT ); Fri, 5 Jul 2019 05:03:41 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x658xWvl187487; Fri, 5 Jul 2019 09:03:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=1g1pDf5Otmvxw/VYPR3CC5244T59MboONzYhSU/S7LA=; b=QpX6MdG+eGOdrPIHnITLpxK1JW0TBiUfePLdu+fVR6qlR1oHg6f43StMcycND18fcTIS pxNZz3LMYUDiUl0iixVsip36/x3vjNsy9FdAWH0scxs39jUZukr4jGUdVC6q3Pdo5KxM dFIFy8uATPsmmIclFjN2Mu1vgaW55p/nhDQ1CXoezeehavSkskgXIk9AY+jzfaT6KeMO IO3qylfY9VnLTH6oxUYRdTfeWdw8TyYASirkf5FoXSJMcNjz0w5rj4QqibJZem8bPe6v UI1fscDMgUzVjEBjOPq6CNNnjbRO1pgIr+s8iNv6dowHnQPGg1e1mKXD51O79f2Byyd1 rw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2te61qa109-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2019 09:03:16 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x65933R7010009; Fri, 5 Jul 2019 09:03:15 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2th5qmdr72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 05 Jul 2019 09:03:15 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x6593DPs021563; Fri, 5 Jul 2019 09:03:13 GMT Received: from [192.168.1.14] (/109.189.94.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 05 Jul 2019 02:03:13 -0700 Subject: Re: [PATCH v2] RDMA/core: Fix race when resolving IP address To: Parav Pandit Cc: Doug Ledford , Jason Gunthorpe , Leon Romanovsky , Parav Pandit , linux-rdma , Linux Kernel Mailing List References: <1561711763-24705-1-git-send-email-dag.moxnes@oracle.com> From: Dag Moxnes Message-ID: <4e46889a-0b13-fa9b-fe8e-d9f6a44d714a@oracle.com> Date: Fri, 5 Jul 2019 11:03:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9308 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907050117 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9308 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907050117 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Den 05.07.2019 04:19, skrev Parav Pandit: > 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. Hi Parav, Thanks for your review. I'll add a sample trace to the commit message as you suggest. Regards, -Dag