Skip to content

Commit e595dd9

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Pull networking fixes from David Miller: 1) Fix memory leak in vti6, from Torsten Hilbrich. 2) Fix double free in xfrm_policy_timer, from YueHaibing. 3) NL80211_ATTR_CHANNEL_WIDTH attribute is put with wrong type, from Johannes Berg. 4) Wrong allocation failure check in qlcnic driver, from Xu Wang. 5) Get ks8851-ml IO operations right, for real this time, from Marek Vasut. * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (22 commits) r8169: fix PHY driver check on platforms w/o module softdeps net: ks8851-ml: Fix IO operations, again mlxsw: spectrum_mr: Fix list iteration in error path qlcnic: Fix bad kzalloc null test mac80211: set IEEE80211_TX_CTRL_PORT_CTRL_PROTO for nl80211 TX mac80211: mark station unauthorized before key removal mac80211: Check port authorization in the ieee80211_tx_dequeue() case cfg80211: Do not warn on same channel at the end of CSA mac80211: drop data frames without key on encrypted links ieee80211: fix HE SPR size calculation nl80211: fix NL80211_ATTR_CHANNEL_WIDTH attribute type xfrm: policy: Fix doulbe free in xfrm_policy_timer bpf: Explicitly memset some bpf info structures declared on the stack bpf: Explicitly memset the bpf_attr structure bpf: Sanitize the bpf_struct_ops tcp-cc name vti6: Fix memory leak of skb if input policy check fails esp: remove the skb from the chain when it's enqueued in cryptd_wq ipv6: xfrm6_tunnel.c: Use built-in RCU list checking xfrm: add the missing verify_sec_ctx_len check in xfrm_add_acquire xfrm: fix uctx len check in verify_sec_ctx_len ...
2 parents 906c404 + a0ba26f commit e595dd9

File tree

23 files changed

+221
-80
lines changed

23 files changed

+221
-80
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,12 @@ static int mlxsw_sp_mr_vif_resolve(struct mlxsw_sp_mr_table *mr_table,
637637
return 0;
638638

639639
err_erif_unresolve:
640-
list_for_each_entry_from_reverse(erve, &mr_vif->route_evif_list,
641-
vif_node)
640+
list_for_each_entry_continue_reverse(erve, &mr_vif->route_evif_list,
641+
vif_node)
642642
mlxsw_sp_mr_route_evif_unresolve(mr_table, erve);
643643
err_irif_unresolve:
644-
list_for_each_entry_from_reverse(irve, &mr_vif->route_ivif_list,
645-
vif_node)
644+
list_for_each_entry_continue_reverse(irve, &mr_vif->route_ivif_list,
645+
vif_node)
646646
mlxsw_sp_mr_route_ivif_unresolve(mr_table, irve);
647647
mr_vif->rif = NULL;
648648
return err;

drivers/net/ethernet/micrel/ks8851_mll.c

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,50 @@ static int msg_enable;
156156
* chip is busy transferring packet data (RX/TX FIFO accesses).
157157
*/
158158

159+
/**
160+
* ks_check_endian - Check whether endianness of the bus is correct
161+
* @ks : The chip information
162+
*
163+
* The KS8851-16MLL EESK pin allows selecting the endianness of the 16bit
164+
* bus. To maintain optimum performance, the bus endianness should be set
165+
* such that it matches the endianness of the CPU.
166+
*/
167+
168+
static int ks_check_endian(struct ks_net *ks)
169+
{
170+
u16 cider;
171+
172+
/*
173+
* Read CIDER register first, however read it the "wrong" way around.
174+
* If the endian strap on the KS8851-16MLL in incorrect and the chip
175+
* is operating in different endianness than the CPU, then the meaning
176+
* of BE[3:0] byte-enable bits is also swapped such that:
177+
* BE[3,2,1,0] becomes BE[1,0,3,2]
178+
*
179+
* Luckily for us, the byte-enable bits are the top four MSbits of
180+
* the address register and the CIDER register is at offset 0xc0.
181+
* Hence, by reading address 0xc0c0, which is not impacted by endian
182+
* swapping, we assert either BE[3:2] or BE[1:0] while reading the
183+
* CIDER register.
184+
*
185+
* If the bus configuration is correct, reading 0xc0c0 asserts
186+
* BE[3:2] and this read returns 0x0000, because to read register
187+
* with bottom two LSbits of address set to 0, BE[1:0] must be
188+
* asserted.
189+
*
190+
* If the bus configuration is NOT correct, reading 0xc0c0 asserts
191+
* BE[1:0] and this read returns non-zero 0x8872 value.
192+
*/
193+
iowrite16(BE3 | BE2 | KS_CIDER, ks->hw_addr_cmd);
194+
cider = ioread16(ks->hw_addr);
195+
if (!cider)
196+
return 0;
197+
198+
netdev_err(ks->netdev, "incorrect EESK endian strap setting\n");
199+
200+
return -EINVAL;
201+
}
202+
159203
/**
160204
* ks_rdreg16 - read 16 bit register from device
161205
* @ks : The chip information
@@ -166,7 +210,7 @@ static int msg_enable;
166210

167211
static u16 ks_rdreg16(struct ks_net *ks, int offset)
168212
{
169-
ks->cmd_reg_cache = (u16)offset | ((BE3 | BE2) >> (offset & 0x02));
213+
ks->cmd_reg_cache = (u16)offset | ((BE1 | BE0) << (offset & 0x02));
170214
iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd);
171215
return ioread16(ks->hw_addr);
172216
}
@@ -181,7 +225,7 @@ static u16 ks_rdreg16(struct ks_net *ks, int offset)
181225

182226
static void ks_wrreg16(struct ks_net *ks, int offset, u16 value)
183227
{
184-
ks->cmd_reg_cache = (u16)offset | ((BE3 | BE2) >> (offset & 0x02));
228+
ks->cmd_reg_cache = (u16)offset | ((BE1 | BE0) << (offset & 0x02));
185229
iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd);
186230
iowrite16(value, ks->hw_addr);
187231
}
@@ -197,7 +241,7 @@ static inline void ks_inblk(struct ks_net *ks, u16 *wptr, u32 len)
197241
{
198242
len >>= 1;
199243
while (len--)
200-
*wptr++ = be16_to_cpu(ioread16(ks->hw_addr));
244+
*wptr++ = (u16)ioread16(ks->hw_addr);
201245
}
202246

203247
/**
@@ -211,7 +255,7 @@ static inline void ks_outblk(struct ks_net *ks, u16 *wptr, u32 len)
211255
{
212256
len >>= 1;
213257
while (len--)
214-
iowrite16(cpu_to_be16(*wptr++), ks->hw_addr);
258+
iowrite16(*wptr++, ks->hw_addr);
215259
}
216260

217261
static void ks_disable_int(struct ks_net *ks)
@@ -1218,6 +1262,10 @@ static int ks8851_probe(struct platform_device *pdev)
12181262
goto err_free;
12191263
}
12201264

1265+
err = ks_check_endian(ks);
1266+
if (err)
1267+
goto err_free;
1268+
12211269
netdev->irq = platform_get_irq(pdev, 0);
12221270

12231271
if ((int)netdev->irq < 0) {

drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@ static int qlcnic_83xx_get_reset_instruction_template(struct qlcnic_adapter *p_d
17201720

17211721
ahw->reset.seq_error = 0;
17221722
ahw->reset.buff = kzalloc(QLC_83XX_RESTART_TEMPLATE_SIZE, GFP_KERNEL);
1723-
if (p_dev->ahw->reset.buff == NULL)
1723+
if (ahw->reset.buff == NULL)
17241724
return -ENOMEM;
17251725

17261726
p_buff = p_dev->ahw->reset.buff;

drivers/net/ethernet/realtek/r8169_main.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5285,6 +5285,13 @@ static int r8169_mdio_register(struct rtl8169_private *tp)
52855285
if (!tp->phydev) {
52865286
mdiobus_unregister(new_bus);
52875287
return -ENODEV;
5288+
} else if (!tp->phydev->drv) {
5289+
/* Most chip versions fail with the genphy driver.
5290+
* Therefore ensure that the dedicated PHY driver is loaded.
5291+
*/
5292+
dev_err(&pdev->dev, "realtek.ko not loaded, maybe it needs to be added to initramfs?\n");
5293+
mdiobus_unregister(new_bus);
5294+
return -EUNATCH;
52885295
}
52895296

52905297
/* PHY will be woken up in rtl_open() */
@@ -5446,15 +5453,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
54465453
int chipset, region;
54475454
int jumbo_max, rc;
54485455

5449-
/* Some tools for creating an initramfs don't consider softdeps, then
5450-
* r8169.ko may be in initramfs, but realtek.ko not. Then the generic
5451-
* PHY driver is used that doesn't work with most chip versions.
5452-
*/
5453-
if (!driver_find("RTL8201CP Ethernet", &mdio_bus_type)) {
5454-
dev_err(&pdev->dev, "realtek.ko not loaded, maybe it needs to be added to initramfs?\n");
5455-
return -ENOENT;
5456-
}
5457-
54585456
dev = devm_alloc_etherdev(&pdev->dev, sizeof (*tp));
54595457
if (!dev)
54605458
return -ENOMEM;

include/linux/bpf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ static inline void copy_map_value(struct bpf_map *map, void *dst, void *src)
160160
}
161161
void copy_map_value_locked(struct bpf_map *map, void *dst, void *src,
162162
bool lock_src);
163+
int bpf_obj_name_cpy(char *dst, const char *src, unsigned int size);
163164

164165
struct bpf_offload_dev;
165166
struct bpf_offloaded_map;

include/linux/ieee80211.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,14 +2102,14 @@ ieee80211_he_spr_size(const u8 *he_spr_ie)
21022102
{
21032103
struct ieee80211_he_spr *he_spr = (void *)he_spr_ie;
21042104
u8 spr_len = sizeof(struct ieee80211_he_spr);
2105-
u32 he_spr_params;
2105+
u8 he_spr_params;
21062106

21072107
/* Make sure the input is not NULL */
21082108
if (!he_spr_ie)
21092109
return 0;
21102110

21112111
/* Calc required length */
2112-
he_spr_params = le32_to_cpu(he_spr->he_sr_control);
2112+
he_spr_params = he_spr->he_sr_control;
21132113
if (he_spr_params & IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT)
21142114
spr_len++;
21152115
if (he_spr_params & IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT)

kernel/bpf/btf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4564,7 +4564,7 @@ int btf_get_info_by_fd(const struct btf *btf,
45644564
union bpf_attr __user *uattr)
45654565
{
45664566
struct bpf_btf_info __user *uinfo;
4567-
struct bpf_btf_info info = {};
4567+
struct bpf_btf_info info;
45684568
u32 info_copy, btf_copy;
45694569
void __user *ubtf;
45704570
u32 uinfo_len;
@@ -4573,6 +4573,7 @@ int btf_get_info_by_fd(const struct btf *btf,
45734573
uinfo_len = attr->info.info_len;
45744574

45754575
info_copy = min_t(u32, uinfo_len, sizeof(info));
4576+
memset(&info, 0, sizeof(info));
45764577
if (copy_from_user(&info, uinfo, info_copy))
45774578
return -EFAULT;
45784579

kernel/bpf/syscall.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -696,14 +696,15 @@ int bpf_get_file_flag(int flags)
696696
offsetof(union bpf_attr, CMD##_LAST_FIELD) - \
697697
sizeof(attr->CMD##_LAST_FIELD)) != NULL
698698

699-
/* dst and src must have at least BPF_OBJ_NAME_LEN number of bytes.
700-
* Return 0 on success and < 0 on error.
699+
/* dst and src must have at least "size" number of bytes.
700+
* Return strlen on success and < 0 on error.
701701
*/
702-
static int bpf_obj_name_cpy(char *dst, const char *src)
702+
int bpf_obj_name_cpy(char *dst, const char *src, unsigned int size)
703703
{
704-
const char *end = src + BPF_OBJ_NAME_LEN;
704+
const char *end = src + size;
705+
const char *orig_src = src;
705706

706-
memset(dst, 0, BPF_OBJ_NAME_LEN);
707+
memset(dst, 0, size);
707708
/* Copy all isalnum(), '_' and '.' chars. */
708709
while (src < end && *src) {
709710
if (!isalnum(*src) &&
@@ -712,11 +713,11 @@ static int bpf_obj_name_cpy(char *dst, const char *src)
712713
*dst++ = *src++;
713714
}
714715

715-
/* No '\0' found in BPF_OBJ_NAME_LEN number of bytes */
716+
/* No '\0' found in "size" number of bytes */
716717
if (src == end)
717718
return -EINVAL;
718719

719-
return 0;
720+
return src - orig_src;
720721
}
721722

722723
int map_check_no_btf(const struct bpf_map *map,
@@ -810,8 +811,9 @@ static int map_create(union bpf_attr *attr)
810811
if (IS_ERR(map))
811812
return PTR_ERR(map);
812813

813-
err = bpf_obj_name_cpy(map->name, attr->map_name);
814-
if (err)
814+
err = bpf_obj_name_cpy(map->name, attr->map_name,
815+
sizeof(attr->map_name));
816+
if (err < 0)
815817
goto free_map;
816818

817819
atomic64_set(&map->refcnt, 1);
@@ -2098,8 +2100,9 @@ static int bpf_prog_load(union bpf_attr *attr, union bpf_attr __user *uattr)
20982100
goto free_prog;
20992101

21002102
prog->aux->load_time = ktime_get_boottime_ns();
2101-
err = bpf_obj_name_cpy(prog->aux->name, attr->prog_name);
2102-
if (err)
2103+
err = bpf_obj_name_cpy(prog->aux->name, attr->prog_name,
2104+
sizeof(attr->prog_name));
2105+
if (err < 0)
21032106
goto free_prog;
21042107

21052108
/* run eBPF verifier */
@@ -2792,7 +2795,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
27922795
union bpf_attr __user *uattr)
27932796
{
27942797
struct bpf_prog_info __user *uinfo = u64_to_user_ptr(attr->info.info);
2795-
struct bpf_prog_info info = {};
2798+
struct bpf_prog_info info;
27962799
u32 info_len = attr->info.info_len;
27972800
struct bpf_prog_stats stats;
27982801
char __user *uinsns;
@@ -2804,6 +2807,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
28042807
return err;
28052808
info_len = min_t(u32, sizeof(info), info_len);
28062809

2810+
memset(&info, 0, sizeof(info));
28072811
if (copy_from_user(&info, uinfo, info_len))
28082812
return -EFAULT;
28092813

@@ -3067,7 +3071,7 @@ static int bpf_map_get_info_by_fd(struct bpf_map *map,
30673071
union bpf_attr __user *uattr)
30683072
{
30693073
struct bpf_map_info __user *uinfo = u64_to_user_ptr(attr->info.info);
3070-
struct bpf_map_info info = {};
3074+
struct bpf_map_info info;
30713075
u32 info_len = attr->info.info_len;
30723076
int err;
30733077

@@ -3076,6 +3080,7 @@ static int bpf_map_get_info_by_fd(struct bpf_map *map,
30763080
return err;
30773081
info_len = min_t(u32, sizeof(info), info_len);
30783082

3083+
memset(&info, 0, sizeof(info));
30793084
info.type = map->map_type;
30803085
info.id = map->id;
30813086
info.key_size = map->key_size;
@@ -3359,7 +3364,7 @@ static int bpf_map_do_batch(const union bpf_attr *attr,
33593364

33603365
SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
33613366
{
3362-
union bpf_attr attr = {};
3367+
union bpf_attr attr;
33633368
int err;
33643369

33653370
if (sysctl_unprivileged_bpf_disabled && !capable(CAP_SYS_ADMIN))
@@ -3371,6 +3376,7 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, siz
33713376
size = min_t(u32, size, sizeof(attr));
33723377

33733378
/* copy attributes from user space, may be less than sizeof(bpf_attr) */
3379+
memset(&attr, 0, sizeof(attr));
33743380
if (copy_from_user(&attr, uattr, size) != 0)
33753381
return -EFAULT;
33763382

net/ipv4/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ config SYN_COOKIES
303303

304304
config NET_IPVTI
305305
tristate "Virtual (secure) IP: tunneling"
306+
depends on IPV6 || IPV6=n
306307
select INET_TUNNEL
307308
select NET_IP_TUNNEL
308309
select XFRM

net/ipv4/bpf_tcp_ca.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ static int bpf_tcp_ca_init_member(const struct btf_type *t,
184184
{
185185
const struct tcp_congestion_ops *utcp_ca;
186186
struct tcp_congestion_ops *tcp_ca;
187-
size_t tcp_ca_name_len;
188187
int prog_fd;
189188
u32 moff;
190189

@@ -199,13 +198,11 @@ static int bpf_tcp_ca_init_member(const struct btf_type *t,
199198
tcp_ca->flags = utcp_ca->flags;
200199
return 1;
201200
case offsetof(struct tcp_congestion_ops, name):
202-
tcp_ca_name_len = strnlen(utcp_ca->name, sizeof(utcp_ca->name));
203-
if (!tcp_ca_name_len ||
204-
tcp_ca_name_len == sizeof(utcp_ca->name))
201+
if (bpf_obj_name_cpy(tcp_ca->name, utcp_ca->name,
202+
sizeof(tcp_ca->name)) <= 0)
205203
return -EINVAL;
206204
if (tcp_ca_find(utcp_ca->name))
207205
return -EEXIST;
208-
memcpy(tcp_ca->name, utcp_ca->name, sizeof(tcp_ca->name));
209206
return 1;
210207
}
211208

0 commit comments

Comments
 (0)