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: 14409 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5873841vqi; Fri, 22 Sep 2023 14:24:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcLNehFcPiEEaOgZHeYG66ecCWnScraDbWdlAfDG5KWEYBrr0/F5TE03LZc8NYK9hXWrIf X-Received: by 2002:a05:6808:7ce:b0:3a1:dc0d:f32b with SMTP id f14-20020a05680807ce00b003a1dc0df32bmr865351oij.40.1695417866377; Fri, 22 Sep 2023 14:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695417866; cv=none; d=google.com; s=arc-20160816; b=SGIOGKQYRwUj2Q4Sh6DTcNIO3Wl63NDBUFiVTB0YuyvxkskFzrf/G/HKvLhQtqZ0wc XiIL/Xf2o0g0/l6xf/xotpAGpEKMt6xPHKLzrZlHp84Higvq5JcNXoTltn5VkeXFX8oi ujV3VhPjwWHuyj9soDPTIUa+WcUpDQEOr73gkYyPmH6xhCqp7gT65nUhHaxaxwaiBzWA Qf0NvQ2K7rb0TRye4Gg/yFoyfZY17vQf2/zGC6qNwiJVxdF7ZWAUck44fDg91577iosV eGlZfMTQGxvWW990NraZ1aDq7/C32jU5UaiAZ3pDHrZ2oG1xGX5se7T7SR0m/x4SMxCp Qt9Q== 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 :message-id:date:subject:cc:to:from; bh=Pn4WOLyulan8COpDJFoPB8+j8ThkORhLngWXjzEExS0=; fh=sS+J4OyOC0EcVLWJpS3mBHGeO+0+dYZJ+ImCUfzsrH4=; b=kLBYkSe4snk/9xfrnCF9KYzg3S/c2xFvRPefg265LMlKIDSsVdXq5L1H0kEjrp3BDr 5HDswJJ67taXN7QutquEbx4V8CEVfQXpxcIk5QZjymLcjUe64Q+ViiQVjqNIL/vC5Zxm H4anHRRH84hJwl5JiZV5xhHqr8DuFvlCf2Go/UUK01DQuXvz1Nm8VDALqtyU8BI0A08n XYrpmaTj1LMmhY4swu686x3bTFna02PmxRomvLNUXM9OLY/R2znOURX7Xt3TW7rGn9ga 8xU5Tg0PChXv3A2xg9WB+n8etEDsLVWJUupIifcA909+GcbBrvJYxlxQO6lCxes8i2km nrbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id ce11-20020a056a002a0b00b006870ed47367si4529086pfb.5.2023.09.22.14.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 14:24:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 5CB678582FDC; Fri, 22 Sep 2023 14:12:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229873AbjIVVML (ORCPT + 28 others); Fri, 22 Sep 2023 17:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbjIVVMJ (ORCPT ); Fri, 22 Sep 2023 17:12:09 -0400 Received: from 66-220-144-179.mail-mxout.facebook.com (66-220-144-179.mail-mxout.facebook.com [66.220.144.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFD64C1 for ; Fri, 22 Sep 2023 14:12:03 -0700 (PDT) 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-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RDNS_DYNAMIC,SPF_HELO_PASS,SPF_NEUTRAL, TVD_RCVD_IP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Fri, 22 Sep 2023 14:12:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777688419617803644 X-GMAIL-MSGID: 1777774484525178106 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