Skip to content

Commit fe55731

Browse files
Christoph Hellwigtorvalds
authored andcommitted
maccess: rename probe_kernel_{read,write} to copy_{from,to}_kernel_nofault
Better describe what these functions do. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b3a9e3b commit fe55731

50 files changed

Lines changed: 138 additions & 122 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/arm/kernel/ftrace.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ static int ftrace_modify_code(unsigned long pc, unsigned long old,
8484
old = __opcode_to_mem_arm(old);
8585

8686
if (validate) {
87-
if (probe_kernel_read(&replaced, (void *)pc, MCOUNT_INSN_SIZE))
87+
if (copy_from_kernel_nofault(&replaced, (void *)pc,
88+
MCOUNT_INSN_SIZE))
8889
return -EFAULT;
8990

9091
if (replaced != old)

‎arch/arm/kernel/kgdb.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
236236
/* patch_text() only supports int-sized breakpoints */
237237
BUILD_BUG_ON(sizeof(int) != BREAK_INSTR_SIZE);
238238

239-
err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
239+
err = copy_from_kernel_nofault(bpt->saved_instr, (char *)bpt->bpt_addr,
240240
BREAK_INSTR_SIZE);
241241
if (err)
242242
return err;

‎arch/arm64/kernel/insn.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ int __kprobes aarch64_insn_read(void *addr, u32 *insnp)
135135
int ret;
136136
__le32 val;
137137

138-
ret = probe_kernel_read(&val, addr, AARCH64_INSN_SIZE);
138+
ret = copy_from_kernel_nofault(&val, addr, AARCH64_INSN_SIZE);
139139
if (!ret)
140140
*insnp = le32_to_cpu(val);
141141

@@ -151,7 +151,7 @@ static int __kprobes __aarch64_insn_write(void *addr, __le32 insn)
151151
raw_spin_lock_irqsave(&patch_lock, flags);
152152
waddr = patch_map(addr, FIX_TEXT_POKE0);
153153

154-
ret = probe_kernel_write(waddr, &insn, AARCH64_INSN_SIZE);
154+
ret = copy_to_kernel_nofault(waddr, &insn, AARCH64_INSN_SIZE);
155155

156156
patch_unmap(FIX_TEXT_POKE0);
157157
raw_spin_unlock_irqrestore(&patch_lock, flags);

‎arch/csky/kernel/ftrace.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ static int ftrace_check_current_nop(unsigned long hook)
7272
uint16_t olds[7];
7373
unsigned long hook_pos = hook - 2;
7474

75-
if (probe_kernel_read((void *)olds, (void *)hook_pos, sizeof(nops)))
75+
if (copy_from_kernel_nofault((void *)olds, (void *)hook_pos,
76+
sizeof(nops)))
7677
return -EFAULT;
7778

7879
if (memcmp((void *)nops, (void *)olds, sizeof(nops))) {
@@ -97,7 +98,7 @@ static int ftrace_modify_code(unsigned long hook, unsigned long target,
9798

9899
make_jbsr(target, hook, call, nolr);
99100

100-
ret = probe_kernel_write((void *)hook_pos, enable ? call : nops,
101+
ret = copy_to_kernel_nofault((void *)hook_pos, enable ? call : nops,
101102
sizeof(nops));
102103
if (ret)
103104
return -EPERM;

‎arch/ia64/kernel/ftrace.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
108108
goto skip_check;
109109

110110
/* read the text we want to modify */
111-
if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
111+
if (copy_from_kernel_nofault(replaced, (void *)ip, MCOUNT_INSN_SIZE))
112112
return -EFAULT;
113113

114114
/* Make sure it is what we expect it to be */
@@ -117,7 +117,7 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
117117

118118
skip_check:
119119
/* replace the text with the new text */
120-
if (probe_kernel_write(((void *)ip), new_code, MCOUNT_INSN_SIZE))
120+
if (copy_to_kernel_nofault(((void *)ip), new_code, MCOUNT_INSN_SIZE))
121121
return -EPERM;
122122
flush_icache_range(ip, ip + MCOUNT_INSN_SIZE);
123123

@@ -129,7 +129,7 @@ static int ftrace_make_nop_check(struct dyn_ftrace *rec, unsigned long addr)
129129
unsigned char __attribute__((aligned(8))) replaced[MCOUNT_INSN_SIZE];
130130
unsigned long ip = rec->ip;
131131

132-
if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
132+
if (copy_from_kernel_nofault(replaced, (void *)ip, MCOUNT_INSN_SIZE))
133133
return -EFAULT;
134134
if (rec->flags & FTRACE_FL_CONVERTED) {
135135
struct ftrace_call_insn *call_insn, *tmp_call;

‎arch/mips/kernel/kprobes.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
8686
goto out;
8787
}
8888

89-
if ((probe_kernel_read(&prev_insn, p->addr - 1,
90-
sizeof(mips_instruction)) == 0) &&
91-
insn_has_delayslot(prev_insn)) {
89+
if (copy_from_kernel_nofault(&prev_insn, p->addr - 1,
90+
sizeof(mips_instruction)) == 0 &&
91+
insn_has_delayslot(prev_insn)) {
9292
pr_notice("Kprobes for branch delayslot are not supported\n");
9393
ret = -EINVAL;
9494
goto out;

‎arch/nds32/kernel/ftrace.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,14 @@ static int __ftrace_modify_code(unsigned long pc, unsigned long *old_insn,
131131
unsigned long orig_insn[3];
132132

133133
if (validate) {
134-
if (probe_kernel_read(orig_insn, (void *)pc, MCOUNT_INSN_SIZE))
134+
if (copy_from_kernel_nofault(orig_insn, (void *)pc,
135+
MCOUNT_INSN_SIZE))
135136
return -EFAULT;
136137
if (memcmp(orig_insn, old_insn, MCOUNT_INSN_SIZE))
137138
return -EINVAL;
138139
}
139140

140-
if (probe_kernel_write((void *)pc, new_insn, MCOUNT_INSN_SIZE))
141+
if (copy_to_kernel_nofault((void *)pc, new_insn, MCOUNT_INSN_SIZE))
141142
return -EPERM;
142143

143144
return 0;

‎arch/parisc/kernel/ftrace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
172172

173173
ip = (void *)(rec->ip + 4 - size);
174174

175-
ret = probe_kernel_read(insn, ip, size);
175+
ret = copy_from_kernel_nofault(insn, ip, size);
176176
if (ret)
177177
return ret;
178178

‎arch/parisc/kernel/kgdb.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long ip)
154154

155155
int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
156156
{
157-
int ret = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
158-
BREAK_INSTR_SIZE);
157+
int ret = copy_from_kernel_nofault(bpt->saved_instr,
158+
(char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
159159
if (ret)
160160
return ret;
161161

‎arch/parisc/lib/memcpy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void * memcpy(void * dst,const void *src, size_t count)
5757
EXPORT_SYMBOL(raw_copy_in_user);
5858
EXPORT_SYMBOL(memcpy);
5959

60-
bool probe_kernel_read_allowed(const void *unsafe_src, size_t size)
60+
bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
6161
{
6262
if ((unsigned long)unsafe_src < PAGE_SIZE)
6363
return false;

0 commit comments

Comments
 (0)