Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9813116f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "qmp: Add support for QSSP Enhancements"

parents 7d7cf1e2 fd65d03f
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -22,12 +22,12 @@ static void encode_seemp_section(char *section_start, char *section_eq,
				char *section_end, bool param, bool numeric,
				int id, __s32 numeric_value);

static void check_param_range(char *section_eq, bool *param,
static void check_param_range(char *section_eq, bool param,
	bool *numeric, int val_len, __s32 *numeric_value)
{
	long long_value = 0;

	if (*param && *numeric) {
	if (param && *numeric) {
		/*check if 2 bytes & in[-99999,999999]*/
		*numeric = (val_len >= 2) && (val_len <= 6);
		if (*numeric) {
@@ -35,9 +35,12 @@ static void check_param_range(char *section_eq, bool *param,
			!= 0) {
				*numeric = false;
			} else {
				*numeric_value = (__s16)long_value;
				*numeric = (*numeric_value >= -32768) &&
					(*numeric_value <= 32767);
				*numeric_value = (__s32)long_value;
				/* We are checking whether the value
				*  lies within 16bits
				*/
				*numeric = (long_value >= -32768) &&
					(long_value <= 32767);
			}
		}
	}
@@ -96,7 +99,7 @@ void encode_seemp_params(struct seemp_logk_blk *blk)
				ch = *s;
				*s = 0;

				check_param_range(section_eq, &param,
				check_param_range(section_eq, param,
					&numeric, val_len, &numeric_value);
				*s = ch;
			}
+4 −89
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@

#define MASK_BUFFER_SIZE 256
#define FOUR_MB 4
#define USER_APP_START_UID 10000
#define YEAR_BASE 1900

static struct seemp_logk_dev *slogk_dev;
@@ -55,7 +54,6 @@ static long seemp_logk_reserve_rdblks(
static long seemp_logk_set_mask(unsigned long arg);
static long seemp_logk_set_mapping(unsigned long arg);
static long seemp_logk_check_filter(unsigned long arg);
static int get_uid_from_message_for_system_event(const char *buffer);

void* (*seemp_logk_kernel_begin)(char **buf);

@@ -78,7 +76,6 @@ void *seemp_logk_kernel_start_record(char **buf)
	int ret;

	DEFINE_WAIT(write_wait);

	ret = 0;
	idx = 0;
	now = current_kernel_time();
@@ -149,87 +146,17 @@ void *seemp_logk_kernel_start_record(char **buf)

void seemp_logk_kernel_end_record(void *blck)
{
	int current_uid_val = 0;
	int parsed_current_uid = 0;
	struct seemp_logk_blk *blk = (struct seemp_logk_blk *)blck;

	if (blk) {
		/*update status at the very end*/
		blk->status |= 0x1;
		current_uid_val = (current_uid()).val;
		if (current_uid_val < USER_APP_START_UID) {
			parsed_current_uid =
			get_uid_from_message_for_system_event(blk->payload.msg);
			if (parsed_current_uid != -1)
				blk->uid = parsed_current_uid;
			else
				blk->uid = current_uid_val;
		} else
			blk->uid = current_uid_val;
		blk->uid =  (current_uid()).val;

		ringbuf_finish_writer(slogk_dev, blk);
	}
}

/*
 * get_uid_from_message_for_system_event() - helper function to get the
 * uid of the actual app that is changing the state and updating it
 * accordingly rather than with the system UID = 1000
 * NOTE: Not a very efficient implementation. This does a N*8 character
 * comparisons everytime a message with UID less than 10000 is seen
 */
static int get_uid_from_message_for_system_event(const char *buffer)
{
	char asciiuid[6];
	long appuid = 0;
	int aindex = 0;
	char *comparator_string = "app_uid=";
	int ret = 0;

	char *p1 = (char *)buffer;

	while (*p1) {
		char *p1begin = p1;
		char *p2 = (char *)comparator_string;

		aindex = 0;

		while (*p1 && *p2 && *p1 == *p2) {
			p1++;
			p2++;
		}

		if (*p2 == '\0') {
			while ((*p1) && (aindex < 5)
				&& (*p1 != ',')) {
				asciiuid[aindex++] = *p1;
				p1++;
			}
			if (*p1 != ',') {
				pr_err("Failed to get app_id\n");
				return -EPERM;
			}
			asciiuid[aindex] = '\0';

			/*
			 * now get the integer value of this ascii
			 * string number
			 */
			ret = kstrtol(asciiuid, 10, &appuid);
			if (ret != 0) {
				pr_err("failed in the kstrtol function uid:%s\n",
						asciiuid);
				return ret;
			} else {
				return (int)(appuid);
			}
		}

		p1 = p1begin + 1;
	}
	return -EPERM;
}

static int seemp_logk_usr_record(const char __user *buf, size_t count)
{
	struct seemp_logk_blk *blk;
@@ -238,10 +165,8 @@ static int seemp_logk_usr_record(const char __user *buf, size_t count)
	struct timespec now;
	struct tm ts;
	int idx, ret;
	int currentuid;
	int parsedcurrentuid;
	DEFINE_WAIT(write_wait);

	DEFINE_WAIT(write_wait);
	if (buf) {
		local_blk = (struct seemp_logk_blk *)buf;
		if (copy_from_user(&usr_blk.pid, &local_blk->pid,
@@ -301,16 +226,7 @@ static int seemp_logk_usr_record(const char __user *buf, size_t count)

	memcpy(&blk->payload, &usr_blk.payload, sizeof(struct blk_payload));
	blk->pid = usr_blk.pid;
	currentuid = usr_blk.uid;
	if (currentuid <= USER_APP_START_UID) {
		parsedcurrentuid = get_uid_from_message_for_system_event
							(blk->payload.msg);
		if (parsedcurrentuid != -EPERM)
			blk->uid = parsedcurrentuid;
		else
			blk->uid = currentuid;
	} else
		blk->uid = currentuid;
	blk->uid = usr_blk.uid;
	blk->tid = usr_blk.tid;
	blk->sec = now.tv_sec;
	blk->nsec = now.tv_nsec;
@@ -421,7 +337,6 @@ static long seemp_logk_reserve_rdblks(
	struct read_range rrange;

	DEFINE_WAIT(read_wait);

	mutex_lock(&sdev->lock);
	if (sdev->num_writers > 0 || sdev->num_read_avail_blks <= 0) {
		ret = -EPERM;
@@ -679,7 +594,7 @@ __init int seemp_logk_init(void)
	}

	slogk_dev = kmalloc(sizeof(*slogk_dev), GFP_KERNEL);
	if (!slogk_dev)
	if (slogk_dev == NULL)
		return -ENOMEM;

	slogk_dev->ring_sz = ring_sz;
+1 −1
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ struct seemp_logk_dev {
};

#define BLK_SIZE       256
#define BLK_HDR_SIZE   68
#define BLK_HDR_SIZE   64
#define TS_SIZE        20
#define BLK_MAX_MSG_SZ (BLK_SIZE - BLK_HDR_SIZE)

+0 −8
Original line number Diff line number Diff line
@@ -87,8 +87,6 @@
#include <linux/slab.h>
#include <linux/flex_array.h>
#include <linux/posix-timers.h>
#include <linux/seemp_api.h>
#include <linux/seemp_instrumentation.h>
#ifdef CONFIG_HARDWALL
#include <asm/hardwall.h>
#endif
@@ -870,9 +868,6 @@ static ssize_t oom_adj_write(struct file *file, const char __user *buf,
		goto out;
	}

	seemp_logk_oom_adjust_write(task->pid,
			task->cred->uid, oom_adj);

	task_lock(task);
	if (!task->mm) {
		err = -EINVAL;
@@ -976,9 +971,6 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
		goto out;
	}

	seemp_logk_oom_adjust_write(task->pid,
			task->cred->uid, oom_score_adj);

	task_lock(task);
	if (!task->mm) {
		err = -EINVAL;
+391 −416

File changed.

Preview size limit exceeded, changes collapsed.

Loading