unused code in net/netfilter/ipset/ip_set_bitmap_ipmac.c
Subsystems (3)
The file net/netfilter/ipset/ip_set_bitmap_ipmac.c seems to contain a lot of static functions that are not used in the file:
bitmap_ipmac_add_timeoutbitmap_ipmac_do_addbitmap_ipmac_do_delbitmap_ipmac_do_headbitmap_ipmac_do_listbitmap_ipmac_do_testbitmap_ipmac_gc_testbitmap_ipmac_is_filledbitmap_ipmac_kadtbitmap_ipmac_same_setbitmap_ipmac_uadt
Have I overooked something?
I was looking at this code, with Daniel Borkmann, because there seems to be a bug in the function bitmap_ipmac_uadt:
if (tb[IPSET_ATTR_ETHER]) {
memcpy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]), ETH_ALEN);
e.add_mac = 1;
}Later in the same file, there is:
static struct ip_set_type bitmap_ipmac_type = {
...
.adt_policy = {
...
[IPSET_ATTR_ETHER] = { .type = NLA_BINARY,
.len = ETH_ALEN },
...},
...
};The type NLA_BINARY indicates that the length is a maximum possible length, and thus a check of the actual length is needed before the memcpy.
The file net/netfilter/ipset/ip_set_hash_mac.c seems to have a similar problem. The following static functions are not used:
hash_mac4_data_equalhash_mac4_data_listhash_mac4_data_nexthash_mac4_kadthash_mac4_uadt
And the following code:
ether_addr_copy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]));
in hash_mac4_uadt does not seem to have a check on the length, and the field is defined in the same way as above.
julia
Hi,
Quoted 15 lines · Julia Lawall
The file
net/netfilter/ipset/ip_set_bitmap_ipmac.cseems to contain a lot of static functions that are not used in the file:
bitmap_ipmac_add_timeoutbitmap_ipmac_do_addbitmap_ipmac_do_delbitmap_ipmac_do_headbitmap_ipmac_do_listbitmap_ipmac_do_testbitmap_ipmac_gc_testbitmap_ipmac_is_filledbitmap_ipmac_kadtbitmap_ipmac_same_setbitmap_ipmac_uadt
Quoted 1 line
Have I overooked something?
Yes: the file includes ip_set_bitmap_gen.h in which all those functions are used.
Quoted 20 lines
I was looking at this code, with Daniel Borkmann, because there seems to be a bug in the function
bitmap_ipmac_uadt:if (tb[IPSET_ATTR_ETHER]) { memcpy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]), ETH_ALEN); e.add_mac = 1; }Later in the same file, there is:
static struct ip_set_type bitmap_ipmac_type = { ... .adt_policy = { ... [IPSET_ATTR_ETHER] = { .type = NLA_BINARY, .len = ETH_ALEN }, ...}, ... };
Quoted 2 lines
The type
NLA_BINARYindicates that the length is a maximum possible length, and thus a check of the actual length is needed before the memcpy.
You are right here (and the similar spotting in ip_set_hash_mac.c) - I'll prepare a patch and submit it.
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
H-1525 Budapest 114, POB. 49, Hungary
Quoted 19 lines · Jozsef Kadlecsik
Hi,
Quoted 15 lines · Julia Lawall
The file
net/netfilter/ipset/ip_set_bitmap_ipmac.cseems to contain a lot of static functions that are not used in the file:
bitmap_ipmac_add_timeoutbitmap_ipmac_do_addbitmap_ipmac_do_delbitmap_ipmac_do_headbitmap_ipmac_do_listbitmap_ipmac_do_testbitmap_ipmac_gc_testbitmap_ipmac_is_filledbitmap_ipmac_kadtbitmap_ipmac_same_setbitmap_ipmac_uadt
Quoted 4 lines
Quoted 1 line
Have I overooked something?
Yes: the file includes
ip_set_bitmap_gen.hin which all those functions are used.
OK, thanks. I saw the incude, but I didn't sufficiently appreciate the #defines at the beginning. Thanks.
Quoted 20 lines
Quoted 20 lines
I was looking at this code, with Daniel Borkmann, because there seems to be a bug in the function
bitmap_ipmac_uadt:if (tb[IPSET_ATTR_ETHER]) { memcpy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]), ETH_ALEN); e.add_mac = 1; }Later in the same file, there is:
static struct ip_set_type bitmap_ipmac_type = { ... .adt_policy = { ... [IPSET_ATTR_ETHER] = { .type = NLA_BINARY, .len = ETH_ALEN }, ...}, ... };
Quoted 5 lines
Quoted 2 lines
The type
NLA_BINARYindicates that the length is a maximum possible length, and thus a check of the actual length is needed before the memcpy.You are right here (and the similar spotting in
ip_set_hash_mac.c) - I'll prepare a patch and submit it.
Great. Thanks.
julia
Quoted 9 lines
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of SciencesH-1525 Budapest 114, POB. 49, Hungary