xref: /OK3568_Linux_fs/buildroot/boot/grub2/0148-templates-Disable-the-os-prober-by-default.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From e346414725a70e5c74ee87ca14e580c66f517666 Mon Sep 17 00:00:00 2001
2From: Alex Burmashev <alexander.burmashev@oracle.com>
3Date: Tue, 16 Feb 2021 11:12:12 +0100
4Subject: [PATCH] templates: Disable the os-prober by default
5
6The os-prober is enabled by default what may lead to potentially
7dangerous use cases and borderline opening attack vectors. This
8patch disables the os-prober, adds warning messages and updates
9GRUB_DISABLE_OS_PROBER configuration option documentation. This
10way we make it clear that the os-prober usage is not recommended.
11
12Simplistic nature of this change allows downstream vendors, who
13really want os-prober to be enabled out of the box in their
14relevant products, easily revert to it's old behavior.
15
16Reported-by: NyankoSec (<nyanko@10x.moe>, https://twitter.com/NyankoSec),
17             working with SSD Secure Disclosure
18Signed-off-by: Alex Burmashev <alexander.burmashev@oracle.com>
19Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
20Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
21---
22 docs/grub.texi              | 18 ++++++++++--------
23 util/grub.d/30_os-prober.in |  5 ++++-
24 2 files changed, 14 insertions(+), 9 deletions(-)
25
26diff --git a/docs/grub.texi b/docs/grub.texi
27index e302797..45a9f80 100644
28--- a/docs/grub.texi
29+++ b/docs/grub.texi
30@@ -1481,10 +1481,13 @@ boot sequence.  If you have problems, set this option to @samp{text} and
31 GRUB will tell Linux to boot in normal text mode.
32
33 @item GRUB_DISABLE_OS_PROBER
34-Normally, @command{grub-mkconfig} will try to use the external
35-@command{os-prober} program, if installed, to discover other operating
36-systems installed on the same system and generate appropriate menu entries
37-for them.  Set this option to @samp{true} to disable this.
38+The @command{grub-mkconfig} has a feature to use the external
39+@command{os-prober} program to discover other operating systems installed on
40+the same machine and generate appropriate menu entries for them. It is disabled
41+by default since automatic and silent execution of @command{os-prober}, and
42+creating boot entries based on that data, is a potential attack vector. Set
43+this option to @samp{false} to enable this feature in the
44+@command{grub-mkconfig} command.
45
46 @item GRUB_OS_PROBER_SKIP_LIST
47 List of space-separated FS UUIDs of filesystems to be ignored from os-prober
48@@ -1812,10 +1815,9 @@ than zero; otherwise 0.
49 @section Multi-boot manual config
50
51 Currently autogenerating config files for multi-boot environments depends on
52-os-prober and has several shortcomings. While fixing it is scheduled for the
53-next release, meanwhile you can make use of the power of GRUB syntax and do it
54-yourself. A possible configuration is detailed here, feel free to adjust to your
55-needs.
56+os-prober and has several shortcomings. Due to that it is disabled by default.
57+It is advised to use the power of GRUB syntax and do it yourself. A possible
58+configuration is detailed here, feel free to adjust to your needs.
59
60 First create a separate GRUB partition, big enough to hold GRUB. Some of the
61 following entries show how to load OS installer images from this same partition,
62diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in
63index 515a68c..99de043 100644
64--- a/util/grub.d/30_os-prober.in
65+++ b/util/grub.d/30_os-prober.in
66@@ -26,7 +26,8 @@ export TEXTDOMAINDIR="@localedir@"
67
68 . "$pkgdatadir/grub-mkconfig_lib"
69
70-if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
71+if [ "x${GRUB_DISABLE_OS_PROBER}" = "xfalse" ]; then
72+  gettext_printf "os-prober will not be executed to detect other bootable partitions.\nSystems on them will not be added to the GRUB boot configuration.\nCheck GRUB_DISABLE_OS_PROBER documentation entry.\n"
73   exit 0
74 fi
75
76@@ -39,6 +40,8 @@ OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
77 if [ -z "${OSPROBED}" ] ; then
78   # empty os-prober output, nothing doing
79   exit 0
80+else
81+  grub_warn "$(gettext_printf "os-prober was executed to detect other bootable partitions.\nIt's output will be used to detect bootable binaries on them and create new boot entries.")"
82 fi
83
84 osx_entry() {
85--
862.14.2
87
88