From: Eric Dumazet <eric.dumazet@gmail.com>
To: Dmitry Kozlov <xeb@mail.ru>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH v5] PPTP: PPP over IPv4 (Point-to-Point Tunneling Protocol)
Date: Wed, 18 Aug 2010 17:22:08 +0200 [thread overview]
Message-ID: <1282144928.2194.104.camel@edumazet-laptop> (raw)
In-Reply-To: <E1OljPK-0006rQ-00.xeb-mail-ru@f238.mail.ru>
Le mercredi 18 août 2010 à 18:14 +0400, Dmitry Kozlov a écrit :
> This patch contains:
> 1. pptp driver
> 2. gre demultiplexer driver for demultiplexing gre packets with different gre version
> so ip_gre and pptp may coexists
> 3. ip_gre modification
> 4. other stuff
>
> Changes from patch v4:
> 1. using spinlock instead mutex
> 2. fixed coding style issues
>
> +static int __init pptp_init_module(void)
> +{
> + int err = 0;
> + printk(KERN_INFO "PPTP driver version " PPTP_DRIVER_VERSION "\n");
> +
> + if (gre_add_protocol(&gre_pptp_protocol, GREPROTO_PPTP) < 0) {
> + printk(KERN_INFO "PPTP: can't add protocol\n");
> + goto out;
> + }
> +
> + err = proto_register(&pptp_sk_proto, 0);
> + if (err) {
> + printk(KERN_INFO "PPTP: can't register sk_proto\n");
> + goto out_inet_del_protocol;
> + }
> +
> + err = register_pppox_proto(PX_PROTO_PPTP, &pppox_pptp_proto);
> + if (err) {
> + printk(KERN_INFO "PPTP: can't register pppox_proto\n");
> + goto out_unregister_sk_proto;
> + }
> +
> + callid_sock = (struct pppox_sock **)vmalloc((MAX_CALLID + 1) * sizeof(void *));
> + memset(callid_sock, 0, (MAX_CALLID + 1) * sizeof(void *));
> +
> +out:
> + return err;
> +out_unregister_sk_proto:
> + proto_unregister(&pptp_sk_proto);
> +out_inet_del_protocol:
> + gre_del_protocol(&gre_pptp_protocol, GREPROTO_PPTP);
> + return err;
> +}
1) Please test return from vmalloc(), it can be NULL
Also, if you need to clear it, you might call
__vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
(and result is already cleared)
2) For new code, it's advised to use :
pr_err(xxx) instead of printk(KERN_ERR xxx)
pr_info(xxx) instead of printk(KERN_INFO xxx)
3) After skb_dst_drop(skb), you dont need to call skb_dst_set(skb,
NULL), as it is already done (for example in pptp_rcv())
4) Since you touch some includes, you also can use __packed
instead of __attribute__ ((__packed__))
5) I feel a bit uncomfortable with lookup_chan_dst()
+static int lookup_chan_dst(__u16 call_id, __be32 d_addr)
+{
+ struct pppox_sock *sock;
+ struct pptp_opt *opt;
+ int i;
+
+ rcu_read_lock();
+ for (i = find_next_bit(callid_bitmap, MAX_CALLID, 1); i < MAX_CALLID; i = find_next_bit(callid_bitmap, MAX_CALLID, i + 1)) {
Split this too long line please, its really awful
+ sock = rcu_dereference(callid_sock[i]);
+ opt = &sock->proto.pptp;
+ if (opt->dst_addr.call_id == call_id && opt->dst_addr.sin_addr.s_addr == d_addr)
+ break;
+ }
+ rcu_read_unlock();
+
+ return i < MAX_CALLID;
+}
Once you get a bit in bitmask, and rcu_dereference(callid_sock[i]),
there is no guarantee sock is not NULL.
You should add a test.
If sock is not NULL, then you have the guarantee (thanks to RCU) that
pointer is safe until the rcu_read_unlock()
Thanks
prev parent reply other threads:[~2010-08-18 15:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-18 14:14 [PATCH v5] PPTP: PPP over IPv4 (Point-to-Point Tunneling Protocol) Dmitry Kozlov
2010-08-18 15:22 ` Eric Dumazet [this message]
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=1282144928.2194.104.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=xeb@mail.ru \
/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