From 9c42288a8011e15a9b5d2afe20cddc8ca95f56df Mon Sep 17 00:00:00 2001 From: Wang Yufen Date: Mon, 16 Aug 2021 20:14:12 +0800 Subject: [PATCH] tcp_comp: Avoiding the null pointer problem of ctx in comp_stream_read hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I45UYC?from=project-issue CVE: NA ------------------------------------------------- In comp_stream_read ctx might be null, add null check to avoid oops. And delete unnecessary tcp_comp_err_abort. Signed-off-by: Wang Yufen Reviewed-by: Yue Haibing Reviewed-by: Wei Yongjun Signed-off-by: Yang Yingliang --- net/ipv4/tcp_comp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_comp.c b/net/ipv4/tcp_comp.c index e7f6094b5aee..f6ebe52f3f7f 100644 --- a/net/ipv4/tcp_comp.c +++ b/net/ipv4/tcp_comp.c @@ -723,8 +723,6 @@ static int tcp_comp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, if (!ctx->rx.decompressed) { err = tcp_comp_decompress(sk, skb); if (err < 0) { - if (err != -ENOSPC) - tcp_comp_err_abort(sk, EBADMSG); goto recv_end; } ctx->rx.decompressed = true; @@ -758,6 +756,9 @@ bool comp_stream_read(const struct sock *sk) { struct tcp_comp_context *ctx = comp_get_ctx(sk); + if (!ctx) + return false; + if (ctx->rx.pkt) return true; -- GitLab