Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit a9556d3

Browse files
author
Tudor Ambarus
committed
Merge 11ab4cd ("Merge tag 'lsm-pr-20240715' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm") into android-mainline
Steps on the way to v6.11-rc1 Change-Id: I47ef26f2266cedd11f007fcec52c83735c68e31a Signed-off-by: Tudor Ambarus <tudordana@google.com>
2 parents 70b8a0c + 11ab4cd commit a9556d3

File tree

28 files changed

+428
-140
lines changed

28 files changed

+428
-140
lines changed

arch/arm/mm/fault.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525

2626
#include "fault.h"
2727

28+
#ifdef CONFIG_MMU
29+
2830
bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
2931
{
3032
unsigned long addr = (unsigned long)unsafe_src;
3133

3234
return addr >= TASK_SIZE && ULONG_MAX - addr >= size;
3335
}
3436

35-
#ifdef CONFIG_MMU
36-
3737
/*
3838
* This is useful to dump out the page tables associated with
3939
* 'addr' in mm 'mm'.

arch/x86/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,6 +2414,15 @@ config STRICT_SIGALTSTACK_SIZE
24142414

24152415
Say 'N' unless you want to really enforce this check.
24162416

2417+
config CFI_AUTO_DEFAULT
2418+
bool "Attempt to use FineIBT by default at boot time"
2419+
depends on FINEIBT
2420+
default y
2421+
help
2422+
Attempt to use FineIBT by default at boot time. If enabled,
2423+
this is the same as booting with "cfi=auto". If disabled,
2424+
this is the same as booting with "cfi=kcfi".
2425+
24172426
source "kernel/livepatch/Kconfig"
24182427

24192428
endmenu

arch/x86/include/asm/cfi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
*
9494
*/
9595
enum cfi_mode {
96-
CFI_DEFAULT, /* FineIBT if hardware has IBT, otherwise kCFI */
96+
CFI_AUTO, /* FineIBT if hardware has IBT, otherwise kCFI */
9797
CFI_OFF, /* Taditional / IBT depending on .config */
9898
CFI_KCFI, /* Optionally CALL_PADDING, IBT, RETPOLINE */
9999
CFI_FINEIBT, /* see arch/x86/kernel/alternative.c */

arch/x86/kernel/alternative.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,8 @@ void __init_or_module apply_seal_endbr(s32 *start, s32 *end) { }
901901

902902
#endif /* CONFIG_X86_KERNEL_IBT */
903903

904-
#ifdef CONFIG_FINEIBT
905-
#define __CFI_DEFAULT CFI_DEFAULT
904+
#ifdef CONFIG_CFI_AUTO_DEFAULT
905+
#define __CFI_DEFAULT CFI_AUTO
906906
#elif defined(CONFIG_CFI_CLANG)
907907
#define __CFI_DEFAULT CFI_KCFI
908908
#else
@@ -1010,7 +1010,7 @@ static __init int cfi_parse_cmdline(char *str)
10101010
}
10111011

10121012
if (!strcmp(str, "auto")) {
1013-
cfi_mode = CFI_DEFAULT;
1013+
cfi_mode = CFI_AUTO;
10141014
} else if (!strcmp(str, "off")) {
10151015
cfi_mode = CFI_OFF;
10161016
cfi_rand = false;
@@ -1270,7 +1270,7 @@ static void __apply_fineibt(s32 *start_retpoline, s32 *end_retpoline,
12701270
"FineIBT preamble wrong size: %ld", fineibt_preamble_size))
12711271
return;
12721272

1273-
if (cfi_mode == CFI_DEFAULT) {
1273+
if (cfi_mode == CFI_AUTO) {
12741274
cfi_mode = CFI_KCFI;
12751275
if (HAS_KERNEL_IBT && cpu_feature_enabled(X86_FEATURE_IBT))
12761276
cfi_mode = CFI_FINEIBT;

drivers/misc/lkdtm/bugs.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,35 @@ static void lkdtm_HARDLOCKUP(void)
286286
cpu_relax();
287287
}
288288

289+
static void __lkdtm_SMP_CALL_LOCKUP(void *unused)
290+
{
291+
for (;;)
292+
cpu_relax();
293+
}
294+
295+
static void lkdtm_SMP_CALL_LOCKUP(void)
296+
{
297+
unsigned int cpu, target;
298+
299+
cpus_read_lock();
300+
301+
cpu = get_cpu();
302+
target = cpumask_any_but(cpu_online_mask, cpu);
303+
304+
if (target >= nr_cpu_ids) {
305+
pr_err("FAIL: no other online CPUs\n");
306+
goto out_put_cpus;
307+
}
308+
309+
smp_call_function_single(target, __lkdtm_SMP_CALL_LOCKUP, NULL, 1);
310+
311+
pr_err("FAIL: did not hang\n");
312+
313+
out_put_cpus:
314+
put_cpu();
315+
cpus_read_unlock();
316+
}
317+
289318
static void lkdtm_SPINLOCKUP(void)
290319
{
291320
/* Must be called twice to trigger. */
@@ -680,6 +709,7 @@ static struct crashtype crashtypes[] = {
680709
CRASHTYPE(UNALIGNED_LOAD_STORE_WRITE),
681710
CRASHTYPE(SOFTLOCKUP),
682711
CRASHTYPE(HARDLOCKUP),
712+
CRASHTYPE(SMP_CALL_LOCKUP),
683713
CRASHTYPE(SPINLOCKUP),
684714
CRASHTYPE(HUNG_TASK),
685715
CRASHTYPE(OVERFLOW_SIGNED),

fs/proc/proc_sysctl.c

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#define list_for_each_table_entry(entry, header) \
2323
entry = header->ctl_table; \
24-
for (size_t i = 0 ; i < header->ctl_table_size && entry->procname; ++i, entry++)
24+
for (size_t i = 0 ; i < header->ctl_table_size; ++i, entry++)
2525

2626
static const struct dentry_operations proc_sys_dentry_operations;
2727
static const struct file_operations proc_sys_file_operations;
@@ -476,12 +476,10 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
476476
make_empty_dir_inode(inode);
477477
}
478478

479+
inode->i_uid = GLOBAL_ROOT_UID;
480+
inode->i_gid = GLOBAL_ROOT_GID;
479481
if (root->set_ownership)
480482
root->set_ownership(head, &inode->i_uid, &inode->i_gid);
481-
else {
482-
inode->i_uid = GLOBAL_ROOT_UID;
483-
inode->i_gid = GLOBAL_ROOT_GID;
484-
}
485483

486484
return inode;
487485
}
@@ -951,14 +949,14 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
951949
char *new_name;
952950

953951
new = kzalloc(sizeof(*new) + sizeof(struct ctl_node) +
954-
sizeof(struct ctl_table)*2 + namelen + 1,
952+
sizeof(struct ctl_table) + namelen + 1,
955953
GFP_KERNEL);
956954
if (!new)
957955
return NULL;
958956

959957
node = (struct ctl_node *)(new + 1);
960958
table = (struct ctl_table *)(node + 1);
961-
new_name = (char *)(table + 2);
959+
new_name = (char *)(table + 1);
962960
memcpy(new_name, name, namelen);
963961
table[0].procname = new_name;
964962
table[0].mode = S_IFDIR|S_IRUGO|S_IXUGO;
@@ -1093,6 +1091,7 @@ static int sysctl_err(const char *path, struct ctl_table *table, char *fmt, ...)
10931091

10941092
static int sysctl_check_table_array(const char *path, struct ctl_table *table)
10951093
{
1094+
unsigned int extra;
10961095
int err = 0;
10971096

10981097
if ((table->proc_handler == proc_douintvec) ||
@@ -1104,6 +1103,19 @@ static int sysctl_check_table_array(const char *path, struct ctl_table *table)
11041103
if (table->proc_handler == proc_dou8vec_minmax) {
11051104
if (table->maxlen != sizeof(u8))
11061105
err |= sysctl_err(path, table, "array not allowed");
1106+
1107+
if (table->extra1) {
1108+
extra = *(unsigned int *) table->extra1;
1109+
if (extra > 255U)
1110+
err |= sysctl_err(path, table,
1111+
"range value too large for proc_dou8vec_minmax");
1112+
}
1113+
if (table->extra2) {
1114+
extra = *(unsigned int *) table->extra2;
1115+
if (extra > 255U)
1116+
err |= sysctl_err(path, table,
1117+
"range value too large for proc_dou8vec_minmax");
1118+
}
11071119
}
11081120

11091121
if (table->proc_handler == proc_dobool) {
@@ -1119,6 +1131,8 @@ static int sysctl_check_table(const char *path, struct ctl_table_header *header)
11191131
struct ctl_table *entry;
11201132
int err = 0;
11211133
list_for_each_table_entry(entry, header) {
1134+
if (!entry->procname)
1135+
err |= sysctl_err(path, entry, "procname is null");
11221136
if ((entry->proc_handler == proc_dostring) ||
11231137
(entry->proc_handler == proc_dobool) ||
11241138
(entry->proc_handler == proc_dointvec) ||
@@ -1154,27 +1168,25 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
11541168
struct ctl_table_header *links;
11551169
struct ctl_node *node;
11561170
char *link_name;
1157-
int nr_entries, name_bytes;
1171+
int name_bytes;
11581172

11591173
name_bytes = 0;
1160-
nr_entries = 0;
11611174
list_for_each_table_entry(entry, head) {
1162-
nr_entries++;
11631175
name_bytes += strlen(entry->procname) + 1;
11641176
}
11651177

11661178
links = kzalloc(sizeof(struct ctl_table_header) +
1167-
sizeof(struct ctl_node)*nr_entries +
1168-
sizeof(struct ctl_table)*(nr_entries + 1) +
1179+
sizeof(struct ctl_node)*head->ctl_table_size +
1180+
sizeof(struct ctl_table)*head->ctl_table_size +
11691181
name_bytes,
11701182
GFP_KERNEL);
11711183

11721184
if (!links)
11731185
return NULL;
11741186

11751187
node = (struct ctl_node *)(links + 1);
1176-
link_table = (struct ctl_table *)(node + nr_entries);
1177-
link_name = (char *)&link_table[nr_entries + 1];
1188+
link_table = (struct ctl_table *)(node + head->ctl_table_size);
1189+
link_name = (char *)(link_table + head->ctl_table_size);
11781190
link = link_table;
11791191

11801192
list_for_each_table_entry(entry, head) {
@@ -1188,7 +1200,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
11881200
}
11891201
init_header(links, dir->header.root, dir->header.set, node, link_table,
11901202
head->ctl_table_size);
1191-
links->nreg = nr_entries;
1203+
links->nreg = head->ctl_table_size;
11921204

11931205
return links;
11941206
}
@@ -1300,37 +1312,31 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path)
13001312
* __register_sysctl_table - register a leaf sysctl table
13011313
* @set: Sysctl tree to register on
13021314
* @path: The path to the directory the sysctl table is in.
1303-
* @table: the top-level table structure without any child. This table
1304-
* should not be free'd after registration. So it should not be
1305-
* used on stack. It can either be a global or dynamically allocated
1306-
* by the caller and free'd later after sysctl unregistration.
1315+
*
1316+
* @table: the top-level table structure. This table should not be free'd
1317+
* after registration. So it should not be used on stack. It can either
1318+
* be a global or dynamically allocated by the caller and free'd later
1319+
* after sysctl unregistration.
13071320
* @table_size : The number of elements in table
13081321
*
13091322
* Register a sysctl table hierarchy. @table should be a filled in ctl_table
1310-
* array. A completely 0 filled entry terminates the table.
1323+
* array.
13111324
*
13121325
* The members of the &struct ctl_table structure are used as follows:
1313-
*
13141326
* procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
13151327
* enter a sysctl file
1316-
*
1317-
* data - a pointer to data for use by proc_handler
1318-
*
1319-
* maxlen - the maximum size in bytes of the data
1320-
*
1321-
* mode - the file permissions for the /proc/sys file
1322-
*
1323-
* child - must be %NULL.
1324-
*
1328+
* data - a pointer to data for use by proc_handler
1329+
* maxlen - the maximum size in bytes of the data
1330+
* mode - the file permissions for the /proc/sys file
1331+
* type - Defines the target type (described in struct definition)
13251332
* proc_handler - the text handler routine (described below)
13261333
*
13271334
* extra1, extra2 - extra pointers usable by the proc handler routines
13281335
* XXX: we should eventually modify these to use long min / max [0]
13291336
* [0] https://lkml.kernel.org/87zgpte9o4.fsf@email.froward.int.ebiederm.org
13301337
*
13311338
* Leaf nodes in the sysctl tree will be represented by a single file
1332-
* under /proc; non-leaf nodes (where child is not NULL) are not allowed,
1333-
* sysctl_check_table() verifies this.
1339+
* under /proc; non-leaf nodes are not allowed.
13341340
*
13351341
* There must be a proc_handler routine for any terminal nodes.
13361342
* Several default handlers are available to cover common cases -

fs/pstore/blk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static int __register_pstore_blk(struct pstore_device_info *dev,
241241
/* get information of pstore/blk */
242242
int pstore_blk_get_config(struct pstore_blk_config *info)
243243
{
244-
strncpy(info->device, blkdev, 80);
244+
strscpy(info->device, blkdev);
245245
info->max_reason = max_reason;
246246
info->kmsg_size = check_size(kmsg_size, 4096);
247247
info->pmsg_size = check_size(pmsg_size, 4096);

fs/pstore/platform.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,4 +761,5 @@ static void __exit pstore_exit(void)
761761
module_exit(pstore_exit)
762762

763763
MODULE_AUTHOR("Tony Luck <tony.luck@intel.com>");
764+
MODULE_DESCRIPTION("Persistent Storage - platform driver interface");
764765
MODULE_LICENSE("GPL");

include/linux/fortify-string.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -601,19 +601,15 @@ __FORTIFY_INLINE bool fortify_memcpy_chk(__kernel_size_t size,
601601
/*
602602
* Warn when writing beyond destination field size.
603603
*
604-
* We must ignore p_size_field == 0 for existing 0-element
605-
* fake flexible arrays, until they are all converted to
606-
* proper flexible arrays.
607-
*
608-
* The implementation of __builtin_*object_size() behaves
604+
* Note the implementation of __builtin_*object_size() behaves
609605
* like sizeof() when not directly referencing a flexible
610606
* array member, which means there will be many bounds checks
611607
* that will appear at run-time, without a way for them to be
612608
* detected at compile-time (as can be done when the destination
613609
* is specifically the flexible array member).
614610
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101832
615611
*/
616-
if (p_size_field != 0 && p_size_field != SIZE_MAX &&
612+
if (p_size_field != SIZE_MAX &&
617613
p_size != p_size_field && p_size_field < size)
618614
return true;
619615

include/linux/lsm_hook_defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ LSM_HOOK(int, 0, inode_setattr, struct mnt_idmap *idmap, struct dentry *dentry,
144144
LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, struct mnt_idmap *idmap,
145145
struct dentry *dentry, int ia_valid)
146146
LSM_HOOK(int, 0, inode_getattr, const struct path *path)
147+
LSM_HOOK(int, 0, inode_xattr_skipcap, const char *name)
147148
LSM_HOOK(int, 0, inode_setxattr, struct mnt_idmap *idmap,
148149
struct dentry *dentry, const char *name, const void *value,
149150
size_t size, int flags)

0 commit comments

Comments
 (0)