From patchwork Sun Nov 8 05:17:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 11889419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5170EC55179 for ; Sun, 8 Nov 2020 05:19:37 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF06320897 for ; Sun, 8 Nov 2020 05:19:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VoxtHT7n"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=arista.com header.i=@arista.com header.b="ic6PU7pb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF06320897 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=arista.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=lSfPcrbGZGm6z0LIKTHm5CSOrTJ9jnb/NBtkS5cheAs=; b=VoxtHT7nXXWx4dcPlGy4hp+63D snCM8Kli/Mj7BSgvPeuX7jMryL7qlfdN71PFSjRehdSYKvUW2SEdM2/5izlQivZpNfoyNJBcnJ7bN boOJYNLYcUrZOBRjeg3gxs1rasVCO43rLZc9H4bOeqGiv3eSaiIrLejUqVwll3WmczwnOyZ+iNekW vfjBpIGekdEztQvqg2vZ7zezwGt736qhRh61S+n9X9huPdYNcRArAlO6EdhQlv2QAxgunIfiE55Vd j79Scbf0N6mWPG3kb8W6R9Ud7pNq86PDJpNa1KnLFSMZ8ouDxiVtVuU338lI/GnmJHZNhC36nakRq 9kWdH42A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kbd59-0001lz-3J; Sun, 08 Nov 2020 05:17:39 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kbd55-0001lO-QV for linux-arm-kernel@lists.infradead.org; Sun, 08 Nov 2020 05:17:37 +0000 Received: by mail-wm1-x344.google.com with SMTP id 10so4327085wml.2 for ; Sat, 07 Nov 2020 21:17:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=r9aT3RV5iTBLi6xVKvy9ESdq01vAtIRf9u+RQFLMlk8=; b=ic6PU7pbuoktFwoy5T07opHN2Jhn3G4P+CLIrkN5Iot7hSjoBM4MbhzKWBtuEw0l8J tOGbKQrRQpjrr1WB/I5DSPP844qlDzNTeEFmrps1rOVMS/7qM+s1ufALAo/IyPNjZISR f3dDMTZxdlB2e1a74qz66cT8JvsZi4s6ow7emxlPuEPruAV3/pWTOOiFeuGr78tKOp5D tdL8doiIiYVeM3UeiL6McDVHcYHRq/yvxPeWkP5AY2A5VoV7bubq9cBcyuk0wicvK7Ko 6oacU0dqbRoEFt3o/6G5eo+c54ghGy/F7/n0WLFMbXMoFzXjJOIE7WzAyFnaEBYMaXCi nuFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=r9aT3RV5iTBLi6xVKvy9ESdq01vAtIRf9u+RQFLMlk8=; b=ZTIJcBzk08Ij6oN2jyCjKuLg1XzDxGSOnK0cEJwl6RF8o2kmd5suXy0Vv6+xVbhpbB ZL2PLqA776wkmJVhnTKAF+NSQRmXnbon9Eww2F7d0s/V3EmnbucASD0JAZ6Xjh40++L1 5x2jbd+1ihkP8pBKjwmMkxCHSfpLzpwWvfaUZbdGFRfpk/zgFVGBBOUH8odn4v+uwhsO hxS5Grm9n2odRLd0VZAZXHhxoGka5z6AksS6yJP0SvpxzV7+AlSQ4O21ScbdVgT8uRZS lGgSeIy3a6Q2oYJnPIgxZ62ZKuyROdv76mc1ALJx+ahUQ/vwJzyI24WN+hNsq3TgzBPP 8TRg== X-Gm-Message-State: AOAM532axJzM3OUWVotqWvW+wmDZImgSirRJHf0QaeR3k944fmX5oziC Z5icnGKkaGqenPYCWS/raVE3cw== X-Google-Smtp-Source: ABdhPJx8kgDcsXzU1GSdZh7iKVRn9ukLbAjTByACEbWQF3Xw3UdIdVxLmbR7qMp+g037hB0U7FwKjQ== X-Received: by 2002:a1c:81c9:: with SMTP id c192mr7530377wmd.1.1604812652574; Sat, 07 Nov 2020 21:17:32 -0800 (PST) Received: from localhost.localdomain ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id r10sm8378462wmg.16.2020.11.07.21.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Nov 2020 21:17:31 -0800 (PST) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Subject: [PATCH 00/19] Add generic user_landing tracking Date: Sun, 8 Nov 2020 05:17:10 +0000 Message-Id: <20201108051730.2042693-1-dima@arista.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201108_001736_069773_BCE0C9A0 X-CRM114-Status: GOOD ( 18.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , Dmitry Safonov <0x7f454c46@gmail.com>, linux-mips@vger.kernel.org, Guo Ren , "H. Peter Anvin" , sparclinux@vger.kernel.org, Vincenzo Frascino , Will Deacon , linux-s390@vger.kernel.org, Vasily Gorbik , Dmitry Safonov , x86@kernel.org, Russell King , Christophe Leroy , Christian Borntraeger , Ingo Molnar , Albert Ou , Arnd Bergmann , Heiko Carstens , Borislav Petkov , Alexander Viro , Andy Lutomirski , Paul Walmsley , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Thomas Bogendoerfer , Oleg Nesterov , Palmer Dabbelt , linux-fsdevel@vger.kernel.org, Andrew Morton , "David S. Miller" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Started from discussion [1], where was noted that currently a couple of architectures support mremap() for vdso/sigpage, but not munmap(). If an application maps something on the ex-place of vdso/sigpage, later after processing signal it will land there (good luck!) Patches set is based on linux-next (next-20201106) and it depends on changes in x86/cleanups (those reclaim TIF_IA32/TIF_X32) and also on my changes in akpm (fixing several mremap() issues). Logically, the patches set divides on: - patch 1: cleanup for patches in x86/cleanups - patches 2-11: cleanups for arch_setup_additional_pages() - patches 12-13: x86 signal changes for unmapped vdso - patches 14-19: provide generic user_landing in mm_struct In the end, besides cleanups, it's now more predictable what happens for applications with unmapped vdso on architectures those support .mremap() for vdso/sigpage. I'm aware of only one user that unmaps vdso - Valgrind [2]. (there possibly are more, but this one is "special", it unmaps vdso, but not vvar, which confuses CRIU [Checkpoint Restore In Userspace], that's why I'm aware of it) Patches as a .git branch: https://github.com/0x7f454c46/linux/tree/setup_additional_pages [1]: https://lore.kernel.org/linux-arch/CAJwJo6ZANqYkSHbQ+3b+Fi_VT80MtrzEV5yreQAWx-L8j8x2zA@mail.gmail.com/ [2]: https://github.com/checkpoint-restore/criu/issues/488 Cc: Alexander Viro Cc: Andrew Morton Cc: Andy Lutomirski Cc: Arnd Bergmann Cc: Borislav Petkov Cc: Catalin Marinas Cc: Christophe Leroy Cc: Guo Ren Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Oleg Nesterov Cc: Russell King Cc: Thomas Bogendoerfer Cc: Thomas Gleixner Cc: Vincenzo Frascino Cc: Will Deacon Cc: x86@kernel.org Dmitry Safonov (19): x86/elf: Check in_x32_syscall() in compat_arch_setup_additional_pages() elf: Move arch_setup_additional_pages() to generic elf.h arm64: Use in_compat_task() in arch_setup_additional_pages() x86: Remove compat_arch_setup_additional_pages() elf: Remove compat_arch_setup_additional_pages() elf/vdso: Reuse arch_setup_additional_pages() parameters elf: Use sysinfo_ehdr in ARCH_DLINFO() arm/vdso: Remove vdso pointer from mm->context s390/vdso: Remove vdso_base pointer from mm->context sparc/vdso: Remove vdso pointer from mm->context mm/mmap: Make vm_special_mapping::mremap return void x86/signal: Land on &frame->retcode when vdso isn't mapped x86/signal: Check if vdso_image_32 is mapped before trying to land on it mm: Add user_landing in mm_struct x86/vdso: Migrate to user_landing arm/vdso: Migrate to user_landing arm64/vdso: Migrate compat signals to user_landing arm64/vdso: Migrate native signals to user_landing mips/vdso: Migrate to user_landing arch/alpha/include/asm/elf.h | 2 +- arch/arm/Kconfig | 2 + arch/arm/include/asm/elf.h | 10 +--- arch/arm/include/asm/mmu.h | 3 - arch/arm/include/asm/vdso.h | 6 +- arch/arm/kernel/process.c | 14 +---- arch/arm/kernel/signal.c | 6 +- arch/arm/kernel/vdso.c | 20 ++----- arch/arm64/Kconfig | 2 + arch/arm64/include/asm/elf.h | 27 ++------- arch/arm64/kernel/signal.c | 10 +++- arch/arm64/kernel/signal32.c | 17 ++++-- arch/arm64/kernel/vdso.c | 47 ++++++--------- arch/csky/Kconfig | 1 + arch/csky/include/asm/elf.h | 4 -- arch/csky/kernel/vdso.c | 3 +- arch/hexagon/Kconfig | 1 + arch/hexagon/include/asm/elf.h | 6 -- arch/hexagon/kernel/vdso.c | 3 +- arch/ia64/include/asm/elf.h | 2 +- arch/mips/Kconfig | 2 + arch/mips/include/asm/elf.h | 10 +--- arch/mips/kernel/signal.c | 11 ++-- arch/mips/kernel/vdso.c | 5 +- arch/mips/vdso/genvdso.c | 9 --- arch/nds32/Kconfig | 1 + arch/nds32/include/asm/elf.h | 8 +-- arch/nds32/kernel/vdso.c | 3 +- arch/nios2/Kconfig | 1 + arch/nios2/include/asm/elf.h | 4 -- arch/nios2/mm/init.c | 2 +- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/elf.h | 9 +-- arch/powerpc/kernel/vdso.c | 3 +- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/elf.h | 10 +--- arch/riscv/kernel/vdso.c | 9 +-- arch/s390/Kconfig | 1 + arch/s390/include/asm/elf.h | 10 +--- arch/s390/include/asm/mmu.h | 1 - arch/s390/kernel/vdso.c | 13 +--- arch/sh/Kconfig | 1 + arch/sh/include/asm/elf.h | 16 ++--- arch/sh/kernel/vsyscall/vsyscall.c | 3 +- arch/sparc/Kconfig | 1 + arch/sparc/include/asm/elf_64.h | 11 +--- arch/sparc/include/asm/mmu_64.h | 1 - arch/sparc/vdso/vma.c | 18 +++--- arch/x86/Kconfig | 2 + arch/x86/entry/common.c | 8 ++- arch/x86/entry/vdso/vma.c | 72 ++++++++++++----------- arch/x86/ia32/ia32_signal.c | 18 +++--- arch/x86/include/asm/compat.h | 6 ++ arch/x86/include/asm/elf.h | 44 +++++--------- arch/x86/include/asm/mmu.h | 1 - arch/x86/include/asm/vdso.h | 4 ++ arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 3 +- arch/x86/kernel/signal.c | 25 ++++---- arch/x86/um/asm/elf.h | 9 +-- arch/x86/um/vdso/vma.c | 2 +- fs/Kconfig.binfmt | 3 + fs/aio.c | 3 +- fs/binfmt_elf.c | 19 +++--- fs/binfmt_elf_fdpic.c | 17 +++--- fs/compat_binfmt_elf.c | 12 ---- include/linux/elf.h | 24 ++++++-- include/linux/mm.h | 3 +- include/linux/mm_types.h | 12 +++- mm/Kconfig | 3 + mm/mmap.c | 21 ++++++- mm/mremap.c | 2 +- 71 files changed, 308 insertions(+), 356 deletions(-) base-commit: c34f157421f6905e6b4a79a312e9175dce2bc607