netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: inbound connection problems when "netlink: test for all flags of the NLM_F_DUMP composite" commit applied
@ 2011-01-18 17:23 Jarek Poplawski
  2011-01-18 18:10 ` Alessandro Suardi
  0 siblings, 1 reply; 39+ messages in thread
From: Jarek Poplawski @ 2011-01-18 17:23 UTC (permalink / raw)
  To: jamal
  Cc: David Miller, pablo, arthur.marsh, jengelh, eric.dumazet, netdev,
	Alessandro Suardi

[PATCH] netlink: Fix possible NLM_F_DUMP misuse in genetlink

NLM_F_DUMP flags should be applied to GET requests only, eg. rtnetlink
tests message type to verify this. Since genetlink can't do the same
use "practical" test for ops->dumpit (assuming NEW request won't be
mixed with GET).

Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Cc: Jan Engelhardt <jengelh@medozas.de>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jamal Hadi Salim <hadi@cyberus.ca>
---
Not for stable before testing!

diff -Nurp a/net/netlink/genetlink.c b/net/netlink/genetlink.c
--- a/net/netlink/genetlink.c	2011-01-18 16:58:16.000000000 +0100
+++ b/net/netlink/genetlink.c	2011-01-18 17:08:43.000000000 +0100
@@ -519,15 +519,16 @@ static int genl_rcv_msg(struct sk_buff *
 	    security_netlink_recv(skb, CAP_NET_ADMIN))
 		return -EPERM;
 
-	if (nlh->nlmsg_flags & NLM_F_DUMP) {
-		if (ops->dumpit == NULL)
+	if (ops->dumpit) {
+		if (nlh->nlmsg_flags & NLM_F_DUMP) {
+			genl_unlock();
+			err = netlink_dump_start(net->genl_sock, skb, nlh,
+						 ops->dumpit, ops->done);
+			genl_lock();
+			return err;
+		} else {
 			return -EOPNOTSUPP;
-
-		genl_unlock();
-		err = netlink_dump_start(net->genl_sock, skb, nlh,
-					 ops->dumpit, ops->done);
-		genl_lock();
-		return err;
+		}
 	}
 
 	if (ops->doit == NULL)

^ permalink raw reply	[flat|nested] 39+ messages in thread
* inbound connection problems when "netlink: test for all flags of the NLM_F_DUMP composite" commit applied
@ 2011-01-16  8:54 Arthur Marsh
  2011-01-16  9:21 ` Eric Dumazet
  0 siblings, 1 reply; 39+ messages in thread
From: Arthur Marsh @ 2011-01-16  8:54 UTC (permalink / raw)
  To: netdev

 
 
 
 This bug was originally posted at https://bugzilla.kernel.org/show_bug.cgi?id=26632 
 
With kernels up to and including 2.6.37-git7, inbound telnetd-ssl connections worked fine. 
With kernel 2.6.37-git9 and later inbound telnetd-ssl connections failed, and on machine shut-down, there were warning messages about daemons not return status. 
 
A git bisect on Linus' kernel tree revealed: 
 
0ab03c2b1478f2438d2c80204f7fef65b1bca9cf is the first bad commit 
commit 0ab03c2b1478f2438d2c80204f7fef65b1bca9cf 
Author: Jan Engelhardt <jengelh@medozas.de> 
Date:   Fri Jan 7 03:15:05 2011 +0000 
 
    netlink: test for all flags of the NLM_F_DUMP composite 
 
    Due to NLM_F_DUMP is composed of two bits, NLM_F_ROOT | NLM_F_MATCH, 
    when doing "if (x & NLM_F_DUMP)", it tests for _either_ of the bits 
    being set. Because NLM_F_MATCH's value overlaps with NLM_F_EXCL, 
    non-dump requests with NLM_F_EXCL set are mistaken as dump requests. 
 
    Substitute the condition to test for _all_ bits being set. 
 
    Signed-off-by: Jan Engelhardt <jengelh@medozas.de> 
    Acked-by: Pablo Neira Ayuso <pablo@netfilter.org> 
    Signed-off-by: David S. Miller <davem@davemloft.net> 
 
:040000 040000 1a0717ab0c87787309c3c3af88d666b44f327f64 
cba6279de85b7ebeaf21f19f1d93b59468fdd01d M      net 
 
I tried git cherry-pick 0ab03c2b1478f2438d2c80204f7fef65b1bca9cf and verified 
that the resulting kernel had these problems, then git revert 
0ab03c2b1478f2438d2c80204f7fef65b1bca9cf and verified that the resulting kernel 
did *not* have problems. 
 
Arthur. 

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2011-01-19 21:33 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-18 17:23 inbound connection problems when "netlink: test for all flags of the NLM_F_DUMP composite" commit applied Jarek Poplawski
2011-01-18 18:10 ` Alessandro Suardi
2011-01-18 18:23   ` Jarek Poplawski
2011-01-18 18:24   ` Jan Engelhardt
2011-01-18 18:28     ` Jarek Poplawski
2011-01-18 18:47       ` Jarek Poplawski
2011-01-18 19:26         ` Alessandro Suardi
2011-01-18 20:07           ` Jarek Poplawski
  -- strict thread matches above, loose matches on Subject: below --
2011-01-16  8:54 Arthur Marsh
2011-01-16  9:21 ` Eric Dumazet
2011-01-16 10:50   ` Jan Engelhardt
2011-01-16 12:39     ` Arthur Marsh
     [not found]     ` <4D32E3BA.5040008@internode.on.net>
2011-01-16 21:17       ` Pablo Neira Ayuso
2011-01-17  1:03         ` Arthur Marsh
2011-01-18  9:38         ` Jarek Poplawski
2011-01-18 10:07           ` David Miller
2011-01-18 10:24             ` Jarek Poplawski
2011-01-18 14:05               ` jamal
2011-01-18 14:07                 ` jamal
2011-01-18 17:22                   ` Jarek Poplawski
2011-01-18 18:11                 ` Jarek Poplawski
2011-01-18 20:39                 ` David Miller
2011-01-18 20:31               ` Pablo Neira Ayuso
2011-01-18 20:50                 ` David Miller
2011-01-19 17:42                   ` Pablo Neira Ayuso
2011-01-19 21:34                     ` David Miller
2011-01-18 20:55                 ` Jarek Poplawski
2011-01-19 14:28                   ` jamal
2011-01-19 16:54                     ` Jarek Poplawski
2011-01-19 16:59                       ` jamal
2011-01-19 17:19                         ` Jarek Poplawski
2011-01-19 17:33                         ` Jarek Poplawski
2011-01-19 18:04                       ` Jan Engelhardt
2011-01-19 19:24                         ` Jarek Poplawski
2011-01-19 19:47                           ` Jan Engelhardt
2011-01-19 20:12                             ` Jarek Poplawski
2011-01-18 21:14                 ` Jarek Poplawski
2011-01-19 14:53                   ` Pablo Neira Ayuso
2011-01-19 16:18                     ` Jarek Poplawski

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).