From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f74.google.com (mail-oa1-f74.google.com [209.85.160.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F25603CAE85 for ; Mon, 23 Mar 2026 17:54:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774288444; cv=none; b=EMoq7+8xsyXqKtq31QE6Zo6CCMZAvNWxEJTF0Blh1LUNsjLk/hjpN6/H5OzvNp5fKcXt85wASc0h6e8Jn8NM8MSF0sYR6RO8dU+pnI/1jOeIyFncsHNcAnXrR4IGhqhF/qlwhUEPYQRLPmlxFS476y11f4TOLeeLd9SixF7rDPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774288444; c=relaxed/simple; bh=yiSvanU+b3R9AvelUdQG47d6JdC1zJCKosFLTaFy2yg=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=f9RiQHqiWj4PTiCz10w2Mz7VGtsB93ekgCTEro9dceAKptfBcXVEm4CATS7fe9ARCV9rujXzblJxuN38RrA5hkB8GIx4kLwfZ33tI4bP6ombku2uqTqb6/FIk4DY40Erb7USthOCV22yxD/wte/VttMaFMMEBbD62vlb7yn+oSU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--avagin.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fgbEKpcZ; arc=none smtp.client-ip=209.85.160.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--avagin.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fgbEKpcZ" Received: by mail-oa1-f74.google.com with SMTP id 586e51a60fabf-41c002d0b04so17191083fac.3 for ; Mon, 23 Mar 2026 10:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774288442; x=1774893242; darn=lists.linux.dev; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=A9CUPvPqmkALquwn3kP/A/dGd5HZtJJQeBn1Jn3L+v0=; b=fgbEKpcZsxr275yPh6YX9A9OKjtK8/MLWsFerM+WUaQpFrQEvxRbkO5Za220spVors Ma2OCLSqjf6Y0c/bfyC+MDVlzmIpeRjeDui3wFvPh3UZnDU0Lmij/f4WcKU+lmfh6Xua 08y+mQapWd7Sbv4eaAd8kaQ0QR07c2JfKqSFyXA73UtJKaItJNNi1yCM8tYkzmxaO/lt 8Hjp93d9vg6VIC+DD/K8mjvjklKUbhb3PR3RbioBrcjtoqOojg5fgyGaPoYK/Ih0m3y2 g6bry1YETJgHlWPTgB93xfxTNKbO3z+nhYp030enqVaFZfDiabgKPeeU63oAFd0b7UXY TONg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774288442; x=1774893242; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=A9CUPvPqmkALquwn3kP/A/dGd5HZtJJQeBn1Jn3L+v0=; b=mtpLDLIKzNlWkp+FLYzVHViux7y+ORfn7ObufzgfIhMQiBf9kbem6KYiMlZiqGbN19 JIvYvy7hB57HdZ5XJl5GZ2ic6v20bp949tvGjuiFETt+C7qJTMOgpDGn3xCtopIQCJU2 XKPEycRIYY4AAvPrj1eIRK9/iAbU2Be3ndyV5Y9sVz+6uEQk2d7YrTGNd3I6hme3lKgW p0Wwj8+Ck387BiSErbq0vct95Av4HueHGywhhuI8r1A/pokRT1zHc5jd951ia6kYNVL/ +RPeIZ6hZ00eGcOOaJKF4zrkeQruSrzLRKdM5PE4mrBQrqU3+T/BevwVvwWtdTf1Bz1a RrAg== X-Forwarded-Encrypted: i=1; AJvYcCVmIqvU2V+xx0iCvf6C94Osa4RATgUlXAdG5VxppRyN56LwLfh4AzOscJ+XOmZeIpkTPTCc@lists.linux.dev X-Gm-Message-State: AOJu0YzW337P65bjjNUfGN8dZLEhxvfsNPiTgzOtgu+Xh6NmODGrhFxH ZgXttvcbJfmv7zlTzTnBhGi3ntb65keF3l9gJP1eRS2yNpWZz10f/K3roMVyLRVuR3azfiaf6FI uo7hTQA== X-Received: from jabjy12.prod.google.com ([2002:a05:6638:a30c:b0:5d4:6f13:358c]) (user=avagin job=prod-delivery.src-stubby-dispatcher) by 2002:a4a:e904:0:b0:67b:d1cc:db3b with SMTP id 006d021491bc7-67c22bb5ed4mr10163213eaf.15.1774288441712; Mon, 23 Mar 2026 10:54:01 -0700 (PDT) Date: Mon, 23 Mar 2026 17:53:36 +0000 Precedence: bulk X-Mailing-List: criu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.983.g0bb29b3bc5-goog Message-ID: <20260323175340.3361311-1-avagin@google.com> Subject: [PATCH 0/4 v5] exec: inherit HWCAPs from the parent process From: Andrei Vagin To: Kees Cook , Andrew Morton Cc: Marek Szyprowski , Cyrill Gorcunov , Mike Rapoport , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, criu@lists.linux.dev, Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Chen Ridong , Christian Brauner , David Hildenbrand , Eric Biederman , Lorenzo Stoakes , Michal Koutny Content-Type: text/plain; charset="UTF-8" This patch series introduces a mechanism to inherit hardware capabilities (AT_HWCAP, AT_HWCAP2, etc.) from a parent process when they have been modified via prctl. To support C/R operations (snapshots, live migration) in heterogeneous clusters, we must ensure that processes utilize CPU features available on all potential target nodes. To solve this, we need to advertise a common feature set across the cluster. Initially, a cgroup-based approach was considered, but it was decided that inheriting HWCAPs from a parent process that has set its own auxiliary vector via prctl is a simpler and more flexible solution. This implementation adds a new mm flag MMF_USER_HWCAP, which is set when the auxiliary vector is modified via prctl(PR_SET_MM_AUXV). When execve() is called, if the current process has MMF_USER_HWCAP set, the HWCAP values are extracted from the current auxiliary vector and inherited by the new process. The first patch fixes AUXV size calculation for ELF_HWCAP3 and ELF_HWCAP4 in binfmt_elf_fdpic and updates AT_VECTOR_SIZE_BASE. The second patch implements the core inheritance logic in execve(). The third patch adds a selftest to verify that HWCAPs are correctly inherited across execve(). v5: - Fix reading of HWCAPs from auxiliary vectors of compat processes. - Defer HWCAP masking until ELF table creation (create_elf_tables) to handle compat process correctly. - arm64: Disable HWCAP inheritance on architecture switch (e.g., AArch64 to AArch32) by clearing MMF_USER_HWCAP, as HWCAP bits have completely different meanings across these architectures. v4: minor fixes based on feedback from the previous version. v3: synchronize saved_auxv access with arg_lock v1: https://lkml.org/lkml/2025/12/5/65 v2: https://lkml.org/lkml/2026/1/8/219 v3: https://lkml.org/lkml/2026/2/9/1233 v4: https://lkml.org/lkml/2026/2/17/963 Cc: Andrew Morton Cc: Chen Ridong Cc: Christian Brauner Cc: David Hildenbrand Cc: Eric Biederman Cc: Kees Cook Cc: Lorenzo Stoakes Cc: Michal Koutny Cc: Cyrill Gorcunov Andrei Vagin (4): exec: inherit HWCAPs from the parent process arm64: elf: clear MMF_USER_HWCAP on architecture switch mm: synchronize saved_auxv access with arg_lock selftests/exec: add test for HWCAP inheritance arch/arm64/include/asm/elf.h | 12 ++- fs/binfmt_elf.c | 13 ++- fs/binfmt_elf_fdpic.c | 13 ++- fs/exec.c | 54 ++++++++++ fs/proc/base.c | 12 ++- include/linux/binfmts.h | 11 ++ include/linux/mm_types.h | 3 +- kernel/fork.c | 8 ++ kernel/sys.c | 30 +++--- tools/testing/selftests/exec/.gitignore | 1 + tools/testing/selftests/exec/Makefile | 1 + tools/testing/selftests/exec/hwcap_inherit.c | 105 +++++++++++++++++++ 12 files changed, 234 insertions(+), 29 deletions(-) create mode 100644 tools/testing/selftests/exec/hwcap_inherit.c -- 2.53.0.959.g497ff81fa9-goog