linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Sound updating, security of strlcpy and a question on pci v unload
@ 2003-07-11 17:05 Alan Cox
  2003-07-11 19:04 ` Mikulas Patocka
  2003-07-12  0:08 ` Greg KH
  0 siblings, 2 replies; 13+ messages in thread
From: Alan Cox @ 2003-07-11 17:05 UTC (permalink / raw)
  To: 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

Secondly a question. pci_driver structures seem to lack an owner: field.
What stops a 2.5 module unload occuring while pci is calling the probe
function having seen a new device ? 


-- 
Alan Cox <alan@lxorguk.ukuu.org.uk>

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: Sound updating, security of strlcpy and a question on pci v unload
@ 2003-07-12 14:03 Albert Cahalan
  0 siblings, 0 replies; 13+ messages in thread
From: Albert Cahalan @ 2003-07-12 14:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: mitch

Mitchell Blank Jr writes:
> Mikulas Patocka wrote:

>> 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.
>
> Not only that, I think the point is usually moot anyway.
> If you're filling in a structure to pass to userspace like:
>
>  struct whatever foo;
>  strncpy(foo.name, "My Driver", sizeof(foo.name));
>  foo.count = 1;
>  [...]
>
> then you're STILL probably at risk of data leakage if "struct whatever"
> requires padding on any architecture.  The real fix is to make sure
> that "foo" is explicitly zero'ed out first.  Then strlcpy-vs-strncpy
> becomes a non-issue.

gcc -Wpadding ...

If the compiler has to add padding, then the programmer
most likely messed up. The warning catches stupidity.
Necessary padding can be explicit.




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

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

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-11 17:05 Sound updating, security of strlcpy and a question on pci v unload Alan Cox
2003-07-11 19:04 ` 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
2003-07-11 22:37   ` Sound updating, security of strlcpy and a question on pci v unload Mitchell Blank Jr
2003-07-12  0:08 ` Greg KH
2003-07-12 14:03 Albert Cahalan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).