浏览代码

[NETFILTER]: nf_conntrack: fix helper structure alignment

Adding the alignment to the size doesn't make any sense, what it
should do is align the size of the conntrack structure to the
alignment requirements of the helper structure and return an
aligned pointer in nfct_help().

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Patrick McHardy 18 年之前
父节点
当前提交
f9aae95828
共有 2 个文件被更改,包括 6 次插入4 次删除
  1. 1 0
      include/net/netfilter/nf_conntrack.h
  2. 5 4
      net/netfilter/nf_conntrack_helper.c

+ 1 - 0
include/net/netfilter/nf_conntrack.h

@@ -273,6 +273,7 @@ static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
 	if (!(ct->features & NF_CT_F_HELP))
 	if (!(ct->features & NF_CT_F_HELP))
 		return NULL;
 		return NULL;
 
 
+	offset = ALIGN(offset, __alignof__(struct nf_conn_help));
 	return (struct nf_conn_help *) ((void *)ct + offset);
 	return (struct nf_conn_help *) ((void *)ct + offset);
 }
 }
 
 

+ 5 - 4
net/netfilter/nf_conntrack_helper.c

@@ -97,13 +97,14 @@ static inline int unhelp(struct nf_conntrack_tuple_hash *i,
 
 
 int nf_conntrack_helper_register(struct nf_conntrack_helper *me)
 int nf_conntrack_helper_register(struct nf_conntrack_helper *me)
 {
 {
-	int ret;
+	int size, ret;
+
 	BUG_ON(me->timeout == 0);
 	BUG_ON(me->timeout == 0);
 
 
+	size = ALIGN(sizeof(struct nf_conn), __alignof__(struct nf_conn_help)) +
+	       sizeof(struct nf_conn_help);
 	ret = nf_conntrack_register_cache(NF_CT_F_HELP, "nf_conntrack:help",
 	ret = nf_conntrack_register_cache(NF_CT_F_HELP, "nf_conntrack:help",
-					  sizeof(struct nf_conn)
-					  + sizeof(struct nf_conn_help)
-					  + __alignof__(struct nf_conn_help));
+					  size);
 	if (ret < 0) {
 	if (ret < 0) {
 		printk(KERN_ERR "nf_conntrack_helper_register: Unable to create slab cache for conntracks\n");
 		printk(KERN_ERR "nf_conntrack_helper_register: Unable to create slab cache for conntracks\n");
 		return ret;
 		return ret;