Re: [PATCH] modpost: detect unterminated device id lists

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Satyam Sharma <satyam.sharma@...>
Cc: Greg KH <greg@...>, Alexey Dobriyan <adobriyan@...>, <linux-kernel@...>, Andrew Morton <akpm@...>, Jeff Garzik <jeff@...>, Michael Wu <flamingice@...>, Ben Collins <bcollins@...>
Date: Sunday, September 16, 2007 - 11:45 pm

Hi Satyam,

On Mon, Sep 17, 2007 at 06:52:52AM +0530, Satyam Sharma wrote:

Thanks!  Hmm, perhaps I'll take that on when I learn kobjects better.  :)


That's true.  I actually threw away an earlier version of this patch
that made some extensive changes to the elf parser (due to the NOBITS
thing I explain below), but instead opted for the smaller version that
stayed out of there.


Ah, yeah, that's much nicer.  I think I must have still have my ELF
parser hat on when I wrote that.  ;)


That's true, yeah.


Yeah, that bugged me when I put that in too.  :)  Yes, "an empty" is
better.


In the ELF format, the .bss segment is initialized by the loader to all
zeros, but it contains no in-file representation (since it's all zeros
and would be a waste of space).  Such segments are flags as "SHT_NOBITS"
meaning that the loader must allocate cleared memory instead of loading
the segment from the file.

In the case of modules that have a totally empty *_device_id list (?!),
the compiler optimizes this into the .bss segment, since there is no need
to store an all-zero-contents object in a segment that would be loaded
from the file itself.

As a result, attempting to dereference such a symbol without noticing
the SHT_NOBITS flag lands you somewhere in uninitialized memory.  So,
the above code basically side-steps the incorrect symbol location
calculation and just aims it at a cleared part of memory.

As I mentioned, there was a larger patch that attempted to sort this
out in the elf parser, but I didn't like it; it was big, not 100%
correct, and the above approach seemed like a much less invasive change.

The cleanups you suggested, who should I send those to?  Or will you (or
Sam?) make them directly to the kbuild.git tree?  (I've never poked at
this part of the kernel source before... I'm unclear on the processes
surrounding it maintainership.)

Thanks!

-Kees

-- 
Kees Cook
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] pci: fix unterminated pci_device_id lists, Kees Cook, (Wed Sep 12, 2:41 am)
Re: [PATCH] pci: fix unterminated pci_device_id lists, Jeff Garzik, (Wed Sep 12, 7:10 am)
Re: [PATCH] pci: fix unterminated pci_device_id lists, Alexey Dobriyan, (Wed Sep 12, 7:48 am)
Re: [PATCH] modpost: detect unterminated device id lists, Satyam Sharma, (Sun Sep 16, 9:22 pm)
Re: [PATCH] modpost: detect unterminated device id lists, Kees Cook, (Sun Sep 16, 11:45 pm)
Re: [PATCH] modpost: detect unterminated device id lists, Andrew Morton, (Mon Sep 17, 2:48 am)
Re: [PATCH] modpost: detect unterminated device id lists, Andrew Morton, (Sun Sep 16, 6:14 pm)
Re: [PATCH] modpost: detect unterminated device id lists, Satyam Sharma, (Sun Sep 16, 8:24 pm)
Re: [PATCH] modpost: detect unterminated device id lists, Andrew Morton, (Mon Sep 17, 2:46 am)
Re: [PATCH] modpost: detect unterminated device id lists, Satyam Sharma, (Mon Sep 17, 5:45 pm)
Re: [PATCH] modpost: detect unterminated device id lists, Andrew Morton, (Mon Sep 17, 5:50 pm)
Re: [PATCH] modpost: detect unterminated device id lists, Mauro Carvalho Chehab, (Mon Sep 17, 7:36 pm)
Re: [PATCH] modpost: detect unterminated device id lists, Andrew Morton, (Wed Sep 12, 9:21 pm)
Re: [PATCH] pci: fix unterminated pci_device_id lists, Andrew Morton, (Wed Sep 12, 7:08 pm)
Re: [PATCH] pci: fix unterminated pci_device_id lists, Alexey Dobriyan, (Thu Sep 13, 2:34 am)
Re: [PATCH] pci: fix unterminated pci_device_id lists, Sam Ravnborg, (Thu Sep 13, 2:58 am)
Re: [PATCH] pci: fix unterminated pci_device_id lists, Jeff Garzik, (Thu Sep 13, 2:42 am)
Re: [PATCH] pci: fix unterminated pci_device_id lists, Jan Engelhardt, (Sat Sep 15, 5:01 am)