提交 a1362bde 编写于 作者: X Xie XiuQi

Revert "net: get rid of an signed integer overflow in ip_idents_reserve()"

hulk inclusion
category: perf
bugzilla: 18689
CVE: CVE

This reverts commit adb03115.

1) This perious patch introduce performance regression,
MySQL performance is reduced by 40% in vm.

2) The previous patch did not resolve the overflow problem,
it just ignore the UBSAN warning.

So, the patch dit not resolve real problem, but introduce
significant performance regression. Just revert it.

https://lkml.org/lkml/2019/7/24/243
https://lore.kernel.org/lkml/b0160f4b-b996-b0ee-405a-3d5f1866272e@gmail.com/
https://lore.kernel.org/lkml/20181101172739.GA3196@hirez.programming.kicks-ass.net/

Cc: Hanjun Guo <guohanjun@huawei.com>
Cc: Yongjun Wei <weiyongjun1@huawei.com>
Cc: Xuefeng Wang <wxf.wang@hisilicon.com>
Tested-by: NChen Tongbiao <chentongbiao@huawei.com>
Signed-off-by: NXie XiuQi <xiexiuqi@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Reviewed-by: NMao Wenan <maowenan@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 f9e0a2f5
......@@ -483,18 +483,12 @@ u32 ip_idents_reserve(u32 hash, int segs)
atomic_t *p_id = ip_idents + hash % IP_IDENTS_SZ;
u32 old = READ_ONCE(*p_tstamp);
u32 now = (u32)jiffies;
u32 new, delta = 0;
u32 delta = 0;
if (old != now && cmpxchg(p_tstamp, old, now) == old)
delta = prandom_u32_max(now - old);
/* Do not use atomic_add_return() as it makes UBSAN unhappy */
do {
old = (u32)atomic_read(p_id);
new = old + delta + segs;
} while (atomic_cmpxchg(p_id, old, new) != old);
return new - segs;
return atomic_add_return(segs + delta, p_id) - segs;
}
EXPORT_SYMBOL(ip_idents_reserve);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册