]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ipc/util.c: sysvipc_find_ipc() should increase position index
authorVasily Averin <vvs@virtuozzo.com>
Fri, 10 Apr 2020 21:34:13 +0000 (14:34 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 10 Apr 2020 22:36:22 +0000 (15:36 -0700)
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 <vvs@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Waiman Long <longman@redhat.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Manfred Spraul <manfred@colorfullife.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: NeilBrown <neilb@suse.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/b7a20945-e315-8bb0-21e6-3875c14a8494@virtuozzo.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
ipc/util.c

index 97638eb2d7cb1c9ed916f45130427a0a16a4b9f3..7acccfded7cb034c9aeada477af8e0bf61302520 100644 (file)
@@ -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;