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 F247E3C9433 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=V6XG773/352YcXuqXzS+8Wwqs/Z9+hNQHzAcYKxwD0K9yi9hA+EEdXvvHp4wnafCRzT4stKIyl3OtKUzrCJSE7o5nZHgpAtKBw1QN7y0K2R0LxwpW19FCnRDGUMaEknWLkOYMhK+Gk3JH9Og8HpfxQewGuK5pvnxfhiJA3mlj8w= 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=IaVXj7tN; 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="IaVXj7tN" Received: by mail-oa1-f74.google.com with SMTP id 586e51a60fabf-41555e51e94so13885398fac.1 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=vger.kernel.org; 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=IaVXj7tNOm0FTsvuLsfrAaX3Fqy+BCj2zxdUQNszdC9crZBr8nmwJ1wPsRb21wHUQQ c8v1qIuUKOYduyJZYsNbsR5miAuYdP5y7eOqS4paxewwL6EjI4mbo5VfxfMR7brIAwUC WBUckgiDitK7GxIyB37KvE2+v08oOEfXs96sHiCHmrERtidZPlkCD5qqFtj9yI/UId6C tvH8FDRHKabdExcHlSOgST0vlydOJ6dS+sM34fSRi8EHf0t2yQBXHpLB2q4PDlGvAWj+ CIeQ2rpyf7BQ9wna10KLXrJPPUa9RmvWlURnKCocCG1hyZUr7N5Bt+eZAUx21ET1rS2l epmw== 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=kFbvE6TtKMohiVNYGs5B/9aR2AIJbApTv9m3IMF8FUiZbEmM3XmdkV0h/6h4rQSQg2 GDcay1IiZ179KX17bfWQqkxKcVi0+23vJrhLVAXG3+97bkUGFluS/K3hAyI58vbaadD7 +ZvvYxZAR4raDJxf6RgES/s4Xzo5L84ujpwAQYa58X7J2Gci/UmCTnG7RVE612x0pq80 z4bqkTyrk2HgjQLRfBdkIqh+T2zyPmFntrPk5OwKW8mKiwTxWlfNBPfhmPlmdxvKAecD pnJ9yDGaddJoW/17CGF3j6sX9mfYUMP/7R5q0XyEiuHj0EpxTrOtsgrjqXqP9muQcQKl 3RvQ== X-Forwarded-Encrypted: i=1; AJvYcCWyv7dp5iNRNcFLBAiI6CDRjweEgN2CucBWU1k188WIgOzJWR3eDgvUJ7GHqb7rPFz1wYchhUo8S3xFBHQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzlgYdwBwl/HLYh7IM9MNzdxtpasgvNQcWWToUzzWbQxebiaihP gdVEVKTME/JxH/LFKwG9c9jz7NQtIR1yxv8gE80BO0cmqQeGGwKrTSNIBEOhvd1c7v4kN2vCvaL AcJ84dg== 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: linux-kernel@vger.kernel.org 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