提交 e405c017 编写于 作者: E Eric Dumazet 提交者: Zheng Zengkai

net: fix sk_wmem_schedule() and sk_rmem_schedule() errors

stable inclusion
from stable-v5.10.137
commit d0412d8f693e6f00b6cda80cc3ae1fbc7c14d392
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5NYY0?from=project-issue
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d0412d8f693e6f00b6cda80cc3ae1fbc7c14d392

--------------------------------

[ Upstream commit 7c80b038 ]

If sk->sk_forward_alloc is 150000, and we need to schedule 150001 bytes,
we want to allocate 1 byte more (rounded up to one page),
instead of 150001 :/

Fixes: 1da177e4 ("Linux-2.6.12-rc2")
Signed-off-by: NEric Dumazet <edumazet@google.com>
Reviewed-by: NShakeel Butt <shakeelb@google.com>
Acked-by: NSoheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
Reviewed-by: NYue Haibing <yuehaibing@huawei.com>
Reviewed-by: NWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 b1698d3d
...@@ -1499,19 +1499,23 @@ static inline bool sk_has_account(struct sock *sk) ...@@ -1499,19 +1499,23 @@ static inline bool sk_has_account(struct sock *sk)
static inline bool sk_wmem_schedule(struct sock *sk, int size) static inline bool sk_wmem_schedule(struct sock *sk, int size)
{ {
int delta;
if (!sk_has_account(sk)) if (!sk_has_account(sk))
return true; return true;
return size <= sk->sk_forward_alloc || delta = size - sk->sk_forward_alloc;
__sk_mem_schedule(sk, size, SK_MEM_SEND); return delta <= 0 || __sk_mem_schedule(sk, delta, SK_MEM_SEND);
} }
static inline bool static inline bool
sk_rmem_schedule(struct sock *sk, struct sk_buff *skb, int size) sk_rmem_schedule(struct sock *sk, struct sk_buff *skb, int size)
{ {
int delta;
if (!sk_has_account(sk)) if (!sk_has_account(sk))
return true; return true;
return size <= sk->sk_forward_alloc || delta = size - sk->sk_forward_alloc;
__sk_mem_schedule(sk, size, SK_MEM_RECV) || return delta <= 0 || __sk_mem_schedule(sk, delta, SK_MEM_RECV) ||
skb_pfmemalloc(skb); skb_pfmemalloc(skb);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册