summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Stelmach <l.stelmach@samsung.com>2021-04-14 17:50:51 +0200
committerKarol Lewandowski <k.lewandowsk@samsung.com>2021-04-22 15:46:17 +0200
commitf9d3bb16ec5e5b7cb1a15a6c1f9e958f06da504e (patch)
tree629f78c1a4ee070072b657cdf62e14b2c6b1103d
parentbb8143df6424030d499d03179bfe21a893a19408 (diff)
downloadlinux-tizen-modules-f9d3bb16ec5e5b7cb1a15a6c1f9e958f06da504e.tar.gz
linux-tizen-modules-f9d3bb16ec5e5b7cb1a15a6c1f9e958f06da504e.tar.bz2
linux-tizen-modules-f9d3bb16ec5e5b7cb1a15a6c1f9e958f06da504e.zip
logger: introduce struct logger_set_taglogger-linux-rpi3
Introduce dedicated structure for LOGGER_SET_TAG ioctl, instead of packing and unpacking arguments by hand. Change-Id: Ic3399ab37f55ba2b8a9a976f8c9495fc487fe7f3 Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com> [ Pick only changes in logger.[ch] while moving code out of tree ] Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
-rw-r--r--drivers/staging/android/logger.c16
-rw-r--r--drivers/staging/android/logger.h10
2 files changed, 19 insertions, 7 deletions
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 */