Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3100732ybi; Thu, 18 Jul 2019 21:02:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8vkmzwgumeOhRUBl3U0SF28ZpamNVtk8z/fcx7C0RWeKrJuh0OWxqDZoPUj/cqxdooSjp X-Received: by 2002:a63:f941:: with SMTP id q1mr52050561pgk.350.1563508971383; Thu, 18 Jul 2019 21:02:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563508971; cv=none; d=google.com; s=arc-20160816; b=zkmFINl4uBsK75PiFEoTTiegx1aiexyCiTvX2NIPhFIxmq8HhZkvrovnCVI6lyeOOa DR4YJMDHuR3bEi2d2Z9pMT+vuXGiR+lGNcsa9dqh129P3PpPn4/Sru74QMeukmk4wa2Z VSJRiyB+7+LjcSj8G206GeD9BFnrelj0JiCNZHXconBOCXEhK/F7B+95q5OSqdT8FkVB ZpFoPNCqzXNaV4X/CSs0iu/jIIP4BH23ZNK+DJ6v60VShOb435pvYj/DHu+AU0hYXwL3 jR4m7c+jrvU4bzxYmi4ESE24FcaoAbLpq28UBty0Dax5PNGMnrnmZ4xFqzDYTAFCk4z+ 2Gew== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b5/F4yoRXFO6PgHAcsd/aEouZ/LUuxZuSGc8Og+Kh0I=; b=hNGuGC/6B5pKWhnSFb6/k0PGmiQfLaCv/qQ8Cd54TgQu9EW1FKtfZfO3AvRIEuUm/Y eCWokgav9DPRYVUZq6BwDlQZIE0tKnLcR3CeX/n2+3P4d2O6ErjEweaVQk6iHwd3d69h YZiSqHZMYu8T/k+ZeI3kdw1+i6Z2YTrFSZAsbDHbpf5hUqF9CmR6OxU1/WH6slNbxfhr RS5hI15xfvKAHMOQsVLxvvKodx28PE1KH5KZNperQKQ2TFp9bu2srPxeEY3/Purf423N YzLVz/PPoAlOSObzOnTA/Buso13aYceh5liPv7v6hh6PFZF/sUFBVlNmJH5AXnRbTWGG BxgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Up6Pljoh; 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 b24si936770pfi.180.2019.07.18.21.02.35; Thu, 18 Jul 2019 21:02:51 -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=Up6Pljoh; 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 S1729464AbfGSEBa (ORCPT + 99 others); Fri, 19 Jul 2019 00:01:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:33092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729404AbfGSEBY (ORCPT ); Fri, 19 Jul 2019 00:01:24 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 33FDB21851; Fri, 19 Jul 2019 04:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508883; bh=T9m1EC5vw6Ony5vr7aqVEUoO4PYsNMhEV4akTk7qcXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Up6PljohJ9Evk4434M3BpHN+mI+ufgfOEycmVO1hlEKZPRBMca87OEPYAA3lA8Cqc 4Lmb+tp35ekcwSjI33EjIB+gzLVTsCuS1zOTsVXTKhEZBT5A3SOpDjqAUxQW/iWiJD 9lSJFy008oo+sarcSc7qOqLekyvGA4CIW0CeK934= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dag Moxnes , =?UTF-8?q?H=C3=A5kon=20Bugge?= , Jason Gunthorpe , Sasha Levin , linux-rdma@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 134/171] RDMA/core: Fix race when resolving IP address Date: Thu, 18 Jul 2019 23:56:05 -0400 Message-Id: <20190719035643.14300-134-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dag Moxnes [ 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