Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3808176ybi; Mon, 29 Jul 2019 13:02:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzj1cmjVoZIqK0wehFdRdxOuTLPdoDuhSGh1JjyETTCVKwh+W2EZ4S4ZPKJdb3zLBoq/EtE X-Received: by 2002:a63:f959:: with SMTP id q25mr105316844pgk.357.1564430557143; Mon, 29 Jul 2019 13:02:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430557; cv=none; d=google.com; s=arc-20160816; b=QEm6UJ4MLwiYmdurI6ZL08gxgIEOOp8Q2fbz5iBH0CpUHJaX64F5nXzcY9mpockPVS CKwjhpQYzL76EECWTwufIh8SsdN+KTLCupYUPzPtRe6D61xAylf3Oae7RqhxBpUhTjJv KqMqIZLXU36lkQbRF1B/kYhmVc/8WF9/JF8AIJRJw6F2Y9DJ/PLviF/KWbtbReI4vIP2 3okb2tZzHoAjDWfhvZSWMzn7vbxRQ0uDNeBSx1y7OcHsDFIqS2N4ihpZqKlGmFLMERa7 LMGM/fcrnudbxtycYK07uSRRM7pRDtQlpv6vD1HYshr+TyG5jJa3Yscf51jH6+F8pj6s wcng== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=W+3uilwOHvPsSE56J+pivvkWO7fjwCsPtFl9jZBPiXU=; b=ZV4M6Ehb/52PPpgQ5dkM8Xh78IVpluVmfFuOHTt9L488+eKit1ZwzAJ7x4ogUDdgCV kivnsR7WYgVm35Uhkzjy+fTZfiPcGBBhD2/TdJ1id/nL02WyLA1isfeYWlVdcpVkulTg 7MIO8Yfzn/G76RBJnikLFoQz/f+pA2/GZMxHCtA4IEIpKBjYAR1cy7cXtkm8LbsfU72M pD8Br5L+Dyke5G3K0G72qkCfS7pVk2P4Zre9vBHtOH97DVJA8pBTGTB5JSm9M6MRjyqK 3y+H9/SoN+6UUHmwQnl3NjyBFuZwpBZ9slRQO/tTq3ekXt4ryK/PwBas3J8awVe5MUP3 GPeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=znLvocsg; 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 o6si27095400pgv.273.2019.07.29.13.02.22; Mon, 29 Jul 2019 13:02:37 -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=znLvocsg; 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 S2391153AbfG2UBK (ORCPT + 99 others); Mon, 29 Jul 2019 16:01:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:43108 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390800AbfG2Tvg (ORCPT ); Mon, 29 Jul 2019 15:51:36 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 7C88E204EC; Mon, 29 Jul 2019 19:51:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429896; bh=fQxvfeb8Oau7nGkThdwi/x3SxOWcDMjxQ9XNvSRw1Rw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=znLvocsgLa9YSqIBZTMG5DIwbdEQu2vO7gOaMz+iJnqak2jh3qNxfOfHGjlEutkkW pgPHPbAQp435CD8rtpfRawQfzKtP9AbDCLqykotzOuLnnFsN7CTPGRW79//28N1Gsl xlnxbGUfEBnlqCpRkLos9VKrvll72odLbvWj2aJ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dag Moxnes , =?UTF-8?q?H=C3=A5kon=20Bugge?= , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.2 131/215] RDMA/core: Fix race when resolving IP address Date: Mon, 29 Jul 2019 21:22:07 +0200 Message-Id: <20190729190802.158910889@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit d8d9ec7dc5abbb3f11d866e983c4984f5c2de9d6 ] Use the neighbour lock when copying the MAC address from the 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 torn MAC address: rdma_resolve_addr() rdma_resolve_ip() addr_resolve() addr_resolve_neigh() fetch_ha() dst_fetch_ha() memcpy(dev_addr->dst_dev_addr, n->ha, MAX_ADDR_LEN) and net_ioctl() arp_ioctl() arp_rec_delete() arp_invalidate() neigh_update() __neigh_update() memcpy(&neigh->ha, lladdr, dev->addr_len) 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. Fixes: 51d45974515c ("infiniband: addr: Consolidate code to fetch neighbour hardware address from dst.") Signed-off-by: Dag Moxnes Signed-off-by: HÃ¥kon Bugge Reviewed-by: Jason Gunthorpe Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/addr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index 2f7d14159841..9b76a8fcdd24 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c @@ -337,7 +337,7 @@ static int dst_fetch_ha(const struct dst_entry *dst, neigh_event_send(n, NULL); ret = -ENODATA; } else { - memcpy(dev_addr->dst_dev_addr, n->ha, MAX_ADDR_LEN); + neigh_ha_snapshot(dev_addr->dst_dev_addr, n, dst->dev); } neigh_release(n); -- 2.20.1