Skip to content

Commit

Permalink
[NETFILTER]: check nf_log function call arguments
Browse files Browse the repository at this point in the history
Check whether pf is too large in order to prevent array overflow.

Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Harald Welte authored and David S. Miller committed Aug 29, 2005
1 parent d72367b commit 8a61fad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/linux/netfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ struct nf_logger {

/* Function to register/unregister log function. */
int nf_log_register(int pf, struct nf_logger *logger);
void nf_log_unregister_pf(int pf);
int nf_log_unregister_pf(int pf);
void nf_log_unregister_logger(struct nf_logger *logger);

/* Calls the registered backend logging function */
Expand Down
10 changes: 9 additions & 1 deletion net/netfilter/nf_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ int nf_log_register(int pf, struct nf_logger *logger)
{
int ret = -EBUSY;

if (pf >= NPROTO)
return -EINVAL;

/* Any setup of logging members must be done before
* substituting pointer. */
spin_lock(&nf_log_lock);
Expand All @@ -38,14 +41,19 @@ int nf_log_register(int pf, struct nf_logger *logger)
}
EXPORT_SYMBOL(nf_log_register);

void nf_log_unregister_pf(int pf)
int nf_log_unregister_pf(int pf)
{
if (pf >= NPROTO)
return -EINVAL;

spin_lock(&nf_log_lock);
nf_logging[pf] = NULL;
spin_unlock(&nf_log_lock);

/* Give time to concurrent readers. */
synchronize_net();

return 0;
}
EXPORT_SYMBOL(nf_log_unregister_pf);

Expand Down

0 comments on commit 8a61fad

Please sign in to comment.