static long logger_set_tag(struct logger_writer *writer, void __user *arg)
{
+ struct logger_set_tag tag;
int len;
char *p, *q;
- if (copy_from_user(&len, arg, sizeof(int)))
+ if (copy_from_user(&tag, arg, sizeof(struct logger_set_tag)))
return -EFAULT;
- arg += sizeof(int);
-
+ if (tag.len > LOGGER_ENTRY_MAX_PAYLOAD)
+ return -EINVAL;
- p = kzalloc(len, GFP_KERNEL);
+ p = kzalloc(tag.len, GFP_KERNEL);
if (!p)
return -ENOMEM;
- if (copy_from_user(p, arg, len)) {
+ if (copy_from_user(p, (void*)(uintptr_t)tag.ptr, tag.len)) {
kfree(p);
return -EFAULT;
}
- p[len-1] = '\0';
+ p[tag.len - 1] = '\0';
+ len = strlen(p);
q = writer->tag;
writer->tag = p;
- writer->tag_len = len - 1; /* without NULL */
+ writer->tag_len = len;
kfree(q);
return 0;
char msg[0];
};
+/**
+ * struct logger_set_tag
+ * @len: Length of a NULL-terminated tag including '\0'
+ * @ptr: Pointer to a user buffer containing the tag
+ */
+struct logger_set_tag {
+ __u64 len;
+ __u64 ptr;
+};
+
#define LOGGER_LOG_RADIO "log_radio" /* radio-related messages */
#define LOGGER_LOG_EVENTS "log_events" /* system/hardware events */
#define LOGGER_LOG_SYSTEM "log_system" /* system/framework messages */