From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 03/11] netfilter: xt_recent: recent_seq_next should increase position index
Date: Fri, 6 Mar 2020 19:15:05 +0100 [thread overview]
Message-ID: <20200306181513.656594-4-pablo@netfilter.org> (raw)
In-Reply-To: <20200306181513.656594-1-pablo@netfilter.org>
From: Vasily Averin <vvs@virtuozzo.com>
If .next function does not change position index,
following .show function will repeat output related
to current position index.
Without the patch:
# dd if=/proc/net/xt_recent/SSH # original file outpt
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
Cc: stable@vger.kernel.org
Fixes: 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code ...")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206283
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/xt_recent.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index 0a9708004e20..225a7ab6d79a 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -492,12 +492,12 @@ static void *recent_seq_next(struct seq_file *seq, void *v, loff_t *pos)
const struct recent_entry *e = v;
const struct list_head *head = e->list.next;
+ (*pos)++;
while (head == &t->iphash[st->bucket]) {
if (++st->bucket >= ip_list_hash_size)
return NULL;
head = t->iphash[st->bucket].next;
}
- (*pos)++;
return list_entry(head, struct recent_entry, list);
}
--
2.11.0
next prev parent reply other threads:[~2020-03-06 18:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-06 18:15 [PATCH 00/11] Netfilter fixes for net Pablo Neira Ayuso
2020-03-06 18:15 ` [PATCH 01/11] netfilter: nf_conntrack: ct_cpu_seq_next should increase position index Pablo Neira Ayuso
2020-03-06 18:15 ` [PATCH 02/11] netfilter: synproxy: synproxy_cpu_seq_next " Pablo Neira Ayuso
2020-03-06 18:15 ` Pablo Neira Ayuso [this message]
2020-03-06 18:15 ` [PATCH 04/11] netfilter: x_tables: xt_mttg_seq_next " Pablo Neira Ayuso
2020-03-06 18:15 ` [PATCH 05/11] netfilter: nf_tables: free flowtable hooks on hook register error Pablo Neira Ayuso
2020-03-06 18:15 ` [PATCH 06/11] netfilter: cthelper: add missing attribute validation for cthelper Pablo Neira Ayuso
2020-03-06 18:15 ` [PATCH 07/11] netfilter: nft_payload: add missing attribute validation for payload csum flags Pablo Neira Ayuso
2020-03-06 18:15 ` [PATCH 08/11] netfilter: nft_tunnel: add missing attribute validation for tunnels Pablo Neira Ayuso
2020-03-06 18:15 ` [PATCH 09/11] netfilter: nf_tables: dump NFTA_CHAIN_FLAGS attribute Pablo Neira Ayuso
2020-03-06 18:15 ` [PATCH 10/11] netfilter: nf_tables: fix infinite loop when expr is not available Pablo Neira Ayuso
2020-03-06 18:15 ` [PATCH 11/11] netfilter: nft_chain_nat: inet family is missing module ownership Pablo Neira Ayuso
2020-03-07 5:38 ` [PATCH 00/11] Netfilter fixes for net David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200306181513.656594-4-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).