On Wed, Jan 4, 2017 at 5:06 AM, Russell King - ARM Linux <li...@armlinux.org.uk> wrote: > On Wed, Jan 04, 2017 at 01:23:41PM +0100, Julia Lawall wrote: >> Basically, the strategy of the patch is that one may consider it >> preferable to duplicate the structure for the different alternatives, >> rather than use __ro_after_init. Perhaps if the structure were larger, >> then __ro_after_init would be a better choice? > > It depends on not just the size, but how many members need to be > modified, and obviously whether there are likely to be more than one > user of the structure as well. > > So I'd say __ro_after_init rarely makes sense for an operations > structure - the only case I can see is: > > - a large structure > - only a small number of elements need to be modified > - it is only single-use > > which is probably quite rare - this one falls into two out of those > three. > > There's another consideration (imho) too - we may wish, at a later > date, to make .text and .rodata both read-only from the start of the > kernel to harden the kernel against possibly init-time exploitation. > (Think about a buggy built-in driver with emulated hardware - much the > same problem that Kees is trying to address in one of his recent patch > sets but with hotplugged hardware while a screen-saver is active.) > Having function pointers in .rodata rather than the ro-after-init > section would provide better protection.
Agreed: I'd much prefer things just be const. :) As to my confusing question, I hadn't looked at how where the pointers to the structure was being stored, so I was just asking if it, too, could be const, which it can't, and that's fine here. -Kees -- Kees Cook Nexus Security -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.