Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2681221iob; Fri, 6 May 2022 08:12:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0U2xS/Rav8R5h3d58yStuvFtAXjRADdIG9k2YQ3zCDgYOjOoRZHr52E7Par/G6EkzRmKJ X-Received: by 2002:a63:204c:0:b0:3c6:3550:d4f9 with SMTP id r12-20020a63204c000000b003c63550d4f9mr3090394pgm.448.1651849935321; Fri, 06 May 2022 08:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651849935; cv=none; d=google.com; s=arc-20160816; b=ZGlgM2rdn1lVbiw2PSFjHgL0EhZyDBMDkL5NuBU08/JjJK6IWjt/42mcMsR9jRfcK0 NSCgbbPdyZxc++MGDUi0FGf4OS104JKUFpXbwkPOXp1tzz/pML7FIiFlqZ6K6wxSV0+S R/G5lyQyOotKC4RP6rtfgz1luVbOECIXnzl3Y9q4yMf9S6fAcI2ATxJ5Y4J/BGcA4GKJ 61lU30LM+6rLrc1MFPbn+aDfxvBI0KEMEq+iw14AV8DDE/Ha+TXf8z/aHAiehc3BiUCQ HA6Lq9wSJJh5amUj723Ac8k9HO/pj0AIQplLnLvjujb891e4PGO1JaJSGFKe4mZ0hk0f dfwA== 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:dkim-signature; bh=LFZ0C5mlGPmihEuwot+5QrHuru8TRraqbSU4Lc8WomU=; b=kM0VQOSHW+jNRiGIVm/vUfQRb1G0tEOgyg4+F9JMSsd9rs7N9PN5C9YVFRfQW8WZCm PJfPrW4Gd+nsiJGexiKT6gHsb20rWCpbY60mc/Q/abRLfa+vMyjmjI+tQgT3QWjKVB+J wCd+OtHm80BXObl7qAfwD6rJE7ivjZY/A+aV/JICKoxwMHQKkCJ4COJXYXKYhN4rIeni rhdcYdYy5W0b2K9MNqAyyXPaXwSFQkN6Vkt2YYksU08Y61TVju56BhT6LIvqVhIC1gCV K/HjzwbZvpNyfEDMdy83UUV4jEqdqMWn+lTMYtiWb1oFnMdZocjrsO0YLc04L1fUhPSd mbTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DWdkr2Zn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a63d950000000b00399149a5d14si5204646pgj.205.2022.05.06.08.11.59; Fri, 06 May 2022 08:12:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DWdkr2Zn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243472AbiECWJR (ORCPT + 99 others); Tue, 3 May 2022 18:09:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243596AbiECWJI (ORCPT ); Tue, 3 May 2022 18:09:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4660201AF for ; Tue, 3 May 2022 15:05:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6BD4861721 for ; Tue, 3 May 2022 22:05:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D6ADC385A9; Tue, 3 May 2022 22:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651615533; bh=UsYHQ2RMFhU+kqPVwKX92XprgxwwCA2T6bnN4o6xFNk=; h=From:To:Cc:Subject:Date:From; b=DWdkr2Zn0xk9I/RIzkgqjqAwye1gPjoCBwYg81adHHk8aJOKVJvquxPtHWZ2f/T7N 4UUC1cYtIHuV/4kDMmqgVmYWZAPKjChzv0VMZ9oSRNpI35+cJdojXbjKj7PbfIwhbm 18QhXlaBtAlUTq5NWFtoYKBxa/ZQWlXkGjQB7oW0XN1QwoAeJiswsuHJyJIbMUo4ZJ Gu1iqZv7IYDG9DMEqYHVQJU/A9roAxikayJ5M/Ala+DhJThDrIVQfdez2W3d7PEAf5 zCsrDiBhbXZbVN6GlsMI88ea8QKsRGsZX2YBWfhWsKiCxpdnSwvWuk0DL7zID+Jfxo LpHAHAsI3RxwQ== From: SeongJae Park To: akpm@linux-foundation.org Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH] mm/damon/sysfs: fix pid leak under fvaddr ops use case Date: Tue, 3 May 2022 22:05:31 +0000 Message-Id: <20220503220531.45913-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Commit c83136469313 ("mm/damon/sysfs: support fixed virtual address ranges monitoring") in 'mm-unstable' does not put the monitoring target pid when fvaddr ops is used. This commit fixes it to put pid properly. Andrew, please merge this into the 'mm-unstable' commit ("mm/damon/sysfs: support fixed virtual address ranges monitoring"). Fixes: c83136469313 ("mm/damon/sysfs: support fixed virtual address ranges monitoring") Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 767ab8c33e4d..f753bb405101 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -2086,7 +2086,8 @@ static void damon_sysfs_destroy_targets(struct damon_ctx *ctx) struct damon_target *t, *next; damon_for_each_target_safe(t, next, ctx) { - if (ctx->ops.id == DAMON_OPS_VADDR) + if (ctx->ops.id == DAMON_OPS_VADDR || + ctx->ops.id == DAMON_OPS_FVADDR) put_pid(t->pid); damon_destroy_target(t); } @@ -2204,7 +2205,7 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx) { struct damon_target *t, *next; - if (ctx->ops.id != DAMON_OPS_VADDR) + if (ctx->ops.id != DAMON_OPS_VADDR && ctx->ops.id != DAMON_OPS_FVADDR) return; mutex_lock(&ctx->kdamond_lock); -- 2.25.1