Re: [PATCH] ipc/util.c: sysvipc_find_ipc() incorrectly updates position index

From: Matthew Wilcox
Date: Thu May 07 2020 - 23:36:34 EST


On Thu, May 07, 2020 at 05:02:42PM -0700, Andrew Morton wrote:
> Here's how I resolved things. Please check?
>
> static struct kern_ipc_perm *sysvipc_find_ipc(struct ipc_ids *ids, loff_t pos,
> loff_t *new_pos)
> {
> unsigned long index = pos;
> struct kern_ipc_perm *ipc;
>
> rcu_read_lock();
> ipc = xa_find(&ids->ipcs, &index, ULONG_MAX, XA_PRESENT);
> if (ipc)
> ipc_lock_object(ipc);
> else
> rcu_read_unlock();
> *new_pos = pos + 1;
> return ipc;
> }

Surely that should be '*new_pos = index + 1'? Or did I misunderstand
the reasoning behind the other patch?