History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf

Alexei Starovoitov says: ==================== pull-request: bpf 2020-08-21 The following pull-request contains BPF updates for your *net* tree. We've added 11 non-merge commits during the last 5 day(s) which contain a total of 12 files changed, 78 insertions(+), 24 deletions(-). The main changes are: 1) three fixes in BPF task iterator logic, from Yonghong. 2) fix for compressed dwarf sections in vmlinux, from Jiri. 3) fix xdp attach regression, from Andrii. ====================

David S. Miller committed 6 years ago

Commit 4af7b322 parents 774d977 b16fc0912 files · +78 −24Browse files

Showing the changes to kernel (2 of 12 files). Show all

Unified · Split

2 files
  1. kernel/bpf/bpf_iter.c +14 −1
  2. kernel/bpf/task_iter.c +4 −2
kernel/bpf/bpf_iter.c+14−1
@@ -67,6 +67,9 @@ static void bpf_iter_done_stop(struct seq_file *seq) · 66 unmodified lines
6767 iter_priv->done_stop = true;
6868 }
6969
70+/* maximum visited objects before bailing out */
71+#define MAX_ITER_OBJECTS 1000000
72+
7073 /* bpf_seq_read, a customized and simpler version for bpf iterator.
7174 * no_llseek is assumed for this file.
7275 * The following are differences from seq_read():
@@ -79,7 +82,7 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size, · 6 unmodified lines
7982 {
8083 struct seq_file *seq = file->private_data;
8184 size_t n, offs, copied = 0;
82− int err = 0;
85+ int err = 0, num_objs = 0;
8386 void *p;
8487
8588 mutex_lock(&seq->lock);
@@ -135,6 +138,7 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size, · 49 unmodified lines
135138 while (1) {
136139 loff_t pos = seq->index;
137140
141+ num_objs++;
138142 offs = seq->count;
139143 p = seq->op->next(seq, p, &seq->index);
140144 if (pos == seq->index) {
@@ -153,6 +157,15 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size, · 12 unmodified lines
153157 if (seq->count >= size)
154158 break;
155159
160+ if (num_objs >= MAX_ITER_OBJECTS) {
161+ if (offs == 0) {
162+ err = -EAGAIN;
163+ seq->op->stop(seq, p);
164+ goto done;
165+ }
166+ break;
167+ }
168+
156169 err = seq->op->show(seq, p);
157170 if (err > 0) {
158171 bpf_iter_dec_seq_num(seq);
kernel/bpf/task_iter.c+4−2
@@ -29,8 +29,9 @@ static struct task_struct *task_seq_get_next(struct pid_namespace *ns, · 28 unmodified lines
2929
3030 rcu_read_lock();
3131 retry:
32− pid = idr_get_next(&ns->idr, tid);
32+ pid = find_ge_pid(*tid, ns);
3333 if (pid) {
34+ *tid = pid_nr_ns(pid, ns);
3435 task = get_pid_task(pid, PIDTYPE_PID);
3536 if (!task) {
3637 ++*tid;
@@ -178,10 +179,11 @@ again: · 141 unmodified lines
178179 f = fcheck_files(curr_files, curr_fd);
179180 if (!f)
180181 continue;
182+ if (!get_file_rcu(f))
183+ continue;
181184
182185 /* set info->fd */
183186 info->fd = curr_fd;
184− get_file(f);
185187 rcu_read_unlock();
186188 return f;
187189 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t