On 04/24/2018 10:27 PM, Eric Dumazet wrote: > When adding tcp mmap() implementation, I forgot that socket lock > had to be taken before current->mm->mmap_sem. syzbot eventually caught > the bug. > + ... > + down_read(¤t->mm->mmap_sem); > + > + ret = -EINVAL; > + vma = find_vma(current->mm, address); > + if (!vma || vma->vm_start > address || vma->vm_ops != &tcp_vm_ops) > goto out; > - } > + zc->length = min_t(unsigned long, zc->length, vma->vm_end - address); > + > tp = tcp_sk(sk); > seq = tp->copied_seq; > - /* Abort if urgent data is in the area */ > - if (unlikely(tp->urg_data)) { > - u32 urg_offset = tp->urg_seq - seq; > + zc->length = min_t(u32, zc->length, tcp_inq(sk)); > > I might have to make sure zc->length is page aligned before calling zap_page_range() ? zc->length &= ~(PAGE_SIZE - 1); + zap_page_range(vma, address, zc->length);