Re: [RFC] 2.5.8 sort kernel tables

Keith Owens (kaos@ocs.com.au)
Fri, 19 Apr 2002 01:38:59 +1000


On Thu, 18 Apr 2002 23:02:11 +1000 (EST),
Paul Mackerras <paulus@samba.org> wrote:
>We already sort the kernel exception table on PPC using an insertion
>sort. We have chrp, pmac, prep sections as well as init, which is why
>we had to do that.

Good, I will pinch that code and use it on all architectures.

>BTW, do you have any valid examples of use of copy_to/from_user or
>get/put_user in an init section?

No, I was using those functions as an example. The problem is
__ex_table, there is other code that uses __ex_table besides
copy_to_user. It is quite legal for an arch setup routine to use a
.fixup/__ex_table wrapper around code that might fail on some platforms
and to have that setup routine marked __init.

For example, arm #defines get8_unaligned_check which uses __ex_table.
__get_qspan_pci_config in ppc also uses __ex_table. Use of any of
these macros (and others) in an __init section will generate unsorted
tables. One table has already broken because of out of order text
sections. Other tables may be broken, depending on what __init code an
architecture uses.

The real nasty is that we do not know if the table is broken until an
exception table entry is used and we fail to find an entry because the
table is not sorted. Some exception table entries will work, others
will not, but there is no mechanism to test if the table is valid, we
blindly assume that it is. It is far safer to sort the tables at boot
time than to hope that they are always sorted.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/