selinux_sb_copy_data requires a whole page?
PATCH 1/1 selinux_sb_copy_data requires a whole page?
Currently selinux_sb_copy_data requires an entire page be allocated to void *orig when the function is called. This "requirement" is based on the fact that we call copy_page(in_save, nosec_save); and in_save = orig. Problem is that the lustre filesystem was calling do_kern_mount with about 10 bytes of options, which got passed here and then we corrupted page size - 10 bytes of memory (with all zeros.) Causing a panic.
The first fix and one that seems we might want to do is change copy_page to memcpy(in_save, nosec_save, strlen(nosec_save)) so we only copy back what we need to.
The lustre fs people have agreed to allocate a whole page because "that's the way sys_mount does it."
Is there a good reason I'm missing why we should require a whole page? Maybe somebody else (or an old version of lustre) is going to hit on this. Comments?
Eric
security/selinux/hooks.c renamed from security/selinux/hooks.c.cor +1 -1
@@ -1980,7 +1980,7 @@ static int selinux_sb_copy_data(struct f } }while (*in_end++); -copy_page (in_save, nosec_save); +memcpy (in_save, nosec_save,strlen (nosec_save));free_page ((unsigned long )nosec_save); out:return rc;
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 3 lines · Eric Paris
Is there a good reason I'm missing why we should require a whole page? Maybe somebody else (or an old version of lustre) is going to hit on this. Comments?
Actually, a strcpy() should work ok here, as the last byte of the options page will always be null terminated (e.g. in do_mount()).
Quoted 19 lines
security/selinux/hooks.c renamed from security/selinux/hooks.c.cor +1
-2@@ -1980,7 +1980,7 @@ static int selinux_sb_copy_data(struct f } }while (*in_end++); -copy_page (in_save, nosec_save); +memcpy (in_save, nosec_save,strlen (nosec_save));free_page ((unsigned long )nosec_save); out:return rc; --This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Signature · 9 lines
James Morris <[email protected]> -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
This would still (maybe) leave sec info in the buffer after the null whereas previously it would have been nulled out. Do we care?
Eric
Quoted 24 lines · James Morris
Quoted 3 lines · Eric Paris
Is there a good reason I'm missing why we should require a whole page? Maybe somebody else (or an old version of lustre) is going to hit on this. Comments?
Actually, a
strcpy()should work ok here, as the last byte of the options page will always be null terminated (e.g. indo_mount()).Quoted 14 lines
security/selinux/hooks.c renamed from security/selinux/hooks.c.cor +1
-1@@ -1980,7 +1980,7 @@ static int selinux_sb_copy_data(struct f } }while (*in_end++); -copy_page (in_save, nosec_save); +memcpy (in_save, nosec_save,strlen (nosec_save));free_page ((unsigned long )nosec_save); out:return rc;
Quoted 6 lines
Quoted 5 lines
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 2 lines · Eric Paris
This would still (maybe) leave sec info in the buffer after the null whereas previously it would have been nulled out. Do we care?
I don't think so. fs code should stop on the NUL byte; if it doesn't, that is a bug in the fs code.
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.