+ seq_file-fix-problem-when-seeking-mid-record.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: seq_file: fix problem when seeking mid-record
has been added to the -mm tree.  Its filename is
     seq_file-fix-problem-when-seeking-mid-record.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/seq_file-fix-problem-when-seeking-mid-record.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/seq_file-fix-problem-when-seeking-mid-record.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: NeilBrown <neilb@xxxxxxxx>
Subject: seq_file: fix problem when seeking mid-record

If you use lseek or similar (e.g.  pread) to access a location in a
seq_file file that is within a record, rather than at a record boundary,
then the first read will return the remainder of the record, and the
second read will return the whole of that same record (instead of the next
record).  When seeking to a record boundary, the next record is correctly
returned.

This bug was introduced by a recent patch (identified below).  Before that
patch, seq_read() would increment m->index when the last of the buffer was
returned (m->count == 0).  After that patch, we rely on ->next to
increment m->index after filling the buffer - but there was one place
where that didn't happen.

Link: https://lkml.kernel.org/lkml/877e7xl029.fsf@xxxxxxxxxxxxxxxxxxxxxxxx/
Fixes: 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface")
Signed-off-by: NeilBrown <neilb@xxxxxxxx>
Reported-by: Sergei Turchanov <turchanov@xxxxxxxxxxx>
Tested-by: Sergei Turchanov <turchanov@xxxxxxxxxxx>
Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Markus Elfring <Markus.Elfring@xxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx>	[4.19+]
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 fs/seq_file.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/seq_file.c~seq_file-fix-problem-when-seeking-mid-record
+++ a/fs/seq_file.c
@@ -119,6 +119,7 @@ static int traverse(struct seq_file *m,
 		}
 		if (seq_has_overflowed(m))
 			goto Eoverflow;
+		p = m->op->next(m, p, &m->index);
 		if (pos + m->count > offset) {
 			m->from = offset - pos;
 			m->count -= m->from;
@@ -126,7 +127,6 @@ static int traverse(struct seq_file *m,
 		}
 		pos += m->count;
 		m->count = 0;
-		p = m->op->next(m, p, &m->index);
 		if (pos == offset)
 			break;
 	}
_

Patches currently in -mm which might be from neilb@xxxxxxxx are

seq_file-fix-problem-when-seeking-mid-record.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux