From patchwork Sun Oct 2 19:31:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12996996 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 32B24C433F5 for ; Sun, 2 Oct 2022 19:31:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5716C8E0002; Sun, 2 Oct 2022 15:31:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5202A8E0001; Sun, 2 Oct 2022 15:31:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E7F48E0002; Sun, 2 Oct 2022 15:31:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2D54B8E0001 for ; Sun, 2 Oct 2022 15:31:39 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E3CD5160596 for ; Sun, 2 Oct 2022 19:31:38 +0000 (UTC) X-FDA: 79977003876.28.90D7718 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 81BC940010 for ; Sun, 2 Oct 2022 19:31:38 +0000 (UTC) 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 7B37C60EC9; Sun, 2 Oct 2022 19:31:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6ADC4C433D6; Sun, 2 Oct 2022 19:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664739096; bh=bQS/eXJeMiPmj71PLej7rSCZfOQeTrzaD8xCsX+qwWs=; h=From:To:Cc:Subject:Date:From; b=mqXGGEijWGYOiDoFBLN96KIHMPXk+iRXIEhFZEthkWkhHbII4hJTk8mU7LmVLy5Hb 27BrqgLA7UBZEmpgEnID8xnk6WO0IGDFKavvDraIxLFdEbbt/bmMCDhtEWDyM8u7aQ yI+/LFUrOlsM1ulAgbtmQxXx5kOqO55fG59CsmEiJ5elUp6M3tiNfsCmq7pqLCMXoZ PbWKrJE01GK1Gt0BUUXA9wxzzh3sAwSL6vF3F1rgr/zEyXKuyp1CuwunE6vDOqW5Zi khuo8Dk5lBvSZ6cMAIlkRdtunin+/MAJCHpz6LYqi5cpCkFwVPDTIoFpa8Spw2bFcR kkDribUKFF/Cg== From: SeongJae Park To: akpm@linux-foundation.org Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, SeongJae Park , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH] mm/damon/core: initialize damon_target->list in damon_new_target() Date: Sun, 2 Oct 2022 19:31:30 +0000 Message-Id: <20221002193130.8227-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664739098; 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:references:dkim-signature; bh=sugAw9mds9T0qQlUACQlhQreOzIIp7rClyZyJ/e9Mq0=; b=AjRxY4cNBk7E+ViUNRkUls8D/bbfdB4WkK1090CHzLEFvz8RlirmnpDWPilGPi0Qeulngt MA/KT/rkgU2vX02FJVtloK9+ytCI12dVDlzr6P23doCB+retRoxSlzdlruP6FEygzXLPFX aq0CUeAmGdvm9ckdfcUHkRt5DpVQXvY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mqXGGEij; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664739098; a=rsa-sha256; cv=none; b=IlLUxHHpSNZ+TPTa9mA7Uf6ZWsS5HNBuM84DUI7VzJN73tI5wgwZCXJEFQlXpZDcNshXCG eW0gqX+w0V8/+2XJT0Fr55QaOoERFDXgzkMKQ4VxvoroXr9JZFNeA0aoXaIuvNurulz4vV jc/zXx2Fj8KpbNj8kvPFPfiCirT4p+g= X-Stat-Signature: g7oxa5aqwkye6ncqmu4rfeinx7dwdk3n X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 81BC940010 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mqXGGEij; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org X-HE-Tag: 1664739098-938801 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: 'struct damon_target' creation function, 'damon_new_target()' is not initializing its '->list' field, unlike other DAMON structs creator functions such as 'damon_new_region()'. Normal users of 'damon_new_target()' initializes the field by adding the target to DAMON context's targets list, but some code could access the uninitialized field. This commit avoids the case by initializing the field in 'damon_new_target()'. Reported-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Fixes: f23b8eee1871 ("mm/damon/core: implement region-based sampling") Signed-off-by: SeongJae Park Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/damon/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/damon/core.c b/mm/damon/core.c index 1d952fa7ba3e..1e6691771a95 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -345,6 +345,7 @@ struct damon_target *damon_new_target(void) t->pid = NULL; t->nr_regions = 0; INIT_LIST_HEAD(&t->regions_list); + INIT_LIST_HEAD(&t->list); return t; }