Skip to content

Commit c6ac37d

Browse files
Snorchummakynes
authored andcommitted
netfilter: nf_log: fix error on write NONE to logger choice sysctl
It is hard to unbind nf-logger: echo NONE > /proc/sys/net/netfilter/nf_log/0 bash: echo: write error: No such file or directory sysctl -w net.netfilter.nf_log.0=NONE sysctl: setting key "net.netfilter.nf_log.0": No such file or directory net.netfilter.nf_log.0 = NONE You need explicitly send '\0', for instance like: echo -e "NONE\0" > /proc/sys/net/netfilter/nf_log/0 That seem to be strange, so fix it using proc_dostring. Now it works fine: modprobe nfnetlink_log echo nfnetlink_log > /proc/sys/net/netfilter/nf_log/0 cat /proc/sys/net/netfilter/nf_log/0 nfnetlink_log echo NONE > /proc/sys/net/netfilter/nf_log/0 cat /proc/sys/net/netfilter/nf_log/0 NONE v2: add missed error check for proc_dostring Signed-off-by: Pavel Tikhomirov <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent c37a2df commit c6ac37d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

net/netfilter/nf_log.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,16 +418,17 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
418418
{
419419
const struct nf_logger *logger;
420420
char buf[NFLOGGER_NAME_LEN];
421-
size_t size = *lenp;
422421
int r = 0;
423422
int tindex = (unsigned long)table->extra1;
424423
struct net *net = current->nsproxy->net_ns;
425424

426425
if (write) {
427-
if (size > sizeof(buf))
428-
size = sizeof(buf);
429-
if (copy_from_user(buf, buffer, size))
430-
return -EFAULT;
426+
struct ctl_table tmp = *table;
427+
428+
tmp.data = buf;
429+
r = proc_dostring(&tmp, write, buffer, lenp, ppos);
430+
if (r)
431+
return r;
431432

432433
if (!strcmp(buf, "NONE")) {
433434
nf_log_unbind_pf(net, tindex);

0 commit comments

Comments
 (0)