netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Haxby <john.haxby@oracle.com>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: Netfilter Development Mailinglist <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH] More secure SYSRQ for xtables-addons
Date: Mon, 01 Dec 2008 22:02:12 +0000	[thread overview]
Message-ID: <49345EE4.3070409@oracle.com> (raw)
In-Reply-To: <alpine.LNX.1.10.0812011952520.17726@fbirervta.pbzchgretzou.qr>

Jan Engelhardt wrote:
> On Thursday 2008-11-27 13:28, John Haxby wrote:
>
>   
>> Hello All,
>>
>> This is a patch to the SYSRQ xtables-addon that is, I believe, secure enough to
>> use in moderately untrustworthy environments.
>>     
>
> Finally - I wondered when someone will augment it with some crypto
> magic :p
>
> What I did not like with the original ipt_SYSRQ is that it used its
> own copy of the SHA algorithm - while being well aware that
> ipt_SYSRQ's root, if I remember correctly, dates to the time where
> in-kernel crypto did not exist yet.
>
>   
I didn't like that much either: the reason given was that it didn't want 
to rely on kernel resources but that's quite a weak reason for including 
its own sha-1.  On the other hand, for kernels where there isn't an 
sha-1 available that does make sense.
>> Ideally the iptables rules for SYSRQ would include a minimum time
>> between requests to avoid the worst effects of sysrq-request
>> bombing, although I haven't mentioned that in the updated man page
>> (mostly because I'm not sure how to do it).
>>     
>
> -p udp --dport discard -m limit --limit 5/minute -j SYSRQ ...
>
>   
Thanks, I'll work that into the man page.
>> .IP
>> -echo -n "password" >/sys/.../password
>> +echo "password" >/sys/module/xt_SYSRQ/parameters/password
>> .PP
>>     
>
> I think we should not rely on \n being there. Checking for \0
> should also catch the echo -n (or open from a perl/c program) case:
>
>   
>> +	for (i = 0; sysrq_password[i]; i++)
>> +		if (sysrq_password[i] == '\n')
>>     
> 		|| sysrq_password[i] == '\0'
>
> (assuming that echoing into string module parameters at least adds a \0)
>
>   
I think it does this anyway doesn't it?   The "sysrq_password[i]" loop 
test stops at the '\0' and the "if (sysrq_password[i] == '\n') break" 
breaks out early if there's a '\n' in the string.  The next assignment 
either overwrites the trailing '\0' with another one or null-terminates 
the string at the first LF.
>> +	sg_init_table(sg, 2);
>> +	sg_set_buf(&sg[0], data, n);
>> +	strcpy(digest_password, sysrq_password);
>> +	i = strlen(digest_password);
>> +	sg_set_buf(&sg[1], digest_password, i);
>>     
>
> Could we directly use sysrq_password instead of copying it
> to digest_password first?
>
>   
No :-)   Eventually I discovered the reason my code wasn't working boils 
down to the definition of sg_set_buf:

    sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf))

which doesn't work for sysrq_password.   I don't know why I'll double check.
>> +	for (i = 0; i < len && data[i] != ','; i++) {
>> +		printk(KERN_INFO KBUILD_MODNAME ": SysRq %c\n", data[i]);
>> #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
>> -	handle_sysrq(c, NULL);
>> +		handle_sysrq(data[i], NULL);
>> #else
>> -	handle_sysrq(c, NULL, NULL);
>> +		handle_sysrq(data[i], NULL, NULL);
>> #endif
>> +	}
>>     
>
> I see you handle multiple sysrq requests in one packet. This should be 
> reflected in the manual/comments (e.g. <keys> instead of <key>).
>
>   
Yes.

> Care to fix it up? This looks good :)
>   

Yes.

Thanks again.

jch

  reply	other threads:[~2008-12-01 22:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-27 12:28 [PATCH] More secure SYSRQ for xtables-addons John Haxby
2008-12-01 19:34 ` Jan Engelhardt
2008-12-01 22:02   ` John Haxby [this message]
2008-12-01 22:37     ` Jan Engelhardt
2008-12-01 22:40     ` sg_set_page not usable for .bss? Jan Engelhardt
2008-12-02  0:10       ` David Miller
2008-12-02  0:13         ` Jan Engelhardt
2008-12-02  0:14           ` David Miller
2008-12-02  1:41             ` Jan Engelhardt
2008-12-02  6:55               ` David Miller
2008-12-02  1:39 ` [PATCH] More secure SYSRQ for xtables-addons Patrick McHardy
2008-12-02  1:53   ` Jan Engelhardt
2008-12-02  9:43   ` John Haxby
2008-12-02 17:46 ` John Haxby
2008-12-12  8:38   ` John Haxby
2008-12-13 22:14     ` Jan Engelhardt
2008-12-15 12:09       ` Jan Engelhardt

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=49345EE4.3070409@oracle.com \
    --to=john.haxby@oracle.com \
    --cc=jengelh@medozas.de \
    --cc=netfilter-devel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).