smack:beyond ARRAY_SIZE of data
Subsystems (2)
PATCH 1/1 smack:beyond ARRAY_SIZE of data
Do not go beyond ARRAY_SIZE of data
---
security/smack/smackfs.c +1 -1
@@ -797,7 +797,7 @@ static ssize_t smk_write_netlbladdr(struct file *file, const char __user *buf,return -EPERM ;if (*ppos !=0 )return -EINVAL ; -if (count <SMK_NETLBLADDRMIN || count >SMK_NETLBLADDRMAX ) +if (count <SMK_NETLBLADDRMIN || count >=SMK_NETLBLADDRMAX )return -EINVAL ;if (copy_from_user (data, buf, count) !=0 )return -EFAULT ;
Casey Schaufler
maintainerQuoted 9 lines · Roel Kluin
Do not go beyond
ARRAY_SIZEof dataSigned-off-by Roel Kluin <[email protected]>---
security/smack/smackfs.c +0
-0
security/smack/smackfs.c static ssize_t smk_write_netlbladdr(struct file *file, const char __user *buf, · line 801
Quoted 6 lines
security/smack/smackfs.c +1
-1@@ -797,7 +797,7 @@ static ssize_t smk_write_netlbladdr(struct file *file, const char __user *buf,return -EPERM ;if (*ppos !=0 )return -EINVAL ; -if (count <SMK_NETLBLADDRMIN || count >SMK_NETLBLADDRMAX ) +if (count <SMK_NETLBLADDRMIN || count >=SMK_NETLBLADDRMAX )
There is a problem here, but this won't fix it. The buffer needs to be allocated bigger than the potential contents (should be SMK_NETLBLADDRMAX + 1 instead of SMK_NETLBLADDRMAX. Your patch will clip the last byte off of a maximum length specification.
Quoted 11 lines
security/smack/smackfs.c +0
-0return -EINVAL ;if (copy_from_user (data, buf, count) !=0 )return
-EFAULT;--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Do not go beyond ARRAY_SIZE of data
---
Quoted 8 lines
Review
Quoted 3 lines
(quoted diff) +1
-1- if (count < SMK_NETLBLADDRMIN || count > SMK_NETLBLADDRMAX) + if (count < SMK_NETLBLADDRMIN || count >= SMK_NETLBLADDRMAX)There is a problem here, but this won't fix it. The buffer needs to be allocated bigger than the potential contents (should be
SMK_NETLBLADDRMAX+ 1 instead ofSMK_NETLBLADDRMAX. Your patch will clip the last byte off of a maximum length specification.
Ok, how about this?
security/smack/smackfs.c +1 -1
@@ -775,7 +775,7 @@ static ssize_t smk_write_netlbladdr(struct file *file, const char __user *buf,struct sockaddr_in newname;char smack[SMK_LABELLEN ];char *sp; -char data[SMK_NETLBLADDRMAX ]; +char data[SMK_NETLBLADDRMAX +1 ];char *host = (char *)&newname.sin_addr.s_addr;int rc;struct netlbl_audit audit_info;
Quoted 4 lines · Roel Kluin
Do not go beyond
ARRAY_SIZEof dataSigned-off-by Roel Kluin <[email protected]>
Thank you. The fix is appreciated.
Quoted 36 lines
---
Quoted 9 lines
Review
Quoted 4 lines
(quoted diff) +1
-1- if (count < SMK_NETLBLADDRMIN || count > SMK_NETLBLADDRMAX) + if (count < SMK_NETLBLADDRMIN || count >= SMK_NETLBLADDRMAX)There is a problem here, but this won't fix it. The buffer needs to be allocated bigger than the potential contents (should be
SMK_NETLBLADDRMAX+ 1 instead ofSMK_NETLBLADDRMAX. Your patch will clip the last byte off of a maximum length specification.Ok, how about this?
security/smack/smackfs.c +1
-2@@ -775,7 +775,7 @@ static ssize_t smk_write_netlbladdr(struct file *file, const char __user *buf,struct sockaddr_in newname;char smack[SMK_LABELLEN ];char *sp; -char data[SMK_NETLBLADDRMAX ]; +char data[SMK_NETLBLADDRMAX +1 ];char *host = (char *)&newname.sin_addr.s_addr;int rc;struct netlbl_audit audit_info; --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
James Morris
maintainerQuoted 10 lines · Casey Schaufler
Quoted 4 lines · Roel Kluin
Do not go beyond
ARRAY_SIZEof dataSigned-off-by Roel Kluin <[email protected]>Acked-by Casey Schaufler <[email protected]>Thank you. The fix is appreciated.
Applied togit://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next
(This needs CAP_MAC_ADMIN to trigger, so I'll assume this is not security-critical, but yell if you disagree).
- James
Signature · 2 lines
James Morris <[email protected]>
Casey Schaufler
maintainerQuoted 16 lines · James Morris
Quoted 12 lines · Casey Schaufler
Quoted 5 lines · Roel Kluin
Do not go beyond
ARRAY_SIZEof dataSigned-off-by Roel Kluin <[email protected]>Acked-by Casey Schaufler <[email protected]>Thank you. The fix is appreciated.
Quoted 7 lines
Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next(This needs
CAP_MAC_ADMINto trigger, so I'll assume this is not security-critical, but yell if you disagree).
Not security critical.
Quoted 2 lines
- James