smackfs: restrict bytes count in smk_set_cipso()
[linux-2.6-microblaze.git] / security / smack / smackfs.c
index 22ded2c..3a75d2a 100644 (file)
@@ -380,7 +380,7 @@ static int smk_parse_rule(const char *data, struct smack_parsed_rule *rule,
  * @data: string to be parsed, null terminated
  * @rule: Will be filled with Smack parsed rule
  * @import: if non-zero, import labels
- * @tokens: numer of substrings expected in data
+ * @tokens: number of substrings expected in data
  *
  * Returns number of processed bytes on success, -ERRNO on failure.
  */
@@ -855,6 +855,8 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
        if (format == SMK_FIXED24_FMT &&
            (count < SMK_CIPSOMIN || count > SMK_CIPSOMAX))
                return -EINVAL;
+       if (count > PAGE_SIZE)
+               return -EINVAL;
 
        data = memdup_user_nul(buf, count);
        if (IS_ERR(data))