Revert "ipc: replace costly bailout check in sysvipc_find_ipc()"

This reverts commit 5d6d68e94e.
This commit is contained in:
Ksawlii 2024-11-24 00:23:50 +01:00
parent 42755cc6a5
commit 15c909dc17

View file

@ -754,13 +754,21 @@ struct pid_namespace *ipc_seq_pid_ns(struct seq_file *s)
static struct kern_ipc_perm *sysvipc_find_ipc(struct ipc_ids *ids, loff_t pos,
loff_t *new_pos)
{
struct kern_ipc_perm *ipc = NULL;
int max_idx = ipc_get_maxidx(ids);
struct kern_ipc_perm *ipc;
int total, id;
if (max_idx == -1 || pos > max_idx)
total = 0;
for (id = 0; id < pos && total < ids->in_use; id++) {
ipc = idr_find(&ids->ipcs_idr, id);
if (ipc != NULL)
total++;
}
ipc = NULL;
if (total >= ids->in_use)
goto out;
for (; pos <= max_idx; pos++) {
for (; pos < ipc_mni; pos++) {
ipc = idr_find(&ids->ipcs_idr, pos);
if (ipc != NULL) {
rcu_read_lock();