Skip to content

Commit ae1bc8d

Browse files
committed
netfilter: propagate net to nf_bridge_get_physindev
jira LE-3201 cve CVE-2024-35839 Rebuild_History Non-Buildable kernel-rt-4.18.0-553.27.1.rt7.368.el8_10 commit-author Pavel Tikhomirov <[email protected]> commit a54e721 This is a preparation patch for replacing physindev with physinif on nf_bridge_info structure. We will use dev_get_by_index_rcu to resolve device, when needed, and it requires net to be available. Signed-off-by: Pavel Tikhomirov <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> (cherry picked from commit a54e721) Signed-off-by: Jonathan Maple <[email protected]>
1 parent d244380 commit ae1bc8d

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

include/linux/netfilter_bridge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static inline int nf_bridge_get_physoutif(const struct sk_buff *skb)
4949
}
5050

5151
static inline struct net_device *
52-
nf_bridge_get_physindev(const struct sk_buff *skb)
52+
nf_bridge_get_physindev(const struct sk_buff *skb, struct net *net)
5353
{
5454
const struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
5555

net/ipv4/netfilter/nf_reject_ipv4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void nf_send_reset(struct net *net, struct sk_buff *oldskb, int hook)
148148
* build the eth header using the original destination's MAC as the
149149
* source, and send the RST packet directly.
150150
*/
151-
br_indev = nf_bridge_get_physindev(oldskb);
151+
br_indev = nf_bridge_get_physindev(oldskb, net);
152152
if (br_indev) {
153153
struct ethhdr *oeth = eth_hdr(oldskb);
154154

net/ipv6/netfilter/nf_reject_ipv6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook)
198198
* build the eth header using the original destination's MAC as the
199199
* source, and send the RST packet directly.
200200
*/
201-
br_indev = nf_bridge_get_physindev(oldskb);
201+
br_indev = nf_bridge_get_physindev(oldskb, net);
202202
if (br_indev) {
203203
struct ethhdr *oeth = eth_hdr(oldskb);
204204

net/netfilter/ipset/ip_set_hash_netiface.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ hash_netiface4_data_next(struct hash_netiface4_elem *next,
136136
#include "ip_set_hash_gen.h"
137137

138138
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
139-
static const char *get_physindev_name(const struct sk_buff *skb)
139+
static const char *get_physindev_name(const struct sk_buff *skb, struct net *net)
140140
{
141-
struct net_device *dev = nf_bridge_get_physindev(skb);
141+
struct net_device *dev = nf_bridge_get_physindev(skb, net);
142142

143143
return dev ? dev->name : NULL;
144144
}
@@ -175,7 +175,7 @@ hash_netiface4_kadt(struct ip_set *set, const struct sk_buff *skb,
175175

176176
if (opt->cmdflags & IPSET_FLAG_PHYSDEV) {
177177
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
178-
const char *eiface = SRCDIR ? get_physindev_name(skb) :
178+
const char *eiface = SRCDIR ? get_physindev_name(skb, xt_net(par)) :
179179
get_physoutdev_name(skb);
180180

181181
if (!eiface)
@@ -387,7 +387,7 @@ hash_netiface6_kadt(struct ip_set *set, const struct sk_buff *skb,
387387

388388
if (opt->cmdflags & IPSET_FLAG_PHYSDEV) {
389389
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
390-
const char *eiface = SRCDIR ? get_physindev_name(skb) :
390+
const char *eiface = SRCDIR ? get_physindev_name(skb, xt_net(par)) :
391391
get_physoutdev_name(skb);
392392

393393
if (!eiface)

net/netfilter/nf_log_syslog.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ nf_log_dump_packet_common(struct nf_log_buf *m, u8 pf,
114114
unsigned int hooknum, const struct sk_buff *skb,
115115
const struct net_device *in,
116116
const struct net_device *out,
117-
const struct nf_loginfo *loginfo, const char *prefix)
117+
const struct nf_loginfo *loginfo, const char *prefix,
118+
struct net *net)
118119
{
119120
const struct net_device *physoutdev __maybe_unused;
120121
const struct net_device *physindev __maybe_unused;
@@ -124,7 +125,7 @@ nf_log_dump_packet_common(struct nf_log_buf *m, u8 pf,
124125
in ? in->name : "",
125126
out ? out->name : "");
126127
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
127-
physindev = nf_bridge_get_physindev(skb);
128+
physindev = nf_bridge_get_physindev(skb, net);
128129
if (physindev && in != physindev)
129130
nf_log_buf_add(m, "PHYSIN=%s ", physindev->name);
130131
physoutdev = nf_bridge_get_physoutdev(skb);
@@ -151,7 +152,7 @@ static void nf_log_arp_packet(struct net *net, u_int8_t pf,
151152
loginfo = &default_loginfo;
152153

153154
nf_log_dump_packet_common(m, pf, hooknum, skb, in, out, loginfo,
154-
prefix);
155+
prefix, net);
155156
dump_arp_packet(m, loginfo, skb, skb_network_offset(skb));
156157

157158
nf_log_buf_close(m);
@@ -848,7 +849,7 @@ static void nf_log_ip_packet(struct net *net, u_int8_t pf,
848849
loginfo = &default_loginfo;
849850

850851
nf_log_dump_packet_common(m, pf, hooknum, skb, in,
851-
out, loginfo, prefix);
852+
out, loginfo, prefix, net);
852853

853854
if (in)
854855
dump_mac_header(m, loginfo, skb);
@@ -883,7 +884,7 @@ static void nf_log_ip6_packet(struct net *net, u_int8_t pf,
883884
loginfo = &default_loginfo;
884885

885886
nf_log_dump_packet_common(m, pf, hooknum, skb, in, out,
886-
loginfo, prefix);
887+
loginfo, prefix, net);
887888

888889
if (in)
889890
dump_mac_header(m, loginfo, skb);
@@ -919,7 +920,7 @@ static void nf_log_unknown_packet(struct net *net, u_int8_t pf,
919920
loginfo = &default_loginfo;
920921

921922
nf_log_dump_packet_common(m, pf, hooknum, skb, in, out, loginfo,
922-
prefix);
923+
prefix, net);
923924

924925
dump_mac_header(m, loginfo, skb);
925926

net/netfilter/nf_queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static void __nf_queue_entry_init_physdevs(struct nf_queue_entry *entry)
8484
const struct sk_buff *skb = entry->skb;
8585

8686
if (nf_bridge_info_exists(skb)) {
87-
entry->physin = nf_bridge_get_physindev(skb);
87+
entry->physin = nf_bridge_get_physindev(skb, entry->state.net);
8888
entry->physout = nf_bridge_get_physoutdev(skb);
8989
} else {
9090
entry->physin = NULL;

net/netfilter/xt_physdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ physdev_mt(const struct sk_buff *skb, struct xt_action_param *par)
6161
(!!outdev ^ !(info->invert & XT_PHYSDEV_OP_BRIDGED)))
6262
return false;
6363

64-
physdev = nf_bridge_get_physindev(skb);
64+
physdev = nf_bridge_get_physindev(skb, xt_net(par));
6565
indev = physdev ? physdev->name : NULL;
6666

6767
if ((info->bitmask & XT_PHYSDEV_OP_ISIN &&

0 commit comments

Comments
 (0)