From: Łukasz Stelmach Date: Wed, 14 Apr 2021 15:50:51 +0000 (+0200) Subject: logger: introduce struct logger_set_tag X-Git-Tag: accepted/tizen/unified/20211126.111914~15^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f9d3bb16ec5e5b7cb1a15a6c1f9e958f06da504e;p=platform%2Fkernel%2Flinux-tizen-modules-source.git logger: introduce struct logger_set_tag Introduce dedicated structure for LOGGER_SET_TAG ioctl, instead of packing and unpacking arguments by hand. Change-Id: Ic3399ab37f55ba2b8a9a976f8c9495fc487fe7f3 Signed-off-by: Łukasz Stelmach [ Pick only changes in logger.[ch] while moving code out of tree ] Signed-off-by: Karol Lewandowski --- diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c index 0d21142..14fb7f7 100644 --- a/drivers/staging/android/logger.c +++ b/drivers/staging/android/logger.c @@ -872,28 +872,30 @@ static long logger_set_prio(struct logger_writer *writer, void __user *arg) 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; diff --git a/drivers/staging/android/logger.h b/drivers/staging/android/logger.h index a02ac11..8054a3e 100644 --- a/drivers/staging/android/logger.h +++ b/drivers/staging/android/logger.h @@ -74,6 +74,16 @@ struct logger_entry { 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 */