From patchwork Mon Nov 11 06:27:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 13870271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF3E1D12D77 for ; Mon, 11 Nov 2024 06:27:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 201536B007B; Mon, 11 Nov 2024 01:27:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B12D6B0083; Mon, 11 Nov 2024 01:27:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 078EB6B0085; Mon, 11 Nov 2024 01:27:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DE67A6B007B for ; Mon, 11 Nov 2024 01:27:42 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5C2E61416FA for ; Mon, 11 Nov 2024 06:27:42 +0000 (UTC) X-FDA: 82772831862.21.B10ECFB Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf18.hostedemail.com (Postfix) with ESMTP id 96C5B1C000C for ; Mon, 11 Nov 2024 06:27:22 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kbpDtUPM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of thehajime@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=thehajime@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731306398; a=rsa-sha256; cv=none; b=DWn1n0+dC1FdMap26bYaEBudo5NN85lXyu3R9SgCpyOi2FYzDhX+CKEAPbM5tz4rDeZg3I qDJMg7sYFeQf7VAXQ4mEwYoiBZziDpcmDDKQbEVOvnxHJ1j/YhOQVboogpQGDNZaIGZX1e zZIURAAGRuP1lqe03QAMZZi0+z37vrc= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kbpDtUPM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of thehajime@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=thehajime@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731306398; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6rxsmZtwDE9hveMIBPCsasEv3gNTZZ8QeBClxURXh1g=; b=GYPmj67gtcgl3jb8hXdNTln0VT0ejjgaKMVgdEG6dCrpEBNUFE0fLKkZUGa8T9LLWRXx4s JVb39k+S0aEkhHutSVpoJSmAqWdW1NpJzH+UNVHTFwqO1fkV9+X6oCkw6LkCIU+SDEMo3Z XTy368B/mr/ZLwzIhqDZTxB4i/jBzKY= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-20c693b68f5so42070585ad.1 for ; Sun, 10 Nov 2024 22:27:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731306459; x=1731911259; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6rxsmZtwDE9hveMIBPCsasEv3gNTZZ8QeBClxURXh1g=; b=kbpDtUPM2QhM+OGvK48mdOocdsgrX6F9vHLDqO2XsPtZJvanP0+DhxT5aZUBMSK7Gq bVkf8lpPy7iaj1zC+ei7xRZeC6leSRoFaxokGDo7uR/fYpjsh5VaSJG/9I9UK1TQVbQj SvvGzAHhN5pAhXPcwEZA2mmbHKGwPXEaKuZnYey7TimIio1ZF467oFZ5lfde910mY6j2 hJ0WJXW9i7Ml0lYt1EL+pXfkoUFkGM5qR7jWz/bTnugd3ZNPfaefOOYEIprXaHJtzaJR MsSmMz9EcU+mnenF43bn8CLRKzV5Jgx2v8XbAr4n6as+HCqMAkJwLAIyS1OoUSokty+m n5mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731306459; x=1731911259; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6rxsmZtwDE9hveMIBPCsasEv3gNTZZ8QeBClxURXh1g=; b=ABwxtlCthzMqFGsvRSC8nfAbPQ3IvONOgg6yuB6RTqnDRZ/ljXavwGIwXhzStrcn8s QGjl9yCbYFOYGjZ5X120TBi6mb/pmO3LXpWcSlwhAnIzbuhd2HMwYCHvlWjst5fhyjNo tInDAJiJhJrSf/C7b4Mzt79P4higjIy0Pv0v5HumlMn9agRVEzHF+5Oz08oeYhjoa8Jh 1wGPQlWIGX/OC21V1F5crTocTSE5pogt3ZYtU3Q0krtyJoBA8mAq/OKc2X627g08eUDe LnjlANANh/p6vvNVQ6kxTUGNIobs/lMcEpHovPDpWdAzMLI92pEoPNaIBrz8fkx0R9Xh tT6A== X-Forwarded-Encrypted: i=1; AJvYcCUFSngIN3t6pw1taKMf6WDYazimnvckJEE4GcvsdloYB22Tar30jTh0mPQ1JZ01uYOgjT7+7n3Vvg==@kvack.org X-Gm-Message-State: AOJu0YwyGg2OumG0WljFsEbs2g7JdxDEiF7j6d0rnyOOiQ67l5h9Ifci 321EqmuyEz0dh2cMKd7Nz5iH6TsdjNBHBe4fdf25Vi6P2CNf80LM X-Google-Smtp-Source: AGHT+IHwpmnY7dnXQcsSzHRDD73tGXzcdssS5VVzqSGyOahZ7QhXBU0+7Fxo/FbpiQKc5P/v4ljTRA== X-Received: by 2002:a17:903:245:b0:20b:5645:d860 with SMTP id d9443c01a7336-211835bf105mr168324925ad.36.1731306458982; Sun, 10 Nov 2024 22:27:38 -0800 (PST) Received: from ikb-h07-29-noble.in.iijlab.net ([202.214.97.5]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177dc836bsm68741545ad.13.2024.11.10.22.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 22:27:38 -0800 (PST) Received: by ikb-h07-29-noble.in.iijlab.net (Postfix, from userid 1010) id E5712DBA914; Mon, 11 Nov 2024 15:27:36 +0900 (JST) From: Hajime Tazaki To: linux-um@lists.infradead.org Cc: thehajime@gmail.com, ricarkol@google.com, Liam.Howlett@oracle.com, Alexander Viro , Christian Brauner , Jan Kara , Eric Biederman , Kees Cook , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 01/13] fs: binfmt_elf_efpic: add architecture hook elf_arch_finalize_exec Date: Mon, 11 Nov 2024 15:27:01 +0900 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 96C5B1C000C X-Rspamd-Server: rspam01 X-Stat-Signature: djg55tffkx9rdykjjzu959ea7stua4pf X-HE-Tag: 1731306442-114259 X-HE-Meta: U2FsdGVkX1/HMA3cRMwaqcIucMlPAxA17jUOKVoJj1rf7BltMk1yVYAyRhBRiCIPJrAGrYYaMmPBeTA+2ZZvVmovjGhcl0r7L8z/lfrGxD/W2twJJX9cy9YUzGb2+VqoOmCq69GDMDcf7IF0bjwuVxTwjcUWLMC629R9U+sbLckB6wLp4fUPdYtgTRKNIhTYJD8lzMQFA2YZUQVGch7hEuSRkE1UC7Pt/sXI42U5OxXnhPAu1G9C8ZpcTWKZ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iBXmbXt7Gur5P2F1CntfxmJNQigCthenIWpwXLpwdafmMTEMJPQy3Js5rzBoJ5sv9hyEW2MddV4IQz28elH21BHaf993T+Jo+84RzRf6rlzD9XYufJ6/AFMNDx250GksZXQKQaRDCCEWTGp7bpkVkETl9kSs9SbZXr6Srli1X2IMokzbje87OhTnBDNmpzviXmG9KJ9dxh4dPKX/BCxgO2xFwTLawkD78HiTq0SGaFOhJYJL6FnmgPsYRS6Jkn6+1xpqPdHH6rpaSHVbYjkz0KOA9rO7K8ZSS269tCQ1tARfJHHW/13g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: FDPIC ELF loader adds an architecture hook at the end of loading binaries to finalize the mapped memory before moving toward exec function. The hook is used by UML under !MMU when translating syscall/sysenter instructions before calling execve. Cc: Alexander Viro Cc: Christian Brauner Cc: Jan Kara Cc: Eric Biederman Cc: Kees Cook Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Signed-off-by: Hajime Tazaki --- fs/binfmt_elf_fdpic.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 4fe5bb9f1b1f..ab16fdf475b0 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -175,6 +175,12 @@ static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params, return 0; } +int __weak elf_arch_finalize_exec(struct elf_fdpic_params *exec_params, + struct elf_fdpic_params *interp_params) +{ + return 0; +} + /*****************************************************************************/ /* * load an fdpic binary into various bits of memory @@ -457,6 +463,10 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) dynaddr); #endif + retval = elf_arch_finalize_exec(&exec_params, &interp_params); + if (retval) + goto error; + finalize_exec(bprm); /* everything is now ready... get the userspace context ready to roll */ entryaddr = interp_params.entry_addr ?: exec_params.entry_addr; From patchwork Mon Nov 11 06:27:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 13870272 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69A1CD12D77 for ; Mon, 11 Nov 2024 06:27:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EFAF16B0085; Mon, 11 Nov 2024 01:27:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA9446B0088; Mon, 11 Nov 2024 01:27:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4A7D6B0089; Mon, 11 Nov 2024 01:27:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B59D06B0085 for ; Mon, 11 Nov 2024 01:27:52 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 413E41616FB for ; Mon, 11 Nov 2024 06:27:52 +0000 (UTC) X-FDA: 82772831526.07.A3FF1F1 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf28.hostedemail.com (Postfix) with ESMTP id 75CDBC0012 for ; Mon, 11 Nov 2024 06:27:09 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Y2zbahVz; spf=pass (imf28.hostedemail.com: domain of thehajime@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=thehajime@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731306329; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xOVZBEb1qaBKyIOwwQleK43822fSZbq/jfSKIeFdX6E=; b=u/xtOlihYws64twMQtnJO8Vtd3gbMiSg3fJ1pwR+uZlfR3sjh97RlIB0RHEzMR5XnGv9aU G1MkXJuVqyubhH4Oqxj0ByrYKGlCk/qJTSgxqjcyrs5BmNJ6Fih5KMb+oMccbXKEZhWvkI 6AgEfsgFgK7MzhsCUbcl5umlPnsso70= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731306329; a=rsa-sha256; cv=none; b=qaVIa6dxfJfCYXGpXByKtEGPhs5WiWL/6lBcrqKgcdZ6ZrmE6IG1oz6Fynaafk/D2jkb1g kFDwaGq3rdH5urLyVT3qX1ynLuvjHs5ap800ePEtZTQ2sXIhdAZNiXok8GR9mEN33KTivS MidSk/3y49IM9YH2V58g4GSdm7G9JHE= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Y2zbahVz; spf=pass (imf28.hostedemail.com: domain of thehajime@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=thehajime@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7ea8c4ce232so3660702a12.0 for ; Sun, 10 Nov 2024 22:27:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731306469; x=1731911269; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xOVZBEb1qaBKyIOwwQleK43822fSZbq/jfSKIeFdX6E=; b=Y2zbahVzqOkAFtMz0XT17iIXbyIqGHWcXQ7M+ao2ZTDb0/aX6vjD/nJb9BZJSX/XnI G2wcDh7UijVPHrSr443A3HpwRu257NxuxB5ol4CearjOFwpOmZwXNlfySTcN8Ppm05kf kkYlB5vE/s19Xe1xoVZ6bBHJbLMflcWOuJXgA7xklXKVVgMtqLf7YzT5hJkx8F6kJqGc dAEr9nN6lm/sMMY2aPWZGg4GtMXZfPI20vT78JsTOjr5AK8OUweajRC8EHZ5jjN1AFI4 Tm1xTSu7CFScOVrryrOufm5dGDYf8e3ZRV/DX9otSmOSRDuJYesKjhqs/a8Ywt016rH2 CZ5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731306469; x=1731911269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xOVZBEb1qaBKyIOwwQleK43822fSZbq/jfSKIeFdX6E=; b=Dbxo3tE9VhPou9imZjGnD5qsgrLpZMPpjuUh94cRw4wVupkAcD1i0JLH9fr+5QELHE fDx/4FI7WvPgoyb+w7y4H6mv6189y90/ZvysvGDCS22IgR/RazsHYfU4ja9iprKueghA Cj5vhkEzHBKsN2LDuy7Ptjx57AgbnIDwPydqWpzGmp34qPF4sdAvh95xvNXMkZv9nNeN Zp1Kwp9xVN1KimdGeDRe8UHB+UMIqbQhvo2fi5UFXvP11iWiJSIzlYTYYphSNT++9U3m SLgY8oc0RdtHaPz8usGiZhfekZHkurwWNC4WMjWmXh4oojyXd7Cuh+12HPFwFz+WnI8M F0Pg== X-Forwarded-Encrypted: i=1; AJvYcCU4y96Q5fKGl22QfC7QRFLCixYutkVq4h5AxKiXLuBqXsDUARSN5Cl83Hc45XEE7cqLWtkJ9DFIIQ==@kvack.org X-Gm-Message-State: AOJu0YwUFmm+SBgF44TROv9OM+V4h+Abh3rwQL5rNe9JUXI++61og3Ol SXMkAVsih/CswmuQA5zMef1gjrX+P1Y6HN6qIF3nRn3MgV9zpab4 X-Google-Smtp-Source: AGHT+IHr4mrXQCJG6ehz4R575ji8XJjfRwnS/MkIAJ3E4bPBw/vNBMDgKXMb0Ui2eNQcCUFveGlOmw== X-Received: by 2002:a05:6a20:4324:b0:1db:f06e:f666 with SMTP id adf61e73a8af0-1dc22b91c5emr16383347637.41.1731306469013; Sun, 10 Nov 2024 22:27:49 -0800 (PST) Received: from ikb-h07-29-noble.in.iijlab.net ([202.214.97.5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e9a5f8f5d3sm7819534a91.27.2024.11.10.22.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2024 22:27:48 -0800 (PST) Received: by ikb-h07-29-noble.in.iijlab.net (Postfix, from userid 1010) id 43199DBA916; Mon, 11 Nov 2024 15:27:46 +0900 (JST) From: Hajime Tazaki To: linux-um@lists.infradead.org Cc: thehajime@gmail.com, ricarkol@google.com, Liam.Howlett@oracle.com, Eric Biederman , Kees Cook , Alexander Viro , Christian Brauner , Jan Kara , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [RFC PATCH v2 02/13] x86/um: nommu: elf loader for fdpic Date: Mon, 11 Nov 2024 15:27:02 +0900 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 75CDBC0012 X-Stat-Signature: jzza8mb9byiww6sbqtirhxdbjx9i5epy X-HE-Tag: 1731306429-7530 X-HE-Meta: U2FsdGVkX1+VDIcwc83tgQJjJgAFw0OXWW0V5zK0H0fEy/zSKyc9NwxveiXqTJKSG3l24M4pCSncZJzgj7U4ds/6lo9ps1o9F/wXNDvho+mngOHISPIXlqbKcn6NWrVA6lvzoZ2nM/Iey+YNZgSusqyGrVSvTFCGNlazNPH1Vw3ZJMI9yn/Lb1zRwI4Y82iIDSlJBaLXxNJvRFtxCWYqRfrUsbWmvuPkxwITW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FMc5ZjwbkVn1J3sugoa4puV2/UIQL7yfFGlfmF7sE2Ck4Dd++udRy5PYdUGKt6SzHHefCKgjHWcMmp0vu/OlWCNX+Q5sWFjAHZjm3Y1s8f/SU7WmiYD+ioaHVTksWq0FKq5ctEcuaaO8R5kY4r/52rtWq6nn+05KIbsvgL//H1NipT+RInBUeuSdrlxS1SedVe51yj94ui6BoQOdIOWptKLnpG5Z9N5aRzighJkq7AGdMODXN3AyHNCTsczsBD5cw2eKvj0M+ZAi6Npl838+G47IJ7swhfZX X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: As UML supports CONFIG_MMU=n case, it has to use an alternate ELF loader, FDPIC ELF loader. In this commit, we added necessary definitions in the arch, as UML has not been used so far. It also updates Kconfig file to use BINFMT_ELF_FDPIC under !MMU environment. Cc: Eric Biederman Cc: Kees Cook Cc: Alexander Viro Cc: Christian Brauner Cc: Jan Kara Cc: linux-mm@kvack.org Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Hajime Tazaki Signed-off-by: Ricardo Koller --- arch/um/include/asm/Kbuild | 1 + arch/um/include/asm/mmu.h | 5 +++++ arch/um/include/asm/ptrace-generic.h | 6 ++++++ arch/x86/um/asm/elf.h | 8 ++++++-- arch/x86/um/asm/module.h | 24 ------------------------ fs/Kconfig.binfmt | 2 +- 6 files changed, 19 insertions(+), 27 deletions(-) delete mode 100644 arch/x86/um/asm/module.h diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild index 18f902da8e99..cf8260fdcfe5 100644 --- a/arch/um/include/asm/Kbuild +++ b/arch/um/include/asm/Kbuild @@ -14,6 +14,7 @@ generic-y += irq_work.h generic-y += kdebug.h generic-y += mcs_spinlock.h generic-y += mmiowb.h +generic-y += module.h generic-y += module.lds.h generic-y += param.h generic-y += parport.h diff --git a/arch/um/include/asm/mmu.h b/arch/um/include/asm/mmu.h index a3eaca41ff61..01422b761aa0 100644 --- a/arch/um/include/asm/mmu.h +++ b/arch/um/include/asm/mmu.h @@ -14,6 +14,11 @@ typedef struct mm_context { /* Address range in need of a TLB sync */ unsigned long sync_tlb_range_from; unsigned long sync_tlb_range_to; + +#ifdef CONFIG_BINFMT_ELF_FDPIC + unsigned long exec_fdpic_loadmap; + unsigned long interp_fdpic_loadmap; +#endif } mm_context_t; #endif diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h index 4696f24d1492..4ff844bcb1cd 100644 --- a/arch/um/include/asm/ptrace-generic.h +++ b/arch/um/include/asm/ptrace-generic.h @@ -29,6 +29,12 @@ struct pt_regs { #define PTRACE_OLDSETOPTIONS 21 +#ifdef CONFIG_BINFMT_ELF_FDPIC +#define PTRACE_GETFDPIC 31 +#define PTRACE_GETFDPIC_EXEC 0 +#define PTRACE_GETFDPIC_INTERP 1 +#endif + struct task_struct; extern long subarch_ptrace(struct task_struct *child, long request, diff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h index 62ed5d68a978..33f69f1eac10 100644 --- a/arch/x86/um/asm/elf.h +++ b/arch/x86/um/asm/elf.h @@ -9,6 +9,7 @@ #include #define CORE_DUMP_USE_REGSET +#define ELF_FDPIC_CORE_EFLAGS 0 #ifdef CONFIG_X86_32 @@ -190,8 +191,11 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, extern unsigned long um_vdso_addr; #define AT_SYSINFO_EHDR 33 -#define ARCH_DLINFO NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr) - +#define ARCH_DLINFO \ +do { \ + NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr); \ + NEW_AUX_ENT(AT_MINSIGSTKSZ, 0); \ +} while (0) #endif typedef unsigned long elf_greg_t; diff --git a/arch/x86/um/asm/module.h b/arch/x86/um/asm/module.h deleted file mode 100644 index a3b061d66082..000000000000 --- a/arch/x86/um/asm/module.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __UM_MODULE_H -#define __UM_MODULE_H - -/* UML is simple */ -struct mod_arch_specific -{ -}; - -#ifdef CONFIG_X86_32 - -#define Elf_Shdr Elf32_Shdr -#define Elf_Sym Elf32_Sym -#define Elf_Ehdr Elf32_Ehdr - -#else - -#define Elf_Shdr Elf64_Shdr -#define Elf_Sym Elf64_Sym -#define Elf_Ehdr Elf64_Ehdr - -#endif - -#endif diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index bd2f530e5740..419ba0282806 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -58,7 +58,7 @@ config ARCH_USE_GNU_PROPERTY config BINFMT_ELF_FDPIC bool "Kernel support for FDPIC ELF binaries" default y if !BINFMT_ELF - depends on ARM || ((M68K || RISCV || SUPERH || XTENSA) && !MMU) + depends on ARM || ((M68K || RISCV || SUPERH || UML || XTENSA) && !MMU) select ELFCORE help ELF FDPIC binaries are based on ELF, but allow the individual load