From patchwork Fri Sep 22 21:11:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13396391 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 066FECE7A81 for ; Fri, 22 Sep 2023 21:12:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8C9576B02F7; Fri, 22 Sep 2023 17:12:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 879E66B02F9; Fri, 22 Sep 2023 17:12:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 768686B02FB; Fri, 22 Sep 2023 17:12:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 668CC6B02F7 for ; Fri, 22 Sep 2023 17:12:05 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 38485801AB for ; Fri, 22 Sep 2023 21:12:05 +0000 (UTC) X-FDA: 81265481010.12.8CBC260 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf09.hostedemail.com (Postfix) with ESMTP id A0EF8140020 for ; Fri, 22 Sep 2023 21:12:03 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf09.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695417123; 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:references; bh=Pn4WOLyulan8COpDJFoPB8+j8ThkORhLngWXjzEExS0=; b=pP4/PtRNZOoOiGTIwzfijN0AHeyrfFx5OlM2vGg6bwwefr+ATGC8UDwUtgSOUPH0mxL0sG gFdHVoqZ29dm+9EgQjVv7NUc7B3fPJHytUwuj6gXsU0ccCm9zOVrC9Q+2WnlLSIppkYZup NsPKZgMVrhMq4MYegkzlhvGTrBlNuvg= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf09.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695417123; a=rsa-sha256; cv=none; b=1YOAmYV9XwNvLmXLgy5d0hWHQnn3OojxYpevFeMOynCYJQm9Bk/CI1rgdRYFjSvzVcfrX+ awQUUB6GYiCma/iXquAmLbMxLxiHRHieCCzULtxQwN3jGJYZELEu+OUcthi9QhJaxtPjo+ vJ+GSyC5m0+1fuCtl6oyb3NXNcAbJyg= Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id CA938C60DC47; Fri, 22 Sep 2023 14:11:49 -0700 (PDT) From: Stefan Roesch To: kernel-team@fb.com Cc: shr@devkernel.io, akpm@linux-foundation.org, david@redhat.com, hannes@cmpxchg.org, riel@surriel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v4 0/2] mm/ksm: add fork-exec support for prctl Date: Fri, 22 Sep 2023 14:11:39 -0700 Message-Id: <20230922211141.320789-1-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A0EF8140020 X-Stat-Signature: p13srjjf4cxkkz7poh1soukhm6gmfytt X-HE-Tag: 1695417123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sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: A process can enable KSM with the prctl system call. When the process is forked the KSM flag is inherited by the child process. However if the process is executing an exec system call directly after the fork, the KSM setting is cleared. This patch series addresses this problem. 1) Change the mask in coredump.h for execing a new process 2) Add a new test case in ksm_functional_tests Changes: - V4: - Added motivation for the fix to the commit message of the first patch - V3: - Combined two lines in function ksm_fork_exec_child() - V2: - Removed the child program from the patch series - Child program is implemented by the program itself - Added a new command line parameter for the child program - Removed new section from Makefile - Removed duplicate ; charaters - Added return in if clause - Used PR_GET_MEMORY_MERGE instead of magic numbers - Resetting PR_SET_MEMROY_MERGE at the end. Stefan Roesch (2): mm/ksm: support fork/exec for prctl mm/ksm: Test case for prctl fork/exec workflow include/linux/sched/coredump.h | 7 +- .../selftests/mm/ksm_functional_tests.c | 66 ++++++++++++++++++- 2 files changed, 70 insertions(+), 3 deletions(-) base-commit: 15bcc9730fcd7526a3b92eff105d6701767a53bb