diff mbox series

[1/1] snic_trc_seq_next should increase position index

Message ID 0617d789-fea3-53ae-cd19-78894d6bbd81@virtuozzo.com (mailing list archive)
State Deferred
Headers show
Series snic: seq_file .next functions should increase position index | expand

Commit Message

Vasily Averin Jan. 24, 2020, 5:56 a.m. UTC
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
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 drivers/scsi/snic/snic_debugfs.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Vasily Averin Feb. 26, 2020, 7:08 a.m. UTC | #1
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

On 1/24/20 8:56 AM, Vasily Averin wrote:
> 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
> Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
> ---
>  drivers/scsi/snic/snic_debugfs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/scsi/snic/snic_debugfs.c b/drivers/scsi/snic/snic_debugfs.c
> index 2b34936..b20c724 100644
> --- a/drivers/scsi/snic/snic_debugfs.c
> +++ b/drivers/scsi/snic/snic_debugfs.c
> @@ -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;
>  }
>  
>
diff mbox series

Patch

diff --git a/drivers/scsi/snic/snic_debugfs.c b/drivers/scsi/snic/snic_debugfs.c
index 2b34936..b20c724 100644
--- a/drivers/scsi/snic/snic_debugfs.c
+++ b/drivers/scsi/snic/snic_debugfs.c
@@ -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;
 }