Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4823479ybl; Wed, 22 Jan 2020 05:25:47 -0800 (PST) X-Google-Smtp-Source: APXvYqyuyt9jGWRvImcxnk4FG1liHA9INWE/dfbhJiOpqsNmzfvSoTgoNQscREP1w5BStbimxPsD X-Received: by 2002:aca:de06:: with SMTP id v6mr6631724oig.168.1579699546362; Wed, 22 Jan 2020 05:25:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699546; cv=none; d=google.com; s=arc-20160816; b=hBkUbDTxCV/R/XaJbuoRvQlB+c1xBhUq+pmD4Ug+85OzMuqzJqLW30rAXodvlU17mo Dgzl+1uHq6J7KXWWjF9ZThVOTVbWgQYtKJ0mt5amgEuTXur3OGg/zptsOuPjJUy7rHbl XuY8KsA5mcRZQDVK3pUzjoW4CuHPgKesaJx0uHfks1/91VR3fB9YJA3J03YxES57Iiox SshWcuPaZH1U5ki+EuISk8jaPNYq3rtvMAFRcNgapbkzJbn7YPqtDPvbe4klLMYk+Q4a o1qiQdVZd05fomhEKvHjGLdoyo/4YXFIng5yezgZ2SFwV4Sc0cPlyVv8WXsVmtKC1P99 AO8g== 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=1hQ0LS5G69rNnXb6nJgAONEPd9orX9rN3gcup0+a3FA=; b=jY3R9wnWZzcA2+sui5/GDYkCFUoHuHd0fbyPcrfkBVuqbkqMpuU59iAn6HCQQrLedy 7JW9xo70eJf9VZFee/OfXSton+QmNeELI5mugxzlTlGtx3GH27ODCUpgN8/ijA2F5j6B C+yoIYtD1IPA88NomASrhidxtLonbaprjQQdSssQ6qPcffxD40LROKpy3k4yW/lasRjT fPKGUZpXTIADZXlsi+HCx3rYmgXkPRqjSiy/6UbJBAkvuT4jp6iotp6S4b3QOi0qlGFi 7pFdXW+IApUMZbBLD5c/Zcn+UlnkH2t9OuC9cl7ekKmmT/rLTjsMzsZQYH1wg3VpJJzP MwoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HsEyKoU4; 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 u84si21555389oib.34.2020.01.22.05.25.34; Wed, 22 Jan 2020 05:25:46 -0800 (PST) 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=HsEyKoU4; 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 S1730751AbgAVNXd (ORCPT + 99 others); Wed, 22 Jan 2020 08:23:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:41742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730749AbgAVNX2 (ORCPT ); Wed, 22 Jan 2020 08:23:28 -0500 Received: from localhost (unknown [84.241.205.26]) (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 7121A205F4; Wed, 22 Jan 2020 13:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699408; bh=8iV/WSxnVwBToM5OZHnGrzIEhzWmi0xOLLnQqDfDNek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HsEyKoU4VvT530NGtSqDjzLwImDEy8r3xLeaDCPTWZSHJAnII7qTonJB/naS8Dgzv nq+0/1wjAUtDq2644fzRYCcOdx/vJHkHonylC7sprZsE5ynnpjhLqtF1uYaZ1cSMVZ 1sLdwzNs2/OWgq87/3S9p4uzST5x+2Y/4b1z4FC4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Eckelmann , Simon Wunderlich Subject: [PATCH 5.4 135/222] batman-adv: Fix DAT candidate selection on little endian systems Date: Wed, 22 Jan 2020 10:28:41 +0100 Message-Id: <20200122092843.407940112@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@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 From: Sven Eckelmann commit 4cc4a1708903f404d2ca0dfde30e71e052c6cbc9 upstream. The distributed arp table is using a DHT to store and retrieve MAC address information for an IP address. This is done using unicast messages to selected peers. The potential peers are looked up using the IP address and the VID. While the IP address is always stored in big endian byte order, this is not the case of the VID. It can (depending on the host system) either be big endian or little endian. The host must therefore always convert it to big endian to ensure that all devices calculate the same peers for the same lookup data. Fixes: be1db4f6615b ("batman-adv: make the Distributed ARP Table vlan aware") Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/distributed-arp-table.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -285,6 +285,7 @@ static u32 batadv_hash_dat(const void *d u32 hash = 0; const struct batadv_dat_entry *dat = data; const unsigned char *key; + __be16 vid; u32 i; key = (const unsigned char *)&dat->ip; @@ -294,7 +295,8 @@ static u32 batadv_hash_dat(const void *d hash ^= (hash >> 6); } - key = (const unsigned char *)&dat->vid; + vid = htons(dat->vid); + key = (__force const unsigned char *)&vid; for (i = 0; i < sizeof(dat->vid); i++) { hash += key[i]; hash += (hash << 10);