Problem
Environment
- linux version:
4.19.65 - mmap_min_addr:
0x1000 - No SMAP
Module
typedef struct request_t {
uint32_t cmd;
uint32_t arg;
} request_t;
int64_t gnote_write(struct file *a1, const request_t *req, size_t a3,
loff_t *a4) {
uint64_t len;
note_data_t *req;
void *new_note_data;
mutex_lock(&lock);
switch (req->cmd) {
case 1:
if ((uint64_t)cnt <= 7) {
len = (uint32_t)req->arg;
cur_note = ¬es[cnt];
cur_note->len = len;
if (len <= 0x10000) {
new_note_data = kmalloc(len, 0x6000C0LL);
++cnt;
cur_note->data = new_note_data;
}
}
break;
case 2:
printk("Edit Not implemented\n");
break;
case 3:
printk("Delete Not implemented\n");
break;
case 4:
printk("Copy Not implemented\n");
break;
case 5:
if ((uint32_t)req->arg < (uint64_t)cnt) selected = (uint32_t)req->arg;
break;
default:
break;
}
mutex_unlock(&lock);
return a3;
}
uint64_t gnote_read(struct file *a1, char *a2, size_t len, loff_t *a4) {
note_data_t *cur_note;
mutex_lock(&lock);
if (selected == -1) {
mutex_unlock(&lock);
return 0LL;
} else {
cur_note = ¬es[selected];
if (cur_note->len <= len) len = cur_note->len;
copy_to_user(a2, cur_note->data, len);
selected = -1LL;
mutex_unlock(&lock);
return len;
}
}The gnote module has just 3 features: add new note, select note and get note’s content. But with these features, we cannot write content to note (Edit is not implemented…).