aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/syscall.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r--kernel/bpf/syscall.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index ccb93277aae2..cf5040fd5434 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -2078,6 +2078,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
2078 info.jited_prog_len = 0; 2078 info.jited_prog_len = 0;
2079 info.xlated_prog_len = 0; 2079 info.xlated_prog_len = 0;
2080 info.nr_jited_ksyms = 0; 2080 info.nr_jited_ksyms = 0;
2081 info.nr_jited_func_lens = 0;
2081 goto done; 2082 goto done;
2082 } 2083 }
2083 2084
@@ -2158,11 +2159,11 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
2158 } 2159 }
2159 2160
2160 ulen = info.nr_jited_ksyms; 2161 ulen = info.nr_jited_ksyms;
2161 info.nr_jited_ksyms = prog->aux->func_cnt; 2162 info.nr_jited_ksyms = prog->aux->func_cnt ? : 1;
2162 if (info.nr_jited_ksyms && ulen) { 2163 if (info.nr_jited_ksyms && ulen) {
2163 if (bpf_dump_raw_ok()) { 2164 if (bpf_dump_raw_ok()) {
2165 unsigned long ksym_addr;
2164 u64 __user *user_ksyms; 2166 u64 __user *user_ksyms;
2165 ulong ksym_addr;
2166 u32 i; 2167 u32 i;
2167 2168
2168 /* copy the address of the kernel symbol 2169 /* copy the address of the kernel symbol
@@ -2170,10 +2171,17 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
2170 */ 2171 */
2171 ulen = min_t(u32, info.nr_jited_ksyms, ulen); 2172 ulen = min_t(u32, info.nr_jited_ksyms, ulen);
2172 user_ksyms = u64_to_user_ptr(info.jited_ksyms); 2173 user_ksyms = u64_to_user_ptr(info.jited_ksyms);
2173 for (i = 0; i < ulen; i++) { 2174 if (prog->aux->func_cnt) {
2174 ksym_addr = (ulong) prog->aux->func[i]->bpf_func; 2175 for (i = 0; i < ulen; i++) {
2175 ksym_addr &= PAGE_MASK; 2176 ksym_addr = (unsigned long)
2176 if (put_user((u64) ksym_addr, &user_ksyms[i])) 2177 prog->aux->func[i]->bpf_func;
2178 if (put_user((u64) ksym_addr,
2179 &user_ksyms[i]))
2180 return -EFAULT;
2181 }
2182 } else {
2183 ksym_addr = (unsigned long) prog->bpf_func;
2184 if (put_user((u64) ksym_addr, &user_ksyms[0]))
2177 return -EFAULT; 2185 return -EFAULT;
2178 } 2186 }
2179 } else { 2187 } else {
@@ -2182,7 +2190,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
2182 } 2190 }
2183 2191
2184 ulen = info.nr_jited_func_lens; 2192 ulen = info.nr_jited_func_lens;
2185 info.nr_jited_func_lens = prog->aux->func_cnt; 2193 info.nr_jited_func_lens = prog->aux->func_cnt ? : 1;
2186 if (info.nr_jited_func_lens && ulen) { 2194 if (info.nr_jited_func_lens && ulen) {
2187 if (bpf_dump_raw_ok()) { 2195 if (bpf_dump_raw_ok()) {
2188 u32 __user *user_lens; 2196 u32 __user *user_lens;
@@ -2191,9 +2199,16 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
2191 /* copy the JITed image lengths for each function */ 2199 /* copy the JITed image lengths for each function */
2192 ulen = min_t(u32, info.nr_jited_func_lens, ulen); 2200 ulen = min_t(u32, info.nr_jited_func_lens, ulen);
2193 user_lens = u64_to_user_ptr(info.jited_func_lens); 2201 user_lens = u64_to_user_ptr(info.jited_func_lens);
2194 for (i = 0; i < ulen; i++) { 2202 if (prog->aux->func_cnt) {
2195 func_len = prog->aux->func[i]->jited_len; 2203 for (i = 0; i < ulen; i++) {
2196 if (put_user(func_len, &user_lens[i])) 2204 func_len =
2205 prog->aux->func[i]->jited_len;
2206 if (put_user(func_len, &user_lens[i]))
2207 return -EFAULT;
2208 }
2209 } else {
2210 func_len = prog->jited_len;
2211 if (put_user(func_len, &user_lens[0]))
2197 return -EFAULT; 2212 return -EFAULT;
2198 } 2213 }
2199 } else { 2214 } else {