From patchwork Sat Jul 29 20:37:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13333211 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 0ED77C001DC for ; Sat, 29 Jul 2023 20:37:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC9808D0002; Sat, 29 Jul 2023 16:37:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D52388D0001; Sat, 29 Jul 2023 16:37:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C19A48D0002; Sat, 29 Jul 2023 16:37:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AED618D0001 for ; Sat, 29 Jul 2023 16:37:41 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7200BA0828 for ; Sat, 29 Jul 2023 20:37:41 +0000 (UTC) X-FDA: 81065810322.04.3BA6C34 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id AD67540017 for ; Sat, 29 Jul 2023 20:37:39 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sdAWiTrM; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1690663059; 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=m/Jq4om9ap8xtHkkQPITf3+6Fw+6C2VJ4TYwZxcfP3g=; b=UdFJLEajqDDwMNs7mxdwdQoTcRIzjNyzUJeJfNPIr7jW3m/lHZIlYvOLwfvFHdWKKkzsde /DChdJ7eKM/RVF1SwBLmjAY3fCl/pVv300WP47cKpau9KcIIpxi81PmrjYo8Y6WxcpyDez gIubIkwtjvScc3kBCiUDBxAYBGXTf/s= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sdAWiTrM; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.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=1690663059; a=rsa-sha256; cv=none; b=AEhvzBkgnbQw7QLeDI2zy32GY18KG4BP2AnwR+L18Sp6A0/xriMDxJ84LPVS+6+1SHbJ3r ml6FFzFabhsple8HGt+bgnUTaA8jasQUgdYr7FOVZjwyezS9Y2uQKvDNQIKdpVa0Kr+Loa KyycMwVc41r1koreVtYiA17nez4fK2g= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D8AAE60A78; Sat, 29 Jul 2023 20:37:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBF87C433CA; Sat, 29 Jul 2023 20:37:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690663058; bh=obtSlnvy07n5RqMkT9ft+YWwsEmXSmZYdkX6jt7/ZH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sdAWiTrM5jLNvyEBr96k2bMsZpKhmFnONlHBuxh9ggS6iOcSUvJwgxLYzbHzBg9wS Ru1MQ8gRyCCNabq0iEEj553U3cF/LPfy0Z0RP1lLlqIranr3CxrK7kwMlydMcHIEt2 mSWUspQMNOceTsGydjYASOP5JF4GQDXRDt5LbRC1/bnb+Qf5GF270paW1Empm5JTfE pms39T+3hsMPHK1s1xJXi3Qz6XelHOE+8iQjtuS/sHfhyIDLjibfxH9NuWXDhb97Ui CwFQtevzKuW9qy+wLJDw5htGv071KBVoNdVp8kywCJ2s4wKeX4TOrviMNnxZTvwnyQ 9TIBw3B3hZQIQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm/damon/core: initialize damo_filter->list from damos_new_filter() Date: Sat, 29 Jul 2023 20:37:32 +0000 Message-Id: <20230729203733.38949-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230729203733.38949-1-sj@kernel.org> References: <20230729203733.38949-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: AD67540017 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: h1517i35tkbb1cbzq9zthwo4mp3tp33i X-HE-Tag: 1690663059-604264 X-HE-Meta: U2FsdGVkX1/r7HQ3og8luxkYcR1hmxQE8SUq4qKwTas8WIB8squ2RgDutgHNaR0ZiQK8afiC5YnTeM10rqyVCgDvuZFaK1UpJKZ+2yRw+ze2G0c0WiPFI7fimJDt7BJ6/UAp4TKiLGrFKgf+YKtByH/reFmo04gl3Ywil/+JGCfolOUErq13zeLHDLqyNKonXdcP7pSMBYBUiuoF5QeemHl198WYwlE+/7DbfY98olW6eQTzk1EB/NBr9DmPWSX6B22W7+tiH419hUq4MpBRCswOwfWAwgHlUN2OvCx/EgLgp7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0iLdV1qSAzIDRHlXAW+ajnUW2GBSjkZ31i36Q5LA== 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: damos_new_filter() is not initializing the list field of newly allocated filter object. However, DAMON sysfs interface and DAMON_RECLAIM are not initializing it after calling damos_new_filter(). As a result, accessing uninitialized memory is possible. Actually, adding multiple DAMOS filters via DAMON sysfs interface caused NULL pointer dereferencing. Initialize the field just after the allocation from damos_new_filter(). Fixes: 98def236f63c ("mm/damon/core: implement damos filter") Cc: stable@vger.kernel.org # 6.3.x- Signed-off-by: SeongJae Park --- mm/damon/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/damon/core.c b/mm/damon/core.c index 91cff7f2997e..eb9580942a5c 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -273,6 +273,7 @@ struct damos_filter *damos_new_filter(enum damos_filter_type type, return NULL; filter->type = type; filter->matching = matching; + INIT_LIST_HEAD(&filter->list); return filter; }