On 21.10.2013 19:44, Jonathan McCune wrote: > On Mon, Oct 21, 2013 at 10:33 AM, Vladimir 'φ-coder/phcoder' Serbinenko > <[email protected] <mailto:[email protected]>> wrote: > > On 18.10.2013 04:44, Andrey Borzenkov wrote: > > В Thu, 17 Oct 2013 23:44:05 +0200 > > Vladimir 'φ-coder/phcoder' Serbinenko <[email protected] > <mailto:[email protected]>> пишет: > > > >> On 17.10.2013 20:28, Jonathan McCune wrote: > >>> Presently the 'trust' and 'verify_detached' commands disable all > filters > >>> (e.g., verify.c:grub_cmd_trust() calls > grub_file_filter_disable_all()) > >>> when opening a file containing a public key (note the > distinction from > >>> verify_detached implicitly using an already-loaded key). > >> > >> This is the intended behaviour. Usecase to manually add keys when > >> needed. Your proposal is for other usecases which would probably > require > >> special arguments or separate functions. > >> > > > > This has the same MITM problem we already discussed and that was fixed > > if pubkey filter is used - you cannot actually know that key you trust > > is the same as key you verified. So I think that at least by default > > "trust" should not disable pubkey filter. > > > > verify_detached probably should, but may be only for file that is > > verified itself, bit for pubkey. > > > I didn't oppose to a command or options having the described > functionality. Thinking about it, I have to agree that default behaviour > should be paranoid with options to relax it. Would you or Jonathan > prepare a patch to change the behaviour with an option to restore > current behaviour? > > > How about addressing this by adding a --skip-sig option to both trust > and verify_detached, that disables signature checking for the loaded > public key? This would be similar in structure to the --skip-sig option > to load_env, and the consistent use of --skip-sig would hopefully make > things easier on the author of a .cfg file. It's mildly confusing to > say verify_detached --skip-sig since the whole point of that command is > to check a signature, but the documentation can make it clear. > > I can prepare a patch but it could be a week or more before I have time > to do so. > Patch attached. Completely untested. Anyone to test it? > Thanks, > -Jon > > > > > > > _______________________________________________ > Grub-devel mailing list > [email protected] > https://lists.gnu.org/mailman/listinfo/grub-devel >
=== modified file 'grub-core/commands/verify.c'
--- grub-core/commands/verify.c 2013-04-05 08:52:13 +0000
+++ grub-core/commands/verify.c 2013-10-21 21:41:41 +0000
@@ -29,9 +29,22 @@
#include <grub/pubkey.h>
#include <grub/env.h>
#include <grub/kernel.h>
+#include <grub/extcmd.h>
GRUB_MOD_LICENSE ("GPLv3+");
+enum
+ {
+ OPTION_SKIP_SIG = 0
+ };
+
+static const struct grub_arg_option options[] =
+ {
+ {"skip-sig", 's', 0,
+ N_("Skip signature-checking of the signature file."), 0, ARG_TYPE_NONE},
+ {0, 0, 0, 0, 0, 0}
+ };
+
static grub_err_t
read_packet_header (grub_file_t sig, grub_uint8_t *out_type, grub_size_t *len)
{
@@ -544,8 +557,8 @@
}
static grub_err_t
-grub_cmd_trust (grub_command_t cmd __attribute__ ((unused)),
- int argc, char **args)
+grub_cmd_trust (grub_extcmd_context_t ctxt,
+ int argc, char **args)
{
grub_file_t pkf;
struct grub_public_key *pk = NULL;
@@ -553,7 +566,8 @@
if (argc < 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
- grub_file_filter_disable_all ();
+ if (ctxt->state[OPTION_SKIP_SIG].set)
+ grub_file_filter_disable_pubkey ();
pkf = grub_file_open (args[0]);
if (!pkf)
return grub_errno;
@@ -625,7 +639,7 @@
}
static grub_err_t
-grub_cmd_verify_signature (grub_command_t cmd __attribute__ ((unused)),
+grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
int argc, char **args)
{
grub_file_t f, sig;
@@ -642,7 +656,8 @@
if (argc > 2)
{
grub_file_t pkf;
- grub_file_filter_disable_all ();
+ if (ctxt->state[OPTION_SKIP_SIG].set)
+ grub_file_filter_disable_pubkey ();
pkf = grub_file_open (args[2]);
if (!pkf)
return grub_errno;
@@ -790,7 +805,8 @@
struct gcry_pk_spec *grub_crypto_pk_ecdsa;
struct gcry_pk_spec *grub_crypto_pk_rsa;
-static grub_command_t cmd, cmd_trust, cmd_distrust, cmd_list;
+static grub_extcmd_t cmd, cmd_trust;
+static grub_command_t cmd_distrust, cmd_list;
GRUB_MOD_INIT(verify)
{
@@ -835,12 +851,14 @@
if (!val)
grub_env_set ("check_signatures", grub_pk_trusted ? "enforce" : "no");
- cmd = grub_register_command ("verify_detached", grub_cmd_verify_signature,
- N_("FILE SIGNATURE_FILE [PUBKEY_FILE]"),
- N_("Verify detached signature."));
- cmd_trust = grub_register_command ("trust", grub_cmd_trust,
- N_("PUBKEY_FILE"),
- N_("Add PKFILE to trusted keys."));
+ cmd = grub_register_extcmd ("verify_detached", grub_cmd_verify_signature, 0,
+ N_("[-s|--skip-sig] FILE SIGNATURE_FILE [PUBKEY_FILE]"),
+ N_("Verify detached signature."),
+ options);
+ cmd_trust = grub_register_extcmd ("trust", grub_cmd_trust, 0,
+ N_("[-s|--skip-sig] PUBKEY_FILE"),
+ N_("Add PKFILE to trusted keys."),
+ options);
cmd_list = grub_register_command ("list_trusted", grub_cmd_list,
0,
N_("List trusted keys."));
@@ -852,8 +870,8 @@
GRUB_MOD_FINI(verify)
{
grub_file_filter_unregister (GRUB_FILE_FILTER_PUBKEY);
- grub_unregister_command (cmd);
- grub_unregister_command (cmd_trust);
+ grub_unregister_extcmd (cmd);
+ grub_unregister_extcmd (cmd_trust);
grub_unregister_command (cmd_list);
grub_unregister_command (cmd_distrust);
}
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
