From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 BDB2030CDAB for ; Wed, 6 May 2026 08:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778057090; cv=none; b=nnHqcpc9/QaddA/1dAGSvlfKXTJH3AqqOQzjYfSwq06vUFUGV0Hq4yv5XTTtgxkSn3ll6DR+ObPZXkE+SzY0+YBVS4i5B6KfTXqXhcOsgoz0/p5n3QGXX+Z7qc2cWaxcv/a77SwMJF4ktwhsti9rS4zk0Kd6KLTnQMl0XZe5W+Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778057090; c=relaxed/simple; bh=rnaW6h7hfxN/ADnzOwIB94lqMk5PhD9k0N7nSX9ctFk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LJBHK5y7obGEap9k7Cfc4BPBd6ybt7WFjRJpF0rASGjk+gCis922GlwZ3xvRAdD4lAcgPcuLBaBt83NRUxxhR2HmLk5bk0Puu0Cj0TZFamHYC864H+sEsr4kPQuh7S8PiWGzcewrp/ZupeP793RyoNazPIBIKd5oWNrA3dXVoXo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=eMXIdxfF; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eMXIdxfF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1778057089; x=1809593089; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=rnaW6h7hfxN/ADnzOwIB94lqMk5PhD9k0N7nSX9ctFk=; b=eMXIdxfFYDumGufbQd+QG2GI6LrGUTbXUJFepK/EsUc5SDxWgBxjt736 U+FxkYXbK1jeGNkpfp4tHVXl4wPlN9BuF4Q2c1aSXpkqhCzNZkGn3twiG KFsOgineBlKEKp4F9IFZqon9QH77E4rP4Gb06LYdpzI0jYeQ+1H9oQdaM JjtsqZWCiWsIfZt4nU9hvTQhN+X2NR1FCL653adMjy0mtPxka1xwFych3 c4sORK8XWwZQxsAoa49qEdKetSqtFyL6/bUf5UPiUxvO3CHTCN1DoR5ls F2Ag26bCVIZW8RBNAMf4p0BOeaHGlpMc7+YsLb+EnwFHEcgI9ubx//DiC Q==; X-CSE-ConnectionGUID: VgCqK9UeTQGzUXilwAsaHg== X-CSE-MsgGUID: bELKhW3XQXqlR7vuqo7Q1w== X-IronPort-AV: E=McAfee;i="6800,10657,11777"; a="82848804" X-IronPort-AV: E=Sophos;i="6.23,219,1770624000"; d="scan'208";a="82848804" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2026 01:44:48 -0700 X-CSE-ConnectionGUID: NXsA1zMVRwKyj3EsZ4hAlQ== X-CSE-MsgGUID: RemB61o9RbWW5rRS2mbhAw== X-ExtLoop1: 1 Received: from abityuts-desk.ger.corp.intel.com (HELO localhost) ([10.245.244.183]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2026 01:44:46 -0700 Date: Wed, 6 May 2026 11:44:43 +0300 From: Andy Shevchenko To: Xie Yuanbin Cc: chleroy@kernel.org, maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, kees@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, lilinjie8@huawei.com, liaohua4@huawei.com Subject: Re: [PATCH V2] powerpc/text-patching: simplify the implementation of ppc_kallsyms_lookup_name() Message-ID: References: <20260506021143.13797-1-xieyuanbin1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260506021143.13797-1-xieyuanbin1@huawei.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Wed, May 06, 2026 at 10:11:43AM +0800, Xie Yuanbin wrote: > ppc_kallsyms_lookup_name() is called only twice in the kernel code, and > the parameters are all constant strings. strnlen(name, KSYM_NAME_LEN) is > called inside ppc_kallsyms_lookup_name(), when the compiler detects that > KSYM_NAME_LEN is larger then the constant strings, > the following error will be triggered: > ```log > CC arch/powerpc/kernel/optprobes.o > In file included from ./arch/powerpc/include/asm/kprobes.h:24, > from ./include/linux/kprobes.h:31, > from arch/powerpc/kernel/optprobes.c:8: > In function 'ppc_kallsyms_lookup_name', > inlined from 'arch_prepare_optimized_kprobe' at arch/powerpc/kernel/optprobes.c:209:21: > ./arch/powerpc/include/asm/text-patching.h:232:13: error: 'strnlen' specified bound 512 exceeds source size 19 [-Werror=stringop-overread] > 232 | if (strnlen(name, KSYM_NAME_LEN) >= KSYM_NAME_LEN) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ > In function 'ppc_kallsyms_lookup_name', > inlined from 'arch_prepare_optimized_kprobe' at arch/powerpc/kernel/optprobes.c:210:22: > ./arch/powerpc/include/asm/text-patching.h:232:13: error: 'strnlen' specified bound 512 exceeds source size 13 [-Werror=stringop-overread] > 232 | if (strnlen(name, KSYM_NAME_LEN) >= KSYM_NAME_LEN) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ > cc1: all warnings being treated as errors > ``` This log can be made more readable: ```log In function 'ppc_kallsyms_lookup_name', ./arch/powerpc/include/asm/text-patching.h:232:13: error: 'strnlen' specified bound 512 exceeds source size 19 [-Werror=stringop-overread] 232 | if (strnlen(name, KSYM_NAME_LEN) >= KSYM_NAME_LEN) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` > The error can be reproduced in the following ways: > Use lastest linux-next source, change ppc_kallsyms_lookup_name() to > __always_inline, use default ppc64_defconfig, set CONFIG_EXPERT=y, > CONFIG_PPC64_BIG_ENDIAN_ELF_ABI_V2=n, CONFIG_CC_OPTIMIZE_FOR_SIZE=y, > and use gcc-14 or a later version for compilation. > > Since ppc_kallsyms_lookup_name() is called only twice in the kernel, > and the parameters are all constant strins, simplify the implementation > of ppc_kallsyms_lookup_name() and avoid calling strnlen(). > Cc: Andy Shevchenko > Cc: Kees Cook Please, keep Cc list... > Suggested-by: Christophe Leroy (CS GROUP) > Signed-off-by: Xie Yuanbin > --- ...somewhere here in the comments block. This will reduce unneeded churn in the commit message when maintainer applies the patch. > v1->v2: https://lore.kernel.org/20260205100517.292858-2-xieyuanbin1@huawei.com > - Not use strlen() -- With Best Regards, Andy Shevchenko