From nobody Sun Feb 8 20:35:48 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05FA4F50F for ; Thu, 15 Jan 2026 03:16:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768446975; cv=none; b=GIdh6mxzvjCys187Z4ELLMh2V9kEofnkOB4RdAmhmYrlSOvBsLKND4lbKHREdLsDD9FLK8F5Vr+DrzYdMyPRtiap1FGVcnGnIhLc3oo03qhBLkcjfXCfDPLdYwyQNV72HdZZyNGIk0keP+0VPXbMAh88CYkBQiWGaHMV5TUJWzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768446975; c=relaxed/simple; bh=wbzpF0vxo21vcVopMGAoSFOVfRNgyO1dpPWCdHbtb9s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kP+32AugLnZ+HSBfBWFhrjGgUeEc4ypIsExPQBBG5IYYI9LMLGCIq/H3HqAV/iTpk/QG5KN142tLxbpJDHu7t5hDVaQhzbvELXlEEmhtp2U6YelIYmd798KbyKB7VUe72xhDtfxMSC3HIUIuX2V4Rz/1IOrjwlpPu/ruK1ODVVA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=LWbtqDmM; arc=none smtp.client-ip=220.197.31.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="LWbtqDmM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=ft Yr0Vux/TRKiah+jH/Pg17vHKfQ65hz71Fr3PI0YMo=; b=LWbtqDmMcfS5RpDZUT WiwVFY/JrqB3o+Jpc8Ww3TkBPk2gVYXFN+nYcme2HbyOg3/InI5L7TmRkzAK54VC btzO3QUMc7+ndiG7BmXQ0Wl8ecA7hytDWJlbEi12A/qB5zz8kISkUDWD1zoGqKPP 8rxWFKt0yzp4n3tPrg1k/cXjI= Received: from ubuntu24-z.. (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wCHOLvbW2hpqcCoGQ--.22184S2; Thu, 15 Jan 2026 11:15:40 +0800 (CST) From: ranxiaokai627@163.com To: surenb@google.com, kent.overstreet@linux.dev, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, ran.xiaokai@zte.com.cn, ranxiaokai627@163.com Subject: [PATCH v2] alloc_tag: fix rw permission issue when handling boot parameter Date: Thu, 15 Jan 2026 03:15:36 +0000 Message-ID: <20260115031536.164254-1-ranxiaokai627@163.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wCHOLvbW2hpqcCoGQ--.22184S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7tw1ktrW3CF15ur15GryUKFg_yoW8trWUpF Z5Wr15Krs5JFyxCF93Aa4Ikryftan7tw43trZFgFW2vwnxKrWDJr1rtrWxtF12qFZrCF4r X3WY9rWkWw45J3JanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zMeHg9UUUUU= X-CM-SenderInfo: xudq5x5drntxqwsxqiywtou0bp/xtbC7RyCzmloW9yDPAAA3E Content-Type: text/plain; charset="utf-8" From: Ran Xiaokai Boot parameters prefixed with "sysctl." are processed during the final stage of system initialization via kernel_init()-> do_sysctl_args(). When CONFIG_MEM_ALLOC_PROFILING_DEBUG is enabled, the sysctl.vm.mem_profiling entry is not writable and will cause a warning. Before run_init_process(), system initialization executes in kernel thread context. Use current->mm to distinguish sysctl writes during do_sysctl_args() from user-space triggered ones. And when the proc_handler is from do_sysctl_args(), always return success because the same value was already set by setup_early_mem_profiling() and this eliminates a permission denied warning. Suggested-by: Suren Baghdasaryan Acked-by: Suren Baghdasaryan Signed-off-by: Ran Xiaokai --- lib/alloc_tag.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c index 846a5b5b44a4..00ae4673a271 100644 --- a/lib/alloc_tag.c +++ b/lib/alloc_tag.c @@ -776,8 +776,22 @@ EXPORT_SYMBOL(page_alloc_tagging_ops); static int proc_mem_profiling_handler(const struct ctl_table *table, int w= rite, void *buffer, size_t *lenp, loff_t *ppos) { - if (!mem_profiling_support && write) - return -EINVAL; + if (write) { + /* + * Call from do_sysctl_args() which is a no-op since the same + * value was already set by setup_early_mem_profiling. + * Return success to avoid warnings from do_sysctl_args(). + */ + if (!current->mm) + return 0; + +#ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG + /* User can't toggle profiling while debugging */ + return -EACCES; +#endif + if (!mem_profiling_support) + return -EINVAL; + } =20 return proc_do_static_key(table, write, buffer, lenp, ppos); } @@ -787,11 +801,7 @@ static const struct ctl_table memory_allocation_profil= ing_sysctls[] =3D { { .procname =3D "mem_profiling", .data =3D &mem_alloc_profiling_key, -#ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG - .mode =3D 0444, -#else .mode =3D 0644, -#endif .proc_handler =3D proc_mem_profiling_handler, }, }; --=20 2.25.1