Print this page
10349 bop_blacklist should cover loader menu


   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  *
  26  * Copyright (c) 2010, Intel Corporation.
  27  * All rights reserved.
  28  *
  29  * Copyright 2018 Joyent, Inc.  All rights reserved.
  30  */
  31 
  32 /*
  33  * This file contains the functionality that mimics the boot operations
  34  * on SPARC systems or the old boot.bin/multiboot programs on x86 systems.
  35  * The x86 kernel now does everything on its own.
  36  */
  37 
  38 #include <sys/types.h>
  39 #include <sys/bootconf.h>
  40 #include <sys/bootsvcs.h>
  41 #include <sys/bootinfo.h>
  42 #include <sys/multiboot.h>
  43 #include <sys/multiboot2.h>
  44 #include <sys/multiboot2_impl.h>
  45 #include <sys/bootvfs.h>
  46 #include <sys/bootprops.h>
  47 #include <sys/varargs.h>
  48 #include <sys/param.h>
  49 #include <sys/machparam.h>


1271          */
1272         saved_file_size[FASTBOOT_NAME_UNIX] = FOUR_MEG - PAGESIZE;
1273         for (i = 0, modp = (struct boot_modules *)(uintptr_t)xbi->bi_modules;
1274             i < xbi->bi_module_cnt; i++, modp++) {
1275                 saved_file_size[FASTBOOT_NAME_BOOTARCHIVE] += modp->bm_size;
1276         }
1277 }
1278 #endif  /* __xpv */
1279 
1280 /*
1281  * Import boot environment module variables as properties, applying
1282  * blacklist filter for variables we know we will not use.
1283  *
1284  * Since the environment can be relatively large, containing many variables
1285  * used only for boot loader purposes, we will use a blacklist based filter.
1286  * To keep the blacklist from growing too large, we use prefix based filtering.
1287  * This is possible because in many cases, the loader variable names are
1288  * using a structured layout.
1289  *
1290  * We will not overwrite already set properties.




1291  */
1292 static struct bop_blacklist {
1293         const char *bl_name;
1294         int bl_name_len;
1295 } bop_prop_blacklist[] = {
1296         { "ISADIR", sizeof ("ISADIR") },
1297         { "acpi", sizeof ("acpi") },
1298         { "autoboot_delay", sizeof ("autoboot_delay") },
1299         { "autoboot_delay", sizeof ("autoboot_delay") },
1300         { "beansi_", sizeof ("beansi_") },
1301         { "beastie", sizeof ("beastie") },
1302         { "bemenu", sizeof ("bemenu") },
1303         { "boot.", sizeof ("boot.") },
1304         { "bootenv", sizeof ("bootenv") },
1305         { "currdev", sizeof ("currdev") },
1306         { "dhcp.", sizeof ("dhcp.") },
1307         { "interpret", sizeof ("interpret") },
1308         { "kernel", sizeof ("kernel") },
1309         { "loaddev", sizeof ("loaddev") },
1310         { "loader_", sizeof ("loader_") },





1311         { "module_path", sizeof ("module_path") },
1312         { "nfs.", sizeof ("nfs.") },



1313         { "pcibios", sizeof ("pcibios") },
1314         { "prompt", sizeof ("prompt") },
1315         { "smbios", sizeof ("smbios") },
1316         { "tem", sizeof ("tem") },
1317         { "twiddle_divisor", sizeof ("twiddle_divisor") },
1318         { "zfs_be", sizeof ("zfs_be") },
1319 };
1320 
1321 /*
1322  * Match the name against prefixes in above blacklist. If the match was
1323  * found, this name is blacklisted.
1324  */
1325 static boolean_t
1326 name_is_blacklisted(const char *name)
1327 {
1328         int i, n;
1329 
1330         n = sizeof (bop_prop_blacklist) / sizeof (bop_prop_blacklist[0]);
1331         for (i = 0; i < n; i++) {
1332                 if (strncmp(bop_prop_blacklist[i].bl_name, name,




   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  *
  26  * Copyright (c) 2010, Intel Corporation.
  27  * All rights reserved.
  28  *
  29  * Copyright (c) 2019, Joyent, Inc.
  30  */
  31 
  32 /*
  33  * This file contains the functionality that mimics the boot operations
  34  * on SPARC systems or the old boot.bin/multiboot programs on x86 systems.
  35  * The x86 kernel now does everything on its own.
  36  */
  37 
  38 #include <sys/types.h>
  39 #include <sys/bootconf.h>
  40 #include <sys/bootsvcs.h>
  41 #include <sys/bootinfo.h>
  42 #include <sys/multiboot.h>
  43 #include <sys/multiboot2.h>
  44 #include <sys/multiboot2_impl.h>
  45 #include <sys/bootvfs.h>
  46 #include <sys/bootprops.h>
  47 #include <sys/varargs.h>
  48 #include <sys/param.h>
  49 #include <sys/machparam.h>


1271          */
1272         saved_file_size[FASTBOOT_NAME_UNIX] = FOUR_MEG - PAGESIZE;
1273         for (i = 0, modp = (struct boot_modules *)(uintptr_t)xbi->bi_modules;
1274             i < xbi->bi_module_cnt; i++, modp++) {
1275                 saved_file_size[FASTBOOT_NAME_BOOTARCHIVE] += modp->bm_size;
1276         }
1277 }
1278 #endif  /* __xpv */
1279 
1280 /*
1281  * Import boot environment module variables as properties, applying
1282  * blacklist filter for variables we know we will not use.
1283  *
1284  * Since the environment can be relatively large, containing many variables
1285  * used only for boot loader purposes, we will use a blacklist based filter.
1286  * To keep the blacklist from growing too large, we use prefix based filtering.
1287  * This is possible because in many cases, the loader variable names are
1288  * using a structured layout.
1289  *
1290  * We will not overwrite already set properties.
1291  *
1292  * Note that the menu items in particular can contain characters not
1293  * well-handled as bootparams, such as spaces, brackets, and the like, so that's
1294  * another reason.
1295  */
1296 static struct bop_blacklist {
1297         const char *bl_name;
1298         int bl_name_len;
1299 } bop_prop_blacklist[] = {
1300         { "ISADIR", sizeof ("ISADIR") },
1301         { "acpi", sizeof ("acpi") },
1302         { "autoboot_delay", sizeof ("autoboot_delay") },

1303         { "beansi_", sizeof ("beansi_") },
1304         { "beastie", sizeof ("beastie") },
1305         { "bemenu", sizeof ("bemenu") },
1306         { "boot.", sizeof ("boot.") },
1307         { "bootenv", sizeof ("bootenv") },
1308         { "currdev", sizeof ("currdev") },
1309         { "dhcp.", sizeof ("dhcp.") },
1310         { "interpret", sizeof ("interpret") },
1311         { "kernel", sizeof ("kernel") },
1312         { "loaddev", sizeof ("loaddev") },
1313         { "loader_", sizeof ("loader_") },
1314         { "mainansi_", sizeof ("mainansi_") },
1315         { "mainmenu_", sizeof ("mainmenu_") },
1316         { "maintoggled_", sizeof ("maintoggled_") },
1317         { "menu_timeout_command", sizeof ("menu_timeout_command") },
1318         { "menuset_", sizeof ("menuset_") },
1319         { "module_path", sizeof ("module_path") },
1320         { "nfs.", sizeof ("nfs.") },
1321         { "optionsansi_", sizeof ("optionsansi_") },
1322         { "optionsmenu_", sizeof ("optionsmenu_") },
1323         { "optionstoggled_", sizeof ("optionstoggled_") },
1324         { "pcibios", sizeof ("pcibios") },
1325         { "prompt", sizeof ("prompt") },
1326         { "smbios", sizeof ("smbios") },
1327         { "tem", sizeof ("tem") },
1328         { "twiddle_divisor", sizeof ("twiddle_divisor") },
1329         { "zfs_be", sizeof ("zfs_be") },
1330 };
1331 
1332 /*
1333  * Match the name against prefixes in above blacklist. If the match was
1334  * found, this name is blacklisted.
1335  */
1336 static boolean_t
1337 name_is_blacklisted(const char *name)
1338 {
1339         int i, n;
1340 
1341         n = sizeof (bop_prop_blacklist) / sizeof (bop_prop_blacklist[0]);
1342         for (i = 0; i < n; i++) {
1343                 if (strncmp(bop_prop_blacklist[i].bl_name, name,