Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/sysinst On amd64 support installation with a KASLR ...



details:   https://anonhg.NetBSD.org/src/rev/52812a9a7708
branches:  trunk
changeset: 461144:52812a9a7708
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Nov 16 21:25:14 2019 +0000

description:
On amd64 support installation with a KASLR kernel, via "custom install"
and selecting the GENERIC_KASLR kernel set.
Setup /prekern and boot.cfg accordingly.

diffstat:

 usr.sbin/sysinst/arch/amd64/md.c     |  19 ++++++++++++++++++-
 usr.sbin/sysinst/arch/amd64/md.h     |   7 ++++++-
 usr.sbin/sysinst/arch/i386/md.c      |  11 ++++++++---
 usr.sbin/sysinst/arch/i386/msg.md.de |   3 ++-
 usr.sbin/sysinst/arch/i386/msg.md.en |   3 ++-
 usr.sbin/sysinst/arch/i386/msg.md.es |   3 ++-
 usr.sbin/sysinst/arch/i386/msg.md.fr |   3 ++-
 usr.sbin/sysinst/arch/i386/msg.md.pl |   3 ++-
 usr.sbin/sysinst/util.c              |   9 ++++++++-
 9 files changed, 50 insertions(+), 11 deletions(-)

diffs (183 lines):

diff -r 16901130e1db -r 52812a9a7708 usr.sbin/sysinst/arch/amd64/md.c
--- a/usr.sbin/sysinst/arch/amd64/md.c  Sat Nov 16 20:26:59 2019 +0000
+++ b/usr.sbin/sysinst/arch/amd64/md.c  Sat Nov 16 21:25:14 2019 +0000
@@ -1,5 +1,22 @@
-/*     $NetBSD: md.c,v 1.1 2014/07/26 19:30:44 dholland Exp $ */
+/*     $NetBSD: md.c,v 1.2 2019/11/16 21:25:14 martin Exp $ */
 
 /* md.c -- Machine specific code for amd64 */
 
 #include "../i386/md.c"
+
+void   amd64_md_boot_cfg_finalize(const char *path);
+
+void
+amd64_md_boot_cfg_finalize(const char *path)
+{
+       char buf[MAXPATHLEN];
+
+       if (get_kernel_set() != SET_KERNEL_2)
+               return;
+
+       run_program(RUN_CHROOT|RUN_FATAL,
+           "sh -c 'sed -e \"s:;boot:;pkboot:\" "
+           "< %s > %s.1", path, path);
+       snprintf(buf, sizeof buf, "%s.1", path);
+       mv_within_target_or_die(buf, path);
+}
diff -r 16901130e1db -r 52812a9a7708 usr.sbin/sysinst/arch/amd64/md.h
--- a/usr.sbin/sysinst/arch/amd64/md.h  Sat Nov 16 20:26:59 2019 +0000
+++ b/usr.sbin/sysinst/arch/amd64/md.h  Sat Nov 16 21:25:14 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.h,v 1.7 2019/10/02 11:16:01 maya Exp $      */
+/*     $NetBSD: md.h,v 1.8 2019/11/16 21:25:14 martin Exp $    */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -85,6 +85,7 @@
  * from floppy.
  */
 #define SET_KERNEL_1_NAME      "kern-GENERIC"
+#define        SET_KERNEL_2_NAME       "kern-GENERIC_KASLR"
 
 #define SET_KERNEL_GENERIC     SET_KERNEL_1
 
@@ -117,9 +118,13 @@
  */
 void x86_md_part_defaults(struct pm_devs*, struct part_usage_info**,
             size_t *num_usage_infos);
+
 #define MD_PART_DEFAULTS(A,B,C)        x86_md_part_defaults(A,&(B),&(C))
 
 /* no need to install bootblock if installing for UEFI */
 bool x86_md_need_bootblock(struct install_partition_desc *install);
 #define        MD_NEED_BOOTBLOCK(A)    x86_md_need_bootblock(A)
 
+/* post-process boot.cfg for KASLR if that kernel has been selected */
+void amd64_md_boot_cfg_finalize(const char*);
+#define        MD_BOOT_CFG_FINALIZE(P) amd64_md_boot_cfg_finalize(P)
diff -r 16901130e1db -r 52812a9a7708 usr.sbin/sysinst/arch/i386/md.c
--- a/usr.sbin/sysinst/arch/i386/md.c   Sat Nov 16 20:26:59 2019 +0000
+++ b/usr.sbin/sysinst/arch/i386/md.c   Sat Nov 16 21:25:14 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.23 2019/11/16 18:08:36 martin Exp $ */
+/*     $NetBSD: md.c,v 1.24 2019/11/16 21:25:14 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -376,6 +376,13 @@
 int
 md_post_newfs(struct install_partition_desc *install)
 {
+#if defined(__amd64__)
+       int ret;
+
+       ret = cp_to_target("/usr/mdec/prekern", "/prekern");
+       if (ret)
+               return ret;
+#endif
 
        return uefi_boot ? md_post_newfs_uefi(install)
            : md_post_newfs_bios(install);
@@ -911,5 +918,3 @@
 
        return !uefi_boot;
 }
-
-
diff -r 16901130e1db -r 52812a9a7708 usr.sbin/sysinst/arch/i386/msg.md.de
--- a/usr.sbin/sysinst/arch/i386/msg.md.de      Sat Nov 16 20:26:59 2019 +0000
+++ b/usr.sbin/sysinst/arch/i386/msg.md.de      Sat Nov 16 21:25:14 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.md.de,v 1.3 2019/11/16 17:53:02 martin Exp $       */
+/*     $NetBSD: msg.md.de,v 1.4 2019/11/16 21:25:14 martin Exp $       */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -165,3 +165,4 @@
 NetBSD Bootcodes updaten?}
 
 message set_kernel_1   {Kernel (GENERIC)}
+message set_kernel_2   {Kernel (GENERIC_KASLR)}
diff -r 16901130e1db -r 52812a9a7708 usr.sbin/sysinst/arch/i386/msg.md.en
--- a/usr.sbin/sysinst/arch/i386/msg.md.en      Sat Nov 16 20:26:59 2019 +0000
+++ b/usr.sbin/sysinst/arch/i386/msg.md.en      Sat Nov 16 21:25:14 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.md.en,v 1.3 2019/11/16 17:53:02 martin Exp $       */
+/*     $NetBSD: msg.md.en,v 1.4 2019/11/16 21:25:14 martin Exp $       */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -161,3 +161,4 @@
 the latest version of the NetBSD bootcode?}
 
 message set_kernel_1   {Kernel (GENERIC)}
+message set_kernel_2   {Kernel (GENERIC_KASLR)}
diff -r 16901130e1db -r 52812a9a7708 usr.sbin/sysinst/arch/i386/msg.md.es
--- a/usr.sbin/sysinst/arch/i386/msg.md.es      Sat Nov 16 20:26:59 2019 +0000
+++ b/usr.sbin/sysinst/arch/i386/msg.md.es      Sat Nov 16 21:25:14 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.md.es,v 1.3 2019/11/16 17:53:02 martin Exp $       */
+/*     $NetBSD: msg.md.es,v 1.4 2019/11/16 21:25:14 martin Exp $       */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -162,3 +162,4 @@
 Record a la ultima versión del código de arranque de NetBSD?}
 
 message set_kernel_1  {Núcleo (GENERIC)}
+message set_kernel_2   {Kernel (GENERIC_KASLR)}
diff -r 16901130e1db -r 52812a9a7708 usr.sbin/sysinst/arch/i386/msg.md.fr
--- a/usr.sbin/sysinst/arch/i386/msg.md.fr      Sat Nov 16 20:26:59 2019 +0000
+++ b/usr.sbin/sysinst/arch/i386/msg.md.fr      Sat Nov 16 21:25:14 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.md.fr,v 1.3 2019/11/16 17:53:02 martin Exp $       */
+/*     $NetBSD: msg.md.fr,v 1.4 2019/11/16 21:25:14 martin Exp $       */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -157,3 +157,4 @@
 avec la dernière version du code d'amorçage de NetBSD ?}
 
 message set_kernel_1   {Kernel (GENERIC)}
+message set_kernel_2   {Kernel (GENERIC_KASLR)}
diff -r 16901130e1db -r 52812a9a7708 usr.sbin/sysinst/arch/i386/msg.md.pl
--- a/usr.sbin/sysinst/arch/i386/msg.md.pl      Sat Nov 16 20:26:59 2019 +0000
+++ b/usr.sbin/sysinst/arch/i386/msg.md.pl      Sat Nov 16 21:25:14 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.md.pl,v 1.3 2019/11/16 17:53:02 martin Exp $       */
+/*     $NetBSD: msg.md.pl,v 1.4 2019/11/16 21:25:14 martin Exp $       */
 /*     Based on english version: */
 /*     NetBSD: msg.md.en,v 1.24 2001/01/27 07:34:39 jmc Exp    */
 
@@ -156,3 +156,4 @@
 kodu rozruchowego NetBSD?}
 
 message set_kernel_1   {Kernel (GENERIC)}
+message set_kernel_2   {Kernel (GENERIC_KASLR)}
diff -r 16901130e1db -r 52812a9a7708 usr.sbin/sysinst/util.c
--- a/usr.sbin/sysinst/util.c   Sat Nov 16 20:26:59 2019 +0000
+++ b/usr.sbin/sysinst/util.c   Sat Nov 16 21:25:14 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.39 2019/11/16 20:26:59 martin Exp $ */
+/*     $NetBSD: util.c,v 1.40 2019/11/16 21:25:14 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1151,9 +1151,16 @@
                                            "> /tmp/boot.cfg.tmp'");
                                mv_within_target_or_die("/tmp/boot.cfg.tmp",
                                                        "/boot.cfg");
+
                        }
                }
 
+#ifdef MD_BOOT_CFG_FINALIZE
+               if (target_file_exists_p("/boot.cfg")) {
+                       MD_BOOT_CFG_FINALIZE("/boot.cfg");
+               }
+#endif
+
                /* Save keyboard type */
                save_kb_encoding();
 



Home | Main Index | Thread Index | Old Index