[PATCH v2 0/4] netfilter: seq_file .next functions should increase position index

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

 



v2: resend with improved patch description

In Aug 2018 NeilBrown noticed 
commit 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface")
"Some ->next functions do not increment *pos when they return NULL...
Note that such ->next functions are buggy and should be fixed. 
A simple demonstration is
   
dd if=/proc/swaps bs=1000 skip=1
    
Choose any block size larger than the size of /proc/swaps.  This will
always show the whole last line of /proc/swaps"

/proc/swaps output was fixed recently, however there are lot of other
affected files, and few of them of them are related to netfilter subsystem.

For example please take look at recent_seq_next()

 # dd if=/proc/net/xt_recent/SSH # original file output
 src=127.0.0.4 ttl: 0 last_seen: 6275444819 oldest_pkt: 1 6275444819
 src=127.0.0.2 ttl: 0 last_seen: 6275438906 oldest_pkt: 1 6275438906
 src=127.0.0.3 ttl: 0 last_seen: 6275441953 oldest_pkt: 1 6275441953
 0+1 records in
 0+1 records out
 204 bytes copied, 6.1332e-05 s, 3.3 MB/s

Read after lseek into middle of last line (offset 140 in example below)
generates expected end of last line and then unexpected whole last line
once again

 # dd if=/proc/net/xt_recent/SSH bs=140 skip=1
 dd: /proc/net/xt_recent/SSH: cannot skip to specified offset
 127.0.0.3 ttl: 0 last_seen: 6275441953 oldest_pkt: 1 6275441953
 src=127.0.0.3 ttl: 0 last_seen: 6275441953 oldest_pkt: 1 6275441953
 0+1 records in
 0+1 records out
 132 bytes copied, 6.2487e-05 s, 2.1 MB/s

In general if .next function does not change position index,
following .show function will repeat output related
to current position index. I.e. position index should be updated 
even if .next function returns NULL.

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

Vasily Averin (4):
  ct_cpu_seq_next should increase position index
  synproxy_cpu_seq_next should increase position index
  recent_seq_next should increase position index
  xt_mttg_seq_next should increase position index

 net/netfilter/nf_conntrack_standalone.c | 2 +-
 net/netfilter/nf_synproxy_core.c        | 2 +-
 net/netfilter/x_tables.c                | 6 +++---
 net/netfilter/xt_recent.c               | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

-- 
1.8.3.1



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux