From: Patrick McHardy <kaber@trash.net>
To: Luciano Coelho <luciano.coelho@nokia.com>
Cc: netfilter-devel@vger.kernel.org, netdev@vger.kernel.org,
jengelh@medozas.de, sameo@linux.intel.com,
janne.ylalehto@nokia.com
Subject: Re: [PATCH RESEND 1/3] netfilter: xtables: inclusion of xt_condition
Date: Wed, 15 Sep 2010 22:39:24 +0200 [thread overview]
Message-ID: <4C912EFC.9070406@trash.net> (raw)
In-Reply-To: <1282034213-1829-2-git-send-email-luciano.coelho@nokia.com>
Am 17.08.2010 10:36, schrieb Luciano Coelho:
> diff --git a/net/netfilter/xt_condition.c b/net/netfilter/xt_condition.c
> new file mode 100644
> index 0000000..a78d832
> --- /dev/null
> +++ b/net/netfilter/xt_condition.c
> @@ -0,0 +1,265 @@
> +/*
> + * "condition" match extension for Xtables
> + *
> + * Description: This module allows firewall rules to match using
> + * condition variables available through procfs.
> + *
> + * Authors:
> + * Stephane Ouellette <ouellettes [at] videotron ca>, 2002-10-22
> + * Massimiliano Hofer <max [at] nucleus it>, 2006-05-15
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License; either version 2
> + * or 3 of the License, as published by the Free Software Foundation.
> + */
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +#include <linux/kernel.h>
> +#include <linux/list.h>
> +#include <linux/module.h>
> +#include <linux/proc_fs.h>
> +#include <linux/spinlock.h>
> +#include <linux/string.h>
> +#include <linux/version.h>
> +#include <linux/netfilter/x_tables.h>
> +#include <linux/netfilter/xt_condition.h>
> +#include <net/netns/generic.h>
> +#include <asm/uaccess.h>
> +
> +/* Defaults, these can be overridden on the module command-line. */
> +static unsigned int condition_list_perms = S_IRUGO | S_IWUSR;
> +static unsigned int condition_uid_perms = 0;
> +static unsigned int condition_gid_perms = 0;
I'm not sure whether we already discussed this, but this isn't
useful if namespaces are used since the IDs aren't global.
> +
> +MODULE_AUTHOR("Stephane Ouellette <ouellettes@videotron.ca>");
> +MODULE_AUTHOR("Massimiliano Hofer <max@nucleus.it>");
> +MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>");
> +MODULE_DESCRIPTION("Allows rules to match against condition variables");
> +MODULE_LICENSE("GPL");
> +module_param(condition_list_perms, uint, S_IRUSR | S_IWUSR);
> +MODULE_PARM_DESC(condition_list_perms, "default permissions on /proc/net/nf_condition/* files");
> +module_param(condition_uid_perms, uint, S_IRUSR | S_IWUSR);
> +MODULE_PARM_DESC(condition_uid_perms, "default user owner of /proc/net/nf_condition/* files");
> +module_param(condition_gid_perms, uint, S_IRUSR | S_IWUSR);
> +MODULE_PARM_DESC(condition_gid_perms, "default group owner of /proc/net/nf_condition/* files");
> +MODULE_ALIAS("ipt_condition");
> +MODULE_ALIAS("ip6t_condition");
> +
> +/* proc_lock is a user context only semaphore used for write access */
> +/* to the conditions' list. */
> +static DEFINE_MUTEX(proc_lock);
Why is this called proc_lock, as the comment states it protects
the condition variable list? The comment is also misleading since
this is a mutex and not a semaphore. I'd suggest list_mutex or
condition_mutex.
> +static int condition_proc_read(char __user *buffer, char **start, off_t offset,
> + int length, int *eof, void *data)
> +{
> + const struct condition_variable *var = data;
> +
> + buffer[0] = var->enabled ? '1' : '0';
> + buffer[1] = '\n';
This is a user buffer, you need copy_to_user(). Also please run
sparse against your code to check for similar errors.
> + if (length >= 2)
> + *eof = true;
> + return 2;
> +}
next prev parent reply other threads:[~2010-09-15 20:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-17 8:36 [PATCH RESEND 0/3] netfilter: xtables: inclusion of condition match and target Luciano Coelho
2010-08-17 8:36 ` [PATCH RESEND 1/3] netfilter: xtables: inclusion of xt_condition Luciano Coelho
2010-09-15 20:39 ` Patrick McHardy [this message]
2010-09-15 20:52 ` Jan Engelhardt
2010-09-15 20:59 ` Patrick McHardy
2010-09-15 21:09 ` Jan Engelhardt
2010-09-16 5:38 ` Patrick McHardy
2010-09-21 20:02 ` Luciano Coelho
2010-09-22 6:46 ` Patrick McHardy
2010-09-21 19:59 ` Luciano Coelho
2010-08-17 8:36 ` [PATCH RESEND 2/3] netfilter: xt_condition: change the value from boolean to u32 Luciano Coelho
2010-09-15 20:41 ` Patrick McHardy
2010-09-15 20:46 ` Jan Engelhardt
2010-09-21 20:00 ` Luciano Coelho
2010-08-17 8:36 ` [PATCH RESEND 3/3] netfilter: xt_condition: add condition target support Luciano Coelho
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=4C912EFC.9070406@trash.net \
--to=kaber@trash.net \
--cc=janne.ylalehto@nokia.com \
--cc=jengelh@medozas.de \
--cc=luciano.coelho@nokia.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=sameo@linux.intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.