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 E6B773F5BFA for ; Mon, 27 Jul 2026 10:28:08 +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=1785148092; cv=none; b=EVrOWR/0KUaSi82TtbvVmPU+GJHYXm1mfGEG3Cp1/aLL4KNwmSuRa6p5xG1sd8oE2AmLpGcAv81pXLO3a56Ed1xevcNClarunFvBm6+AgL7YY+gG8bm6HvewsXoX95iw++nDVoWW9RaB9LKn1/JCqZoMXgqoNufLQ8xx2vIw5p4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785148092; c=relaxed/simple; bh=ImUrdLcJwnX4dchBzUGcvdOSOQxO48vQT2FJEL4Q9+I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=O0qlUfy0sEsUPxpWnLm83T11kve/b7BizS6j0jQKDop00v0ggBZc4OevV0fNuhYOwreIBS3dZ7OQIfEaD4cmaXs+BvDdVYd70hxVOoT6HSUASo5mMaPqg0+tIPnQ5zNsHrogv2vwRuq9tPyXp0a8lQMEB1cjn4DzUQS/6lw1/zo= 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=IZJF8nil; 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="IZJF8nil" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785148085; 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: content-transfer-encoding:content-transfer-encoding; bh=O0vpSKqw8JomasdhceoRcsiAZL4N+9X1cPkziQWBqCs=; b=IZJF8nilsz88Rw9pwdOuM0ZkH4OdZY8MoEqoKM1decp3fMw+reG/U2pvJF/ezskPZNl77k UQgClXETFanmd5ixDW/hi+YQkE7MRn/FffzWyO+1Fq18oz5c/pY/74D3dg9Cx+3UND2XLc TcyVGgxo7exXPdlooszy+nW4Uag0zbQ= 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-56-PaAqPFpDNU6ZQcoUfJtKUQ-1; Mon, 27 Jul 2026 06:28:04 -0400 X-MC-Unique: PaAqPFpDNU6ZQcoUfJtKUQ-1 X-Mimecast-MFC-AGG-ID: PaAqPFpDNU6ZQcoUfJtKUQ_1785148083 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 A28871955E9E for ; Mon, 27 Jul 2026 10:28:03 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.24.14]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 80A6D18002A6; Mon, 27 Jul 2026 10:28:02 +0000 (UTC) From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= To: linux-kernel@vger.kernel.org Cc: ahajkova@redhat.com Subject: [PATCH RESEND] elf: add AT_ARGV and AT_ENVV auxiliary vector entries Date: Mon, 27 Jul 2026 10:26:05 +0200 Message-ID: <20260727082710.22446-1-ahajkova@redhat.com> 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=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Add AT_ARGV (52), which contains the address of the argv pointer array on the initial process stack, and AT_ENVV (53), which contains the address of the envp pointer array. The motivation is to allow GDB to find argv and envp in core dumps cleanly. Currently GDB locates them by scanning backwards through stack memory from AT_EXECFN, which is fragile. With AT_ARGV and AT_ENVV it can read the addresses directly from the core dump's auxv note. Signed-off-by: Alexandra Hájková --- Resending after no response for 4 weeks. fs/binfmt_elf.c | 9 ++++++++- include/linux/auxvec.h | 2 +- include/uapi/linux/auxvec.h | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 8e89cc5b2820..c2b3032adccb 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -182,6 +182,8 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec, int ei_index; const struct cred *cred = current_cred(); struct vm_area_struct *vma; + elf_addr_t *at_argv_val; + elf_addr_t *at_envv_val; /* * In some cases (e.g. Hyper-Threading), we want to avoid L1 @@ -288,6 +290,10 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec, NEW_AUX_ENT(AT_RSEQ_FEATURE_SIZE, offsetof(struct rseq, end)); NEW_AUX_ENT(AT_RSEQ_ALIGN, __alignof__(struct rseq)); #endif + at_argv_val = elf_info + 1; + NEW_AUX_ENT(AT_ARGV, 0); + at_envv_val = elf_info + 1; + NEW_AUX_ENT(AT_ENVV, 0); #undef NEW_AUX_ENT /* AT_NULL is zero; clear the rest too */ memset(elf_info, 0, (char *)mm->saved_auxv + @@ -309,7 +315,8 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec, #else sp = (elf_addr_t __user *)bprm->p; #endif - + *at_argv_val = (unsigned long)(sp + sizeof(elf_addr_t)); + *at_envv_val = (unsigned long)(sp + (argc + 2)); /* * Grow the stack manually; some architectures have a limit on how diff --git a/include/linux/auxvec.h b/include/linux/auxvec.h index 8bcb9b726262..7184de95b89d 100644 --- a/include/linux/auxvec.h +++ b/include/linux/auxvec.h @@ -4,6 +4,6 @@ #include -#define AT_VECTOR_SIZE_BASE 24 /* NEW_AUX_ENT entries in auxiliary table */ +#define AT_VECTOR_SIZE_BASE 26 /* NEW_AUX_ENT entries in auxiliary table */ /* number of "#define AT_.*" above, minus {AT_NULL, AT_IGNORE, AT_NOTELF} */ #endif /* _LINUX_AUXVEC_H */ diff --git a/include/uapi/linux/auxvec.h b/include/uapi/linux/auxvec.h index cc61cb9b3e9a..e7af32709aba 100644 --- a/include/uapi/linux/auxvec.h +++ b/include/uapi/linux/auxvec.h @@ -40,5 +40,7 @@ #ifndef AT_MINSIGSTKSZ #define AT_MINSIGSTKSZ 51 /* minimal stack size for signal delivery */ #endif +#define AT_ARGV 52 /* address of argv[] */ +#define AT_ENVV 53 /* address of envp[] */ #endif /* _UAPI_LINUX_AUXVEC_H */ -- 2.52.0