Skip to content

Commit c727b4c

Browse files
committed
Merge branch 'akpm' (incoming fixes from Andrew)
Merge misc fixes from Andrew Morton: "The audit fixes have been floating around for a while - Al and Eric aren't responding to either myself or Kees so I asked Kees to re-review them and here they are." * emailed patches from Andrew Morton <[email protected]>: (22 commits) lib/rbtree.c: avoid the use of non-static __always_inline MAINTAINERS: Omar had moved mm: compaction: partially revert capture of suitable high-order page linux/audit.h: move ptrace.h include to kernel header kernel/audit.c: avoid negative sleep durations audit: catch possible NULL audit buffers audit: create explicit AUDIT_SECCOMP event type MAINTAINERS: fix a status pattern MAINTAINERS: fix arch/arm/plat-omap/include/plat/omap_hwmod.h mm: thp: acquire the anon_vma rwsem for write during split mm: mmap: annotate vm_lock_anon_vma locking properly for lockdep lockdep, rwsem: provide down_write_nest_lock() arch/mn10300/Kconfig: select CONFIG_GENERIC_ATOMIC64 mm: bootmem: fix free_all_bootmem_core() with odd bitmap alignment mm: use aligned zone start for pfn_to_bitidx calculation fs/exec.c: work around icc miscompilation mm: compaction: fix echo 1 > compact_memory return error issue mm: memblock: fix wrong memmove size in memblock_merge_regions() drivers/video/ssd1307fb.c: fix bit order bug in the byte translation function mm: migrate: check page_count of THP before migrating ...
2 parents 93ccb39 + 3cb7a56 commit c727b4c

26 files changed

+227
-78
lines changed

MAINTAINERS

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ F: arch/arm/
648648

649649
ARM SUB-ARCHITECTURES
650650
L: [email protected] (moderated for non-subscribers)
651-
S: MAINTAINED
651+
S: Maintained
652652
F: arch/arm/mach-*/
653653
F: arch/arm/plat-*/
654654
T: git git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc.git
@@ -5507,8 +5507,7 @@ M: Benoît Cousson <[email protected]>
55075507
M: Paul Walmsley <[email protected]>
55085508
55095509
S: Maintained
5510-
F: arch/arm/mach-omap2/omap_hwmod.c
5511-
F: arch/arm/plat-omap/include/plat/omap_hwmod.h
5510+
F: arch/arm/mach-omap2/omap_hwmod.*
55125511

55135512
OMAP HWMOD DATA FOR OMAP4-BASED DEVICES
55145513
M: Benoît Cousson <[email protected]>
@@ -7334,7 +7333,7 @@ S: Odd Fixes
73347333
F: drivers/staging/speakup/
73357334

73367335
STAGING - TI DSP BRIDGE DRIVERS
7337-
M: Omar Ramirez Luna <omar.ramirez@ti.com>
7336+
M: Omar Ramirez Luna <omar.ramirez@copitl.com>
73387337
S: Odd Fixes
73397338
F: drivers/staging/tidspbridge/
73407339

arch/mn10300/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ config MN10300
66
select ARCH_WANT_IPC_PARSE_VERSION
77
select HAVE_ARCH_TRACEHOOK
88
select HAVE_ARCH_KGDB
9+
select GENERIC_ATOMIC64
910
select HAVE_NMI_WATCHDOG if MN10300_WD_TIMER
1011
select GENERIC_CLOCKEVENTS
1112
select MODULES_USE_ELF_RELA

drivers/rtc/rtc-da9055.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static const struct rtc_class_ops da9055_rtc_ops = {
227227
.alarm_irq_enable = da9055_rtc_alarm_irq_enable,
228228
};
229229

230-
static int __init da9055_rtc_device_init(struct da9055 *da9055,
230+
static int da9055_rtc_device_init(struct da9055 *da9055,
231231
struct da9055_pdata *pdata)
232232
{
233233
int ret;

drivers/video/ssd1307fb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ static void ssd1307fb_update_display(struct ssd1307fb_par *par)
145145
u32 page_length = SSD1307FB_WIDTH * i;
146146
u32 index = page_length + (SSD1307FB_WIDTH * k + j) / 8;
147147
u8 byte = *(vmem + index);
148-
u8 bit = byte & (1 << (7 - (j % 8)));
149-
bit = bit >> (7 - (j % 8));
148+
u8 bit = byte & (1 << (j % 8));
149+
bit = bit >> (j % 8);
150150
buf |= bit << k;
151151
}
152152
ssd1307fb_write_data(par->client, buf);

fs/exec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,9 @@ static int count(struct user_arg_ptr argv, int max)
434434
if (IS_ERR(p))
435435
return -EFAULT;
436436

437-
if (i++ >= max)
437+
if (i >= max)
438438
return -E2BIG;
439+
++i;
439440

440441
if (fatal_signal_pending(current))
441442
return -ERESTARTNOHAND;

include/linux/audit.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define _LINUX_AUDIT_H_
2525

2626
#include <linux/sched.h>
27+
#include <linux/ptrace.h>
2728
#include <uapi/linux/audit.h>
2829

2930
struct audit_sig_info {
@@ -157,7 +158,8 @@ void audit_core_dumps(long signr);
157158

158159
static inline void audit_seccomp(unsigned long syscall, long signr, int code)
159160
{
160-
if (unlikely(!audit_dummy_context()))
161+
/* Force a record to be reported if a signal was delivered. */
162+
if (signr || unlikely(!audit_dummy_context()))
161163
__audit_seccomp(syscall, signr, code);
162164
}
163165

include/linux/cpu_rmap.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@
1313
#include <linux/cpumask.h>
1414
#include <linux/gfp.h>
1515
#include <linux/slab.h>
16+
#include <linux/kref.h>
1617

1718
/**
1819
* struct cpu_rmap - CPU affinity reverse-map
20+
* @refcount: kref for object
1921
* @size: Number of objects to be reverse-mapped
2022
* @used: Number of objects added
2123
* @obj: Pointer to array of object pointers
2224
* @near: For each CPU, the index and distance to the nearest object,
2325
* based on affinity masks
2426
*/
2527
struct cpu_rmap {
28+
struct kref refcount;
2629
u16 size, used;
2730
void **obj;
2831
struct {
@@ -33,15 +36,7 @@ struct cpu_rmap {
3336
#define CPU_RMAP_DIST_INF 0xffff
3437

3538
extern struct cpu_rmap *alloc_cpu_rmap(unsigned int size, gfp_t flags);
36-
37-
/**
38-
* free_cpu_rmap - free CPU affinity reverse-map
39-
* @rmap: Reverse-map allocated with alloc_cpu_rmap(), or %NULL
40-
*/
41-
static inline void free_cpu_rmap(struct cpu_rmap *rmap)
42-
{
43-
kfree(rmap);
44-
}
39+
extern int cpu_rmap_put(struct cpu_rmap *rmap);
4540

4641
extern int cpu_rmap_add(struct cpu_rmap *rmap, void *obj);
4742
extern int cpu_rmap_update(struct cpu_rmap *rmap, u16 index,

include/linux/interrupt.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,6 @@ struct irq_affinity_notify {
268268
extern int
269269
irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
270270

271-
static inline void irq_run_affinity_notifiers(void)
272-
{
273-
flush_scheduled_work();
274-
}
275-
276271
#else /* CONFIG_SMP */
277272

278273
static inline int irq_set_affinity(unsigned int irq, const struct cpumask *m)

include/linux/lockdep.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,14 +524,17 @@ static inline void print_irqtrace_events(struct task_struct *curr)
524524
#ifdef CONFIG_DEBUG_LOCK_ALLOC
525525
# ifdef CONFIG_PROVE_LOCKING
526526
# define rwsem_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 2, NULL, i)
527+
# define rwsem_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 2, n, i)
527528
# define rwsem_acquire_read(l, s, t, i) lock_acquire(l, s, t, 1, 2, NULL, i)
528529
# else
529530
# define rwsem_acquire(l, s, t, i) lock_acquire(l, s, t, 0, 1, NULL, i)
531+
# define rwsem_acquire_nest(l, s, t, n, i) lock_acquire(l, s, t, 0, 1, n, i)
530532
# define rwsem_acquire_read(l, s, t, i) lock_acquire(l, s, t, 1, 1, NULL, i)
531533
# endif
532534
# define rwsem_release(l, n, i) lock_release(l, n, i)
533535
#else
534536
# define rwsem_acquire(l, s, t, i) do { } while (0)
537+
# define rwsem_acquire_nest(l, s, t, n, i) do { } while (0)
535538
# define rwsem_acquire_read(l, s, t, i) do { } while (0)
536539
# define rwsem_release(l, n, i) do { } while (0)
537540
#endif

include/linux/rbtree_augmented.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ __rb_change_child(struct rb_node *old, struct rb_node *new,
123123
extern void __rb_erase_color(struct rb_node *parent, struct rb_root *root,
124124
void (*augment_rotate)(struct rb_node *old, struct rb_node *new));
125125

126-
static __always_inline void
127-
rb_erase_augmented(struct rb_node *node, struct rb_root *root,
128-
const struct rb_augment_callbacks *augment)
126+
static __always_inline struct rb_node *
127+
__rb_erase_augmented(struct rb_node *node, struct rb_root *root,
128+
const struct rb_augment_callbacks *augment)
129129
{
130130
struct rb_node *child = node->rb_right, *tmp = node->rb_left;
131131
struct rb_node *parent, *rebalance;
@@ -217,6 +217,14 @@ rb_erase_augmented(struct rb_node *node, struct rb_root *root,
217217
}
218218

219219
augment->propagate(tmp, NULL);
220+
return rebalance;
221+
}
222+
223+
static __always_inline void
224+
rb_erase_augmented(struct rb_node *node, struct rb_root *root,
225+
const struct rb_augment_callbacks *augment)
226+
{
227+
struct rb_node *rebalance = __rb_erase_augmented(node, root, augment);
220228
if (rebalance)
221229
__rb_erase_color(rebalance, root, augment->rotate);
222230
}

include/linux/rwsem.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,17 @@ extern void downgrade_write(struct rw_semaphore *sem);
125125
*/
126126
extern void down_read_nested(struct rw_semaphore *sem, int subclass);
127127
extern void down_write_nested(struct rw_semaphore *sem, int subclass);
128+
extern void _down_write_nest_lock(struct rw_semaphore *sem, struct lockdep_map *nest_lock);
129+
130+
# define down_write_nest_lock(sem, nest_lock) \
131+
do { \
132+
typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
133+
_down_write_nest_lock(sem, &(nest_lock)->dep_map); \
134+
} while (0);
135+
128136
#else
129137
# define down_read_nested(sem, subclass) down_read(sem)
138+
# define down_write_nest_lock(sem, nest_lock) down_read(sem)
130139
# define down_write_nested(sem, subclass) down_write(sem)
131140
#endif
132141

include/uapi/linux/audit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
#include <linux/types.h>
2828
#include <linux/elf-em.h>
29-
#include <linux/ptrace.h>
3029

3130
/* The netlink messages for the audit system is divided into blocks:
3231
* 1000 - 1099 are for commanding the audit system
@@ -106,6 +105,7 @@
106105
#define AUDIT_MMAP 1323 /* Record showing descriptor and flags in mmap */
107106
#define AUDIT_NETFILTER_PKT 1324 /* Packets traversing netfilter chains */
108107
#define AUDIT_NETFILTER_CFG 1325 /* Netfilter chain modifications */
108+
#define AUDIT_SECCOMP 1326 /* Secure Computing event */
109109

110110
#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
111111
#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */

kernel/audit.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ static int audit_log_config_change(char *function_name, int new, int old,
272272
int rc = 0;
273273

274274
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE);
275+
if (unlikely(!ab))
276+
return rc;
275277
audit_log_format(ab, "%s=%d old=%d auid=%u ses=%u", function_name, new,
276278
old, from_kuid(&init_user_ns, loginuid), sessionid);
277279
if (sid) {
@@ -619,6 +621,8 @@ static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type,
619621
}
620622

621623
*ab = audit_log_start(NULL, GFP_KERNEL, msg_type);
624+
if (unlikely(!*ab))
625+
return rc;
622626
audit_log_format(*ab, "pid=%d uid=%u auid=%u ses=%u",
623627
task_tgid_vnr(current),
624628
from_kuid(&init_user_ns, current_uid()),
@@ -1097,6 +1101,23 @@ static inline void audit_get_stamp(struct audit_context *ctx,
10971101
}
10981102
}
10991103

1104+
/*
1105+
* Wait for auditd to drain the queue a little
1106+
*/
1107+
static void wait_for_auditd(unsigned long sleep_time)
1108+
{
1109+
DECLARE_WAITQUEUE(wait, current);
1110+
set_current_state(TASK_INTERRUPTIBLE);
1111+
add_wait_queue(&audit_backlog_wait, &wait);
1112+
1113+
if (audit_backlog_limit &&
1114+
skb_queue_len(&audit_skb_queue) > audit_backlog_limit)
1115+
schedule_timeout(sleep_time);
1116+
1117+
__set_current_state(TASK_RUNNING);
1118+
remove_wait_queue(&audit_backlog_wait, &wait);
1119+
}
1120+
11001121
/* Obtain an audit buffer. This routine does locking to obtain the
11011122
* audit buffer, but then no locking is required for calls to
11021123
* audit_log_*format. If the tsk is a task that is currently in a
@@ -1142,20 +1163,13 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
11421163

11431164
while (audit_backlog_limit
11441165
&& skb_queue_len(&audit_skb_queue) > audit_backlog_limit + reserve) {
1145-
if (gfp_mask & __GFP_WAIT && audit_backlog_wait_time
1146-
&& time_before(jiffies, timeout_start + audit_backlog_wait_time)) {
1166+
if (gfp_mask & __GFP_WAIT && audit_backlog_wait_time) {
1167+
unsigned long sleep_time;
11471168

1148-
/* Wait for auditd to drain the queue a little */
1149-
DECLARE_WAITQUEUE(wait, current);
1150-
set_current_state(TASK_INTERRUPTIBLE);
1151-
add_wait_queue(&audit_backlog_wait, &wait);
1152-
1153-
if (audit_backlog_limit &&
1154-
skb_queue_len(&audit_skb_queue) > audit_backlog_limit)
1155-
schedule_timeout(timeout_start + audit_backlog_wait_time - jiffies);
1156-
1157-
__set_current_state(TASK_RUNNING);
1158-
remove_wait_queue(&audit_backlog_wait, &wait);
1169+
sleep_time = timeout_start + audit_backlog_wait_time -
1170+
jiffies;
1171+
if ((long)sleep_time > 0)
1172+
wait_for_auditd(sleep_time);
11591173
continue;
11601174
}
11611175
if (audit_rate_check() && printk_ratelimit())

kernel/audit_tree.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -449,26 +449,34 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
449449
return 0;
450450
}
451451

452+
static void audit_log_remove_rule(struct audit_krule *rule)
453+
{
454+
struct audit_buffer *ab;
455+
456+
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE);
457+
if (unlikely(!ab))
458+
return;
459+
audit_log_format(ab, "op=");
460+
audit_log_string(ab, "remove rule");
461+
audit_log_format(ab, " dir=");
462+
audit_log_untrustedstring(ab, rule->tree->pathname);
463+
audit_log_key(ab, rule->filterkey);
464+
audit_log_format(ab, " list=%d res=1", rule->listnr);
465+
audit_log_end(ab);
466+
}
467+
452468
static void kill_rules(struct audit_tree *tree)
453469
{
454470
struct audit_krule *rule, *next;
455471
struct audit_entry *entry;
456-
struct audit_buffer *ab;
457472

458473
list_for_each_entry_safe(rule, next, &tree->rules, rlist) {
459474
entry = container_of(rule, struct audit_entry, rule);
460475

461476
list_del_init(&rule->rlist);
462477
if (rule->tree) {
463478
/* not a half-baked one */
464-
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE);
465-
audit_log_format(ab, "op=");
466-
audit_log_string(ab, "remove rule");
467-
audit_log_format(ab, " dir=");
468-
audit_log_untrustedstring(ab, rule->tree->pathname);
469-
audit_log_key(ab, rule->filterkey);
470-
audit_log_format(ab, " list=%d res=1", rule->listnr);
471-
audit_log_end(ab);
479+
audit_log_remove_rule(rule);
472480
rule->tree = NULL;
473481
list_del_rcu(&entry->list);
474482
list_del(&entry->rule.list);

kernel/audit_watch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ static void audit_watch_log_rule_change(struct audit_krule *r, struct audit_watc
240240
if (audit_enabled) {
241241
struct audit_buffer *ab;
242242
ab = audit_log_start(NULL, GFP_NOFS, AUDIT_CONFIG_CHANGE);
243+
if (unlikely(!ab))
244+
return;
243245
audit_log_format(ab, "auid=%u ses=%u op=",
244246
from_kuid(&init_user_ns, audit_get_loginuid(current)),
245247
audit_get_sessionid(current));

kernel/auditsc.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,14 +1464,14 @@ static void show_special(struct audit_context *context, int *call_panic)
14641464
audit_log_end(ab);
14651465
ab = audit_log_start(context, GFP_KERNEL,
14661466
AUDIT_IPC_SET_PERM);
1467+
if (unlikely(!ab))
1468+
return;
14671469
audit_log_format(ab,
14681470
"qbytes=%lx ouid=%u ogid=%u mode=%#ho",
14691471
context->ipc.qbytes,
14701472
context->ipc.perm_uid,
14711473
context->ipc.perm_gid,
14721474
context->ipc.perm_mode);
1473-
if (!ab)
1474-
return;
14751475
}
14761476
break; }
14771477
case AUDIT_MQ_OPEN: {
@@ -2675,7 +2675,7 @@ void __audit_mmap_fd(int fd, int flags)
26752675
context->type = AUDIT_MMAP;
26762676
}
26772677

2678-
static void audit_log_abend(struct audit_buffer *ab, char *reason, long signr)
2678+
static void audit_log_task(struct audit_buffer *ab)
26792679
{
26802680
kuid_t auid, uid;
26812681
kgid_t gid;
@@ -2693,6 +2693,11 @@ static void audit_log_abend(struct audit_buffer *ab, char *reason, long signr)
26932693
audit_log_task_context(ab);
26942694
audit_log_format(ab, " pid=%d comm=", current->pid);
26952695
audit_log_untrustedstring(ab, current->comm);
2696+
}
2697+
2698+
static void audit_log_abend(struct audit_buffer *ab, char *reason, long signr)
2699+
{
2700+
audit_log_task(ab);
26962701
audit_log_format(ab, " reason=");
26972702
audit_log_string(ab, reason);
26982703
audit_log_format(ab, " sig=%ld", signr);
@@ -2715,6 +2720,8 @@ void audit_core_dumps(long signr)
27152720
return;
27162721

27172722
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_ANOM_ABEND);
2723+
if (unlikely(!ab))
2724+
return;
27182725
audit_log_abend(ab, "memory violation", signr);
27192726
audit_log_end(ab);
27202727
}
@@ -2723,8 +2730,11 @@ void __audit_seccomp(unsigned long syscall, long signr, int code)
27232730
{
27242731
struct audit_buffer *ab;
27252732

2726-
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_ANOM_ABEND);
2727-
audit_log_abend(ab, "seccomp", signr);
2733+
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_SECCOMP);
2734+
if (unlikely(!ab))
2735+
return;
2736+
audit_log_task(ab);
2737+
audit_log_format(ab, " sig=%ld", signr);
27282738
audit_log_format(ab, " syscall=%ld", syscall);
27292739
audit_log_format(ab, " compat=%d", is_compat_task());
27302740
audit_log_format(ab, " ip=0x%lx", KSTK_EIP(current));

0 commit comments

Comments
 (0)