From patchwork Thu Oct 24 12:09:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 13848843 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 3585CCE8E68 for ; Thu, 24 Oct 2024 12:09:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8BBE16B007B; Thu, 24 Oct 2024 08:09:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86C4B6B0082; Thu, 24 Oct 2024 08:09:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 733C16B0083; Thu, 24 Oct 2024 08:09:52 -0400 (EDT) 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 5364F6B007B for ; Thu, 24 Oct 2024 08:09:52 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7559C1412B8 for ; Thu, 24 Oct 2024 12:09:32 +0000 (UTC) X-FDA: 82708376184.08.F8F244A Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf12.hostedemail.com (Postfix) with ESMTP id 7537C40025 for ; Thu, 24 Oct 2024 12:09:41 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Y0lMmzPH; spf=pass (imf12.hostedemail.com: domain of thehajime@gmail.com designates 209.85.216.42 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=1729771637; 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=fpm504fGI5ZV6x9lfhFkD/X3VtZwXzqIGGrR3MmriLWhmXmltwT3hhMFgxVZEWbQltafSj em7rX4vYW22GKHB7IeB9favcsHeNN4wfRGqCCHpliq6sPTMAXWusClHItbeCwkrN64fQ40 eC0iQDYwDEmr8Wl3N2Z7fSJ7HVTEDj0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729771637; a=rsa-sha256; cv=none; b=4fIETls4Ev6uhtijciygirtNDnLw2MLvzRLfAT6Bm4zSlrl2BjtOoZSs+7K/AVkonXV5VB TwhyxTQg14t2rtg7F9KLJsWtUmz2v53UDx64U4wtDn99Tl86KPTOjiUL0X8Yc/CsRawH2S tHGzU4sLevnkKwRlcuZ3b5yDJNMV0u4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Y0lMmzPH; spf=pass (imf12.hostedemail.com: domain of thehajime@gmail.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=thehajime@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2e56750bb0dso615186a91.0 for ; Thu, 24 Oct 2024 05:09:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729771788; x=1730376588; 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=Y0lMmzPHIQ1gCg7pJlZUpKE/ahzO1yFhkcsEmckC5JephmXQ0ebskEplrd9HLRWCOL gJfBox/KGbeqLLdV+RqIlSedC3hQwMJ2Xg6uoeXtLUjga2/e61mmlLiDkjKLm8Rfwxmv rGhEXw+hyahMI+u2jIzf9+Q8Zkr/zPNygMdiz/mnbRGTIPtRJpH0g9GlXD6ZKTLQp+r0 CRBdZSSTfKZWqEoOFv0F9sXvjNXTpJ+p69E/bzHlJnDv3efDxxpnS9AUSB+s/8jpvIY/ MbL6hnb6yh3nRsVvq2x2drRDG2rGTDbEJyzND/bm01zIjFUnfk1LpEa9eNwEkQr51UBW WSjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729771788; x=1730376588; 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=H8W0ntoewlNNifWZ2utvdn6Y7/1nqJ5Bz+jmc4BSdQZbwcCnuq8oQLY2asesJU2bL5 XxTlImoAOyYUuJtekgYF3u8MnzY89Ty+IVbHCNS37b4Gkf1PKDLRUDwTNK5OMF0mkUKf BijTZVvBW272iaDU/cmPtriuskMMSUcMf2qGl3sGvlP94NF09SEzmpjz9yOkdb5K/3Yj PKidT8rg6QyZ+RGPABUCz7hXfuw1xKwINwebilur9gZDZ+P2okdzIlNihduX3PrBWGAx FaIl1ssOmOGPUmDKF3kuDKxcud3cnLMzjziwvJy3qUxZBRTz/YFuj+NvlNKgWJv47CpE fKzw== X-Forwarded-Encrypted: i=1; AJvYcCU10X0SVqWv3mSi8Rcq0UjI5SqS1VDa2WnJa5NAbaE5fFG2ZzEx87pg6GIyl1jdlmR5//RIhdMuzg==@kvack.org X-Gm-Message-State: AOJu0YyR552ZHcMbp8MeWnLlRz2MkxHmax++ms1ovuyUt5H53ANjBOyt DJ4ZGsswabMvs7cnUByzFn515eq7O+kzKRi5TLmLUBV3+7Tet2Kr X-Google-Smtp-Source: AGHT+IEDeGgbLE/zgvIx9Neo7X/Tvc/kwVBKGo3SVswnkbyJjKLA71wygrf5Z7lZwgpXfxWF3CU2mQ== X-Received: by 2002:a17:90a:f0d2:b0:2e2:973b:f8e7 with SMTP id 98e67ed59e1d1-2e76b70c381mr5909794a91.38.1729771788065; Thu, 24 Oct 2024 05:09:48 -0700 (PDT) Received: from ikb-h07-29-noble.in.iijlab.net ([202.214.97.5]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e76df50eb7sm3335163a91.16.2024.10.24.05.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 05:09:47 -0700 (PDT) Received: by ikb-h07-29-noble.in.iijlab.net (Postfix, from userid 1010) id 0CDB1D51249; Thu, 24 Oct 2024 21:09:46 +0900 (JST) From: Hajime Tazaki To: linux-um@lists.infradead.org, jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net Cc: thehajime@gmail.com, ricarkol@google.com, Alexander Viro , Christian Brauner , Jan Kara , Eric Biederman , Kees Cook , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 01/13] fs: binfmt_elf_efpic: add architecture hook elf_arch_finalize_exec Date: Thu, 24 Oct 2024 21:09:09 +0900 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 7537C40025 X-Stat-Signature: brbd46amzu35o45nnnh375yu1je3xu3k X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1729771781-448348 X-HE-Meta: U2FsdGVkX19lcXMFjYP65zWbBOTKEPzK6XmF7i6M+wgzreFWs7dA3f3ZOb0qXH+gcLfVYnTzeAgt1/gDMHT6T73fOze8x0SnV0Lg6xkcyvG2VEzQzQh7Hf2d/wj6VJuYAi7VMpSOY0UYa/NXihmp5N9Mg/PvDw5Q0fBn36g1bpz40UpmCF7n93tB4mZ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6mGDbxeTnPiSz2Sn6oDP833gd1hmcDlgfZcMFcfkXntkAQTOnu9xb/lGGHfJLms79SsELEAbj/UTTd7xPmgb4YMzFhvXGYpo6tJeSD5j/cSG+WmD32VEowFmd0bGDyGyzGHkltb9vwSXhwa4mebSvJgwuRPi+jT+oDDNNB9Igj1BLwyzYYXbzZ/tbt7nmRvHwxe+R538ITVSbiN3kUkcZdy72EemCA1rpqk4ntMvnSTSj5pAJZcNv+kMNCMrA1dBva2lccrUdj8QC15TjcQtXoT17mEdpMU/zmzfRAeuiH3AxBE6Hr92zEuy3noyM+LECsZ1HZ/KC/Go/1OlBfeosBgTC8QJJgbEjug== 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 Thu Oct 24 12:09:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 13848844 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 4D628CE8E68 for ; Thu, 24 Oct 2024 12:10:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA25F6B0085; Thu, 24 Oct 2024 08:10:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B2B906B0088; Thu, 24 Oct 2024 08:10:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CBE46B0089; Thu, 24 Oct 2024 08:10:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7A40E6B0085 for ; Thu, 24 Oct 2024 08:10:05 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 51FFE1412D9 for ; Thu, 24 Oct 2024 12:09:42 +0000 (UTC) X-FDA: 82708376730.25.9B2DE06 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by imf02.hostedemail.com (Postfix) with ESMTP id 9856C80010 for ; Thu, 24 Oct 2024 12:09:24 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WmE3UKOu; spf=pass (imf02.hostedemail.com: domain of thehajime@gmail.com designates 209.85.215.176 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=1729771647; 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=PIytQe80ylla7Sl/fe5LxDRRHtWVNhv8vhvelm/o17c=; b=D0mOtg9VvMWShqzLB59GXfyKlXXoOp3qBTSCami1Y3ppA9fcv4OCcmJlvCY76ALXj0So74 egllFo65q2gVHX5vr9wYQlLRb/ksykTGCuGcFKRGnTJCnVogkBxMwrKOTFe+or39DDwqG+ w0jBH+RVDLa1DarK72zj6mArORgeXvQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729771647; a=rsa-sha256; cv=none; b=kMbU4vvP5cr6AR0FgJTH7bNrm6E2d90sBRiSGnu3x1WDnw2yXNzNpqI51VeT4+q2XVhzVJ 65g+3vGlp5z8YMx2soVlVm45ws+y4VlpSSWclLfJBmzrbU0zF5UsoMTix+22eVcwSSbX5j R+mmxZc351c/wKmY5FyvRNDFozm+Gdo= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WmE3UKOu; spf=pass (imf02.hostedemail.com: domain of thehajime@gmail.com designates 209.85.215.176 as permitted sender) smtp.mailfrom=thehajime@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-7d916b6a73aso417629a12.1 for ; Thu, 24 Oct 2024 05:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729771798; x=1730376598; 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=PIytQe80ylla7Sl/fe5LxDRRHtWVNhv8vhvelm/o17c=; b=WmE3UKOuRnHUO2YOuHo7YsYdqZtX9+YhhLW8A0nETKkthnytQoa2DGYYm3EXouHgA/ 0NR1rFxI+/mNf7MKbe5CItlKZVQkyNrHhQrRE6sveknwGNIFcxVZGnTGrDQmu+19jNlb n1/kLZTanwyCN0/b5ldxX80jiI3bbf+tnS7j8ss0IBJJRN25LNweU0pMwVsSYZXZ5Pxs cqZ8JoUrlvOnNg4ev6hlsWsLydtUEOOLX9HYbhLJn7w7be2Q0zE5R51+1bnyM6a6k0Kx zop8hkVlmBFcTlblU+JOyMhQB10xRYf42JnuMayLGABFnXewebFcyO6+H+BevuD0SRob YzCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729771798; x=1730376598; 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=PIytQe80ylla7Sl/fe5LxDRRHtWVNhv8vhvelm/o17c=; b=NyoSs+vQ3GeVmgW+DLV6o+turbA8QGznPiHFyo5VhuBsG3Oo3P/H9p5ixJOIMx7+Zg AWT3gQ9ajunKMteoXUklkjad2OiuJy9BCSvbkNPgrhEVNu9o0y1XTJ1ZgkleKrU8Asvl hIoM8hEBeasquSZHuoXKeIAmE2ilhCu9eeQGwGfadZi9SXdR6vMjHTmLJa6Y39WvE5rj 6tcPQ04I2eO709A3Jgc/V+brsNdrKQjnapOWYu+HfxXWBSheJbaoLJy3fHMsIUXKx0jH ZqOV/cKQ+6Q26UdsHGVOhqXyMj1uSEEGiQ7MPuYC+PLNYV3dwgVEXngQClBYWW3f/wss JaFA== X-Forwarded-Encrypted: i=1; AJvYcCXjFc2b3it8hAgttIZh2BkdhkMq2ZpI/uNfqYJgMKFB/nTqZaZF3kLO6YjJgovx2SK5D7dK3zmJNg==@kvack.org X-Gm-Message-State: AOJu0YwU0+fTa1g0EdJgNmh1OELarHxOqvf2BTguKpROnrkE4OxzKL00 /wxy79XPfAz8080nmEMkZ85Rqbk416ebRs2K+XPHVFhQsxNFnvvB X-Google-Smtp-Source: AGHT+IEWx31qom/T9NynWTwcS94S2CIs7HjdghwcESDW4t/deHJ+ZjzUUv7QSQwXyIjcl4756ZTDog== X-Received: by 2002:a05:6a20:43a7:b0:1d8:d3b4:7a73 with SMTP id adf61e73a8af0-1d9898fda0cmr2115741637.4.1729771797871; Thu, 24 Oct 2024 05:09:57 -0700 (PDT) Received: from ikb-h07-29-noble.in.iijlab.net ([202.214.97.5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7eaeabda22fsm8492096a12.88.2024.10.24.05.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 05:09:57 -0700 (PDT) Received: by ikb-h07-29-noble.in.iijlab.net (Postfix, from userid 1010) id 4C46BD5124B; Thu, 24 Oct 2024 21:09:55 +0900 (JST) From: Hajime Tazaki To: linux-um@lists.infradead.org, jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net Cc: thehajime@gmail.com, ricarkol@google.com, Eric Biederman , Kees Cook , Alexander Viro , Christian Brauner , Jan Kara , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [RFC PATCH 02/13] x86/um: nommu: elf loader for fdpic Date: Thu, 24 Oct 2024 21:09:10 +0900 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 9856C80010 X-Stat-Signature: nee713fppxe84w3tkaspwtft1ud9xgba X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1729771764-812628 X-HE-Meta: U2FsdGVkX1+ZcWoXEfxvlaWHJzPjeWXcjJB3PGt4gUmLW00S7ahoYe+PIUUDCH3Tg4Y2a5OJ1P2TV6lBZoECGAvHNeaxbeZOnBPaQuQ6Jn2pUQAZ1C6yRULwEuMiI4bo1izhSxfCEuf/y56MZ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ce2qF8uYWK9YLqk6XRT8F+rJtK//hjXXb3OBupmZ3ltXzKrrTdiyqLEexDsvelDPZFh8zBOU9ujKh6p40ama6BWFrJq2u5mmijlvDvHxj5gky9ui5vlirzyizCY3/ahjdL4ZyNclp8UnbQUyWzqQUukuQTIKbzHaWEy1pENtj7iE0mtLdQRNZQhTlk2ekOtsKdb4/m5jM8eiMiIM5+ZarOMzqorM634QVf+jmCfu404W3DJgW+nL9BWhK9ZCsmGOLgORjmEZhJNits6PKyiCOQ8DxpmCjkfHSSpBUIMhx191P6Q36CHVm8YfF2JWbDF6SnFNLYLAml97ObkJ38DoDTLyyy1g4GH9Okww/fBQPATjxINHAkh6y72jml5YMY+zk 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/mmu.h | 5 +++++ arch/um/include/asm/ptrace-generic.h | 17 +++++++++++++++++ arch/x86/um/asm/elf.h | 9 +++++++-- arch/x86/um/asm/module.h | 19 +------------------ fs/Kconfig.binfmt | 2 +- 5 files changed, 31 insertions(+), 21 deletions(-) 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..fefa7631394e 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, @@ -44,6 +50,17 @@ extern void clear_flushed_tls(struct task_struct *task); extern int syscall_trace_enter(struct pt_regs *regs); extern void syscall_trace_leave(struct pt_regs *regs); +#ifndef CONFIG_MMU +#include + +static inline const struct user_regset_view *task_user_regset_view( + struct task_struct *task) +{ + WARN_ON_ONCE(true); + return 0; +} +#endif + #endif #endif diff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h index 6052200fe925..4f87980bc9e9 100644 --- a/arch/x86/um/asm/elf.h +++ b/arch/x86/um/asm/elf.h @@ -8,6 +8,8 @@ #include #include +#define ELF_FDPIC_CORE_EFLAGS 0 + #ifdef CONFIG_X86_32 #define R_386_NONE 0 @@ -188,8 +190,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 index a3b061d66082..4f7be1481979 100644 --- a/arch/x86/um/asm/module.h +++ b/arch/x86/um/asm/module.h @@ -2,23 +2,6 @@ #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 +#include #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