Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp903988rdb; Tue, 19 Sep 2023 13:54:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhqI36Jf9hT7dR1SpNW+RfA9GrXZFoUjaEE2dfIxB9XMEWbN6bsyrQfP+SLP1R5yKA4KY7 X-Received: by 2002:a05:6a20:9382:b0:159:e04f:e184 with SMTP id x2-20020a056a20938200b00159e04fe184mr4777876pzh.7.1695156896314; Tue, 19 Sep 2023 13:54:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695156896; cv=none; d=google.com; s=arc-20160816; b=vF7dhCmRzxxzviFrYy3SUanU+/4K15ztJELpGPpjwgRKWMaiYo/2SkYhe3hRj3sLYP tgVJjVmh37H6lq6dKiOzp358BsxK1Wmd13mHLJlH9v3t5uMSK0GphiWpJv+Ckx62bCcO PXQd8qR6LRIEIP6Ru6NpzIX/vC0KgVmeny9PQD3ywwvWZVnc7K6qjMO61wVJDldSOAIn ySUwEs3rYlNpJFzT4xhuwTlpuceUlCXkmpriBnC9Rma/HuEO0P8D3/Xza/yF8e196S8r njvzS/Sc7EpkC39jNzQrFia49XvSh5kqB6N9NzXb78ykB+dGY0wv/mB1yRx0bl3lamvQ RfPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3lEmbQKIShknOwu0d4x/n3fyPteL3kdNeGzeCybOtVA=; fh=trQN94Iqca1GMQF1AkSOofuqg8pe0AKHPTTlJaXdYFw=; b=X7RayyplaTdMFo6kBEp4eH14ZxJQVQqs2pbAu39wgCaGpBV1K+f8JfAUVE506BL8ET 6WEix90A5xoIzGtvbZ6RmnYr6gEObllcaBk9IvcSOt+qB2sXFDSF5gLaAY7BFcfSN2YN orw7p/KQDnjlLCi/5QFWGz8WbjvqGY/2r4V4hJ4YLIq30FAyD1OUlhGMo+Kffs2drJ5q CY8OiV62TgjsRvjjEgmAJePKUP98laCzmH/Lq2gjuLtmgCThmvkdr4LusKxQcZd44KHV XZkndGhid1snZFQf0RiNfjLOBOIwMGoKDmbVz4Ma3ZlonCmKNMTaRfvsycgdJdphA1ca JwkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id z2-20020a656102000000b0056f7592d732si9984561pgu.424.2023.09.19.13.54.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 13:54:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C571F80ABDE4; Tue, 19 Sep 2023 13:52:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233266AbjISUwY (ORCPT + 99 others); Tue, 19 Sep 2023 16:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbjISUwV (ORCPT ); Tue, 19 Sep 2023 16:52:21 -0400 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A50FBD for ; Tue, 19 Sep 2023 13:52:14 -0700 (PDT) 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 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 13:52:36 -0700 (PDT) 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 --- 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/coredum= p.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) =20 #define MMF_DISABLE_THP_MASK (1 << MMF_DISABLE_THP) =20 +#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) =20 -#define MMF_VM_MERGE_ANY 29 #endif /* _LINUX_SCHED_COREDUMP_H */ --=20 2.39.3