net/ceph/decode.c:164:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value

From: kernel test robot
Date: Mon Nov 01 2021 - 12:21:05 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 8bb7eca972ad531c9b149c0a51ab43a417385813
commit: cd1a677cad994021b19665ed476aea63f5d54f31 libceph, ceph: implement msgr2.1 protocol (crc and secure modes)
date: 11 months ago
config: mips-randconfig-r011-20211101 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 82ed106567063ea269c6d5669278b733e173a42f)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cd1a677cad994021b19665ed476aea63f5d54f31
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout cd1a677cad994021b19665ed476aea63f5d54f31
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=mips

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

In file included from net/ceph/decode.c:4:
In file included from include/linux/inet.h:42:
In file included from include/net/net_namespace.h:39:
In file included from include/linux/skbuff.h:28:
In file included from include/net/checksum.h:22:
arch/mips/include/asm/checksum.h:161:9: error: unsupported inline asm: input with type 'unsigned long' matching output with type '__wsum' (aka 'unsigned int')
: "0" ((__force unsigned long)daddr),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from net/ceph/decode.c:6:
include/linux/ceph/decode.h:236:33: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
__be16 ss_family = *(__be16 *)&a->in_addr.ss_family;
^~~~~~~~~~~~~~~~~~~~
>> net/ceph/decode.c:164:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:13:52: note: expanded from macro '__get_unaligned_le'
#define __get_unaligned_le(ptr) ((__force typeof(*(ptr)))({ \
^~~
>> net/ceph/decode.c:164:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:14:33: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \
^~~
>> net/ceph/decode.c:164:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:14:47: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \
^~~
>> net/ceph/decode.c:164:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:15:33: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_le16((ptr)), \
^~~
>> net/ceph/decode.c:164:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:16:33: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_le32((ptr)), \
^~~
>> net/ceph/decode.c:164:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:16:65: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_le32((ptr)), \
^~~
>> net/ceph/decode.c:164:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:17:33: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_le64((ptr)), \
^~~
>> net/ceph/decode.c:164:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:17:65: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_le64((ptr)), \
^~~
net/ceph/decode.c:172:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:13:52: note: expanded from macro '__get_unaligned_le'
#define __get_unaligned_le(ptr) ((__force typeof(*(ptr)))({ \
^~~
net/ceph/decode.c:172:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:14:33: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \
^~~
net/ceph/decode.c:172:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:14:47: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \
^~~
net/ceph/decode.c:172:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:15:33: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_le16((ptr)), \
^~~
net/ceph/decode.c:172:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:16:33: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_le32((ptr)), \
^~~
net/ceph/decode.c:172:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:16:65: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_le32((ptr)), \
^~~
net/ceph/decode.c:172:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:17:33: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_le64((ptr)), \
^~~
net/ceph/decode.c:172:38: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
^~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/unaligned.h:22:24: note: expanded from macro 'get_unaligned'
# define get_unaligned __get_unaligned_le
^
include/linux/unaligned/generic.h:17:65: note: expanded from macro '__get_unaligned_le'
__builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_le64((ptr)), \
^~~
17 warnings and 1 error generated.
--
In file included from net/ceph/messenger_v2.c:20:
In file included from include/net/sock.h:46:
In file included from include/linux/netdevice.h:37:
In file included from include/linux/ethtool.h:18:
In file included from include/uapi/linux/ethtool.h:19:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:28:
In file included from include/net/checksum.h:22:
arch/mips/include/asm/checksum.h:161:9: error: unsupported inline asm: input with type 'unsigned long' matching output with type '__wsum' (aka 'unsigned int')
: "0" ((__force unsigned long)daddr),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from net/ceph/messenger_v2.c:20:
In file included from include/net/sock.h:61:
include/linux/poll.h:142:27: warning: division by zero is undefined [-Wdivision-by-zero]
M(RDNORM) | M(RDBAND) | M(WRNORM) | M(WRBAND) |
^~~~~~~~~
include/linux/poll.h:140:32: note: expanded from macro 'M'
#define M(X) (__force __poll_t)__MAP(val, POLL##X, (__force __u16)EPOLL##X)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/poll.h:126:51: note: expanded from macro '__MAP'
(from < to ? (v & from) * (to/from) : (v & from) / (from/to))
^ ~~~~~~~~~
include/linux/poll.h:142:39: warning: division by zero is undefined [-Wdivision-by-zero]
M(RDNORM) | M(RDBAND) | M(WRNORM) | M(WRBAND) |
^~~~~~~~~
include/linux/poll.h:140:32: note: expanded from macro 'M'
#define M(X) (__force __poll_t)__MAP(val, POLL##X, (__force __u16)EPOLL##X)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/poll.h:126:51: note: expanded from macro '__MAP'
(from < to ? (v & from) * (to/from) : (v & from) / (from/to))
^ ~~~~~~~~~
In file included from net/ceph/messenger_v2.c:24:
include/linux/ceph/decode.h:236:33: warning: taking address of packed member 'in_addr' of class or structure 'ceph_entity_addr' may result in an unaligned pointer value [-Waddress-of-packed-member]
__be16 ss_family = *(__be16 *)&a->in_addr.ss_family;
^~~~~~~~~~~~~~~~~~~~
>> net/ceph/messenger_v2.c:557:16: warning: taking address of packed member 'front_crc' of class or structure 'ceph_connection_v2_info::(anonymous struct)::(anonymous union)::(anonymous)' may result in an unaligned pointer value [-Waddress-of-packed-member]
cpu_to_le32s(&con->v2.out_epil.front_crc);
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/byteorder/generic.h:112:22: note: expanded from macro 'cpu_to_le32s'
#define cpu_to_le32s __cpu_to_le32s
^
include/uapi/linux/byteorder/little_endian.h:94:39: note: expanded from macro '__cpu_to_le32s'
#define __cpu_to_le32s(x) do { (void)(x); } while (0)
^
>> net/ceph/messenger_v2.c:558:16: warning: taking address of packed member 'middle_crc' of class or structure 'ceph_connection_v2_info::(anonymous struct)::(anonymous union)::(anonymous)' may result in an unaligned pointer value [-Waddress-of-packed-member]
cpu_to_le32s(&con->v2.out_epil.middle_crc);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/byteorder/generic.h:112:22: note: expanded from macro 'cpu_to_le32s'
#define cpu_to_le32s __cpu_to_le32s
^
include/uapi/linux/byteorder/little_endian.h:94:39: note: expanded from macro '__cpu_to_le32s'
#define __cpu_to_le32s(x) do { (void)(x); } while (0)
^
>> net/ceph/messenger_v2.c:559:16: warning: taking address of packed member 'data_crc' of class or structure 'ceph_connection_v2_info::(anonymous struct)::(anonymous union)::(anonymous)' may result in an unaligned pointer value [-Waddress-of-packed-member]
cpu_to_le32s(&con->v2.out_epil.data_crc);
^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/byteorder/generic.h:112:22: note: expanded from macro 'cpu_to_le32s'
#define cpu_to_le32s __cpu_to_le32s
^
include/uapi/linux/byteorder/little_endian.h:94:39: note: expanded from macro '__cpu_to_le32s'
#define __cpu_to_le32s(x) do { (void)(x); } while (0)
^
6 warnings and 1 error generated.


vim +164 net/ceph/decode.c

5
> 6 #include <linux/ceph/decode.h>
7
8 static int
9 ceph_decode_entity_addr_versioned(void **p, void *end,
10 struct ceph_entity_addr *addr)
11 {
12 int ret;
13 u8 struct_v;
14 u32 struct_len, addr_len;
15 void *struct_end;
16
17 ret = ceph_start_decoding(p, end, 1, "entity_addr_t", &struct_v,
18 &struct_len);
19 if (ret)
20 goto bad;
21
22 ret = -EINVAL;
23 struct_end = *p + struct_len;
24
25 ceph_decode_copy_safe(p, end, &addr->type, sizeof(addr->type), bad);
26
27 ceph_decode_copy_safe(p, end, &addr->nonce, sizeof(addr->nonce), bad);
28
29 ceph_decode_32_safe(p, end, addr_len, bad);
30 if (addr_len > sizeof(addr->in_addr))
31 goto bad;
32
33 memset(&addr->in_addr, 0, sizeof(addr->in_addr));
34 if (addr_len) {
35 ceph_decode_copy_safe(p, end, &addr->in_addr, addr_len, bad);
36
37 addr->in_addr.ss_family =
38 le16_to_cpu((__force __le16)addr->in_addr.ss_family);
39 }
40
41 /* Advance past anything the client doesn't yet understand */
42 *p = struct_end;
43 ret = 0;
44 bad:
45 return ret;
46 }
47
48 static int
49 ceph_decode_entity_addr_legacy(void **p, void *end,
50 struct ceph_entity_addr *addr)
51 {
52 int ret = -EINVAL;
53
54 /* Skip rest of type field */
55 ceph_decode_skip_n(p, end, 3, bad);
56
57 /*
58 * Clients that don't support ADDR2 always send TYPE_NONE, change it
59 * to TYPE_LEGACY for forward compatibility.
60 */
61 addr->type = CEPH_ENTITY_ADDR_TYPE_LEGACY;
62 ceph_decode_copy_safe(p, end, &addr->nonce, sizeof(addr->nonce), bad);
63 memset(&addr->in_addr, 0, sizeof(addr->in_addr));
64 ceph_decode_copy_safe(p, end, &addr->in_addr,
65 sizeof(addr->in_addr), bad);
66 addr->in_addr.ss_family =
67 be16_to_cpu((__force __be16)addr->in_addr.ss_family);
68 ret = 0;
69 bad:
70 return ret;
71 }
72
73 int
74 ceph_decode_entity_addr(void **p, void *end, struct ceph_entity_addr *addr)
75 {
76 u8 marker;
77
78 ceph_decode_8_safe(p, end, marker, bad);
79 if (marker == 1)
80 return ceph_decode_entity_addr_versioned(p, end, addr);
81 else if (marker == 0)
82 return ceph_decode_entity_addr_legacy(p, end, addr);
83 bad:
84 return -EINVAL;
85 }
86 EXPORT_SYMBOL(ceph_decode_entity_addr);
87
88 /*
89 * Return addr of desired type (MSGR2 or LEGACY) or error.
90 * Make sure there is only one match.
91 *
92 * Assume encoding with MSG_ADDR2.
93 */
94 int ceph_decode_entity_addrvec(void **p, void *end, bool msgr2,
95 struct ceph_entity_addr *addr)
96 {
97 __le32 my_type = msgr2 ? CEPH_ENTITY_ADDR_TYPE_MSGR2 :
98 CEPH_ENTITY_ADDR_TYPE_LEGACY;
99 struct ceph_entity_addr tmp_addr;
100 int addr_cnt;
101 bool found;
102 u8 marker;
103 int ret;
104 int i;
105
106 ceph_decode_8_safe(p, end, marker, e_inval);
107 if (marker != 2) {
108 pr_err("bad addrvec marker %d\n", marker);
109 return -EINVAL;
110 }
111
112 ceph_decode_32_safe(p, end, addr_cnt, e_inval);
113
114 found = false;
115 for (i = 0; i < addr_cnt; i++) {
116 ret = ceph_decode_entity_addr(p, end, &tmp_addr);
117 if (ret)
118 return ret;
119
120 if (tmp_addr.type == my_type) {
121 if (found) {
122 pr_err("another match of type %d in addrvec\n",
123 le32_to_cpu(my_type));
124 return -EINVAL;
125 }
126
127 memcpy(addr, &tmp_addr, sizeof(*addr));
128 found = true;
129 }
130 }
131 if (!found && addr_cnt != 0) {
132 pr_err("no match of type %d in addrvec\n",
133 le32_to_cpu(my_type));
134 return -ENOENT;
135 }
136
137 return 0;
138
139 e_inval:
140 return -EINVAL;
141 }
142 EXPORT_SYMBOL(ceph_decode_entity_addrvec);
143
144 static int get_sockaddr_encoding_len(sa_family_t family)
145 {
146 union {
147 struct sockaddr sa;
148 struct sockaddr_in sin;
149 struct sockaddr_in6 sin6;
150 } u;
151
152 switch (family) {
153 case AF_INET:
154 return sizeof(u.sin);
155 case AF_INET6:
156 return sizeof(u.sin6);
157 default:
158 return sizeof(u);
159 }
160 }
161
162 int ceph_entity_addr_encoding_len(const struct ceph_entity_addr *addr)
163 {
> 164 sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
165 int addr_len = get_sockaddr_encoding_len(family);
166
167 return 1 + CEPH_ENCODING_START_BLK_LEN + 4 + 4 + 4 + addr_len;
168 }
169

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip