Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1397099imm; Thu, 23 Aug 2018 02:20:19 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZjcj1p7fL21b2BrSz3LI0oO6xBGQygWDmuQSwbEXvTX2cVTC9k1GWVKuzwsHpV6nYwDyWZ X-Received: by 2002:a62:5d03:: with SMTP id r3-v6mr1033086pfb.150.1535016019270; Thu, 23 Aug 2018 02:20:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535016019; cv=none; d=google.com; s=arc-20160816; b=gubIjqOs2MPQD7U8UHWEqBxbVN3ukWAWv6G6U25jdnAtFCff047rdRO3g1UQPxGYyU VMWqJ12atoMmkV/mk0lW/eMN76qRYISLsm5BPKP9zcG31TSayOORCWVHs0vgf3Jelgfc VLpWHqv+85YD/qloauqQj4EYHOhTyZaJ3Gdf4oeQ9Ln0Pm6EpnZjonz8jJ608J4IXlI/ oQcds14/RPAlf4Kbgg8kAK0xj8ANjX8e2tbPqS3MYuuIx5VFcbcjB3JgOuJwwvxnAwK4 74uJUTWCBYDrpAbNZ49bdYO4TKY+Vg/LMRNKQxF9H/4EZ9N7jA3zyf2Vsy5KEWi0zLp2 fj/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=HtXnimH5imDGgabMpvMhBw1wjj/6XLhG2dwB/P3IEyk=; b=WWe6SvzPu4Riiw9XefNbDeQOj235K3+K9v5yxh30TaFz4tEWVdHX1uBXXpj+OnQetK A0uZ4ZB8cYTst9OS86fFQElD2k2o6d1DxladuxLdQqt5p8BDIp4pV3bpBcY4jZLYN9hF JCFoxR2tLxs4ulFFBiyJeqUK+23fuepdIcH271apvkia/5+2JeluOgxEV/BwM0en0Bkd 7m2M4R4TzNTFaAkiozRArlqHDMgd0Jvi8ixRJeh+LeeVly35f23zTeN5JgYcj093yQIQ CCVWp6h3yEHoBECxKFrUA3KdZkZRBla8DbegwTWm9fuhWasIapzmQMsCy/Wfqz+1juuD fglQ== 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 x6-v6si3929853pgk.597.2018.08.23.02.20.03; Thu, 23 Aug 2018 02:20: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 S1729962AbeHWMqv (ORCPT + 99 others); Thu, 23 Aug 2018 08:46:51 -0400 Received: from mail5.windriver.com ([192.103.53.11]:60202 "EHLO mail5.wrs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727646AbeHWMqv (ORCPT ); Thu, 23 Aug 2018 08:46:51 -0400 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id w7N9HxXx006775 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Thu, 23 Aug 2018 02:18:00 -0700 Received: from pek-lpgtest5.wrs.com (128.224.153.85) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.3.399.0; Thu, 23 Aug 2018 02:17:59 -0700 From: Haiqing Bai To: , , , CC: , , Subject: [PATCH net] tipc: fix the big/little endian issue in tipc_dest Date: Thu, 23 Aug 2018 16:49:18 +0800 Message-ID: <1535014158-18578-1-git-send-email-Haiqing.Bai@windriver.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: d06b2fa34f18 ("tipc: improve destination linked list") Signed-off-by: Zhenbo Gao Acked-by: Jon Maloy Signed-off-by: Haiqing Bai --- net/tipc/name_table.c | 10 ++++------ net/tipc/name_table.h | 9 ++------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 88f027b..66d5b2c 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c @@ -980,20 +980,17 @@ int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb) 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, u32 node, u32 port) 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; } diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h index 0febba4..892bd75 100644 --- a/net/tipc/name_table.h +++ b/net/tipc/name_table.h @@ -133,13 +133,8 @@ struct publication *tipc_nametbl_remove_publ(struct net *net, u32 type, 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); -- 1.9.1