bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,
                     enum skb_drop_reason *reason)
 {
-       u32 limit, tail_gso_size, tail_gso_segs;
+       u32 tail_gso_size, tail_gso_segs;
        struct skb_shared_info *shinfo;
        const struct tcphdr *th;
        struct tcphdr *thtail;
        bool fragstolen;
        u32 gso_segs;
        u32 gso_size;
+       u64 limit;
        int delta;
 
        /* In case all data was pulled from skb frags (in __pskb_pull_tail()),
        __skb_push(skb, hdrlen);
 
 no_coalesce:
-       limit = (u32)READ_ONCE(sk->sk_rcvbuf) + (u32)(READ_ONCE(sk->sk_sndbuf) >> 1);
+       /* sk->sk_backlog.len is reset only at the end of __release_sock().
+        * Both sk->sk_backlog.len and sk->sk_rmem_alloc could reach
+        * sk_rcvbuf in normal conditions.
+        */
+       limit = ((u64)READ_ONCE(sk->sk_rcvbuf)) << 1;
+
+       limit += ((u32)READ_ONCE(sk->sk_sndbuf)) >> 1;
 
        /* Only socket owner can try to collapse/prune rx queues
         * to reduce memory overhead, so add a little headroom here.
         */
        limit += 64 * 1024;
 
+       limit = min_t(u64, limit, UINT_MAX);
+
        if (unlikely(sk_add_backlog(sk, skb, limit))) {
                bh_unlock_sock(sk);
                *reason = SKB_DROP_REASON_SOCKET_BACKLOG;