From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65A4D347BB8 for ; Wed, 7 Jan 2026 14:33:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767796392; cv=none; b=YLHKxySscYKmT5RkSvd1oYDEJ2XsvsaR8Ij85Jbs/mesv4AjGRogyvpXNqwljOn81xP0xWNcYJGXsIF6pIkSa+XLdsGJSZI5qDWyRyZswhaa+IuQQFnbq38J9xoA+RQX0d+BRUHxhGizKmDUOGfVwz+L4ZBvqm1IxvVrd16DnZ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767796392; c=relaxed/simple; bh=5hnfmrVX4PvyL2uPpL5zJ/qIQTC8PVEwqxrwSjrEKvo=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=jSHK2obhkoj37YJIScFPh/dt0ITSmzF3mGbbIjyW4ForKuZV9Hnu9oECwaFgrBEpttCfcnWyNfTNkNslVUvJMJ5twYp7Ny81gfL9h47uJ1GpZqkd9/YJ3nmCZo+KejQusOpqP/RIhz1YybMTyAdRGLfxTPqwCqDPDzHhWZtw8RY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Em9qvQ0X; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Em9qvQ0X" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767796387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=NG1Go/SFUn7MjHkPKWKg2ckPktX+qlhMwyAJulKg79w=; b=Em9qvQ0X77MQFSwN6Vc9frQiL9SRzR82ak+5NNukGEj3UYwTazkRdhdPYQ1L8/GNy3OBJo VkQbgGibSCaboyoeIrWgkPfyJENZKnfn5IX8YrBN8pS0c6XJJT7/AW+qiOZ/bOiVtbm0hr oQ7wKFz/+2Pc+AZZSbsiZ1e4GYVEFcg= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-486-ChGNuFT9NjyfMNvKh-29kQ-1; Wed, 07 Jan 2026 09:33:04 -0500 X-MC-Unique: ChGNuFT9NjyfMNvKh-29kQ-1 X-Mimecast-MFC-AGG-ID: ChGNuFT9NjyfMNvKh-29kQ_1767796381 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5BA4C1954237; Wed, 7 Jan 2026 14:33:00 +0000 (UTC) Received: from fedora (unknown [10.45.226.75]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id C92611956048; Wed, 7 Jan 2026 14:32:54 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 7 Jan 2026 15:32:59 +0100 (CET) Date: Wed, 7 Jan 2026 15:32:53 +0100 From: Oleg Nesterov To: Andrii Nakryiko , Borislav Petkov , Dave Hansen , David Hildenbrand , "H. Peter Anvin" , Ingo Molnar , Jiri Olsa , Masami Hiramatsu , Paulo Andrade , Peter Zijlstra , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, x86@kernel.org Subject: [BUG] x86: 32-bit uprobes are broken Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Paulo reported that uprobing the 32-bit tasks is broken. This script #!/usr/bin/bash echo 0 > /proc/sys/kernel/randomize_va_space echo 'void main(void) {}' > TEST.c # -fcf-protection to ensure that the 1st endbr32 insn can't be eulated gcc -m32 -fcf-protection=branch TEST.c -o test bpftrace -e 'uprobe:./test:main {}' -c ./test "hangs", the probed ./test task enters the endless loop. This patch --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -1710,8 +1710,11 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area) if (!area->vaddr) { /* Try to map as high as possible, this is only a hint. */ + if (test_thread_flag(TIF_ADDR32)) + current_thread_info()->status |= TS_COMPAT; area->vaddr = get_unmapped_area(NULL, TASK_SIZE - PAGE_SIZE, PAGE_SIZE, 0, 0); + current_thread_info()->status &= ~TS_COMPAT; if (IS_ERR_VALUE(area->vaddr)) { ret = area->vaddr; goto fail; or this one --- a/arch/x86/kernel/sys_x86_64.c +++ b/arch/x86/kernel/sys_x86_64.c @@ -205,6 +205,8 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr0, info.low_limit = PAGE_SIZE; info.high_limit = get_mmap_base(0); + if (test_thread_flag(TIF_ADDR32)) + info.high_limit = current->mm->mmap_compat_base; if (!(filp && is_file_hugepages(filp))) { info.start_gap = stack_guard_placement(vm_flags); info.align_offset = pgoff << PAGE_SHIFT; "fixes" the problem. ----------------------------------------------------------------------------------------- The problem is that with randomize_va_space == 0 get_unmapped_area(TASK_SIZE - PAGE_SIZE) called by xol_add_vma() can't just return the "addr == TASK_SIZE - PAGE_SIZE" hint, this addr is used by the stack vma. arch_get_unmapped_area/arch_get_unmapped_area_topdown() doesn't take TIF_ADDR32 into account and in_32bit_syscall() is false, this leads to info.high_limit > TASK_SIZE. get_area() happily returns the "high" address and then get_unmapped_area() returns ENOMEM after the if (addr > TASK_SIZE - len) return -ENOMEM; check; TASK_SIZE checks TIF_ADDR32. handle_swbp() doesn't report this failure (probably it should) and silently restarts the probed insn. Endless loop. ----------------------------------------------------------------------------------------- I am considering the patch which adds something like // x86 version will use the TS_COMPAT hack unsigned long __weak arch_uprobe_area(void) { return get_unmapped_area(NULL, TASK_SIZE - PAGE_SIZE, PAGE_SIZE, 0, 0); } but perhaps there is a better solution? perhaps it makes more sense to change arch/x86/kernel/sys_x86_64.c? What is the point of ignoring TIF_ADDR32 if the high adress will be nacked by the "if (addr > TASK_SIZE - len)" check anyway? Oleg.