From patchwork Mon Nov 6 23:34:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13447594 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 A6839C4708E for ; Mon, 6 Nov 2023 23:34:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40FF96B0255; Mon, 6 Nov 2023 18:34:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 34B1B6B0256; Mon, 6 Nov 2023 18:34:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1767C6B0258; Mon, 6 Nov 2023 18:34:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 05C3B6B0255 for ; Mon, 6 Nov 2023 18:34:15 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CEF17C084F for ; Mon, 6 Nov 2023 23:34:14 +0000 (UTC) X-FDA: 81429135228.29.643E950 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf11.hostedemail.com (Postfix) with ESMTP id 16BB140005 for ; Mon, 6 Nov 2023 23:34:12 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UyoPvSX0; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699313653; 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:dkim-signature; bh=bjxQ1LmSyqWFZikG6cYNs/ewKsq9df3Hd0LideRpIcQ=; b=H4UGAkrobJUvRiypnMbL5XBAiHu4vcUaTCq1LLhHF8p/NEAwb8EUsW/86v7/M6FVUV+ZjY 80wJVueLGcrmXn+LXwCRCvBzi+xJU3M5RZ0tSDvsh607D5zTRfAXqyznuIptFz15S3/U1I 5XXCKYGVv3kUWR1r9HLaIyuRS+YSeaM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699313653; a=rsa-sha256; cv=none; b=0m4lN8xqu2weFDPRKyGGSVBUsO1nsRLxBxCABfE/caamCwgmQ/jz5JrfodGFBjs1UYECAU SC6ugaGLb+pA8YNvhPDf0uICoUh6p9aySR0d0UVqFeSrEBAtlgeBiny5Q67nfU3/GuYeCm y/PBx6RR4JA8aMMpRylWOSCK2Kxdsik= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UyoPvSX0; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id D8374B811E1; Mon, 6 Nov 2023 23:34:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D15AEC433C8; Mon, 6 Nov 2023 23:34:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699313651; bh=MtIChiGlAMl9WTJvVSRQmuDT6RxSD+NBrsKsO1Hl6Io=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UyoPvSX0uc/PWJFKoa+VUDxKq/E/FXknGdVXc5LledMo3lXe9IT0oRt5RQemS8eDn ofZwHuP518ZGSpd/p2iBOmqYK51qD8Jfy+GUrzPHxN3Efbc12q8lf3CyJVlx5SCaeE yyTR10BkFHQeE4KhahwXsPuOaDPe+rBdNAWYOwCW6mxNfkOc3H8kz/nw9ziN3Td/B8 ccVLiR9YzBxtkhVjVtOTIIqYPB4+2MiBrqNyFMGGVzs2/Q+OeJiPYZYodODtGKExOQ eRaMsQXN36VQLRMi6tPFYVJJYI+AA75HN3DJf9l/fg/xDKdWUtd7iRuYq0d/eUxfZz YOYXIHDrJhrhA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/3] mm/damon/sysfs: check error from damon_sysfs_update_target() Date: Mon, 6 Nov 2023 23:34:06 +0000 Message-Id: <20231106233408.51159-2-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106233408.51159-1-sj@kernel.org> References: <20231106233408.51159-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 16BB140005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: bj6rj9insmaptwe8psbq8omokfgx6uu6 X-HE-Tag: 1699313652-299381 X-HE-Meta: U2FsdGVkX1/OFxxNbMUDbwtZCPkuwU/Sj/PFixoFCymlKvhVjxBSGdGiB+HNqZuX5Iadbl2cNRryjOOqLPvGatPWpZsX8sNpFeVFHiLAj8iAenRllB3uxt02ng3hPcSDObF6VqLCyo9KP1MeFbsHXO4XZMYvDIOkVqrR8XzItlZBoJtICad3zvApTFByq53tqGzxY8lLM9BzApSF9yPzB9CVaM/s28P7avjkrXRh98xDB9CySABh6MDRBjHml6x6rBY8oqyn3c6d4YnGs7z0nbYg2pU/fCpMBRTzRYTT/NklLV4TPIcd7liVUly5CKM2NFmfybJysuoS9a5iyCiFXji9aXv/wurWzlHpMIQYFufTqa7f4cVVp9S7LBUwfcXiZnKb9Uug1f+C4CRj+WKfXEgqTqZ1vp11uuJft1wROTX6/vbODaZTHvUOx7jRiqVtz93jR7q4yPMiCDOEAh37aWqKBnSHlTuG+DZ1psA1o5PCGXvAerp4IbiJNzbezUS8b2lxfkHFNm9ZCkmd4ken9JAhz+O+VClsJHvrQss7HMYtr2+/9G75r2X90MRpEv+WSIvr5QjXzmpMBd4UluTtkdabXv5EePEzxRpsr/7h6HyU7kg67ZkfLr2QQTotHd+1JifvtqGmDLHyyLbF6C9qb3Cr25cgwTUTZrxsywPrGI/COmrlzHtuXvrcWqtJUdyFfGfbVt5tJttRUIDGL+ixE1Lq7coi02v6RHkJ6sgmZXZUuU4Z7b5VCv7Pq6p3gHxRqBJ8HJqCVVZRq7KDycfyySDf6zU+7mhCmp+bT/z841uVG1xTozVT6g63YtC6vCGLF38kT56+pix646fGP/OycD+bHfgWbkYihZ//8Xivxmlt142tvlXD0Ddi10+YcAZOy+CqvQ9hLh2gi4qEOirkNViAbxVey+NbIvMfw1FOo0q07QeH5cj5hrFHtH4AnkgaZosmPq0CFzrKldMga+0 PlMXXsl0 4M52EJelrHh8+gNdth0Vm8/igHBO3i8jDAd23btysMOUcSWZyAzsPx/pXAyit2+UhCPQQ6GlQ5zTom4a6MuhpJQaPXk01kFzrmb4etUoGaI1WS+h1nfwFgMew/zHrG1W9BICdU9UH95DnB/ZvjGzFq1i3PlEwOpn8v9jBRZJT8UqA+WiGYK2VpT1Tb/IzyaibCwcUS6qKUSY//6erOCm/rYmgDsa85k/JqKqnlpzmRvFjxAKNR9a0dY+T2i/IfooWR5k1RUS5OJuZeg/3JdNE58uk8g== 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: List-Subscribe: List-Unsubscribe: damon_sysfs_update_target() returns error code for failures, but its caller, damon_sysfs_set_targets() is ignoring that. The update function seems making no critical change in case of such failures, but the behavior will look like DAMON sysfs is silently ignoring or only partially accepting the user input. Fix it. Fixes: 19467a950b49 ("mm/damon/sysfs: remove requested targets when online-commit inputs") Cc: # 5.19.x Signed-off-by: SeongJae Park --- Note that yet another fix[1] should be applied before this. [1] https://lore.kernel.org/all/739e6aaf-a634-4e33-98a8-16546379ec9f@moroto.mountain/ mm/damon/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 1dfa96d4de99..7472404456aa 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1203,8 +1203,10 @@ static int damon_sysfs_set_targets(struct damon_ctx *ctx, damon_for_each_target_safe(t, next, ctx) { if (i < sysfs_targets->nr) { - damon_sysfs_update_target(t, ctx, + err = damon_sysfs_update_target(t, ctx, sysfs_targets->targets_arr[i]); + if (err) + return err; } else { if (damon_target_has_pid(ctx)) put_pid(t->pid); From patchwork Mon Nov 6 23:34:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13447595 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 9A266C4167B for ; Mon, 6 Nov 2023 23:34:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FF226B0258; Mon, 6 Nov 2023 18:34:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 288B36B025A; Mon, 6 Nov 2023 18:34:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12A286B025B; Mon, 6 Nov 2023 18:34:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 007BD6B0258 for ; Mon, 6 Nov 2023 18:34:18 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C8E2B40964 for ; Mon, 6 Nov 2023 23:34:18 +0000 (UTC) X-FDA: 81429135396.29.67B3241 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf28.hostedemail.com (Postfix) with ESMTP id C210AC001A for ; Mon, 6 Nov 2023 23:34:16 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=l7EqwQOv; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699313657; 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:dkim-signature; bh=w0kEAmDIiB+nNiOxil7eazkNdbm+gUZoY9qzJclbFfs=; b=8G1a0eS7sa8ioIBJMerif9Aj5c0iY7sWHPAfjbGAEjfqcZHG77vz7CBHDTuOYnF13szjpi fjrC78H0sd1X3edavyWG9Kivm1IvXhjcT5/r9Rfr7h04T2N/+yXq/I8nD15vfDk5vqU3/q eGHMr0mZSzIm4vo2R3RVRuBIuymTzDM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=l7EqwQOv; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699313657; a=rsa-sha256; cv=none; b=G+lRu7fSlKiyN3EAIRPCn0VpDdeaPSmPesYPEpGnhQYLnEo/nCsVYsudZzA9PdZqqhjllH TaCr7UDGeSVG8PWtXHJmEzG5Q0cksfPFOrd7mt3HvNeN9bgT7fMDJZQrQTtPg6RnOX3UUt P1Gox0UmD85dLQh5vPEtzdTdPhiGyRM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 4F5C3CE0E3C; Mon, 6 Nov 2023 23:34:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B5E5C433C7; Mon, 6 Nov 2023 23:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699313652; bh=W1YiwkaUjwsrSNghKHLS4esY06g2LoID2WDuKt3I9RI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l7EqwQOv3ujXdIdXqqLv7Yl2LZRZP4XIrLtoom+8gJLK5oV+OiHLT+vhbC/H1l//N 3ys60zJfeXmo1OBsPoTrzHX39yAklgEWMZGpaL5dQ84d1Wm494msHCkhjxa3lLv/o+ bmlBz1f8LPIrbknFW1iBJdvA5QQacQ1blL3tn2CUS9dsVOdkdhD3h1h9hzWsXsD+lD cQcF6kLh9zlF7uEHKE33vL0PahvmSow2SGpG0LP18EhMlmxAFu7oZpV7nWkVBLUK+y KXwSQej944ZLmBtdEJft4FhJiRYzEA2O1R8i/uGHUKVQC5EUGKH8wVyaId3jKSixkj qTvuPBpthovEA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 2/3] mm/damon/sysfs-schemes: handle tried regions sysfs directory allocation failure Date: Mon, 6 Nov 2023 23:34:07 +0000 Message-Id: <20231106233408.51159-3-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106233408.51159-1-sj@kernel.org> References: <20231106233408.51159-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: C210AC001A X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ji338zwgegxntxxfnwhjc5ewy4jourgk X-HE-Tag: 1699313656-500313 X-HE-Meta: U2FsdGVkX1+vq/CmRHZwTwuFgfNtY4XBfFY+GzxseLYY/6Nz/gETnhxx96zUEDRsYSCnBltM0q7dvSBN3oHk/FKU3XmYljm4aGT8QaF5NoTAnJmg7tu85K8z+ERsBzqQLJRucDwgM1dXYnLo6OSKbOoubcRt0YL84ALfWxi5rlvvy+b/Fb4r7T2Jm7vJ/TbjzLSwCy0SNGI2b+uJHgTVunzEQ2HKIxI65WGSdHjGv/rRM/iBgZ5zDDHuCrsBtq4BYdh5BOoXbBvmmjipQhlqD96o1UdkYcscxtFKtCEu3CNJv56YT23gBSilT276Yl3WIzfoPCfW48Mg+DpeXh0bDwa0u7/ejQaKix0XVpI7St+M4oJF5Kn6qNhB8HcPkwXa3eoOArMMR6f8rXdcdR2uczyLVSsStC5McO+2J+Atz1m9AJFm30ZCCbpJJc1Bdwj9E/CTXvciG1mo4wi/i+VawCLHju76tHmevDdbQECoImv8kQsJ3jNP08Uz9BE57Yr5FsYHaHrr5b9brRgs3O/RbPxzM8JvdJyPntIqgyPFkkUhyJpGODSfjNg1WRcm3MVrm8OYP3SVeBjUTBms7KSKHwDXvH5QHuzZQZwk5CkVKqbwT0LokIdX0YX/Da7Vr9p92jYfZkhmBldm1mTRaU/g7RCX5pGlYluJJNYruKgRj1mZbcoDRoyR1PmCQtSoYlGF3DyID9TXFkl5v22tVQ3BJBjvUmKVKBoyqJHqQWvlctmJ5HLRhPw6X7BNeMvTTrTlsYsrwCwSW/gsqQPnbyvbiCweziWYRbV83a4jAjdY1sRBFuip6hehsWHPHRY7ump6mLfZkkr4zijxBPaT3mDbTslsqElVX5YZZhZiiekJfs9MlssD3YCxEHAxnlpTupIIO6yWtBRT/Q7ce84cpM3hKnPbgZiFl8qISDUJFkK+AFGqU97icJonu6xDLzXfQd8fuyfSeX1gHZ6pnB/unNw FBklTq83 SIWBdQaN5nK8gKqE2iIsoO44txJ4OOAMWZG9fHofNmAYLF/x37RLyt7UDM5GRx9Gpu3pudhYdTbQTkijLzFbu3NMHcFuwA85Xon6y5x2VEQ76i7j5b2wFtu6S2nTeFy7bTrKVht10ImBSh6kLwSBphgUwD0IOmAiOgXBdpAiUUWbYNqyCf0YHWwM9oJm2cn0L81oExqneAHHpcDPup4t+3iEHgdk/ZA/hFg5yXy0rf4A8ghxyVYTKAbvvqV1WERUEhWt9 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: List-Subscribe: List-Unsubscribe: DAMOS tried regions sysfs directory allocation function (damon_sysfs_scheme_regions_alloc()) is not handling the memory allocation failure. In the case, the code will dereference NULL pointer. Handle the failure to avoid such invalid access. Fixes: 9277d0367ba1 ("mm/damon/sysfs-schemes: implement scheme region directory") Cc: # 6.2.x Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 45bd0fd4a8b1..7413cb35c5a9 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -162,6 +162,9 @@ damon_sysfs_scheme_regions_alloc(void) struct damon_sysfs_scheme_regions *regions = kmalloc(sizeof(*regions), GFP_KERNEL); + if (!regions) + return NULL; + regions->kobj = (struct kobject){}; INIT_LIST_HEAD(®ions->regions_list); regions->nr_regions = 0; From patchwork Mon Nov 6 23:34:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13447596 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 ED463C4332F for ; Mon, 6 Nov 2023 23:34:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3ACE6B025A; Mon, 6 Nov 2023 18:34:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C27B46B025C; Mon, 6 Nov 2023 18:34:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9D986B025E; Mon, 6 Nov 2023 18:34:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 99F186B025A for ; Mon, 6 Nov 2023 18:34:19 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6DB4D140955 for ; Mon, 6 Nov 2023 23:34:19 +0000 (UTC) X-FDA: 81429135438.17.B6A41E6 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf30.hostedemail.com (Postfix) with ESMTP id 4E30780011 for ; Mon, 6 Nov 2023 23:34:16 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=D1wTspPU; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699313657; 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:dkim-signature; bh=ED/5VRqDjeQ3vhbsBXBAmAewjBcby2wVIAxcWWWm3uU=; b=cLoLDGpTlLSHfK+BcW+WlBNAznGs0JgJPW2TQRm72XyHQ37OUXWtq+TC2LLK3BpV3Be/kS V30bcO2UprE+Xe29CR8vM1/w02FJZucxq6q2hv44fth+WF6WUrIIYel1Ea4QmY37D3EdX7 TO6QupvifhCvpcY6M+tuEU1RwbBz7NQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=D1wTspPU; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699313657; a=rsa-sha256; cv=none; b=ecnKcn8JQfMXZnuTnBXv3ZSaLefdHwQ+TWt6F5j1+6E009gI1rLLzCL/mhga79JiBoSZFc se0MAKM0w0iABDYnj+iNTN/mTk45jLbEYtshzdV3VVIBbnNQcoDWL7egCMl+L47hlePska fW0oSF9JOrDjVZQN+LLxUZQ450kDJ+4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 7BAADCE0E33; Mon, 6 Nov 2023 23:34:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55F12C433CA; Mon, 6 Nov 2023 23:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699313653; bh=19smz8vjkknnlftKxQDFJP/XhxeknF20W/DyGkIS8Os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D1wTspPUeGLo6x8Q/O1NGf9r8R7Y77Rea13Em+t/uPG+M8MB1RkYbqzvbkzEFu/2o +EbJZr5EpmuJNr37DT7pK4w7FQz0S3gGCgTdLEjwu0j0llYH7NAk8oU5KIZyMrGTDa xU8ou+PE7Hw8IjLv9dyB+hxXwQngY+1i+Ioz1CMmAr4QR9KqCjMOtErZW426EoDG0n ZWwH3Jx6nAAnd11/pOFJY9vSHUNoDTRFu1AngsTYsvE2korQlJDZmaQT6CsbPoIwr5 yzi1Mp+MivvdfbKoUGQsKHXEJT583q7JL2Znk9lwUlXiHrruB3lltIK3NLWFk4pDhE SzPy2Mk286CAw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 3/3] mm/damon/sysfs-schemes: handle tried region directory allocation failure Date: Mon, 6 Nov 2023 23:34:08 +0000 Message-Id: <20231106233408.51159-4-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106233408.51159-1-sj@kernel.org> References: <20231106233408.51159-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4E30780011 X-Stat-Signature: utfzf19fgdd13p7j7ypxm3jj89k1sfh9 X-HE-Tag: 1699313656-924233 X-HE-Meta: U2FsdGVkX180zTDYZ6//ZpzRw0rGVPHO6zsiC7/204hmkFgAHipSSM8U59qIjB7A00vkwWIJa/ivmUS3zOI+qETbpIjtRXx8HrirYqGsOquGgRhQaUUPA3eovkxrRMyyprdSXWdfvZcho6zcnc3vP9atIBL25MaIdeGIku4qRrfHKHGUOVcB2lLPngNFv7Upx4cg39+wxmhhOdOK9bQ0BstnfbaQNtW4x2WU6M907bmMbuLciz2F+d421bQpYi3h1iEJheLrcaVkEoksmdvs6zIXffmehiOl/8YO9yzc39Ge+eltBZZlcAwxaw60RA31KqIAMGbQ3OrnhUSKn0+PgkEmbIsjvlYmI6N87lfW5u/E6lO0yul4tPlVCUKZkrHIx31dpOdEnt0gjHSNzDyXts3pGkkqN2mqh8tkRp4AJSeq2JZqd2MEwvqAnGtHY7DQnoOvPDK7CbTc5SwNGV9+TFnD8LLPxH5HCSdZkf19jLU8BVrFdSJJGFm9PmGqlUbf0+5Fwwys24FOmjXsghHoVvTq7b6Ey/For1xdtxrpRjG3fipsa9M4jjY0UkSYWjrOz/MOAOV7hT3dwM7e0w4o7KKVChTqZmEdBIS+EAr+gEEOABHk2FIz6WQoyku1Lo7jbxpMZX7jO8qiJfmYeRThYN62JJqIztGQvypcibF0JqSteRgYWXD2LMZ/c+bSpbYo4/ewgGZJpjEA3hpbwTiSXbYJw9qUQAsCm+DIfQyOdkPmkCX3GmU1bEr1lDP512JcbaBoPTkHq+VSnr4/DcZDbLcJ7I9ZP1G4m4+zFwXDau+jY4U7KF6mzEYvT6LKC17o39trfVOfqutQIYlOuJJIGMRdI4yEIoGfgtXkINhKkGFJbuZYYUfiRIDCcXMnhm9AHoZ/rXci7t2afuiIRkBnrZQZy35tFuGiuSvTVMqqUtt8q89/JRNWUuDe4CsHG56cHFiHsBQg8Vhd5wx3ob9 7hQOpQ6r +j/o+EAXP9jsSuLLoHHcrijlrYiW3ei4XvcPn3GkWy3JGBHb7cShJzfXYvEKVuQQz6zua0i4R9ajyIffXv4+XIV7ytsOA39FzuHImY+d2JIk9R0qfDrDDBKVBNBgliIHyaGRNgNlwsMQs/idz/z7y03xyk9C7xFjTkhHF6Tu84dE3WxMdh924mK9wT63nDQYVqHpQAjbK/LxQf0BTsniB25EqMfBTI7VvURoueA1YpNdLHPM= 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: List-Subscribe: List-Unsubscribe: DAMON sysfs interface's before_damos_apply callback (damon_sysfs_before_damos_apply()), which creates the DAMOS tried regions for each DAMOS action applied region, is not handling the allocation failure for the sysfs directory data. As a result, NULL pointer derefeence is possible. Fix it by handling the case. Fixes: f1d13cacabe1 ("mm/damon/sysfs: implement DAMOS tried regions update command") Cc: # 6.2.x Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 7413cb35c5a9..be667236b8e6 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1826,6 +1826,8 @@ static int damon_sysfs_before_damos_apply(struct damon_ctx *ctx, return 0; region = damon_sysfs_scheme_region_alloc(r); + if (!region) + return 0; list_add_tail(®ion->list, &sysfs_regions->regions_list); sysfs_regions->nr_regions++; if (kobject_init_and_add(®ion->kobj,