Skip to contentSkip to conversation

snic_trc_seq_next should increase position index

PATCH In review Vasily Averin 1 participant 2 messages Jan 24, 2020 – Feb 26, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 snic_trc_seq_next should increase position index

if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.

https://bugzilla.kernel.org/show_bug.cgi?id=206283

---
 drivers/scsi/snic/snic_debugfs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/snic/snic_debugfs.c +1 -0
index 2b34936..b20c724 100644
@@ -419,6 +419,7 @@ void snic_stats_debugfs_init(struct snic *snic)
 static void *
 snic_trc_seq_next(struct seq_file *sfp, void *data, loff_t *pos)
 {
+	(*pos)++;
 	return NULL;
 }
 
Signature · 1 line
1.8.3.1
#1 lore raw

James, Martin,
I did not get any feedback from Cisco developers,
could you please pick up this patch?

Unfortunately I have no related hardware and cannot verify the patch.

Usually you can observe following related problems:
- read after lseek beyond end of file, described by NeilBrown in
commit 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface") "dd if=<AFFECTED_FILE> bs=1000 skip=1" will incorrectly generate whole last line

- read after lseek on into middle of last line will output expected rest of last line but then repeat whole last line once again.

- If .show() function generates multi-line output following bash script will never finish.

 $ q=;while read -r r;do echo "$((++q)) $r";done < AFFECTED_FILE
Quoted 22 lines · Vasily Averin

if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.

https://bugzilla.kernel.org/show_bug.cgi?id=206283

---
 drivers/scsi/snic/snic_debugfs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/snic/snic_debugfs.c +1 -0
index 2b34936..b20c724 100644
@@ -419,6 +419,7 @@ void snic_stats_debugfs_init(struct snic *snic)
 static void *
 snic_trc_seq_next(struct seq_file *sfp, void *data, loff_t *pos)
 {
+	(*pos)++;
 	return NULL;
 }