Skip to content

Commit c8cedca

Browse files
author
Herton R. Krzesinski
committed
Merge: net/other: phase-2 backports for RHEL-9.2
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1965 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2164865 Upstream Status: All mainline in net.git. Tested: boot-tested only Conflicts: None kerneloscope shows a follow-up for patch 6/7, but it does not seem to give any real improvement unless we also backport de43708 ("af_unix: Show number of inflight fds for sockets in TCP_LISTEN state too"). Let's skip both, given the phase-2 stage. Signed-off-by: Davide Caratti <dcaratti@redhat.com> Approved-by: Andrea Claudi <aclaudi@redhat.com> Approved-by: Paolo Abeni <pabeni@redhat.com> Approved-by: Guillaume Nault <gnault@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents f56960e + 75dacf7 commit c8cedca

File tree

6 files changed

+48
-20
lines changed

6 files changed

+48
-20
lines changed

drivers/net/veth.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,9 @@ static int veth_poll(struct napi_struct *napi, int budget)
985985
xdp_set_return_frame_no_direct();
986986
done = veth_xdp_rcv(rq, budget, &bq, &stats);
987987

988+
if (stats.xdp_redirect > 0)
989+
xdp_do_flush();
990+
988991
if (done < budget && napi_complete_done(napi, done)) {
989992
/* Write rx_notify_masked before reading ptr_ring */
990993
smp_store_mb(rq->rx_notify_masked, false);
@@ -998,8 +1001,6 @@ static int veth_poll(struct napi_struct *napi, int budget)
9981001

9991002
if (stats.xdp_tx > 0)
10001003
veth_xdp_flush(rq, &bq);
1001-
if (stats.xdp_redirect > 0)
1002-
xdp_do_flush();
10031004
xdp_clear_return_frame_no_direct();
10041005

10051006
return done;

include/net/addrconf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,9 @@ static inline bool ip6_ignore_linkdown(const struct net_device *dev)
403403
{
404404
const struct inet6_dev *idev = __in6_dev_get(dev);
405405

406+
if (unlikely(!idev))
407+
return true;
408+
406409
return !!idev->cnf.ignore_routes_with_linkdown;
407410
}
408411

net/ethtool/eeprom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static int eeprom_prepare_data(const struct ethnl_req_info *req_base,
124124
if (ret)
125125
goto err_free;
126126

127-
ret = get_module_eeprom_by_page(dev, &page_data, info->extack);
127+
ret = get_module_eeprom_by_page(dev, &page_data, info ? info->extack : NULL);
128128
if (ret < 0)
129129
goto err_ops;
130130

net/key/af_key.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,9 +2937,10 @@ static int count_esp_combs(const struct xfrm_tmpl *t)
29372937
return sz + sizeof(struct sadb_prop);
29382938
}
29392939

2940-
static void dump_ah_combs(struct sk_buff *skb, const struct xfrm_tmpl *t)
2940+
static int dump_ah_combs(struct sk_buff *skb, const struct xfrm_tmpl *t)
29412941
{
29422942
struct sadb_prop *p;
2943+
int sz = 0;
29432944
int i;
29442945

29452946
p = skb_put(skb, sizeof(struct sadb_prop));
@@ -2967,13 +2968,17 @@ static void dump_ah_combs(struct sk_buff *skb, const struct xfrm_tmpl *t)
29672968
c->sadb_comb_soft_addtime = 20*60*60;
29682969
c->sadb_comb_hard_usetime = 8*60*60;
29692970
c->sadb_comb_soft_usetime = 7*60*60;
2971+
sz += sizeof(*c);
29702972
}
29712973
}
2974+
2975+
return sz + sizeof(*p);
29722976
}
29732977

2974-
static void dump_esp_combs(struct sk_buff *skb, const struct xfrm_tmpl *t)
2978+
static int dump_esp_combs(struct sk_buff *skb, const struct xfrm_tmpl *t)
29752979
{
29762980
struct sadb_prop *p;
2981+
int sz = 0;
29772982
int i, k;
29782983

29792984
p = skb_put(skb, sizeof(struct sadb_prop));
@@ -3015,8 +3020,11 @@ static void dump_esp_combs(struct sk_buff *skb, const struct xfrm_tmpl *t)
30153020
c->sadb_comb_soft_addtime = 20*60*60;
30163021
c->sadb_comb_hard_usetime = 8*60*60;
30173022
c->sadb_comb_soft_usetime = 7*60*60;
3023+
sz += sizeof(*c);
30183024
}
30193025
}
3026+
3027+
return sz + sizeof(*p);
30203028
}
30213029

30223030
static int key_notify_policy_expire(struct xfrm_policy *xp, const struct km_event *c)
@@ -3146,6 +3154,7 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
31463154
struct sadb_x_sec_ctx *sec_ctx;
31473155
struct xfrm_sec_ctx *xfrm_ctx;
31483156
int ctx_size = 0;
3157+
int alg_size = 0;
31493158

31503159
sockaddr_size = pfkey_sockaddr_size(x->props.family);
31513160
if (!sockaddr_size)
@@ -3157,16 +3166,16 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
31573166
sizeof(struct sadb_x_policy);
31583167

31593168
if (x->id.proto == IPPROTO_AH)
3160-
size += count_ah_combs(t);
3169+
alg_size = count_ah_combs(t);
31613170
else if (x->id.proto == IPPROTO_ESP)
3162-
size += count_esp_combs(t);
3171+
alg_size = count_esp_combs(t);
31633172

31643173
if ((xfrm_ctx = x->security)) {
31653174
ctx_size = PFKEY_ALIGN8(xfrm_ctx->ctx_len);
31663175
size += sizeof(struct sadb_x_sec_ctx) + ctx_size;
31673176
}
31683177

3169-
skb = alloc_skb(size + 16, GFP_ATOMIC);
3178+
skb = alloc_skb(size + alg_size + 16, GFP_ATOMIC);
31703179
if (skb == NULL)
31713180
return -ENOMEM;
31723181

@@ -3220,10 +3229,13 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
32203229
pol->sadb_x_policy_priority = xp->priority;
32213230

32223231
/* Set sadb_comb's. */
3232+
alg_size = 0;
32233233
if (x->id.proto == IPPROTO_AH)
3224-
dump_ah_combs(skb, t);
3234+
alg_size = dump_ah_combs(skb, t);
32253235
else if (x->id.proto == IPPROTO_ESP)
3226-
dump_esp_combs(skb, t);
3236+
alg_size = dump_esp_combs(skb, t);
3237+
3238+
hdr->sadb_msg_len += alg_size / 8;
32273239

32283240
/* security context */
32293241
if (xfrm_ctx) {

net/unix/af_unix.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,13 +1945,20 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
19451945
unix_state_lock(sk);
19461946

19471947
err = 0;
1948-
if (unix_peer(sk) == other) {
1948+
if (sk->sk_type == SOCK_SEQPACKET) {
1949+
/* We are here only when racing with unix_release_sock()
1950+
* is clearing @other. Never change state to TCP_CLOSE
1951+
* unlike SOCK_DGRAM wants.
1952+
*/
1953+
unix_state_unlock(sk);
1954+
err = -EPIPE;
1955+
} else if (unix_peer(sk) == other) {
19491956
unix_peer(sk) = NULL;
19501957
unix_dgram_peer_wake_disconnect_wakeup(sk, other);
19511958

1959+
sk->sk_state = TCP_CLOSE;
19521960
unix_state_unlock(sk);
19531961

1954-
sk->sk_state = TCP_CLOSE;
19551962
unix_dgram_disconnected(sk, other);
19561963
sock_put(other);
19571964
err = -ECONNREFUSED;
@@ -3512,6 +3519,7 @@ static int __init af_unix_init(void)
35123519
rc = proto_register(&unix_stream_proto, 1);
35133520
if (rc != 0) {
35143521
pr_crit("%s: Cannot create unix_sock SLAB cache!\n", __func__);
3522+
proto_unregister(&unix_dgram_proto);
35153523
goto out;
35163524
}
35173525

net/unix/diag.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,16 @@ static int sk_diag_show_rqlen(struct sock *sk, struct sk_buff *nlskb)
114114
return nla_put(nlskb, UNIX_DIAG_RQLEN, sizeof(rql), &rql);
115115
}
116116

117-
static int sk_diag_dump_uid(struct sock *sk, struct sk_buff *nlskb)
117+
static int sk_diag_dump_uid(struct sock *sk, struct sk_buff *nlskb,
118+
struct user_namespace *user_ns)
118119
{
119-
uid_t uid = from_kuid_munged(sk_user_ns(nlskb->sk), sock_i_uid(sk));
120+
uid_t uid = from_kuid_munged(user_ns, sock_i_uid(sk));
120121
return nla_put(nlskb, UNIX_DIAG_UID, sizeof(uid_t), &uid);
121122
}
122123

123124
static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_req *req,
124-
u32 portid, u32 seq, u32 flags, int sk_ino)
125+
struct user_namespace *user_ns,
126+
u32 portid, u32 seq, u32 flags, int sk_ino)
125127
{
126128
struct nlmsghdr *nlh;
127129
struct unix_diag_msg *rep;
@@ -167,7 +169,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
167169
goto out_nlmsg_trim;
168170

169171
if ((req->udiag_show & UDIAG_SHOW_UID) &&
170-
sk_diag_dump_uid(sk, skb))
172+
sk_diag_dump_uid(sk, skb, user_ns))
171173
goto out_nlmsg_trim;
172174

173175
nlmsg_end(skb, nlh);
@@ -179,7 +181,8 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
179181
}
180182

181183
static int sk_diag_dump(struct sock *sk, struct sk_buff *skb, struct unix_diag_req *req,
182-
u32 portid, u32 seq, u32 flags)
184+
struct user_namespace *user_ns,
185+
u32 portid, u32 seq, u32 flags)
183186
{
184187
int sk_ino;
185188

@@ -190,7 +193,7 @@ static int sk_diag_dump(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
190193
if (!sk_ino)
191194
return 0;
192195

193-
return sk_diag_fill(sk, skb, req, portid, seq, flags, sk_ino);
196+
return sk_diag_fill(sk, skb, req, user_ns, portid, seq, flags, sk_ino);
194197
}
195198

196199
static int unix_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
@@ -218,7 +221,7 @@ static int unix_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
218221
goto next;
219222
if (!(req->udiag_states & (1 << sk->sk_state)))
220223
goto next;
221-
if (sk_diag_dump(sk, skb, req,
224+
if (sk_diag_dump(sk, skb, req, sk_user_ns(skb->sk),
222225
NETLINK_CB(cb->skb).portid,
223226
cb->nlh->nlmsg_seq,
224227
NLM_F_MULTI) < 0) {
@@ -286,7 +289,8 @@ static int unix_diag_get_exact(struct sk_buff *in_skb,
286289
if (!rep)
287290
goto out;
288291

289-
err = sk_diag_fill(sk, rep, req, NETLINK_CB(in_skb).portid,
292+
err = sk_diag_fill(sk, rep, req, sk_user_ns(NETLINK_CB(in_skb).sk),
293+
NETLINK_CB(in_skb).portid,
290294
nlh->nlmsg_seq, 0, req->udiag_ino);
291295
if (err < 0) {
292296
nlmsg_free(rep);

0 commit comments

Comments
 (0)