From mboxrd@z Thu Jan 1 00:00:00 1970 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 118DCC433EF for ; Mon, 21 Mar 2022 20:01:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5BC586B0072; Mon, 21 Mar 2022 16:01:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 569FE6B0073; Mon, 21 Mar 2022 16:01:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 431226B0074; Mon, 21 Mar 2022 16:01:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id 33AD86B0072 for ; Mon, 21 Mar 2022 16:01:38 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C12F9A4A4E for ; Mon, 21 Mar 2022 20:01:37 +0000 (UTC) X-FDA: 79269463434.22.5BDBE99 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf07.hostedemail.com (Postfix) with ESMTP id ABADE40035 for ; Mon, 21 Mar 2022 20:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647892896; x=1679428896; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=iNelwzpwtuttr7MOXX06oG+BXc/mNSezZr36ZwGZAjA=; b=BAXDEsv6ugKaW+Dp05lI5DyYpG+XGE8GuaKNYYRyqdBinbPPJM3yc0nk 3oVsaAgPA+hgysoGxD7MIZVZxJ9Hwn0qTjDUqAHUMXY1jSjvV2ZkoMP1/ 9MWT881/9QmQsHZEI5J9/TxT7ez14v/2Hm424iy0jKVtkckz1UALVkmva Otk3Pd4pFJjXwyVBBGicBGkWCC19xZWUnf8mS3XdOmUVQqfvyWD8e/Txb XY1KgBgHP2u4/FQ+WGP3i/rSJIX0KOFBWE9IjRDY60fok6Fou2cQ2xdNa kZO/bY7CgTStdsdl45AO0khwsg+IwLUiZZVqBTl4Sd3by5Llu3uhuK0ye A==; X-IronPort-AV: E=McAfee;i="6200,9189,10293"; a="344066983" X-IronPort-AV: E=Sophos;i="5.90,199,1643702400"; d="scan'208";a="344066983" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2022 13:01:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,199,1643702400"; d="scan'208";a="600596303" Received: from lkp-server02.sh.intel.com (HELO 89b41b6ae01c) ([10.239.97.151]) by fmsmga008.fm.intel.com with ESMTP; 21 Mar 2022 13:01:32 -0700 Received: from kbuild by 89b41b6ae01c with local (Exim 4.92) (envelope-from ) id 1nWODc-000I6r-0o; Mon, 21 Mar 2022 20:01:32 +0000 Date: Tue, 22 Mar 2022 04:01:05 +0800 From: kernel test robot To: Miaohe Lin , akpm@linux-foundation.org, mhocko@suse.com Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org, kosaki.motohiro@jp.fujitsu.com, mgorman@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linmiaohe@huawei.com Subject: Re: [PATCH v2] mm/mempolicy: fix mpol_new leak in shared_policy_replace Message-ID: <202203220336.VpfVL4ng-lkp@intel.com> References: <20220322083456.16563-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220322083456.16563-1-linmiaohe@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspam-User: X-Rspamd-Queue-Id: ABADE40035 X-Stat-Signature: jyqngkin6rz4bt3wphzme7xs8krip5b6 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=BAXDEsv6; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf07.hostedemail.com: domain of lkp@intel.com has no SPF policy when checking 192.55.52.43) smtp.mailfrom=lkp@intel.com X-Rspamd-Server: rspam05 X-HE-Tag: 1647892896-58242 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: Hi Miaohe, Thank you for the patch! Yet something to improve: [auto build test ERROR on linux/master] [also build test ERROR on linus/master v5.17] [cannot apply to hnaz-mm/master next-20220321] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Miaohe-Lin/mm-mempolicy-fix-mpol_new-leak-in-shared_policy_replace/20220321-200100 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2c271fe77d52a0555161926c232cd5bc07178b39 config: x86_64-randconfig-a002-20220321 (https://download.01.org/0day-ci/archive/20220322/202203220336.VpfVL4ng-lkp@intel.com/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 85e9b2687a13d1908aa86d1b89c5ce398a06cd39) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/9a91a8a7964a3af0b60f08dc38b7815e5118206a git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Miaohe-Lin/mm-mempolicy-fix-mpol_new-leak-in-shared_policy_replace/20220321-200100 git checkout 9a91a8a7964a3af0b60f08dc38b7815e5118206a # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): >> mm/mempolicy.c:2745:15: error: incompatible pointer types passing 'atomic_t *' to parameter of type 'refcount_t *' (aka 'struct refcount_struct *') [-Werror,-Wincompatible-pointer-types] refcount_set(&mpol_new->refcnt, 1); ^~~~~~~~~~~~~~~~~ include/linux/refcount.h:134:45: note: passing argument to parameter 'r' here static inline void refcount_set(refcount_t *r, int n) ^ 1 error generated. vim +2745 mm/mempolicy.c 2681 2682 /* Replace a policy range. */ 2683 static int shared_policy_replace(struct shared_policy *sp, unsigned long start, 2684 unsigned long end, struct sp_node *new) 2685 { 2686 struct sp_node *n; 2687 struct sp_node *n_new = NULL; 2688 struct mempolicy *mpol_new = NULL; 2689 int ret = 0; 2690 2691 restart: 2692 write_lock(&sp->lock); 2693 n = sp_lookup(sp, start, end); 2694 /* Take care of old policies in the same range. */ 2695 while (n && n->start < end) { 2696 struct rb_node *next = rb_next(&n->nd); 2697 if (n->start >= start) { 2698 if (n->end <= end) 2699 sp_delete(sp, n); 2700 else 2701 n->start = end; 2702 } else { 2703 /* Old policy spanning whole new range. */ 2704 if (n->end > end) { 2705 if (!n_new) 2706 goto alloc_new; 2707 2708 *mpol_new = *n->policy; 2709 atomic_set(&mpol_new->refcnt, 1); 2710 sp_node_init(n_new, end, n->end, mpol_new); 2711 n->end = start; 2712 sp_insert(sp, n_new); 2713 n_new = NULL; 2714 mpol_new = NULL; 2715 break; 2716 } else 2717 n->end = start; 2718 } 2719 if (!next) 2720 break; 2721 n = rb_entry(next, struct sp_node, nd); 2722 } 2723 if (new) 2724 sp_insert(sp, new); 2725 write_unlock(&sp->lock); 2726 ret = 0; 2727 2728 err_out: 2729 if (mpol_new) 2730 mpol_put(mpol_new); 2731 if (n_new) 2732 kmem_cache_free(sn_cache, n_new); 2733 2734 return ret; 2735 2736 alloc_new: 2737 write_unlock(&sp->lock); 2738 ret = -ENOMEM; 2739 n_new = kmem_cache_alloc(sn_cache, GFP_KERNEL); 2740 if (!n_new) 2741 goto err_out; 2742 mpol_new = kmem_cache_alloc(policy_cache, GFP_KERNEL); 2743 if (!mpol_new) 2744 goto err_out; > 2745 refcount_set(&mpol_new->refcnt, 1); 2746 goto restart; 2747 } 2748 -- 0-DAY CI Kernel Test Service https://01.org/lkp