mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] x86/apic: Replace deprecated simple_strtol() with sscanf() for robust parsing
@ 2026-10-05 16:32 Habil Eren Türker
  2026-10-05 16:32 ` [PATCH v2 1/2] " Habil Eren Türker
  2026-10-05 16:32 ` [PATCH v2 2/2] x86/apic: Replace deprecated simple_strtol() with sscanf() in x86_fwspec_is_hpet() Habil Eren Türker
  0 siblings, 2 replies; 5+ messages in thread
From: Habil Eren Türker @ 2026-10-05 16:32 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86
  Cc: hpa, linux-kernel, Habil Eren Türker

This patch series replaces the deprecated simple_strtol() function
with the sscanf() in the x86 APIC code to ensure robust parsing.

The simple_strtol() function is deprecated as it silently ignores
overflows. Replacing it with sscanf() maintains the original flexible
parsing behavior while eliminating the deprecated function usage.

Changes in v2:
- Replaced the initial strict kstrtouint() implementation with sscanf()
  to prevent regressions on platforms where fwnode names contain trailing
  hardware addresses.
- Cleaned up redundant strncmp() invocations since sscanf() handles format
  matching.

Habil Eren Türker (2):
  x86/apic: Replace deprecated simple_strtol() with sscanf() for robust
    parsing
  x86/apic: Replace deprecated simple_strtol() with sscanf() in
    x86_fwspec_is_hpet()

 arch/x86/kernel/apic/vector.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] x86/apic: Replace deprecated simple_strtol() with sscanf() for robust parsing
  2026-10-05 16:32 [PATCH v2 0/2] x86/apic: Replace deprecated simple_strtol() with sscanf() for robust parsing Habil Eren Türker
@ 2026-10-05 16:32 ` Habil Eren Türker
  2026-10-05 16:32 ` [PATCH v2 2/2] x86/apic: Replace deprecated simple_strtol() with sscanf() in x86_fwspec_is_hpet() Habil Eren Türker
  1 sibling, 0 replies; 5+ messages in thread
From: Habil Eren Türker @ 2026-10-05 16:32 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86
  Cc: hpa, linux-kernel, Habil Eren Türker

The simple_strtol() function is deprecated because it explicitly ignores
overflows. Replace it with sscanf() for proper check 
in x86_fwspec_is_ioapic.

It was detected while running a static analysis on the use of
simple_strtol() in the kernel.

Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com>
---
 arch/x86/kernel/apic/vector.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index bddc54465..1a30b47c5 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -663,14 +663,21 @@ static void x86_vector_debug_show(struct seq_file *m, struct irq_domain *d,
 
 int x86_fwspec_is_ioapic(struct irq_fwspec *fwspec)
 {
+	const char *fwname;
+	unsigned int val;
+
 	if (fwspec->param_count != 1)
 		return 0;
 
 	if (is_fwnode_irqchip(fwspec->fwnode)) {
-		const char *fwname = fwnode_get_name(fwspec->fwnode);
-		return fwname && !strncmp(fwname, "IO-APIC-", 8) &&
-			simple_strtol(fwname+8, NULL, 10) == fwspec->param[0];
+		fwname = fwnode_get_name(fwspec->fwnode);
+
+		if (fwname && sscanf(fwname, "IO-APIC-%u", &val) == 1 &&
+		    val == fwspec->param[0])
+			return 1;
+		return 0;
 	}
+
 	return to_of_node(fwspec->fwnode) &&
 		of_device_is_compatible(to_of_node(fwspec->fwnode),
 					"intel,ce4100-ioapic");
-- 
2.47.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] x86/apic: Replace deprecated simple_strtol() with sscanf() in x86_fwspec_is_hpet()
  2026-10-05 16:32 [PATCH v2 0/2] x86/apic: Replace deprecated simple_strtol() with sscanf() for robust parsing Habil Eren Türker
  2026-10-05 16:32 ` [PATCH v2 1/2] " Habil Eren Türker
@ 2026-10-05 16:32 ` Habil Eren Türker
  2026-10-06  3:11   ` kernel test robot
  2026-10-06  5:09   ` kernel test robot
  1 sibling, 2 replies; 5+ messages in thread
From: Habil Eren Türker @ 2026-10-05 16:32 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86
  Cc: hpa, linux-kernel, Habil Eren Türker

The simple_strtol() function is deprecated because it explicitly ignores
overflows. Replace it with the sscanf for proper check
in x86_fwspec_is_hpet(). Also add early returns.

It was detected while running a static analysis on the use of
simple_strtol() in the kernel.

Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com>
---
 arch/x86/kernel/apic/vector.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 1a30b47c5..accd7797d 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -685,14 +685,21 @@ int x86_fwspec_is_ioapic(struct irq_fwspec *fwspec)
 
 int x86_fwspec_is_hpet(struct irq_fwspec *fwspec)
 {
+	const char *fwname;
+	unsigned int val;
+
 	if (fwspec->param_count != 1)
 		return 0;
 
-	if (is_fwnode_irqchip(fwspec->fwnode)) {
-		const char *fwname = fwnode_get_name(fwspec->fwnode);
-		return fwname && !strncmp(fwname, "HPET-MSI-", 9) &&
-			simple_strtol(fwname+9, NULL, 10) == fwspec->param[0];
-	}
+	if (!is_fwnode_irqchip(fwspec->fwnode))
+		return 0;
+
+	fwname = fwnode_get_name(fwspec->fwnode);
+
+	if (fwname && sscanf(fwname, "HPET-MSI-%u", &val) == 1 &&
+	    val == fwspec->param)
+		return 1;
+
 	return 0;
 }
 
-- 
2.47.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] x86/apic: Replace deprecated simple_strtol() with sscanf() in x86_fwspec_is_hpet()
  2026-10-05 16:32 ` [PATCH v2 2/2] x86/apic: Replace deprecated simple_strtol() with sscanf() in x86_fwspec_is_hpet() Habil Eren Türker
@ 2026-10-06  3:11   ` kernel test robot
  2026-10-06  5:09   ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-10-06  3:11 UTC (permalink / raw)
  To: Habil Eren Türker, tglx, mingo, bp, dave.hansen, x86
  Cc: oe-kbuild-all, hpa, linux-kernel, Habil Eren Türker

Hi Habil,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/x86/core]
[also build test WARNING on linus/master v7.3-rc6 next-20261005]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Habil-Eren-T-rker/x86-apic-Replace-deprecated-simple_strtol-with-sscanf-for-robust-parsing/20261005-163219
base:   tip/x86/core
patch link:    https://lore.kernel.org/r/20261005163213.6515-3-habilerenturker%40hotmail.com
patch subject: [PATCH v2 2/2] x86/apic: Replace deprecated simple_strtol() with sscanf() in x86_fwspec_is_hpet()
config: x86_64-buildonly-randconfig-1004-20261006 (https://download.01.org/0day-ci/archive/20261006/202610061159.7E9WkD7I-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261006/202610061159.7E9WkD7I-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610061159.7E9WkD7I-lkp@intel.com/

All warnings (new ones prefixed by >>):

   arch/x86/kernel/apic/vector.c: In function 'x86_fwspec_is_hpet':
>> arch/x86/kernel/apic/vector.c:700:17: warning: comparison between pointer and integer
     700 |             val == fwspec->param)
         |                 ^~


vim +700 arch/x86/kernel/apic/vector.c

   685	
   686	int x86_fwspec_is_hpet(struct irq_fwspec *fwspec)
   687	{
   688		const char *fwname;
   689		unsigned int val;
   690	
   691		if (fwspec->param_count != 1)
   692			return 0;
   693	
   694		if (!is_fwnode_irqchip(fwspec->fwnode))
   695			return 0;
   696	
   697		fwname = fwnode_get_name(fwspec->fwnode);
   698	
   699		if (fwname && sscanf(fwname, "HPET-MSI-%u", &val) == 1 &&
 > 700		    val == fwspec->param)
   701			return 1;
   702	
   703		return 0;
   704	}
   705	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] x86/apic: Replace deprecated simple_strtol() with sscanf() in x86_fwspec_is_hpet()
  2026-10-05 16:32 ` [PATCH v2 2/2] x86/apic: Replace deprecated simple_strtol() with sscanf() in x86_fwspec_is_hpet() Habil Eren Türker
  2026-10-06  3:11   ` kernel test robot
@ 2026-10-06  5:09   ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-10-06  5:09 UTC (permalink / raw)
  To: Habil Eren Türker, tglx, mingo, bp, dave.hansen, x86
  Cc: llvm, oe-kbuild-all, hpa, linux-kernel, Habil Eren Türker

Hi Habil,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/x86/core]
[also build test WARNING on linus/master v7.3-rc6 next-20261005]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Habil-Eren-T-rker/x86-apic-Replace-deprecated-simple_strtol-with-sscanf-for-robust-parsing/20261005-163219
base:   tip/x86/core
patch link:    https://lore.kernel.org/r/20261005163213.6515-3-habilerenturker%40hotmail.com
patch subject: [PATCH v2 2/2] x86/apic: Replace deprecated simple_strtol() with sscanf() in x86_fwspec_is_hpet()
config: x86_64-buildonly-randconfig-1003-20261006 (https://download.01.org/0day-ci/archive/20261006/202610061356.8VHVO1CY-lkp@intel.com/config)
compiler: clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261006/202610061356.8VHVO1CY-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610061356.8VHVO1CY-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> arch/x86/kernel/apic/vector.c:700:10: warning: comparison between pointer and integer ('unsigned int' and 'u32 *' (aka 'unsigned int *')) [-Wpointer-integer-compare]
     700 |             val == fwspec->param)
         |             ~~~ ^  ~~~~~~~~~~~~~
   1 warning generated.


vim +700 arch/x86/kernel/apic/vector.c

   685	
   686	int x86_fwspec_is_hpet(struct irq_fwspec *fwspec)
   687	{
   688		const char *fwname;
   689		unsigned int val;
   690	
   691		if (fwspec->param_count != 1)
   692			return 0;
   693	
   694		if (!is_fwnode_irqchip(fwspec->fwnode))
   695			return 0;
   696	
   697		fwname = fwnode_get_name(fwspec->fwnode);
   698	
   699		if (fwname && sscanf(fwname, "HPET-MSI-%u", &val) == 1 &&
 > 700		    val == fwspec->param)
   701			return 1;
   702	
   703		return 0;
   704	}
   705	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-06  5:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-05 16:32 [PATCH v2 0/2] x86/apic: Replace deprecated simple_strtol() with sscanf() for robust parsing Habil Eren Türker
2026-10-05 16:32 ` [PATCH v2 1/2] " Habil Eren Türker
2026-10-05 16:32 ` [PATCH v2 2/2] x86/apic: Replace deprecated simple_strtol() with sscanf() in x86_fwspec_is_hpet() Habil Eren Türker
2026-10-06  3:11   ` kernel test robot
2026-10-06  5:09   ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®