mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: SECURITY - data leakage due to incorrect strncpy implementation
@ 2004-01-29  8:57 Martin Schwidefsky
  0 siblings, 0 replies; 9+ messages in thread
From: Martin Schwidefsky @ 2004-01-29  8:57 UTC (permalink / raw)
  To: zaitcev; +Cc: linux-kernel

Hi Pete,
> I do not undestand Alan's position, if he is for it or against it.
> Anyway, in case you want it, here's what I wrote for s390.
> I wrote some userland tests, it seems to check out. BUT I warn you,
> someone better check my assembly.
Learning to write inline assembly? Nice, but it has one small
problem, the count in %r4 is not decremented for 0x00 byte.
Try my little patch.

blue skies,
  Martin.

diff -urN linux-2.6.1/arch/s390/lib/strncpy.S linux-2.6.1-s390/arch/s390/lib/strncpy.S
--- linux-2.6.1/arch/s390/lib/strncpy.S	Fri Jan  9 07:59:45 2004
+++ linux-2.6.1-s390/arch/s390/lib/strncpy.S	Thu Jan 29 09:53:02 2004
@@ -23,8 +23,13 @@
 	LA      3,1(3)
         STC     0,0(1)
 	LA      1,1(1)
-        JZ      strncpy_exit   # ICM inserted a 0x00
+        JZ      strncpy_pad    # ICM inserted a 0x00
         BRCT    4,strncpy_loop # R4 -= 1, jump to strncpy_loop if >  0
 strncpy_exit:
         BR      14
-
+strncpy_clear:
+	STC	0,0(1)
+	LA	1,1(1)
+strncpy_pad:
+	BRCT	4,strncpy_clear
+	BR	14
diff -urN linux-2.6.1/arch/s390/lib/strncpy64.S linux-2.6.1-s390/arch/s390/lib/strncpy64.S
--- linux-2.6.1/arch/s390/lib/strncpy64.S	Fri Jan  9 07:59:10 2004
+++ linux-2.6.1-s390/arch/s390/lib/strncpy64.S	Thu Jan 29 09:53:02 2004
@@ -23,8 +23,13 @@
 	LA      3,1(3)
         STC     0,0(1)
 	LA      1,1(1)
-        JZ      strncpy_exit   # ICM inserted a 0x00
+        JZ      strncpy_pad    # ICM inserted a 0x00
         BRCTG   4,strncpy_loop # R4 -= 1, jump to strncpy_loop if > 0
 strncpy_exit:
         BR      14
-
+strncpy_clear:
+	STC	0,0(1)
+	LA	1,1(1)
+strncpy_pad:
+	BRCTG	4,strncpy_clear
+	BR	14

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Sound updating, security of strlcpy and a question on pci v unload
@ 2003-07-11 19:04 Mikulas Patocka
  2003-07-11 21:45 ` SECURITY - data leakage due to incorrect strncpy implementation Alan Cox
  0 siblings, 1 reply; 9+ messages in thread
From: Mikulas Patocka @ 2003-07-11 19:04 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel Mailing List

> I'm currently updating the prehistoric OSS audio code in 2.5 to include
> all the new 2.4 drivers and 2.4 work. While some of them overlap ALSA
> drivers others are not in ALSA yet either.
>
> Firstly someone turned half the kernel into using strlcpy. Every single
> change I looked at bar two in the sound layer introduced a security
> hole. It looks like whoever did it just fired up a perl macro without
> realising the strncpy properties matter for data copied to user space.
> Looks like the rest wants auditing

What's the difference there? strlcpy always creates null-terminated
string, strncpy doesn't. strncpy in kernel (unlike user strncpy) does not
pad the whole destination buffer with zeros (see comment and
implementation in lib/string.c), so I don't see any point why strncpy
should be more secure.

Mikulas


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

end of thread, other threads:[~2004-01-29  8:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-29  8:57 SECURITY - data leakage due to incorrect strncpy implementation Martin Schwidefsky
  -- strict thread matches above, loose matches on Subject: below --
2003-07-11 19:04 Sound updating, security of strlcpy and a question on pci v unload Mikulas Patocka
2003-07-11 21:45 ` SECURITY - data leakage due to incorrect strncpy implementation Alan Cox
2003-07-11 22:10   ` Alan Cox
2003-07-11 23:49     ` Paul Mackerras
2003-07-12 21:28     ` Horst von Brand
2003-07-13  8:02       ` Alan Cox
2003-07-11 22:44   ` Linus Torvalds
2003-07-11 22:50     ` Alan Cox
2004-01-29  3:11       ` Pete Zaitcev

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

Powered by JetHome