From: Vasily Averin Date: Fri, 10 Apr 2020 21:34:13 +0000 (-0700) Subject: ipc/util.c: sysvipc_find_ipc() should increase position index X-Git-Tag: baikal/mips/sdk5.9~13875^2 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=cc91a2162246f21e5020f6a10d0d2557b65efd77;p=kernel.git ipc/util.c: sysvipc_find_ipc() should increase position index If seq_file .next function does not change position index, read after some lseek can generate unexpected output. https://bugzilla.kernel.org/show_bug.cgi?id=206283 Signed-off-by: Vasily Averin Signed-off-by: Andrew Morton Acked-by: Waiman Long Cc: Davidlohr Bueso Cc: Manfred Spraul Cc: Al Viro Cc: Ingo Molnar Cc: NeilBrown Cc: Peter Oberparleiter Cc: Steven Rostedt Link: http://lkml.kernel.org/r/b7a20945-e315-8bb0-21e6-3875c14a8494@virtuozzo.com Signed-off-by: Linus Torvalds --- diff --git a/ipc/util.c b/ipc/util.c index 97638eb2d7cb1..7acccfded7cb0 100644 --- a/ipc/util.c +++ b/ipc/util.c @@ -764,13 +764,13 @@ static struct kern_ipc_perm *sysvipc_find_ipc(struct ipc_ids *ids, loff_t pos, total++; } + *new_pos = pos + 1; if (total >= ids->in_use) return NULL; for (; pos < ipc_mni; pos++) { ipc = idr_find(&ids->ipcs_idr, pos); if (ipc != NULL) { - *new_pos = pos + 1; rcu_read_lock(); ipc_lock_object(ipc); return ipc;