Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp725470imm; Thu, 13 Sep 2018 06:53:19 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbeBSAt/pHSxF9+fF+iVrdbKdTL09uAUitjZt7UpyBfznFcilDFWryhdMn/uMjckgrzWZo8 X-Received: by 2002:aa7:84c2:: with SMTP id x2-v6mr7617017pfn.220.1536846799624; Thu, 13 Sep 2018 06:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846799; cv=none; d=google.com; s=arc-20160816; b=FibJ5XBEmTrzEYKsPbYDOA5AZINC8vp5rXs9xqWzoI7px4KrE1hAEXC9aHK+RJ9MOK Bti/udHVrD2mm7FOSRBshaDAASSULdpMCfo7AiQUDVXw1ee+OLvvQdOcP3aywWZq8mTD 5W22iSTBtZLNOuSDuYUkvompNqD9eHDkmLMZZqDxVwXym+cMzvUJYLKvH+5/FEqf/htT NsI9Lg5V2MIxPPbTOYy/ITgQ6R6yAExrBQw/Kiz1GXoHv059ZogedZWQVXKBpq5YQL6f WpfJqa8TlrxsNaEPwZ/1vMHHj4yr0eohMG+SMLp78HEyzBAKm5QT20LbtQxygFyOnMsy 7FAg== 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; bh=IMo/jAeGuubYBf7OiTvxKEuGsuR4dAsfCD2dyZTbc6I=; b=dtTr2dpvzjFumcf1oeWjJA6ihiD3CEyWF/zUwi1AR5HI9N1ZB0h4HZMXj0UnH0cb0S 7ryGT31Woi5y1nBTYdwp1hojxKm2G/GPVKykTROo2aEAV3Cp+oLSPwDAlZt7Q65GHFPm a9/IJI2sMWYJviGC/ToLPUGB6PxFvH/y+8ED8kKjQRHuO5UJGDdVf3DRZJQ8gArSBKK7 IiBFZoJqp6VHDGuVuEBoetQErCXuP0kRBocOY8gr70366mlIZZLqqdY8wbaYvhL6rg1h +Bibqs8K6nDke70XUJNC9sChoZNkASABJRBg/vbsR7XsnbPe9PtVAMotTA2MYn2eWzcW nyzQ== ARC-Authentication-Results: i=1; mx.google.com; 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 p19-v6si4022980plo.432.2018.09.13.06.53.04; Thu, 13 Sep 2018 06:53:19 -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; 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 S1730771AbeIMTAh (ORCPT + 99 others); Thu, 13 Sep 2018 15:00:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33236 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728484AbeIMTAg (ORCPT ); Thu, 13 Sep 2018 15:00:36 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CFDEACFE; Thu, 13 Sep 2018 13:51:01 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhenbo Gao , Jon Maloy , Haiqing Bai , "David S. Miller" Subject: [PATCH 4.18 019/197] tipc: fix the big/little endian issue in tipc_dest Date: Thu, 13 Sep 2018 15:29:28 +0200 Message-Id: <20180913131842.338293774@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Haiqing Bai [ Upstream commit 30935198b7d0be12b1c45c328b66a7fdefb16256 ] In function tipc_dest_push, the 32bit variables 'node' and 'port' are stored separately in uppper and lower part of 64bit 'value'. Then this value is assigned to dst->value which is a union like: union { struct { u32 port; u32 node; }; u64 value; } This works on little-endian machines like x86 but fails on big-endian machines. The fix remove the 'value' stack parameter and even the 'value' member of the union in tipc_dest, assign the 'node' and 'port' member directly with the input parameter to avoid the endian issue. Fixes: a80ae5306a73 ("tipc: improve destination linked list") Signed-off-by: Zhenbo Gao Acked-by: Jon Maloy Signed-off-by: Haiqing Bai Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tipc/name_table.c | 10 ++++------ net/tipc/name_table.h | 9 ++------- 2 files changed, 6 insertions(+), 13 deletions(-) --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c @@ -980,20 +980,17 @@ int tipc_nl_name_table_dump(struct sk_bu struct tipc_dest *tipc_dest_find(struct list_head *l, u32 node, u32 port) { - u64 value = (u64)node << 32 | port; struct tipc_dest *dst; list_for_each_entry(dst, l, list) { - if (dst->value != value) - continue; - return dst; + if (dst->node == node && dst->port == port) + return dst; } return NULL; } bool tipc_dest_push(struct list_head *l, u32 node, u32 port) { - u64 value = (u64)node << 32 | port; struct tipc_dest *dst; if (tipc_dest_find(l, node, port)) @@ -1002,7 +999,8 @@ bool tipc_dest_push(struct list_head *l, dst = kmalloc(sizeof(*dst), GFP_ATOMIC); if (unlikely(!dst)) return false; - dst->value = value; + dst->node = node; + dst->port = port; list_add(&dst->list, l); return true; } --- a/net/tipc/name_table.h +++ b/net/tipc/name_table.h @@ -133,13 +133,8 @@ void tipc_nametbl_stop(struct net *net); struct tipc_dest { struct list_head list; - union { - struct { - u32 port; - u32 node; - }; - u64 value; - }; + u32 port; + u32 node; }; struct tipc_dest *tipc_dest_find(struct list_head *l, u32 node, u32 port);