Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2807426rwb; Sat, 29 Jul 2023 14:52:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlGdayz0WeQ+YbUxP76VAjAY6Geqz68mQQAJY4PkkBLPChpA6aw4eGx1MIS4oW9YQEtBBNwZ X-Received: by 2002:adf:f611:0:b0:314:3a3d:5d1f with SMTP id t17-20020adff611000000b003143a3d5d1fmr5058242wrp.19.1690667553131; Sat, 29 Jul 2023 14:52:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690667553; cv=none; d=google.com; s=arc-20160816; b=VUhN/Vvts9Y/a30z3NGdiDBo1A3JqQe+KBFmaVLWMSSo8xtroi2frkzQt6A8ujDyxT R7570A5HLBMEV27qE5R8mIp7VdFTkoAcx74aWYrf2JiywZaZ32+tstwthc4yQs/ga958 mIkD3ElV/Zopa789X/HDS6Sfk5Kh8ezeiTbBb8k/K7llneGowasv5gtYsQjSExfe581+ gt1LAUxk7k1s1RFnFSrivTjJ+5bgUeqG/yqNWOBcW4eJdhwpR53TbntzXnHqA2BOZugJ LPLfa2j4lANYY4DjcpnkaqfKmeeQAZWXTV3bslA8kBfQzseaRZZfyW4ySiXvvve64ab1 xV7A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m/Jq4om9ap8xtHkkQPITf3+6Fw+6C2VJ4TYwZxcfP3g=; fh=F1ufHVvjlz/m0p/dUna/lpyohajJgTo1g7WvhXO0dp8=; b=L65IiCTJCv9UhT+KTLLn3On/ZOkHcyq6QJ06q7yv+IoD60lBzw2TaXmbO5mOoxwdQh k1PdmQH+nvdIyapFCN4qJcpX4tnTBd0fR2xad0sRmkbfPOLhz2464VE4tMZyw7QnmSLT II8Da8YthHAFeZzQexI1Pi3PJyBZNRmlbuO5Ee/0TA/CVbnE6ODGQ2pTMalpyzLq2ZyM H58iuICt/hTIT6sK8tr9Osw9Ucc/BzTcDZKOdDngQjGFHQzXv6UOvT1Py/tFT6/WwkKN WH60dsoVRlF03hj+zfXRJzdmD3gLXCGswnMkK4EkotZacmvohNzoHDNSgCyzEy/7wN/V cT9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sdAWiTrM; 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 u3-20020aa7d983000000b005222114ba0asi4861557eds.390.2023.07.29.14.52.08; Sat, 29 Jul 2023 14:52:33 -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=sdAWiTrM; 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 S229492AbjG2Uhm (ORCPT + 99 others); Sat, 29 Jul 2023 16:37:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjG2Uhk (ORCPT ); Sat, 29 Jul 2023 16:37:40 -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 512B918B; Sat, 29 Jul 2023 13:37:39 -0700 (PDT) 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 CF9A260765; 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 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; } -- 2.25.1