History

Merge branch 'linus' into timers/urgent, to pick up fixes

Ingo Molnar committed 10 years ago

Commit fdbdfef2 parents 6731b0d a0cba214843 files · +205309 −138546Browse files

Showing the changes to kernel (20 of 4843 files). Show all

Unified · Split

20 files
  1. kernel/configs/android-base.config +152 −0
  2. kernel/configs/android-recommended.config +121 −0
  3. kernel/events/core.c +1 −1
  4. kernel/exit.c +1 −1
  5. kernel/jump_label.c +60 −1
  6. kernel/kexec.c +2 −1
  7. kernel/kexec_core.c +45 −24
  8. kernel/ksysfs.c +3 −3
  9. kernel/livepatch/core.c +1 −1
  10. kernel/module.c +101 −21
  11. kernel/panic.c +4 −9
  12. kernel/printk/printk.c +154 −16
  13. kernel/ptrace.c +2 −2
  14. kernel/relay.c +32 −2
  15. kernel/seccomp.c +3 −3
  16. kernel/sysctl.c +7 −0
  17. kernel/task_work.c +6 −4
  18. kernel/trace/Makefile +4 −0
  19. kernel/trace/blktrace.c +3 −3
  20. kernel/trace/trace_events_hist.c +7 −7
kernel/configs/android-base.config+152−0
@@ -0,0 +1,152 @@
1# KEEP ALPHABETICALLY SORTED
2# CONFIG_DEVKMEM is not set
3# CONFIG_DEVMEM is not set
4# CONFIG_INET_LRO is not set
5# CONFIG_MODULES is not set
6# CONFIG_OABI_COMPAT is not set
7# CONFIG_SYSVIPC is not set
8CONFIG_ANDROID=y
9CONFIG_ANDROID_BINDER_IPC=y
10CONFIG_ANDROID_LOW_MEMORY_KILLER=y
11CONFIG_ARMV8_DEPRECATED=y
12CONFIG_ASHMEM=y
13CONFIG_AUDIT=y
14CONFIG_BLK_DEV_DM=y
15CONFIG_BLK_DEV_INITRD=y
16CONFIG_CGROUPS=y
17CONFIG_CGROUP_CPUACCT=y
18CONFIG_CGROUP_DEBUG=y
19CONFIG_CGROUP_FREEZER=y
20CONFIG_CGROUP_SCHED=y
21CONFIG_CP15_BARRIER_EMULATION=y
22CONFIG_DM_CRYPT=y
23CONFIG_DM_VERITY=y
24CONFIG_DM_VERITY_FEC=y
25CONFIG_EMBEDDED=y
26CONFIG_FB=y
27CONFIG_HIGH_RES_TIMERS=y
28CONFIG_INET6_AH=y
29CONFIG_INET6_ESP=y
30CONFIG_INET6_IPCOMP=y
31CONFIG_INET=y
32CONFIG_INET_DIAG_DESTROY=y
33CONFIG_INET_ESP=y
34CONFIG_INET_XFRM_MODE_TUNNEL=y
35CONFIG_IP6_NF_FILTER=y
36CONFIG_IP6_NF_IPTABLES=y
37CONFIG_IP6_NF_MANGLE=y
38CONFIG_IP6_NF_RAW=y
39CONFIG_IP6_NF_TARGET_REJECT=y
40CONFIG_IPV6=y
41CONFIG_IPV6_MIP6=y
42CONFIG_IPV6_MULTIPLE_TABLES=y
43CONFIG_IPV6_OPTIMISTIC_DAD=y
44CONFIG_IPV6_PRIVACY=y
45CONFIG_IPV6_ROUTER_PREF=y
46CONFIG_IPV6_ROUTE_INFO=y
47CONFIG_IP_ADVANCED_ROUTER=y
48CONFIG_IP_MULTICAST=y
49CONFIG_IP_MULTIPLE_TABLES=y
50CONFIG_IP_NF_ARPFILTER=y
51CONFIG_IP_NF_ARPTABLES=y
52CONFIG_IP_NF_ARP_MANGLE=y
53CONFIG_IP_NF_FILTER=y
54CONFIG_IP_NF_IPTABLES=y
55CONFIG_IP_NF_MANGLE=y
56CONFIG_IP_NF_MATCH_AH=y
57CONFIG_IP_NF_MATCH_ECN=y
58CONFIG_IP_NF_MATCH_TTL=y
59CONFIG_IP_NF_NAT=y
60CONFIG_IP_NF_RAW=y
61CONFIG_IP_NF_SECURITY=y
62CONFIG_IP_NF_TARGET_MASQUERADE=y
63CONFIG_IP_NF_TARGET_NETMAP=y
64CONFIG_IP_NF_TARGET_REDIRECT=y
65CONFIG_IP_NF_TARGET_REJECT=y
66CONFIG_NET=y
67CONFIG_NETDEVICES=y
68CONFIG_NETFILTER=y
69CONFIG_NETFILTER_TPROXY=y
70CONFIG_NETFILTER_XT_MATCH_COMMENT=y
71CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=y
72CONFIG_NETFILTER_XT_MATCH_CONNMARK=y
73CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
74CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=y
75CONFIG_NETFILTER_XT_MATCH_HELPER=y
76CONFIG_NETFILTER_XT_MATCH_IPRANGE=y
77CONFIG_NETFILTER_XT_MATCH_LENGTH=y
78CONFIG_NETFILTER_XT_MATCH_LIMIT=y
79CONFIG_NETFILTER_XT_MATCH_MAC=y
80CONFIG_NETFILTER_XT_MATCH_MARK=y
81CONFIG_NETFILTER_XT_MATCH_PKTTYPE=y
82CONFIG_NETFILTER_XT_MATCH_POLICY=y
83CONFIG_NETFILTER_XT_MATCH_QUOTA=y
84CONFIG_NETFILTER_XT_MATCH_SOCKET=y
85CONFIG_NETFILTER_XT_MATCH_STATE=y
86CONFIG_NETFILTER_XT_MATCH_STATISTIC=y
87CONFIG_NETFILTER_XT_MATCH_STRING=y
88CONFIG_NETFILTER_XT_MATCH_TIME=y
89CONFIG_NETFILTER_XT_MATCH_U32=y
90CONFIG_NETFILTER_XT_TARGET_CLASSIFY=y
91CONFIG_NETFILTER_XT_TARGET_CONNMARK=y
92CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=y
93CONFIG_NETFILTER_XT_TARGET_IDLETIMER=y
94CONFIG_NETFILTER_XT_TARGET_MARK=y
95CONFIG_NETFILTER_XT_TARGET_NFLOG=y
96CONFIG_NETFILTER_XT_TARGET_NFQUEUE=y
97CONFIG_NETFILTER_XT_TARGET_SECMARK=y
98CONFIG_NETFILTER_XT_TARGET_TCPMSS=y
99CONFIG_NETFILTER_XT_TARGET_TPROXY=y
100CONFIG_NETFILTER_XT_TARGET_TRACE=y
101CONFIG_NET_CLS_ACT=y
102CONFIG_NET_CLS_U32=y
103CONFIG_NET_EMATCH=y
104CONFIG_NET_EMATCH_U32=y
105CONFIG_NET_KEY=y
106CONFIG_NET_SCHED=y
107CONFIG_NET_SCH_HTB=y
108CONFIG_NF_CONNTRACK=y
109CONFIG_NF_CONNTRACK_AMANDA=y
110CONFIG_NF_CONNTRACK_EVENTS=y
111CONFIG_NF_CONNTRACK_FTP=y
112CONFIG_NF_CONNTRACK_H323=y
113CONFIG_NF_CONNTRACK_IPV4=y
114CONFIG_NF_CONNTRACK_IPV6=y
115CONFIG_NF_CONNTRACK_IRC=y
116CONFIG_NF_CONNTRACK_NETBIOS_NS=y
117CONFIG_NF_CONNTRACK_PPTP=y
118CONFIG_NF_CONNTRACK_SANE=y
119CONFIG_NF_CONNTRACK_SECMARK=y
120CONFIG_NF_CONNTRACK_TFTP=y
121CONFIG_NF_CT_NETLINK=y
122CONFIG_NF_CT_PROTO_DCCP=y
123CONFIG_NF_CT_PROTO_SCTP=y
124CONFIG_NF_CT_PROTO_UDPLITE=y
125CONFIG_NF_NAT=y
126CONFIG_NO_HZ=y
127CONFIG_PACKET=y
128CONFIG_PM_AUTOSLEEP=y
129CONFIG_PM_WAKELOCKS=y
130CONFIG_PPP=y
131CONFIG_PPP_BSDCOMP=y
132CONFIG_PPP_DEFLATE=y
133CONFIG_PPP_MPPE=y
134CONFIG_PREEMPT=y
135CONFIG_QUOTA=y
136CONFIG_RTC_CLASS=y
137CONFIG_RT_GROUP_SCHED=y
138CONFIG_SECURITY=y
139CONFIG_SECURITY_NETWORK=y
140CONFIG_SECURITY_SELINUX=y
141CONFIG_SETEND_EMULATION=y
142CONFIG_STAGING=y
143CONFIG_SWP_EMULATION=y
144CONFIG_SYNC=y
145CONFIG_TUN=y
146CONFIG_UNIX=y
147CONFIG_USB_GADGET=y
148CONFIG_USB_CONFIGFS=y
149CONFIG_USB_CONFIGFS_F_FS=y
150CONFIG_USB_CONFIGFS_F_MIDI=y
151CONFIG_USB_OTG_WAKELOCK=y
152CONFIG_XFRM_USER=y
kernel/configs/android-recommended.config+121−0
@@ -0,0 +1,121 @@
1# KEEP ALPHABETICALLY SORTED
2# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
3# CONFIG_INPUT_MOUSE is not set
4# CONFIG_LEGACY_PTYS is not set
5# CONFIG_NF_CONNTRACK_SIP is not set
6# CONFIG_PM_WAKELOCKS_GC is not set
7# CONFIG_VT is not set
8CONFIG_BACKLIGHT_LCD_SUPPORT=y
9CONFIG_BLK_DEV_LOOP=y
10CONFIG_BLK_DEV_RAM=y
11CONFIG_BLK_DEV_RAM_SIZE=8192
12CONFIG_COMPACTION=y
13CONFIG_DEBUG_RODATA=y
14CONFIG_DM_UEVENT=y
15CONFIG_DRAGONRISE_FF=y
16CONFIG_ENABLE_DEFAULT_TRACERS=y
17CONFIG_EXT4_FS=y
18CONFIG_EXT4_FS_SECURITY=y
19CONFIG_FUSE_FS=y
20CONFIG_GREENASIA_FF=y
21CONFIG_HIDRAW=y
22CONFIG_HID_A4TECH=y
23CONFIG_HID_ACRUX=y
24CONFIG_HID_ACRUX_FF=y
25CONFIG_HID_APPLE=y
26CONFIG_HID_BELKIN=y
27CONFIG_HID_CHERRY=y
28CONFIG_HID_CHICONY=y
29CONFIG_HID_CYPRESS=y
30CONFIG_HID_DRAGONRISE=y
31CONFIG_HID_ELECOM=y
32CONFIG_HID_EMS_FF=y
33CONFIG_HID_EZKEY=y
34CONFIG_HID_GREENASIA=y
35CONFIG_HID_GYRATION=y
36CONFIG_HID_HOLTEK=y
37CONFIG_HID_KENSINGTON=y
38CONFIG_HID_KEYTOUCH=y
39CONFIG_HID_KYE=y
40CONFIG_HID_LCPOWER=y
41CONFIG_HID_LOGITECH=y
42CONFIG_HID_LOGITECH_DJ=y
43CONFIG_HID_MAGICMOUSE=y
44CONFIG_HID_MICROSOFT=y
45CONFIG_HID_MONTEREY=y
46CONFIG_HID_MULTITOUCH=y
47CONFIG_HID_NTRIG=y
48CONFIG_HID_ORTEK=y
49CONFIG_HID_PANTHERLORD=y
50CONFIG_HID_PETALYNX=y
51CONFIG_HID_PICOLCD=y
52CONFIG_HID_PRIMAX=y
53CONFIG_HID_PRODIKEYS=y
54CONFIG_HID_ROCCAT=y
55CONFIG_HID_SAITEK=y
56CONFIG_HID_SAMSUNG=y
57CONFIG_HID_SMARTJOYPLUS=y
58CONFIG_HID_SONY=y
59CONFIG_HID_SPEEDLINK=y
60CONFIG_HID_SUNPLUS=y
61CONFIG_HID_THRUSTMASTER=y
62CONFIG_HID_TIVO=y
63CONFIG_HID_TOPSEED=y
64CONFIG_HID_TWINHAN=y
65CONFIG_HID_UCLOGIC=y
66CONFIG_HID_WACOM=y
67CONFIG_HID_WALTOP=y
68CONFIG_HID_WIIMOTE=y
69CONFIG_HID_ZEROPLUS=y
70CONFIG_HID_ZYDACRON=y
71CONFIG_INPUT_EVDEV=y
72CONFIG_INPUT_GPIO=y
73CONFIG_INPUT_JOYSTICK=y
74CONFIG_INPUT_MISC=y
75CONFIG_INPUT_TABLET=y
76CONFIG_INPUT_UINPUT=y
77CONFIG_ION=y
78CONFIG_JOYSTICK_XPAD=y
79CONFIG_JOYSTICK_XPAD_FF=y
80CONFIG_JOYSTICK_XPAD_LEDS=y
81CONFIG_KALLSYMS_ALL=y
82CONFIG_KSM=y
83CONFIG_LOGIG940_FF=y
84CONFIG_LOGIRUMBLEPAD2_FF=y
85CONFIG_LOGITECH_FF=y
86CONFIG_MD=y
87CONFIG_MEDIA_SUPPORT=y
88CONFIG_MSDOS_FS=y
89CONFIG_PANIC_TIMEOUT=5
90CONFIG_PANTHERLORD_FF=y
91CONFIG_PERF_EVENTS=y
92CONFIG_PM_DEBUG=y
93CONFIG_PM_RUNTIME=y
94CONFIG_PM_WAKELOCKS_LIMIT=0
95CONFIG_POWER_SUPPLY=y
96CONFIG_PSTORE=y
97CONFIG_PSTORE_CONSOLE=y
98CONFIG_PSTORE_RAM=y
99CONFIG_SCHEDSTATS=y
100CONFIG_SMARTJOYPLUS_FF=y
101CONFIG_SND=y
102CONFIG_SOUND=y
103CONFIG_SUSPEND_TIME=y
104CONFIG_TABLET_USB_ACECAD=y
105CONFIG_TABLET_USB_AIPTEK=y
106CONFIG_TABLET_USB_GTCO=y
107CONFIG_TABLET_USB_HANWANG=y
108CONFIG_TABLET_USB_KBTAB=y
109CONFIG_TASKSTATS=y
110CONFIG_TASK_DELAY_ACCT=y
111CONFIG_TASK_IO_ACCOUNTING=y
112CONFIG_TASK_XACCT=y
113CONFIG_TIMER_STATS=y
114CONFIG_TMPFS=y
115CONFIG_TMPFS_POSIX_ACL=y
116CONFIG_UHID=y
117CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
118CONFIG_USB_EHCI_HCD=y
119CONFIG_USB_HIDDEV=y
120CONFIG_USB_USBNET=y
121CONFIG_VFAT_FS=y
kernel/events/core.c+1−1
@@ -448,7 +448,7 @@ static u64 __report_allowed; · 447 unmodified lines
448 448
449static void perf_duration_warn(struct irq_work *w)449static void perf_duration_warn(struct irq_work *w)
450{450{
451 printk_ratelimited(KERN_WARNING451 printk_ratelimited(KERN_INFO
452 "perf: interrupt took too long (%lld > %lld), lowering "452 "perf: interrupt took too long (%lld > %lld), lowering "
453 "kernel.perf_event_max_sample_rate to %d\n",453 "kernel.perf_event_max_sample_rate to %d\n",
454 __report_avg, __report_allowed,454 __report_avg, __report_allowed,
kernel/exit.c+1−1
@@ -715,7 +715,7 @@ static void check_stack_usage(void) · 714 unmodified lines
715 715
716 spin_lock(&low_water_lock);716 spin_lock(&low_water_lock);
717 if (free < lowest_to_date) {717 if (free < lowest_to_date) {
718 pr_warn("%s (%d) used greatest stack depth: %lu bytes left\n",718 pr_info("%s (%d) used greatest stack depth: %lu bytes left\n",
719 current->comm, task_pid_nr(current), free);719 current->comm, task_pid_nr(current), free);
720 lowest_to_date = free;720 lowest_to_date = free;
721 }721 }
kernel/jump_label.c+60−1
@@ -14,6 +14,7 @@ · 13 unmodified lines
14#include <linux/err.h>14#include <linux/err.h>
15#include <linux/static_key.h>15#include <linux/static_key.h>
16#include <linux/jump_label_ratelimit.h>16#include <linux/jump_label_ratelimit.h>
17#include <linux/bug.h>
17 18
18#ifdef HAVE_JUMP_LABEL19#ifdef HAVE_JUMP_LABEL
19 20
@@ -56,6 +57,49 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop) · 36 unmodified lines
56 57
57static void jump_label_update(struct static_key *key);58static void jump_label_update(struct static_key *key);
58 59
60/*
61 * There are similar definitions for the !HAVE_JUMP_LABEL case in jump_label.h.
62 * The use of 'atomic_read()' requires atomic.h and its problematic for some
63 * kernel headers such as kernel.h and others. Since static_key_count() is not
64 * used in the branch statements as it is for the !HAVE_JUMP_LABEL case its ok
65 * to have it be a function here. Similarly, for 'static_key_enable()' and
66 * 'static_key_disable()', which require bug.h. This should allow jump_label.h
67 * to be included from most/all places for HAVE_JUMP_LABEL.
68 */
69int static_key_count(struct static_key *key)
70{
71 /*
72 * -1 means the first static_key_slow_inc() is in progress.
73 * static_key_enabled() must return true, so return 1 here.
74 */
75 int n = atomic_read(&key->enabled);
76
77 return n >= 0 ? n : 1;
78}
79EXPORT_SYMBOL_GPL(static_key_count);
80
81void static_key_enable(struct static_key *key)
82{
83 int count = static_key_count(key);
84
85 WARN_ON_ONCE(count < 0 || count > 1);
86
87 if (!count)
88 static_key_slow_inc(key);
89}
90EXPORT_SYMBOL_GPL(static_key_enable);
91
92void static_key_disable(struct static_key *key)
93{
94 int count = static_key_count(key);
95
96 WARN_ON_ONCE(count < 0 || count > 1);
97
98 if (count)
99 static_key_slow_dec(key);
100}
101EXPORT_SYMBOL_GPL(static_key_disable);
102
59void static_key_slow_inc(struct static_key *key)103void static_key_slow_inc(struct static_key *key)
60{104{
61 int v, v1;105 int v, v1;
@@ -235,6 +279,18 @@ void __init jump_label_init(void) · 173 unmodified lines
235 struct static_key *key = NULL;279 struct static_key *key = NULL;
236 struct jump_entry *iter;280 struct jump_entry *iter;
237 281
282 /*
283 * Since we are initializing the static_key.enabled field with
284 * with the 'raw' int values (to avoid pulling in atomic.h) in
285 * jump_label.h, let's make sure that is safe. There are only two
286 * cases to check since we initialize to 0 or 1.
287 */
288 BUILD_BUG_ON((int)ATOMIC_INIT(0) != 0);
289 BUILD_BUG_ON((int)ATOMIC_INIT(1) != 1);
290
291 if (static_key_initialized)
292 return;
293
238 jump_label_lock();294 jump_label_lock();
239 jump_label_sort_entries(iter_start, iter_stop);295 jump_label_sort_entries(iter_start, iter_stop);
240 296
@@ -284,11 +340,14 @@ static int __jump_label_mod_text_reserved(void *start, void *end) · 43 unmodified lines
284{340{
285 struct module *mod;341 struct module *mod;
286 342
343 preempt_disable();
287 mod = __module_text_address((unsigned long)start);344 mod = __module_text_address((unsigned long)start);
345 WARN_ON_ONCE(__module_text_address((unsigned long)end) != mod);
346 preempt_enable();
347
288 if (!mod)348 if (!mod)
289 return 0;349 return 0;
290 350
291 WARN_ON_ONCE(__module_text_address((unsigned long)end) != mod);
292 351
293 return __jump_label_text_reserved(mod->jump_entries,352 return __jump_label_text_reserved(mod->jump_entries,
294 mod->jump_entries + mod->num_jump_entries,353 mod->jump_entries + mod->num_jump_entries,
kernel/kexec.c+2−1
@@ -48,7 +48,8 @@ static int kimage_alloc_init(struct kimage **rimage, unsigned long entry, · 47 unmodified lines
48 48
49 if (kexec_on_panic) {49 if (kexec_on_panic) {
50 /* Verify we have a valid entry point */50 /* Verify we have a valid entry point */
51 if ((entry < crashk_res.start) || (entry > crashk_res.end))51 if ((entry < phys_to_boot_phys(crashk_res.start)) ||
52 (entry > phys_to_boot_phys(crashk_res.end)))
52 return -EADDRNOTAVAIL;53 return -EADDRNOTAVAIL;
53 }54 }
54 55
kernel/kexec_core.c+45−24
@@ -95,6 +95,12 @@ int kexec_should_crash(struct task_struct *p) · 94 unmodified lines
95 return 0;95 return 0;
96}96}
97 97
98int kexec_crash_loaded(void)
99{
100 return !!kexec_crash_image;
101}
102EXPORT_SYMBOL_GPL(kexec_crash_loaded);
103
98/*104/*
99 * When kexec transitions to the new kernel there is a one-to-one105 * When kexec transitions to the new kernel there is a one-to-one
100 * mapping between physical and virtual addresses. On processors106 * mapping between physical and virtual addresses. On processors
@@ -140,6 +146,7 @@ int kexec_should_crash(struct task_struct *p) · 39 unmodified lines
140 * allocating pages whose destination address we do not care about.146 * allocating pages whose destination address we do not care about.
141 */147 */
142#define KIMAGE_NO_DEST (-1UL)148#define KIMAGE_NO_DEST (-1UL)
149#define PAGE_COUNT(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
143 150
144static struct page *kimage_alloc_page(struct kimage *image,151static struct page *kimage_alloc_page(struct kimage *image,
145 gfp_t gfp_mask,152 gfp_t gfp_mask,
@@ -147,8 +154,9 @@ static struct page *kimage_alloc_page(struct kimage *image, · 1 unmodified line
147 154
148int sanity_check_segment_list(struct kimage *image)155int sanity_check_segment_list(struct kimage *image)
149{156{
150 int result, i;157 int i;
151 unsigned long nr_segments = image->nr_segments;158 unsigned long nr_segments = image->nr_segments;
159 unsigned long total_pages = 0;
152 160
153 /*161 /*
154 * Verify we have good destination addresses. The caller is162 * Verify we have good destination addresses. The caller is
@@ -163,16 +171,17 @@ int sanity_check_segment_list(struct kimage *image) · 8 unmodified lines
163 * simply because addresses are changed to page size171 * simply because addresses are changed to page size
164 * granularity.172 * granularity.
165 */173 */
166 result = -EADDRNOTAVAIL;
167 for (i = 0; i < nr_segments; i++) {174 for (i = 0; i < nr_segments; i++) {
168 unsigned long mstart, mend;175 unsigned long mstart, mend;
169 176
170 mstart = image->segment[i].mem;177 mstart = image->segment[i].mem;
171 mend = mstart + image->segment[i].memsz;178 mend = mstart + image->segment[i].memsz;
179 if (mstart > mend)
180 return -EADDRNOTAVAIL;
172 if ((mstart & ~PAGE_MASK) || (mend & ~PAGE_MASK))181 if ((mstart & ~PAGE_MASK) || (mend & ~PAGE_MASK))
173 return result;182 return -EADDRNOTAVAIL;
174 if (mend >= KEXEC_DESTINATION_MEMORY_LIMIT)183 if (mend >= KEXEC_DESTINATION_MEMORY_LIMIT)
175 return result;184 return -EADDRNOTAVAIL;
176 }185 }
177 186
178 /* Verify our destination addresses do not overlap.187 /* Verify our destination addresses do not overlap.
@@ -180,7 +189,6 @@ int sanity_check_segment_list(struct kimage *image) · 1 unmodified line
180 * through very weird things can happen with no189 * through very weird things can happen with no
181 * easy explanation as one segment stops on another.190 * easy explanation as one segment stops on another.
182 */191 */
183 result = -EINVAL;
184 for (i = 0; i < nr_segments; i++) {192 for (i = 0; i < nr_segments; i++) {
185 unsigned long mstart, mend;193 unsigned long mstart, mend;
186 unsigned long j;194 unsigned long j;
@@ -194,7 +202,7 @@ int sanity_check_segment_list(struct kimage *image) · 7 unmodified lines
194 pend = pstart + image->segment[j].memsz;202 pend = pstart + image->segment[j].memsz;
195 /* Do the segments overlap ? */203 /* Do the segments overlap ? */
196 if ((mend > pstart) && (mstart < pend))204 if ((mend > pstart) && (mstart < pend))
197 return result;205 return -EINVAL;
198 }206 }
199 }207 }
200 208
@@ -203,12 +211,26 @@ int sanity_check_segment_list(struct kimage *image) · 2 unmodified lines
203 * and it is easier to check up front than to be surprised211 * and it is easier to check up front than to be surprised
204 * later on.212 * later on.
205 */213 */
206 result = -EINVAL;
207 for (i = 0; i < nr_segments; i++) {214 for (i = 0; i < nr_segments; i++) {
208 if (image->segment[i].bufsz > image->segment[i].memsz)215 if (image->segment[i].bufsz > image->segment[i].memsz)
209 return result;216 return -EINVAL;
217 }
218
219 /*
220 * Verify that no more than half of memory will be consumed. If the
221 * request from userspace is too large, a large amount of time will be
222 * wasted allocating pages, which can cause a soft lockup.
223 */
224 for (i = 0; i < nr_segments; i++) {
225 if (PAGE_COUNT(image->segment[i].memsz) > totalram_pages / 2)
226 return -EINVAL;
227
228 total_pages += PAGE_COUNT(image->segment[i].memsz);
210 }229 }
211 230
231 if (total_pages > totalram_pages / 2)
232 return -EINVAL;
233
212 /*234 /*
213 * Verify we have good destination addresses. Normally235 * Verify we have good destination addresses. Normally
214 * the caller is responsible for making certain we don't236 * the caller is responsible for making certain we don't
@@ -220,16 +242,15 @@ int sanity_check_segment_list(struct kimage *image) · 5 unmodified lines
220 */242 */
221 243
222 if (image->type == KEXEC_TYPE_CRASH) {244 if (image->type == KEXEC_TYPE_CRASH) {
223 result = -EADDRNOTAVAIL;
224 for (i = 0; i < nr_segments; i++) {245 for (i = 0; i < nr_segments; i++) {
225 unsigned long mstart, mend;246 unsigned long mstart, mend;
226 247
227 mstart = image->segment[i].mem;248 mstart = image->segment[i].mem;
228 mend = mstart + image->segment[i].memsz - 1;249 mend = mstart + image->segment[i].memsz - 1;
229 /* Ensure we are within the crash kernel limits */250 /* Ensure we are within the crash kernel limits */
230 if ((mstart < crashk_res.start) ||251 if ((mstart < phys_to_boot_phys(crashk_res.start)) ||
231 (mend > crashk_res.end))252 (mend > phys_to_boot_phys(crashk_res.end)))
232 return result;253 return -EADDRNOTAVAIL;
233 }254 }
234 }255 }
235 256
@@ -352,7 +373,7 @@ static struct page *kimage_alloc_normal_control_pages(struct kimage *image, · 116 unmodified lines
352 pages = kimage_alloc_pages(KEXEC_CONTROL_MEMORY_GFP, order);373 pages = kimage_alloc_pages(KEXEC_CONTROL_MEMORY_GFP, order);
353 if (!pages)374 if (!pages)
354 break;375 break;
355 pfn = page_to_pfn(pages);376 pfn = page_to_boot_pfn(pages);
356 epfn = pfn + count;377 epfn = pfn + count;
357 addr = pfn << PAGE_SHIFT;378 addr = pfn << PAGE_SHIFT;
358 eaddr = epfn << PAGE_SHIFT;379 eaddr = epfn << PAGE_SHIFT;
@@ -478,7 +499,7 @@ static int kimage_add_entry(struct kimage *image, kimage_entry_t entry) · 119 unmodified lines
478 return -ENOMEM;499 return -ENOMEM;
479 500
480 ind_page = page_address(page);501 ind_page = page_address(page);
481 *image->entry = virt_to_phys(ind_page) | IND_INDIRECTION;502 *image->entry = virt_to_boot_phys(ind_page) | IND_INDIRECTION;
482 image->entry = ind_page;503 image->entry = ind_page;
483 image->last_entry = ind_page +504 image->last_entry = ind_page +
484 ((PAGE_SIZE/sizeof(kimage_entry_t)) - 1);505 ((PAGE_SIZE/sizeof(kimage_entry_t)) - 1);
@@ -533,13 +554,13 @@ void kimage_terminate(struct kimage *image) · 48 unmodified lines
533#define for_each_kimage_entry(image, ptr, entry) \554#define for_each_kimage_entry(image, ptr, entry) \
534 for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE); \555 for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE); \
535 ptr = (entry & IND_INDIRECTION) ? \556 ptr = (entry & IND_INDIRECTION) ? \
536 phys_to_virt((entry & PAGE_MASK)) : ptr + 1)557 boot_phys_to_virt((entry & PAGE_MASK)) : ptr + 1)
537 558
538static void kimage_free_entry(kimage_entry_t entry)559static void kimage_free_entry(kimage_entry_t entry)
539{560{
540 struct page *page;561 struct page *page;
541 562
542 page = pfn_to_page(entry >> PAGE_SHIFT);563 page = boot_pfn_to_page(entry >> PAGE_SHIFT);
543 kimage_free_pages(page);564 kimage_free_pages(page);
544}565}
545 566
@@ -633,7 +654,7 @@ static struct page *kimage_alloc_page(struct kimage *image, · 87 unmodified lines
633 * have a match.654 * have a match.
634 */655 */
635 list_for_each_entry(page, &image->dest_pages, lru) {656 list_for_each_entry(page, &image->dest_pages, lru) {
636 addr = page_to_pfn(page) << PAGE_SHIFT;657 addr = page_to_boot_pfn(page) << PAGE_SHIFT;
637 if (addr == destination) {658 if (addr == destination) {
638 list_del(&page->lru);659 list_del(&page->lru);
639 return page;660 return page;
@@ -648,12 +669,12 @@ static struct page *kimage_alloc_page(struct kimage *image, · 8 unmodified lines
648 if (!page)669 if (!page)
649 return NULL;670 return NULL;
650 /* If the page cannot be used file it away */671 /* If the page cannot be used file it away */
651 if (page_to_pfn(page) >672 if (page_to_boot_pfn(page) >
652 (KEXEC_SOURCE_MEMORY_LIMIT >> PAGE_SHIFT)) {673 (KEXEC_SOURCE_MEMORY_LIMIT >> PAGE_SHIFT)) {
653 list_add(&page->lru, &image->unusable_pages);674 list_add(&page->lru, &image->unusable_pages);
654 continue;675 continue;
655 }676 }
656 addr = page_to_pfn(page) << PAGE_SHIFT;677 addr = page_to_boot_pfn(page) << PAGE_SHIFT;
657 678
658 /* If it is the destination page we want use it */679 /* If it is the destination page we want use it */
659 if (addr == destination)680 if (addr == destination)
@@ -676,7 +697,7 @@ static struct page *kimage_alloc_page(struct kimage *image, · 16 unmodified lines
676 struct page *old_page;697 struct page *old_page;
677 698
678 old_addr = *old & PAGE_MASK;699 old_addr = *old & PAGE_MASK;
679 old_page = pfn_to_page(old_addr >> PAGE_SHIFT);700 old_page = boot_pfn_to_page(old_addr >> PAGE_SHIFT);
680 copy_highpage(page, old_page);701 copy_highpage(page, old_page);
681 *old = addr | (*old & ~PAGE_MASK);702 *old = addr | (*old & ~PAGE_MASK);
682 703
@@ -732,7 +753,7 @@ static int kimage_load_normal_segment(struct kimage *image, · 49 unmodified lines
732 result = -ENOMEM;753 result = -ENOMEM;
733 goto out;754 goto out;
734 }755 }
735 result = kimage_add_page(image, page_to_pfn(page)756 result = kimage_add_page(image, page_to_boot_pfn(page)
736 << PAGE_SHIFT);757 << PAGE_SHIFT);
737 if (result < 0)758 if (result < 0)
738 goto out;759 goto out;
@@ -793,7 +814,7 @@ static int kimage_load_crash_segment(struct kimage *image, · 54 unmodified lines
793 char *ptr;814 char *ptr;
794 size_t uchunk, mchunk;815 size_t uchunk, mchunk;
795 816
796 page = pfn_to_page(maddr >> PAGE_SHIFT);817 page = boot_pfn_to_page(maddr >> PAGE_SHIFT);
797 if (!page) {818 if (!page) {
798 result = -ENOMEM;819 result = -ENOMEM;
799 goto out;820 goto out;
@@ -921,7 +942,7 @@ void __weak crash_free_reserved_phys_range(unsigned long begin, · 121 unmodified lines
921 unsigned long addr;942 unsigned long addr;
922 943
923 for (addr = begin; addr < end; addr += PAGE_SIZE)944 for (addr = begin; addr < end; addr += PAGE_SIZE)
924 free_reserved_page(pfn_to_page(addr >> PAGE_SHIFT));945 free_reserved_page(boot_pfn_to_page(addr >> PAGE_SHIFT));
925}946}
926 947
927int crash_shrink_memory(unsigned long new_size)948int crash_shrink_memory(unsigned long new_size)
@@ -1374,7 +1395,7 @@ void vmcoreinfo_append_str(const char *fmt, ...) · 446 unmodified lines
1374void __weak arch_crash_save_vmcoreinfo(void)1395void __weak arch_crash_save_vmcoreinfo(void)
1375{}1396{}
1376 1397
1377unsigned long __weak paddr_vmcoreinfo_note(void)1398phys_addr_t __weak paddr_vmcoreinfo_note(void)
1378{1399{
1379 return __pa((unsigned long)(char *)&vmcoreinfo_note);1400 return __pa((unsigned long)(char *)&vmcoreinfo_note);
1380}1401}
kernel/ksysfs.c+3−3
@@ -101,7 +101,7 @@ KERNEL_ATTR_RO(kexec_loaded); · 100 unmodified lines
101static ssize_t kexec_crash_loaded_show(struct kobject *kobj,101static ssize_t kexec_crash_loaded_show(struct kobject *kobj,
102 struct kobj_attribute *attr, char *buf)102 struct kobj_attribute *attr, char *buf)
103{103{
104 return sprintf(buf, "%d\n", !!kexec_crash_image);104 return sprintf(buf, "%d\n", kexec_crash_loaded());
105}105}
106KERNEL_ATTR_RO(kexec_crash_loaded);106KERNEL_ATTR_RO(kexec_crash_loaded);
107 107
@@ -128,8 +128,8 @@ KERNEL_ATTR_RW(kexec_crash_size); · 20 unmodified lines
128static ssize_t vmcoreinfo_show(struct kobject *kobj,128static ssize_t vmcoreinfo_show(struct kobject *kobj,
129 struct kobj_attribute *attr, char *buf)129 struct kobj_attribute *attr, char *buf)
130{130{
131 return sprintf(buf, "%lx %x\n",131 phys_addr_t vmcore_base = paddr_vmcoreinfo_note();
132 paddr_vmcoreinfo_note(),132 return sprintf(buf, "%pa %x\n", &vmcore_base,
133 (unsigned int)sizeof(vmcoreinfo_note));133 (unsigned int)sizeof(vmcoreinfo_note));
134}134}
135KERNEL_ATTR_RO(vmcoreinfo);135KERNEL_ATTR_RO(vmcoreinfo);
kernel/livepatch/core.c+1−1
@@ -309,7 +309,7 @@ static int klp_write_object_relocations(struct module *pmod, · 308 unmodified lines
309 break;309 break;
310 }310 }
311 311
312 module_enable_ro(pmod);312 module_enable_ro(pmod, true);
313 return ret;313 return ret;
314}314}
315 315
kernel/module.c+101−21
@@ -60,6 +60,7 @@ · 59 unmodified lines
60#include <linux/jump_label.h>60#include <linux/jump_label.h>
61#include <linux/pfn.h>61#include <linux/pfn.h>
62#include <linux/bsearch.h>62#include <linux/bsearch.h>
63#include <linux/dynamic_debug.h>
63#include <uapi/linux/module.h>64#include <uapi/linux/module.h>
64#include "module-internal.h"65#include "module-internal.h"
65 66
@@ -264,7 +265,7 @@ static void module_assert_mutex_or_preempt(void) · 198 unmodified lines
264 if (unlikely(!debug_locks))265 if (unlikely(!debug_locks))
265 return;266 return;
266 267
267 WARN_ON(!rcu_read_lock_sched_held() &&268 WARN_ON_ONCE(!rcu_read_lock_sched_held() &&
268 !lockdep_is_held(&module_mutex));269 !lockdep_is_held(&module_mutex));
269#endif270#endif
270}271}
@@ -336,7 +337,7 @@ static inline void add_taint_module(struct module *mod, unsigned flag, · 65 unmodified lines
336 * A thread that wants to hold a reference to a module only while it337 * A thread that wants to hold a reference to a module only while it
337 * is running can call this to safely exit. nfsd and lockd use this.338 * is running can call this to safely exit. nfsd and lockd use this.
338 */339 */
339void __module_put_and_exit(struct module *mod, long code)340void __noreturn __module_put_and_exit(struct module *mod, long code)
340{341{
341 module_put(mod);342 module_put(mod);
342 do_exit(code);343 do_exit(code);
@@ -1693,8 +1694,7 @@ static int module_add_modinfo_attrs(struct module *mod) · 1350 unmodified lines
1693 1694
1694 temp_attr = mod->modinfo_attrs;1695 temp_attr = mod->modinfo_attrs;
1695 for (i = 0; (attr = modinfo_attrs[i]) && !error; i++) {1696 for (i = 0; (attr = modinfo_attrs[i]) && !error; i++) {
1696 if (!attr->test ||1697 if (!attr->test || attr->test(mod)) {
1697 (attr->test && attr->test(mod))) {
1698 memcpy(temp_attr, attr, sizeof(*temp_attr));1698 memcpy(temp_attr, attr, sizeof(*temp_attr));
1699 sysfs_attr_init(&temp_attr->attr);1699 sysfs_attr_init(&temp_attr->attr);
1700 error = sysfs_create_file(&mod->mkobj.kobj,1700 error = sysfs_create_file(&mod->mkobj.kobj,
@@ -1858,10 +1858,11 @@ static void mod_sysfs_teardown(struct module *mod) · 157 unmodified lines
1858 * from modification and any data from execution.1858 * from modification and any data from execution.
1859 *1859 *
1860 * General layout of module is:1860 * General layout of module is:
1861 * [text] [read-only-data] [writable data]1861 * [text] [read-only-data] [ro-after-init] [writable data]
1862 * text_size -----^ ^ ^1862 * text_size -----^ ^ ^ ^
1863 * ro_size ------------------------| |1863 * ro_size ------------------------| | |
1864 * size -------------------------------------------|1864 * ro_after_init_size -----------------------------| |
1865 * size -----------------------------------------------------------|
1865 *1866 *
1866 * These values are always page-aligned (as is base)1867 * These values are always page-aligned (as is base)
1867 */1868 */
@@ -1884,14 +1885,24 @@ static void frob_rodata(const struct module_layout *layout, · 16 unmodified lines
1884 (layout->ro_size - layout->text_size) >> PAGE_SHIFT);1885 (layout->ro_size - layout->text_size) >> PAGE_SHIFT);
1885}1886}
1886 1887
1888static void frob_ro_after_init(const struct module_layout *layout,
1889 int (*set_memory)(unsigned long start, int num_pages))
1890{
1891 BUG_ON((unsigned long)layout->base & (PAGE_SIZE-1));
1892 BUG_ON((unsigned long)layout->ro_size & (PAGE_SIZE-1));
1893 BUG_ON((unsigned long)layout->ro_after_init_size & (PAGE_SIZE-1));
1894 set_memory((unsigned long)layout->base + layout->ro_size,
1895 (layout->ro_after_init_size - layout->ro_size) >> PAGE_SHIFT);
1896}
1897
1887static void frob_writable_data(const struct module_layout *layout,1898static void frob_writable_data(const struct module_layout *layout,
1888 int (*set_memory)(unsigned long start, int num_pages))1899 int (*set_memory)(unsigned long start, int num_pages))
1889{1900{
1890 BUG_ON((unsigned long)layout->base & (PAGE_SIZE-1));1901 BUG_ON((unsigned long)layout->base & (PAGE_SIZE-1));
1891 BUG_ON((unsigned long)layout->ro_size & (PAGE_SIZE-1));1902 BUG_ON((unsigned long)layout->ro_after_init_size & (PAGE_SIZE-1));
1892 BUG_ON((unsigned long)layout->size & (PAGE_SIZE-1));1903 BUG_ON((unsigned long)layout->size & (PAGE_SIZE-1));
1893 set_memory((unsigned long)layout->base + layout->ro_size,1904 set_memory((unsigned long)layout->base + layout->ro_after_init_size,
1894 (layout->size - layout->ro_size) >> PAGE_SHIFT);1905 (layout->size - layout->ro_after_init_size) >> PAGE_SHIFT);
1895}1906}
1896 1907
1897/* livepatching wants to disable read-only so it can frob module. */1908/* livepatching wants to disable read-only so it can frob module. */
@@ -1899,21 +1910,26 @@ void module_disable_ro(const struct module *mod) · 1 unmodified line
1899{1910{
1900 frob_text(&mod->core_layout, set_memory_rw);1911 frob_text(&mod->core_layout, set_memory_rw);
1901 frob_rodata(&mod->core_layout, set_memory_rw);1912 frob_rodata(&mod->core_layout, set_memory_rw);
1913 frob_ro_after_init(&mod->core_layout, set_memory_rw);
1902 frob_text(&mod->init_layout, set_memory_rw);1914 frob_text(&mod->init_layout, set_memory_rw);
1903 frob_rodata(&mod->init_layout, set_memory_rw);1915 frob_rodata(&mod->init_layout, set_memory_rw);
1904}1916}
1905 1917
1906void module_enable_ro(const struct module *mod)1918void module_enable_ro(const struct module *mod, bool after_init)
1907{1919{
1908 frob_text(&mod->core_layout, set_memory_ro);1920 frob_text(&mod->core_layout, set_memory_ro);
1909 frob_rodata(&mod->core_layout, set_memory_ro);1921 frob_rodata(&mod->core_layout, set_memory_ro);
1910 frob_text(&mod->init_layout, set_memory_ro);1922 frob_text(&mod->init_layout, set_memory_ro);
1911 frob_rodata(&mod->init_layout, set_memory_ro);1923 frob_rodata(&mod->init_layout, set_memory_ro);
1924
1925 if (after_init)
1926 frob_ro_after_init(&mod->core_layout, set_memory_ro);
1912}1927}
1913 1928
1914static void module_enable_nx(const struct module *mod)1929static void module_enable_nx(const struct module *mod)
1915{1930{
1916 frob_rodata(&mod->core_layout, set_memory_nx);1931 frob_rodata(&mod->core_layout, set_memory_nx);
1932 frob_ro_after_init(&mod->core_layout, set_memory_nx);
1917 frob_writable_data(&mod->core_layout, set_memory_nx);1933 frob_writable_data(&mod->core_layout, set_memory_nx);
1918 frob_rodata(&mod->init_layout, set_memory_nx);1934 frob_rodata(&mod->init_layout, set_memory_nx);
1919 frob_writable_data(&mod->init_layout, set_memory_nx);1935 frob_writable_data(&mod->init_layout, set_memory_nx);
@@ -1922,6 +1938,7 @@ static void module_enable_nx(const struct module *mod) · 2 unmodified lines
1922static void module_disable_nx(const struct module *mod)1938static void module_disable_nx(const struct module *mod)
1923{1939{
1924 frob_rodata(&mod->core_layout, set_memory_x);1940 frob_rodata(&mod->core_layout, set_memory_x);
1941 frob_ro_after_init(&mod->core_layout, set_memory_x);
1925 frob_writable_data(&mod->core_layout, set_memory_x);1942 frob_writable_data(&mod->core_layout, set_memory_x);
1926 frob_rodata(&mod->init_layout, set_memory_x);1943 frob_rodata(&mod->init_layout, set_memory_x);
1927 frob_writable_data(&mod->init_layout, set_memory_x);1944 frob_writable_data(&mod->init_layout, set_memory_x);
@@ -1964,6 +1981,8 @@ static void disable_ro_nx(const struct module_layout *layout) · 36 unmodified lines
1964 frob_text(layout, set_memory_rw);1981 frob_text(layout, set_memory_rw);
1965 frob_rodata(layout, set_memory_rw);1982 frob_rodata(layout, set_memory_rw);
1966 frob_rodata(layout, set_memory_x);1983 frob_rodata(layout, set_memory_x);
1984 frob_ro_after_init(layout, set_memory_rw);
1985 frob_ro_after_init(layout, set_memory_x);
1967 frob_writable_data(layout, set_memory_x);1986 frob_writable_data(layout, set_memory_x);
1968}1987}
1969 1988
@@ -2306,6 +2325,7 @@ static void layout_sections(struct module *mod, struct load_info *info) · 336 unmodified lines
2306 * finder in the two loops below */2325 * finder in the two loops below */
2307 { SHF_EXECINSTR | SHF_ALLOC, ARCH_SHF_SMALL },2326 { SHF_EXECINSTR | SHF_ALLOC, ARCH_SHF_SMALL },
2308 { SHF_ALLOC, SHF_WRITE | ARCH_SHF_SMALL },2327 { SHF_ALLOC, SHF_WRITE | ARCH_SHF_SMALL },
2328 { SHF_RO_AFTER_INIT | SHF_ALLOC, ARCH_SHF_SMALL },
2309 { SHF_WRITE | SHF_ALLOC, ARCH_SHF_SMALL },2329 { SHF_WRITE | SHF_ALLOC, ARCH_SHF_SMALL },
2310 { ARCH_SHF_SMALL | SHF_ALLOC, 0 }2330 { ARCH_SHF_SMALL | SHF_ALLOC, 0 }
2311 };2331 };
@@ -2337,7 +2357,11 @@ static void layout_sections(struct module *mod, struct load_info *info) · 25 unmodified lines
2337 mod->core_layout.size = debug_align(mod->core_layout.size);2357 mod->core_layout.size = debug_align(mod->core_layout.size);
2338 mod->core_layout.ro_size = mod->core_layout.size;2358 mod->core_layout.ro_size = mod->core_layout.size;
2339 break;2359 break;
2340 case 3: /* whole core */2360 case 2: /* RO after init */
2361 mod->core_layout.size = debug_align(mod->core_layout.size);
2362 mod->core_layout.ro_after_init_size = mod->core_layout.size;
2363 break;
2364 case 4: /* whole core */
2341 mod->core_layout.size = debug_align(mod->core_layout.size);2365 mod->core_layout.size = debug_align(mod->core_layout.size);
2342 break;2366 break;
2343 }2367 }
@@ -2367,7 +2391,14 @@ static void layout_sections(struct module *mod, struct load_info *info) · 23 unmodified lines
2367 mod->init_layout.size = debug_align(mod->init_layout.size);2391 mod->init_layout.size = debug_align(mod->init_layout.size);
2368 mod->init_layout.ro_size = mod->init_layout.size;2392 mod->init_layout.ro_size = mod->init_layout.size;
2369 break;2393 break;
2370 case 3: /* whole init */2394 case 2:
2395 /*
2396 * RO after init doesn't apply to init_layout (only
2397 * core_layout), so it just takes the value of ro_size.
2398 */
2399 mod->init_layout.ro_after_init_size = mod->init_layout.ro_size;
2400 break;
2401 case 4: /* whole init */
2371 mod->init_layout.size = debug_align(mod->init_layout.size);2402 mod->init_layout.size = debug_align(mod->init_layout.size);
2372 break;2403 break;
2373 }2404 }
@@ -2687,13 +2718,18 @@ static inline void kmemleak_load_module(const struct module *mod, · 313 unmodified lines
2687#endif2718#endif
2688 2719
2689#ifdef CONFIG_MODULE_SIG2720#ifdef CONFIG_MODULE_SIG
2690static int module_sig_check(struct load_info *info)2721static int module_sig_check(struct load_info *info, int flags)
2691{2722{
2692 int err = -ENOKEY;2723 int err = -ENOKEY;
2693 const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1;2724 const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1;
2694 const void *mod = info->hdr;2725 const void *mod = info->hdr;
2695 2726
2696 if (info->len > markerlen &&2727 /*
2728 * Require flags == 0, as a module with version information
2729 * removed is no longer the module that was signed
2730 */
2731 if (flags == 0 &&
2732 info->len > markerlen &&
2697 memcmp(mod + info->len - markerlen, MODULE_SIG_STRING, markerlen) == 0) {2733 memcmp(mod + info->len - markerlen, MODULE_SIG_STRING, markerlen) == 0) {
2698 /* We truncate the module to discard the signature */2734 /* We truncate the module to discard the signature */
2699 info->len -= markerlen;2735 info->len -= markerlen;
@@ -2712,7 +2748,7 @@ static int module_sig_check(struct load_info *info) · 12 unmodified lines
2712 return err;2748 return err;
2713}2749}
2714#else /* !CONFIG_MODULE_SIG */2750#else /* !CONFIG_MODULE_SIG */
2715static int module_sig_check(struct load_info *info)2751static int module_sig_check(struct load_info *info, int flags)
2716{2752{
2717 return 0;2753 return 0;
2718}2754}
@@ -2920,8 +2956,12 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags) · 201 unmodified lines
2920 return -ENOEXEC;2956 return -ENOEXEC;
2921 }2957 }
2922 2958
2923 if (!get_modinfo(info, "intree"))2959 if (!get_modinfo(info, "intree")) {
2960 if (!test_taint(TAINT_OOT_MODULE))
2961 pr_warn("%s: loading out-of-tree module taints kernel.\n",
2962 mod->name);
2924 add_taint_module(mod, TAINT_OOT_MODULE, LOCKDEP_STILL_OK);2963 add_taint_module(mod, TAINT_OOT_MODULE, LOCKDEP_STILL_OK);
2964 }
2925 2965
2926 if (get_modinfo(info, "staging")) {2966 if (get_modinfo(info, "staging")) {
2927 add_taint_module(mod, TAINT_CRAP, LOCKDEP_STILL_OK);2967 add_taint_module(mod, TAINT_CRAP, LOCKDEP_STILL_OK);
@@ -3090,6 +3130,8 @@ static int move_module(struct module *mod, struct load_info *info) · 162 unmodified lines
3090 3130
3091static int check_module_license_and_versions(struct module *mod)3131static int check_module_license_and_versions(struct module *mod)
3092{3132{
3133 int prev_taint = test_taint(TAINT_PROPRIETARY_MODULE);
3134
3093 /*3135 /*
3094 * ndiswrapper is under GPL by itself, but loads proprietary modules.3136 * ndiswrapper is under GPL by itself, but loads proprietary modules.
3095 * Don't use add_taint_module(), as it would prevent ndiswrapper from3137 * Don't use add_taint_module(), as it would prevent ndiswrapper from
@@ -3108,6 +3150,9 @@ static int check_module_license_and_versions(struct module *mod) · 12 unmodified lines
3108 add_taint_module(mod, TAINT_PROPRIETARY_MODULE,3150 add_taint_module(mod, TAINT_PROPRIETARY_MODULE,
3109 LOCKDEP_NOW_UNRELIABLE);3151 LOCKDEP_NOW_UNRELIABLE);
3110 3152
3153 if (!prev_taint && test_taint(TAINT_PROPRIETARY_MODULE))
3154 pr_warn("%s: module license taints kernel.\n", mod->name);
3155
3111#ifdef CONFIG_MODVERSIONS3156#ifdef CONFIG_MODVERSIONS
3112 if ((mod->num_syms && !mod->crcs)3157 if ((mod->num_syms && !mod->crcs)
3113 || (mod->num_gpl_syms && !mod->gpl_crcs)3158 || (mod->num_gpl_syms && !mod->gpl_crcs)
@@ -3155,16 +3200,41 @@ int __weak module_frob_arch_sections(Elf_Ehdr *hdr, · 41 unmodified lines
3155 return 0;3200 return 0;
3156}3201}
3157 3202
3203/* module_blacklist is a comma-separated list of module names */
3204static char *module_blacklist;
3205static bool blacklisted(char *module_name)
3206{
3207 const char *p;
3208 size_t len;
3209
3210 if (!module_blacklist)
3211 return false;
3212
3213 for (p = module_blacklist; *p; p += len) {
3214 len = strcspn(p, ",");
3215 if (strlen(module_name) == len && !memcmp(module_name, p, len))
3216 return true;
3217 if (p[len] == ',')
3218 len++;
3219 }
3220 return false;
3221}
3222core_param(module_blacklist, module_blacklist, charp, 0400);
3223
3158static struct module *layout_and_allocate(struct load_info *info, int flags)3224static struct module *layout_and_allocate(struct load_info *info, int flags)
3159{3225{
3160 /* Module within temporary copy. */3226 /* Module within temporary copy. */
3161 struct module *mod;3227 struct module *mod;
3228 unsigned int ndx;
3162 int err;3229 int err;
3163 3230
3164 mod = setup_load_info(info, flags);3231 mod = setup_load_info(info, flags);
3165 if (IS_ERR(mod))3232 if (IS_ERR(mod))
3166 return mod;3233 return mod;
3167 3234
3235 if (blacklisted(mod->name))
3236 return ERR_PTR(-EPERM);
3237
3168 err = check_modinfo(mod, info, flags);3238 err = check_modinfo(mod, info, flags);
3169 if (err)3239 if (err)
3170 return ERR_PTR(err);3240 return ERR_PTR(err);
@@ -3178,6 +3248,15 @@ static struct module *layout_and_allocate(struct load_info *info, int flags) · 7 unmodified lines
3178 /* We will do a special allocation for per-cpu sections later. */3248 /* We will do a special allocation for per-cpu sections later. */
3179 info->sechdrs[info->index.pcpu].sh_flags &= ~(unsigned long)SHF_ALLOC;3249 info->sechdrs[info->index.pcpu].sh_flags &= ~(unsigned long)SHF_ALLOC;
3180 3250
3251 /*
3252 * Mark ro_after_init section with SHF_RO_AFTER_INIT so that
3253 * layout_sections() can put it in the right place.
3254 * Note: ro_after_init sections also have SHF_{WRITE,ALLOC} set.
3255 */
3256 ndx = find_sec(info, ".data..ro_after_init");
3257 if (ndx)
3258 info->sechdrs[ndx].sh_flags |= SHF_RO_AFTER_INIT;
3259
3181 /* Determine total sizes, and put offsets in sh_entsize. For now3260 /* Determine total sizes, and put offsets in sh_entsize. For now
3182 this is done generically; there doesn't appear to be any3261 this is done generically; there doesn't appear to be any
3183 special cases for the architectures. */3262 special cases for the architectures. */
@@ -3344,12 +3423,14 @@ static noinline int do_init_module(struct module *mod) · 160 unmodified lines
3344 /* Switch to core kallsyms now init is done: kallsyms may be walking! */3423 /* Switch to core kallsyms now init is done: kallsyms may be walking! */
3345 rcu_assign_pointer(mod->kallsyms, &mod->core_kallsyms);3424 rcu_assign_pointer(mod->kallsyms, &mod->core_kallsyms);
3346#endif3425#endif
3426 module_enable_ro(mod, true);
3347 mod_tree_remove_init(mod);3427 mod_tree_remove_init(mod);
3348 disable_ro_nx(&mod->init_layout);3428 disable_ro_nx(&mod->init_layout);
3349 module_arch_freeing_init(mod);3429 module_arch_freeing_init(mod);
3350 mod->init_layout.base = NULL;3430 mod->init_layout.base = NULL;
3351 mod->init_layout.size = 0;3431 mod->init_layout.size = 0;
3352 mod->init_layout.ro_size = 0;3432 mod->init_layout.ro_size = 0;
3433 mod->init_layout.ro_after_init_size = 0;
3353 mod->init_layout.text_size = 0;3434 mod->init_layout.text_size = 0;
3354 /*3435 /*
3355 * We want to free module_init, but be aware that kallsyms may be3436 * We want to free module_init, but be aware that kallsyms may be
@@ -3441,8 +3522,7 @@ static int complete_formation(struct module *mod, struct load_info *info) · 85 unmodified lines
3441 /* This relies on module_mutex for list integrity. */3522 /* This relies on module_mutex for list integrity. */
3442 module_bug_finalize(info->hdr, info->sechdrs, mod);3523 module_bug_finalize(info->hdr, info->sechdrs, mod);
3443 3524
3444 /* Set RO and NX regions */3525 module_enable_ro(mod, false);
3445 module_enable_ro(mod);
3446 module_enable_nx(mod);3526 module_enable_nx(mod);
3447 3527
3448 /* Mark state as coming so strong_try_module_get() ignores us,3528 /* Mark state as coming so strong_try_module_get() ignores us,
@@ -3498,7 +3578,7 @@ static int load_module(struct load_info *info, const char __user *uargs, · 49 unmodified lines
3498 long err;3578 long err;
3499 char *after_dashes;3579 char *after_dashes;
3500 3580
3501 err = module_sig_check(info);3581 err = module_sig_check(info, flags);
3502 if (err)3582 if (err)
3503 goto free_copy;3583 goto free_copy;
3504 3584
kernel/panic.c+4−9
@@ -108,6 +108,7 @@ void panic(const char *fmt, ...) · 107 unmodified lines
108 long i, i_next = 0;108 long i, i_next = 0;
109 int state = 0;109 int state = 0;
110 int old_cpu, this_cpu;110 int old_cpu, this_cpu;
111 bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;
111 112
112 /*113 /*
113 * Disable local interrupts. This will prevent panic_smp_self_stop114 * Disable local interrupts. This will prevent panic_smp_self_stop
@@ -160,7 +161,7 @@ void panic(const char *fmt, ...) · 46 unmodified lines
160 *161 *
161 * Bypass the panic_cpu check and call __crash_kexec directly.162 * Bypass the panic_cpu check and call __crash_kexec directly.
162 */163 */
163 if (!crash_kexec_post_notifiers) {164 if (!_crash_kexec_post_notifiers) {
164 printk_nmi_flush_on_panic();165 printk_nmi_flush_on_panic();
165 __crash_kexec(NULL);166 __crash_kexec(NULL);
166 }167 }
@@ -191,7 +192,7 @@ void panic(const char *fmt, ...) · 24 unmodified lines
191 *192 *
192 * Bypass the panic_cpu check and call __crash_kexec directly.193 * Bypass the panic_cpu check and call __crash_kexec directly.
193 */194 */
194 if (crash_kexec_post_notifiers)195 if (_crash_kexec_post_notifiers)
195 __crash_kexec(NULL);196 __crash_kexec(NULL);
196 197
197 bust_spinlocks(0);198 bust_spinlocks(0);
@@ -571,13 +572,7 @@ EXPORT_SYMBOL(__stack_chk_fail); · 373 unmodified lines
571core_param(panic, panic_timeout, int, 0644);572core_param(panic, panic_timeout, int, 0644);
572core_param(pause_on_oops, pause_on_oops, int, 0644);573core_param(pause_on_oops, pause_on_oops, int, 0644);
573core_param(panic_on_warn, panic_on_warn, int, 0644);574core_param(panic_on_warn, panic_on_warn, int, 0644);
574 575core_param(crash_kexec_post_notifiers, crash_kexec_post_notifiers, bool, 0644);
575static int __init setup_crash_kexec_post_notifiers(char *s)
576{
577 crash_kexec_post_notifiers = true;
578 return 0;
579}
580early_param("crash_kexec_post_notifiers", setup_crash_kexec_post_notifiers);
581 576
582static int __init oops_setup(char *s)577static int __init oops_setup(char *s)
583{578{
kernel/printk/printk.c+154−16
@@ -26,7 +26,6 @@ · 25 unmodified lines
26#include <linux/nmi.h>26#include <linux/nmi.h>
27#include <linux/module.h>27#include <linux/module.h>
28#include <linux/moduleparam.h>28#include <linux/moduleparam.h>
29#include <linux/interrupt.h> /* For in_interrupt() */
30#include <linux/delay.h>29#include <linux/delay.h>
31#include <linux/smp.h>30#include <linux/smp.h>
32#include <linux/security.h>31#include <linux/security.h>
@@ -48,7 +47,7 @@ · 15 unmodified lines
48#include <linux/uio.h>47#include <linux/uio.h>
49 48
50#include <asm/uaccess.h>49#include <asm/uaccess.h>
51#include <asm-generic/sections.h>50#include <asm/sections.h>
52 51
53#define CREATE_TRACE_POINTS52#define CREATE_TRACE_POINTS
54#include <trace/events/printk.h>53#include <trace/events/printk.h>
@@ -86,6 +85,111 @@ static struct lockdep_map console_lock_dep_map = { · 31 unmodified lines
86};85};
87#endif86#endif
88 87
88enum devkmsg_log_bits {
89 __DEVKMSG_LOG_BIT_ON = 0,
90 __DEVKMSG_LOG_BIT_OFF,
91 __DEVKMSG_LOG_BIT_LOCK,
92};
93
94enum devkmsg_log_masks {
95 DEVKMSG_LOG_MASK_ON = BIT(__DEVKMSG_LOG_BIT_ON),
96 DEVKMSG_LOG_MASK_OFF = BIT(__DEVKMSG_LOG_BIT_OFF),
97 DEVKMSG_LOG_MASK_LOCK = BIT(__DEVKMSG_LOG_BIT_LOCK),
98};
99
100/* Keep both the 'on' and 'off' bits clear, i.e. ratelimit by default: */
101#define DEVKMSG_LOG_MASK_DEFAULT 0
102
103static unsigned int __read_mostly devkmsg_log = DEVKMSG_LOG_MASK_DEFAULT;
104
105static int __control_devkmsg(char *str)
106{
107 if (!str)
108 return -EINVAL;
109
110 if (!strncmp(str, "on", 2)) {
111 devkmsg_log = DEVKMSG_LOG_MASK_ON;
112 return 2;
113 } else if (!strncmp(str, "off", 3)) {
114 devkmsg_log = DEVKMSG_LOG_MASK_OFF;
115 return 3;
116 } else if (!strncmp(str, "ratelimit", 9)) {
117 devkmsg_log = DEVKMSG_LOG_MASK_DEFAULT;
118 return 9;
119 }
120 return -EINVAL;
121}
122
123static int __init control_devkmsg(char *str)
124{
125 if (__control_devkmsg(str) < 0)
126 return 1;
127
128 /*
129 * Set sysctl string accordingly:
130 */
131 if (devkmsg_log == DEVKMSG_LOG_MASK_ON) {
132 memset(devkmsg_log_str, 0, DEVKMSG_STR_MAX_SIZE);
133 strncpy(devkmsg_log_str, "on", 2);
134 } else if (devkmsg_log == DEVKMSG_LOG_MASK_OFF) {
135 memset(devkmsg_log_str, 0, DEVKMSG_STR_MAX_SIZE);
136 strncpy(devkmsg_log_str, "off", 3);
137 }
138 /* else "ratelimit" which is set by default. */
139
140 /*
141 * Sysctl cannot change it anymore. The kernel command line setting of
142 * this parameter is to force the setting to be permanent throughout the
143 * runtime of the system. This is a precation measure against userspace
144 * trying to be a smarta** and attempting to change it up on us.
145 */
146 devkmsg_log |= DEVKMSG_LOG_MASK_LOCK;
147
148 return 0;
149}
150__setup("printk.devkmsg=", control_devkmsg);
151
152char devkmsg_log_str[DEVKMSG_STR_MAX_SIZE] = "ratelimit";
153
154int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write,
155 void __user *buffer, size_t *lenp, loff_t *ppos)
156{
157 char old_str[DEVKMSG_STR_MAX_SIZE];
158 unsigned int old;
159 int err;
160
161 if (write) {
162 if (devkmsg_log & DEVKMSG_LOG_MASK_LOCK)
163 return -EINVAL;
164
165 old = devkmsg_log;
166 strncpy(old_str, devkmsg_log_str, DEVKMSG_STR_MAX_SIZE);
167 }
168
169 err = proc_dostring(table, write, buffer, lenp, ppos);
170 if (err)
171 return err;
172
173 if (write) {
174 err = __control_devkmsg(devkmsg_log_str);
175
176 /*
177 * Do not accept an unknown string OR a known string with
178 * trailing crap...
179 */
180 if (err < 0 || (err + 1 != *lenp)) {
181
182 /* ... and restore old setting. */
183 devkmsg_log = old;
184 strncpy(devkmsg_log_str, old_str, DEVKMSG_STR_MAX_SIZE);
185
186 return -EINVAL;
187 }
188 }
189
190 return 0;
191}
192
89/*193/*
90 * Number of registered extended console drivers.194 * Number of registered extended console drivers.
91 *195 *
@@ -614,6 +718,7 @@ struct devkmsg_user { · 522 unmodified lines
614 u64 seq;718 u64 seq;
615 u32 idx;719 u32 idx;
616 enum log_flags prev;720 enum log_flags prev;
721 struct ratelimit_state rs;
617 struct mutex lock;722 struct mutex lock;
618 char buf[CONSOLE_EXT_LOG_MAX];723 char buf[CONSOLE_EXT_LOG_MAX];
619};724};
@@ -623,11 +728,24 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from) · 3 unmodified lines
623 char *buf, *line;728 char *buf, *line;
624 int level = default_message_loglevel;729 int level = default_message_loglevel;
625 int facility = 1; /* LOG_USER */730 int facility = 1; /* LOG_USER */
731 struct file *file = iocb->ki_filp;
732 struct devkmsg_user *user = file->private_data;
626 size_t len = iov_iter_count(from);733 size_t len = iov_iter_count(from);
627 ssize_t ret = len;734 ssize_t ret = len;
628 735
629 if (len > LOG_LINE_MAX)736 if (!user || len > LOG_LINE_MAX)
630 return -EINVAL;737 return -EINVAL;
738
739 /* Ignore when user logging is disabled. */
740 if (devkmsg_log & DEVKMSG_LOG_MASK_OFF)
741 return len;
742
743 /* Ratelimit when not explicitly enabled. */
744 if (!(devkmsg_log & DEVKMSG_LOG_MASK_ON)) {
745 if (!___ratelimit(&user->rs, current->comm))
746 return ret;
747 }
748
631 buf = kmalloc(len+1, GFP_KERNEL);749 buf = kmalloc(len+1, GFP_KERNEL);
632 if (buf == NULL)750 if (buf == NULL)
633 return -ENOMEM;751 return -ENOMEM;
@@ -800,19 +918,24 @@ static int devkmsg_open(struct inode *inode, struct file *file) · 166 unmodified lines
800 struct devkmsg_user *user;918 struct devkmsg_user *user;
801 int err;919 int err;
802 920
803 /* write-only does not need any file context */921 if (devkmsg_log & DEVKMSG_LOG_MASK_OFF)
804 if ((file->f_flags & O_ACCMODE) == O_WRONLY)922 return -EPERM;
805 return 0;
806 923
807 err = check_syslog_permissions(SYSLOG_ACTION_READ_ALL,924 /* write-only does not need any file context */
808 SYSLOG_FROM_READER);925 if ((file->f_flags & O_ACCMODE) != O_WRONLY) {
809 if (err)926 err = check_syslog_permissions(SYSLOG_ACTION_READ_ALL,
810 return err;927 SYSLOG_FROM_READER);
928 if (err)
929 return err;
930 }
811 931
812 user = kmalloc(sizeof(struct devkmsg_user), GFP_KERNEL);932 user = kmalloc(sizeof(struct devkmsg_user), GFP_KERNEL);
813 if (!user)933 if (!user)
814 return -ENOMEM;934 return -ENOMEM;
815 935
936 ratelimit_default_init(&user->rs);
937 ratelimit_set_flags(&user->rs, RATELIMIT_MSG_ON_RELEASE);
938
816 mutex_init(&user->lock);939 mutex_init(&user->lock);
817 940
818 raw_spin_lock_irq(&logbuf_lock);941 raw_spin_lock_irq(&logbuf_lock);
@@ -831,6 +954,8 @@ static int devkmsg_release(struct inode *inode, struct file *file) · 12 unmodified lines
831 if (!user)954 if (!user)
832 return 0;955 return 0;
833 956
957 ratelimit_state_exit(&user->rs);
958
834 mutex_destroy(&user->lock);959 mutex_destroy(&user->lock);
835 kfree(user);960 kfree(user);
836 return 0;961 return 0;
@@ -986,6 +1111,11 @@ module_param(ignore_loglevel, bool, S_IRUGO | S_IWUSR); · 149 unmodified lines
986MODULE_PARM_DESC(ignore_loglevel,1111MODULE_PARM_DESC(ignore_loglevel,
987 "ignore loglevel setting (prints all kernel messages to the console)");1112 "ignore loglevel setting (prints all kernel messages to the console)");
988 1113
1114static bool suppress_message_printing(int level)
1115{
1116 return (level >= console_loglevel && !ignore_loglevel);
1117}
1118
989#ifdef CONFIG_BOOT_PRINTK_DELAY1119#ifdef CONFIG_BOOT_PRINTK_DELAY
990 1120
991static int boot_delay; /* msecs delay after each printk during bootup */1121static int boot_delay; /* msecs delay after each printk during bootup */
@@ -1015,7 +1145,7 @@ static void boot_delay_msec(int level) · 23 unmodified lines
1015 unsigned long timeout;1145 unsigned long timeout;
1016 1146
1017 if ((boot_delay == 0 || system_state != SYSTEM_BOOTING)1147 if ((boot_delay == 0 || system_state != SYSTEM_BOOTING)
1018 || (level >= console_loglevel && !ignore_loglevel)) {1148 || suppress_message_printing(level)) {
1019 return;1149 return;
1020 }1150 }
1021 1151
@@ -1439,8 +1569,6 @@ static void call_console_drivers(int level, · 417 unmodified lines
1439 1569
1440 trace_console(text, len);1570 trace_console(text, len);
1441 1571
1442 if (level >= console_loglevel && !ignore_loglevel)
1443 return;
1444 if (!console_drivers)1572 if (!console_drivers)
1445 return;1573 return;
1446 1574
@@ -1888,6 +2016,7 @@ static void call_console_drivers(int level, · 441 unmodified lines
1888static size_t msg_print_text(const struct printk_log *msg, enum log_flags prev,2016static size_t msg_print_text(const struct printk_log *msg, enum log_flags prev,
1889 bool syslog, char *buf, size_t size) { return 0; }2017 bool syslog, char *buf, size_t size) { return 0; }
1890static size_t cont_print_text(char *text, size_t size) { return 0; }2018static size_t cont_print_text(char *text, size_t size) { return 0; }
2019static bool suppress_message_printing(int level) { return false; }
1891 2020
1892/* Still needs to be defined for users */2021/* Still needs to be defined for users */
1893DEFINE_PER_CPU(printk_func_t, printk_func);2022DEFINE_PER_CPU(printk_func_t, printk_func);
@@ -2167,6 +2296,13 @@ static void console_cont_flush(char *text, size_t size) · 273 unmodified lines
2167 if (!cont.len)2296 if (!cont.len)
2168 goto out;2297 goto out;
2169 2298
2299 if (suppress_message_printing(cont.level)) {
2300 cont.cons = cont.len;
2301 if (cont.flushed)
2302 cont.len = 0;
2303 goto out;
2304 }
2305
2170 /*2306 /*
2171 * We still queue earlier records, likely because the console was2307 * We still queue earlier records, likely because the console was
2172 * busy. The earlier ones need to be printed before this one, we2308 * busy. The earlier ones need to be printed before this one, we
@@ -2270,10 +2406,13 @@ skip: · 97 unmodified lines
2270 break;2406 break;
2271 2407
2272 msg = log_from_idx(console_idx);2408 msg = log_from_idx(console_idx);
2273 if (msg->flags & LOG_NOCONS) {2409 level = msg->level;
2410 if ((msg->flags & LOG_NOCONS) ||
2411 suppress_message_printing(level)) {
2274 /*2412 /*
2275 * Skip record we have buffered and already printed2413 * Skip record we have buffered and already printed
2276 * directly to the console when we received it.2414 * directly to the console when we received it, and
2415 * record that has level above the console loglevel.
2277 */2416 */
2278 console_idx = log_next(console_idx);2417 console_idx = log_next(console_idx);
2279 console_seq++;2418 console_seq++;
@@ -2287,7 +2426,6 @@ skip: · 7 unmodified lines
2287 goto skip;2426 goto skip;
2288 }2427 }
2289 2428
2290 level = msg->level;
2291 len += msg_print_text(msg, console_prev, false,2429 len += msg_print_text(msg, console_prev, false,
2292 text + len, sizeof(text) - len);2430 text + len, sizeof(text) - len);
2293 if (nr_ext_console_drivers) {2431 if (nr_ext_console_drivers) {
kernel/ptrace.c+2−2
@@ -585,8 +585,8 @@ static int ptrace_setoptions(struct task_struct *child, unsigned long data) · 584 unmodified lines
585 return -EINVAL;585 return -EINVAL;
586 586
587 if (unlikely(data & PTRACE_O_SUSPEND_SECCOMP)) {587 if (unlikely(data & PTRACE_O_SUSPEND_SECCOMP)) {
588 if (!config_enabled(CONFIG_CHECKPOINT_RESTORE) ||588 if (!IS_ENABLED(CONFIG_CHECKPOINT_RESTORE) ||
589 !config_enabled(CONFIG_SECCOMP))589 !IS_ENABLED(CONFIG_SECCOMP))
590 return -EINVAL;590 return -EINVAL;
591 591
592 if (!capable(CAP_SYS_ADMIN))592 if (!capable(CAP_SYS_ADMIN))
kernel/relay.c+32−2
@@ -451,6 +451,13 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu) · 450 unmodified lines
451 if (!dentry)451 if (!dentry)
452 goto free_buf;452 goto free_buf;
453 relay_set_buf_dentry(buf, dentry);453 relay_set_buf_dentry(buf, dentry);
454 } else {
455 /* Only retrieve global info, nothing more, nothing less */
456 dentry = chan->cb->create_buf_file(NULL, NULL,
457 S_IRUSR, buf,
458 &chan->is_global);
459 if (WARN_ON(dentry))
460 goto free_buf;
454 }461 }
455 462
456 buf->cpu = cpu;463 buf->cpu = cpu;
@@ -562,6 +569,10 @@ static int relay_hotcpu_callback(struct notifier_block *nb, · 105 unmodified lines
562 * attributes specified. The created channel buffer files569 * attributes specified. The created channel buffer files
563 * will be named base_filename0...base_filenameN-1. File570 * will be named base_filename0...base_filenameN-1. File
564 * permissions will be %S_IRUSR.571 * permissions will be %S_IRUSR.
572 *
573 * If opening a buffer (@parent = NULL) that you later wish to register
574 * in a filesystem, call relay_late_setup_files() once the @parent dentry
575 * is available.
565 */576 */
566struct rchan *relay_open(const char *base_filename,577struct rchan *relay_open(const char *base_filename,
567 struct dentry *parent,578 struct dentry *parent,
@@ -640,8 +651,12 @@ static void __relay_set_buf_dentry(void *info) · 72 unmodified lines
640 *651 *
641 * Returns 0 if successful, non-zero otherwise.652 * Returns 0 if successful, non-zero otherwise.
642 *653 *
643 * Use to setup files for a previously buffer-only channel.654 * Use to setup files for a previously buffer-only channel created
644 * Useful to do early tracing in kernel, before VFS is up, for example.655 * by relay_open() with a NULL parent dentry.
656 *
657 * For example, this is useful for perfomring early tracing in kernel,
658 * before VFS is up and then exposing the early results once the dentry
659 * is available.
645 */660 */
646int relay_late_setup_files(struct rchan *chan,661int relay_late_setup_files(struct rchan *chan,
647 const char *base_filename,662 const char *base_filename,
@@ -666,6 +681,20 @@ int relay_late_setup_files(struct rchan *chan, · 18 unmodified lines
666 }681 }
667 chan->has_base_filename = 1;682 chan->has_base_filename = 1;
668 chan->parent = parent;683 chan->parent = parent;
684
685 if (chan->is_global) {
686 err = -EINVAL;
687 if (!WARN_ON_ONCE(!chan->buf[0])) {
688 dentry = relay_create_buf_file(chan, chan->buf[0], 0);
689 if (dentry && !WARN_ON_ONCE(!chan->is_global)) {
690 relay_set_buf_dentry(chan->buf[0], dentry);
691 err = 0;
692 }
693 }
694 mutex_unlock(&relay_channels_mutex);
695 return err;
696 }
697
669 curr_cpu = get_cpu();698 curr_cpu = get_cpu();
670 /*699 /*
671 * The CPU hotplug notifier ran before us and created buffers with700 * The CPU hotplug notifier ran before us and created buffers with
@@ -706,6 +735,7 @@ int relay_late_setup_files(struct rchan *chan, · 34 unmodified lines
706 735
707 return err;736 return err;
708}737}
738EXPORT_SYMBOL_GPL(relay_late_setup_files);
709 739
710/**740/**
711 * relay_switch_subbuf - switch to a new sub-buffer741 * relay_switch_subbuf - switch to a new sub-buffer
kernel/seccomp.c+3−3
@@ -347,7 +347,7 @@ static struct seccomp_filter *seccomp_prepare_filter(struct sock_fprog *fprog) · 346 unmodified lines
347{347{
348 struct seccomp_filter *sfilter;348 struct seccomp_filter *sfilter;
349 int ret;349 int ret;
350 const bool save_orig = config_enabled(CONFIG_CHECKPOINT_RESTORE);350 const bool save_orig = IS_ENABLED(CONFIG_CHECKPOINT_RESTORE);
351 351
352 if (fprog->len == 0 || fprog->len > BPF_MAXINSNS)352 if (fprog->len == 0 || fprog->len > BPF_MAXINSNS)
353 return ERR_PTR(-EINVAL);353 return ERR_PTR(-EINVAL);
@@ -542,7 +542,7 @@ void secure_computing_strict(int this_syscall) · 188 unmodified lines
542{542{
543 int mode = current->seccomp.mode;543 int mode = current->seccomp.mode;
544 544
545 if (config_enabled(CONFIG_CHECKPOINT_RESTORE) &&545 if (IS_ENABLED(CONFIG_CHECKPOINT_RESTORE) &&
546 unlikely(current->ptrace & PT_SUSPEND_SECCOMP))546 unlikely(current->ptrace & PT_SUSPEND_SECCOMP))
547 return;547 return;
548 548
@@ -655,7 +655,7 @@ int __secure_computing(const struct seccomp_data *sd) · 106 unmodified lines
655 int mode = current->seccomp.mode;655 int mode = current->seccomp.mode;
656 int this_syscall;656 int this_syscall;
657 657
658 if (config_enabled(CONFIG_CHECKPOINT_RESTORE) &&658 if (IS_ENABLED(CONFIG_CHECKPOINT_RESTORE) &&
659 unlikely(current->ptrace & PT_SUSPEND_SECCOMP))659 unlikely(current->ptrace & PT_SUSPEND_SECCOMP))
660 return 0;660 return 0;
661 661
kernel/sysctl.c+7−0
@@ -813,6 +813,13 @@ static struct ctl_table kern_table[] = { · 812 unmodified lines
813 .extra1 = &zero,813 .extra1 = &zero,
814 .extra2 = &ten_thousand,814 .extra2 = &ten_thousand,
815 },815 },
816 {
817 .procname = "printk_devkmsg",
818 .data = devkmsg_log_str,
819 .maxlen = DEVKMSG_STR_MAX_SIZE,
820 .mode = 0644,
821 .proc_handler = devkmsg_sysctl_set_loglvl,
822 },
816 {823 {
817 .procname = "dmesg_restrict",824 .procname = "dmesg_restrict",
818 .data = &dmesg_restrict,825 .data = &dmesg_restrict,
kernel/task_work.c+6−4
@@ -29,7 +29,7 @@ task_work_add(struct task_struct *task, struct callback_head *work, bool notify) · 28 unmodified lines
29 struct callback_head *head;29 struct callback_head *head;
30 30
31 do {31 do {
32 head = ACCESS_ONCE(task->task_works);32 head = READ_ONCE(task->task_works);
33 if (unlikely(head == &work_exited))33 if (unlikely(head == &work_exited))
34 return -ESRCH;34 return -ESRCH;
35 work->next = head;35 work->next = head;
@@ -57,6 +57,9 @@ task_work_cancel(struct task_struct *task, task_work_func_t func) · 21 unmodified lines
57 struct callback_head **pprev = &task->task_works;57 struct callback_head **pprev = &task->task_works;
58 struct callback_head *work;58 struct callback_head *work;
59 unsigned long flags;59 unsigned long flags;
60
61 if (likely(!task->task_works))
62 return NULL;
60 /*63 /*
61 * If cmpxchg() fails we continue without updating pprev.64 * If cmpxchg() fails we continue without updating pprev.
62 * Either we raced with task_work_add() which added the65 * Either we raced with task_work_add() which added the
@@ -64,8 +67,7 @@ task_work_cancel(struct task_struct *task, task_work_func_t func) · 1 unmodified line
64 * we raced with task_work_run(), *pprev == NULL/exited.67 * we raced with task_work_run(), *pprev == NULL/exited.
65 */68 */
66 raw_spin_lock_irqsave(&task->pi_lock, flags);69 raw_spin_lock_irqsave(&task->pi_lock, flags);
67 while ((work = ACCESS_ONCE(*pprev))) {70 while ((work = lockless_dereference(*pprev))) {
68 smp_read_barrier_depends();
69 if (work->func != func)71 if (work->func != func)
70 pprev = &work->next;72 pprev = &work->next;
71 else if (cmpxchg(pprev, work, work->next) == work)73 else if (cmpxchg(pprev, work, work->next) == work)
@@ -95,7 +97,7 @@ void task_work_run(void) · 23 unmodified lines
95 * work_exited unless the list is empty.97 * work_exited unless the list is empty.
96 */98 */
97 do {99 do {
98 work = ACCESS_ONCE(task->task_works);100 work = READ_ONCE(task->task_works);
99 head = !work && (task->flags & PF_EXITING) ?101 head = !work && (task->flags & PF_EXITING) ?
100 &work_exited : NULL;102 &work_exited : NULL;
101 } while (cmpxchg(&task->task_works, work, head) != work);103 } while (cmpxchg(&task->task_works, work, head) != work);
kernel/trace/Makefile+4−0
@@ -1,4 +1,8 @@
1 1
2# We are fully aware of the dangers of __builtin_return_address()
3FRAME_CFLAGS := $(call cc-disable-warning,frame-address)
4KBUILD_CFLAGS += $(FRAME_CFLAGS)
5
2# Do not instrument the tracer itself:6# Do not instrument the tracer itself:
3 7
4ifdef CONFIG_FUNCTION_TRACER8ifdef CONFIG_FUNCTION_TRACER
kernel/trace/blktrace.c+3−3
@@ -776,7 +776,7 @@ static void blk_add_trace_bio(struct request_queue *q, struct bio *bio, · 775 unmodified lines
776 return;776 return;
777 777
778 __blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size,778 __blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size,
779 bio_op(bio), bio->bi_rw, what, error, 0, NULL);779 bio_op(bio), bio->bi_opf, what, error, 0, NULL);
780}780}
781 781
782static void blk_add_trace_bio_bounce(void *ignore,782static void blk_add_trace_bio_bounce(void *ignore,
@@ -881,7 +881,7 @@ static void blk_add_trace_split(void *ignore, · 98 unmodified lines
881 __be64 rpdu = cpu_to_be64(pdu);881 __be64 rpdu = cpu_to_be64(pdu);
882 882
883 __blk_add_trace(bt, bio->bi_iter.bi_sector,883 __blk_add_trace(bt, bio->bi_iter.bi_sector,
884 bio->bi_iter.bi_size, bio_op(bio), bio->bi_rw,884 bio->bi_iter.bi_size, bio_op(bio), bio->bi_opf,
885 BLK_TA_SPLIT, bio->bi_error, sizeof(rpdu),885 BLK_TA_SPLIT, bio->bi_error, sizeof(rpdu),
886 &rpdu);886 &rpdu);
887 }887 }
@@ -915,7 +915,7 @@ static void blk_add_trace_bio_remap(void *ignore, · 27 unmodified lines
915 r.sector_from = cpu_to_be64(from);915 r.sector_from = cpu_to_be64(from);
916 916
917 __blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size,917 __blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size,
918 bio_op(bio), bio->bi_rw, BLK_TA_REMAP, bio->bi_error,918 bio_op(bio), bio->bi_opf, BLK_TA_REMAP, bio->bi_error,
919 sizeof(r), &r);919 sizeof(r), &r);
920}920}
921 921
kernel/trace/trace_events_hist.c+7−7
@@ -1441,6 +1441,9 @@ static int hist_register_trigger(char *glob, struct event_trigger_ops *ops, · 1440 unmodified lines
1441 goto out;1441 goto out;
1442 }1442 }
1443 1443
1444 if (hist_data->attrs->pause)
1445 data->paused = true;
1446
1444 if (named_data) {1447 if (named_data) {
1445 destroy_hist_data(data->private_data);1448 destroy_hist_data(data->private_data);
1446 data->private_data = named_data->private_data;1449 data->private_data = named_data->private_data;
@@ -1448,9 +1451,6 @@ static int hist_register_trigger(char *glob, struct event_trigger_ops *ops, · 1 unmodified line
1448 data->ops = &event_hist_trigger_named_ops;1451 data->ops = &event_hist_trigger_named_ops;
1449 }1452 }
1450 1453
1451 if (hist_data->attrs->pause)
1452 data->paused = true;
1453
1454 if (data->ops->init) {1454 if (data->ops->init) {
1455 ret = data->ops->init(data->ops, data);1455 ret = data->ops->init(data->ops, data);
1456 if (ret < 0)1456 if (ret < 0)
@@ -1500,9 +1500,9 @@ static void hist_unregister_trigger(char *glob, struct event_trigger_ops *ops, · 43 unmodified lines
1500 1500
1501static void hist_unreg_all(struct trace_event_file *file)1501static void hist_unreg_all(struct trace_event_file *file)
1502{1502{
1503 struct event_trigger_data *test;1503 struct event_trigger_data *test, *n;
1504 1504
1505 list_for_each_entry_rcu(test, &file->triggers, list) {1505 list_for_each_entry_safe(test, n, &file->triggers, list) {
1506 if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {1506 if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) {
1507 list_del_rcu(&test->list);1507 list_del_rcu(&test->list);
1508 trace_event_trigger_enable_disable(file, 0);1508 trace_event_trigger_enable_disable(file, 0);
@@ -1699,9 +1699,9 @@ hist_enable_get_trigger_ops(char *cmd, char *param) · 190 unmodified lines
1699 1699
1700static void hist_enable_unreg_all(struct trace_event_file *file)1700static void hist_enable_unreg_all(struct trace_event_file *file)
1701{1701{
1702 struct event_trigger_data *test;1702 struct event_trigger_data *test, *n;
1703 1703
1704 list_for_each_entry_rcu(test, &file->triggers, list) {1704 list_for_each_entry_safe(test, n, &file->triggers, list) {
1705 if (test->cmd_ops->trigger_type == ETT_HIST_ENABLE) {1705 if (test->cmd_ops->trigger_type == ETT_HIST_ENABLE) {
1706 list_del_rcu(&test->list);1706 list_del_rcu(&test->list);
1707 update_cond_flag(file);1707 update_cond_flag(file);