From patchwork Tue Sep 19 20:51:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13391870 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 410E6CE79A8 for ; Tue, 19 Sep 2023 20:52:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C67D76B00D6; Tue, 19 Sep 2023 16:52:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF0C56B00D7; Tue, 19 Sep 2023 16:52:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A91FF6B00D8; Tue, 19 Sep 2023 16:52:15 -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 9718A6B00D6 for ; Tue, 19 Sep 2023 16:52:15 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 702B51206E0 for ; Tue, 19 Sep 2023 20:52:15 +0000 (UTC) X-FDA: 81254544630.19.3F9FEC7 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf01.hostedemail.com (Postfix) with ESMTP id D06D24000D for ; Tue, 19 Sep 2023 20:52:13 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=neutral (imf01.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695156734; a=rsa-sha256; cv=none; b=J5Kd3nAl0rcDvVjVfsxtS6UvYsH4Z6xok8YQzNWqexd49K1PU7VK+66pUSbqNYJ2f26zUy mHV8KI7gpSJhJfmpSGSSh9h1m2Fz+wB3nmigv3X4OkYUCA9XGN1BO5v+qYPEWfgp8qxMaO OLZ1aMYIzI8wTll275kVMMeI3WCtXlw= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=neutral (imf01.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695156733; 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; bh=3lEmbQKIShknOwu0d4x/n3fyPteL3kdNeGzeCybOtVA=; b=FDuTWAs7bKzZ95n5b2KkIE/NII+mraElOeuh8aYYN22ynPtqtFasIwMlpXNyQw8/CLL1On ocWLrzjGK9BP2D6+0tI0m2wgJcEUdlPeeMsM/5pHs7IS9vBxIE912fmXKP/KtP/5i7g+R8 nVlL3zIl0xE+ffsSNCpqpi8H6YRZpOQ= Received: by devbig1114.prn1.facebook.com (Postfix, from userid 425415) id 51999C361C1D; Tue, 19 Sep 2023 13:51:59 -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, Carl Klemm Subject: [PATCH v1 1/2] mm/ksm: support fork/exec for prctl Date: Tue, 19 Sep 2023 13:51:57 -0700 Message-Id: <20230919205158.1897353-2-shr@devkernel.io> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230919205158.1897353-1-shr@devkernel.io> References: <20230919205158.1897353-1-shr@devkernel.io> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-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JdcXUeexJ7PmwL zwkp1M9Z hojtF4Gzrp2fiR5kIvxZIfQ2nADwDXtf7WlTUx8NiPdz6CZd2p12PUypuE0ftZbmzrXvUuq7ymK74xOM2BT3l9o/CFQ078dA1fisjQy4B5MVAfDFvbNQBAB48Z4nPPUypWjSrJvurIUlZQJoZB/SQxASxMWxKcLzbLh7D 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: 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 addresses this problem. Signed-off-by: Stefan Roesch Reported-by: Carl Klemm Tested-by: Carl Klemm Reviewed-by: David Hildenbrand --- include/linux/sched/coredump.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/coredump.h b/include/linux/sched/coredump.h index 0ee96ea7a0e9..205aa9917394 100644 --- a/include/linux/sched/coredump.h +++ b/include/linux/sched/coredump.h @@ -87,8 +87,11 @@ static inline int get_dumpable(struct mm_struct *mm) #define MMF_DISABLE_THP_MASK (1 << MMF_DISABLE_THP) +#define MMF_VM_MERGE_ANY 29 +#define MMF_VM_MERGE_ANY_MASK (1 << MMF_VM_MERGE_ANY) + #define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\ - MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK) + MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK |\ + MMF_VM_MERGE_ANY_MASK) -#define MMF_VM_MERGE_ANY 29 #endif /* _LINUX_SCHED_COREDUMP_H */