Skip to content

Commit e24dd9e

Browse files
committed
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security layer updates from James Morris: - a major update for AppArmor. From JJ: * several bug fixes and cleanups * the patch to add symlink support to securityfs that was floated on the list earlier and the apparmorfs changes that make use of securityfs symlinks * it introduces the domain labeling base code that Ubuntu has been carrying for several years, with several cleanups applied. And it converts the current mediation over to using the domain labeling base, which brings domain stacking support with it. This finally will bring the base upstream code in line with Ubuntu and provide a base to upstream the new feature work that Ubuntu carries. * This does _not_ contain any of the newer apparmor mediation features/controls (mount, signals, network, keys, ...) that Ubuntu is currently carrying, all of which will be RFC'd on top of this. - Notable also is the Infiniband work in SELinux, and the new file:map permission. From Paul: "While we're down to 21 patches for v4.13 (it was 31 for v4.12), the diffstat jumps up tremendously with over 2k of line changes. Almost all of these changes are the SELinux/IB work done by Daniel Jurgens; some other noteworthy changes include a NFS v4.2 labeling fix, a new file:map permission, and reporting of policy capabilities on policy load" There's also now genfscon labeling support for tracefs, which was lost in v4.1 with the separation from debugfs. - Smack incorporates a safer socket check in file_receive, and adds a cap_capable call in privilege check. - TPM as usual has a bunch of fixes and enhancements. - Multiple calls to security_add_hooks() can now be made for the same LSM, to allow LSMs to have hook declarations across multiple files. - IMA now supports different "ima_appraise=" modes (eg. log, fix) from the boot command line. * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (126 commits) apparmor: put back designators in struct initialisers seccomp: Switch from atomic_t to recount_t seccomp: Adjust selftests to avoid double-join seccomp: Clean up core dump logic IMA: update IMA policy documentation to include pcr= option ima: Log the same audit cause whenever a file has no signature ima: Simplify policy_func_show. integrity: Small code improvements ima: fix get_binary_runtime_size() ima: use ima_parse_buf() to parse template data ima: use ima_parse_buf() to parse measurements headers ima: introduce ima_parse_buf() ima: Add cgroups2 to the defaults list ima: use memdup_user_nul ima: fix up #endif comments IMA: Correct Kconfig dependencies for hash selection ima: define is_ima_appraise_enabled() ima: define Kconfig IMA_APPRAISE_BOOTPARAM option ima: define a set of appraisal rules requiring file signatures ima: extend the "ima_policy" boot command line to support multiple policies ...
2 parents 7391786 + c4758fa commit e24dd9e

101 files changed

Lines changed: 9904 additions & 2397 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/ABI/testing/ima_policy‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ Description:
3434
fsuuid:= file system UUID (e.g 8bcbe394-4f13-4144-be8e-5aa9ea2ce2f6)
3535
uid:= decimal value
3636
euid:= decimal value
37-
fowner:=decimal value
37+
fowner:= decimal value
3838
lsm: are LSM specific
3939
option: appraise_type:= [imasig]
40+
pcr:= decimal value
4041

4142
default policy:
4243
# PROC_SUPER_MAGIC
@@ -96,3 +97,8 @@ Description:
9697

9798
Smack:
9899
measure subj_user=_ func=FILE_CHECK mask=MAY_READ
100+
101+
Example of measure rules using alternate PCRs:
102+
103+
measure func=KEXEC_KERNEL_CHECK pcr=4
104+
measure func=KEXEC_INITRAMFS_CHECK pcr=5

‎Documentation/admin-guide/kernel-parameters.txt‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,12 +1501,21 @@
15011501
in crypto/hash_info.h.
15021502

15031503
ima_policy= [IMA]
1504-
The builtin measurement policy to load during IMA
1505-
setup. Specyfing "tcb" as the value, measures all
1506-
programs exec'd, files mmap'd for exec, and all files
1507-
opened with the read mode bit set by either the
1508-
effective uid (euid=0) or uid=0.
1509-
Format: "tcb"
1504+
The builtin policies to load during IMA setup.
1505+
Format: "tcb | appraise_tcb | secure_boot"
1506+
1507+
The "tcb" policy measures all programs exec'd, files
1508+
mmap'd for exec, and all files opened with the read
1509+
mode bit set by either the effective uid (euid=0) or
1510+
uid=0.
1511+
1512+
The "appraise_tcb" policy appraises the integrity of
1513+
all files owned by root. (This is the equivalent
1514+
of ima_appraise_tcb.)
1515+
1516+
The "secure_boot" policy appraises the integrity
1517+
of files (eg. kexec kernel image, kernel modules,
1518+
firmware, policy, etc) based on file signatures.
15101519

15111520
ima_tcb [IMA] Deprecated. Use ima_policy= instead.
15121521
Load a policy which meets the needs of the Trusted

‎drivers/char/tpm/st33zp24/i2c.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static int st33zp24_i2c_acpi_request_resources(struct i2c_client *client)
127127
struct device *dev = &client->dev;
128128
int ret;
129129

130-
ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_st33zp24_gpios);
130+
ret = devm_acpi_dev_add_driver_gpios(dev, acpi_st33zp24_gpios);
131131
if (ret)
132132
return ret;
133133

@@ -285,7 +285,6 @@ static int st33zp24_i2c_remove(struct i2c_client *client)
285285
if (ret)
286286
return ret;
287287

288-
acpi_dev_remove_driver_gpios(ACPI_COMPANION(&client->dev));
289288
return 0;
290289
}
291290

‎drivers/char/tpm/st33zp24/spi.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static int st33zp24_spi_acpi_request_resources(struct spi_device *spi_dev)
246246
struct device *dev = &spi_dev->dev;
247247
int ret;
248248

249-
ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), acpi_st33zp24_gpios);
249+
ret = devm_acpi_dev_add_driver_gpios(dev, acpi_st33zp24_gpios);
250250
if (ret)
251251
return ret;
252252

@@ -402,7 +402,6 @@ static int st33zp24_spi_remove(struct spi_device *dev)
402402
if (ret)
403403
return ret;
404404

405-
acpi_dev_remove_driver_gpios(ACPI_COMPANION(&dev->dev));
406405
return 0;
407406
}
408407

‎drivers/char/tpm/tpm-interface.c‎

Lines changed: 65 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
416416
/* Store the decision as chip->locality will be changed. */
417417
need_locality = chip->locality == -1;
418418

419-
if (need_locality && chip->ops->request_locality) {
419+
if (!(flags & TPM_TRANSMIT_RAW) &&
420+
need_locality && chip->ops->request_locality) {
420421
rc = chip->ops->request_locality(chip, 0);
421422
if (rc < 0)
422423
goto out_no_locality;
@@ -429,8 +430,9 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
429430

430431
rc = chip->ops->send(chip, (u8 *) buf, count);
431432
if (rc < 0) {
432-
dev_err(&chip->dev,
433-
"tpm_transmit: tpm_send: error %d\n", rc);
433+
if (rc != -EPIPE)
434+
dev_err(&chip->dev,
435+
"%s: tpm_send: error %d\n", __func__, rc);
434436
goto out;
435437
}
436438

@@ -536,59 +538,62 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space,
536538

537539
return 0;
538540
}
541+
EXPORT_SYMBOL_GPL(tpm_transmit_cmd);
539542

540543
#define TPM_DIGEST_SIZE 20
541544
#define TPM_RET_CODE_IDX 6
542545
#define TPM_INTERNAL_RESULT_SIZE 200
543-
#define TPM_ORD_GET_CAP cpu_to_be32(101)
544-
#define TPM_ORD_GET_RANDOM cpu_to_be32(70)
546+
#define TPM_ORD_GET_CAP 101
547+
#define TPM_ORD_GET_RANDOM 70
545548

546549
static const struct tpm_input_header tpm_getcap_header = {
547-
.tag = TPM_TAG_RQU_COMMAND,
550+
.tag = cpu_to_be16(TPM_TAG_RQU_COMMAND),
548551
.length = cpu_to_be32(22),
549-
.ordinal = TPM_ORD_GET_CAP
552+
.ordinal = cpu_to_be32(TPM_ORD_GET_CAP)
550553
};
551554

552555
ssize_t tpm_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap,
553556
const char *desc, size_t min_cap_length)
554557
{
555-
struct tpm_cmd_t tpm_cmd;
558+
struct tpm_buf buf;
556559
int rc;
557560

558-
tpm_cmd.header.in = tpm_getcap_header;
561+
rc = tpm_buf_init(&buf, TPM_TAG_RQU_COMMAND, TPM_ORD_GET_CAP);
562+
if (rc)
563+
return rc;
564+
559565
if (subcap_id == TPM_CAP_VERSION_1_1 ||
560566
subcap_id == TPM_CAP_VERSION_1_2) {
561-
tpm_cmd.params.getcap_in.cap = cpu_to_be32(subcap_id);
562-
/*subcap field not necessary */
563-
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(0);
564-
tpm_cmd.header.in.length -= cpu_to_be32(sizeof(__be32));
567+
tpm_buf_append_u32(&buf, subcap_id);
568+
tpm_buf_append_u32(&buf, 0);
565569
} else {
566570
if (subcap_id == TPM_CAP_FLAG_PERM ||
567571
subcap_id == TPM_CAP_FLAG_VOL)
568-
tpm_cmd.params.getcap_in.cap =
569-
cpu_to_be32(TPM_CAP_FLAG);
572+
tpm_buf_append_u32(&buf, TPM_CAP_FLAG);
570573
else
571-
tpm_cmd.params.getcap_in.cap =
572-
cpu_to_be32(TPM_CAP_PROP);
573-
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
574-
tpm_cmd.params.getcap_in.subcap = cpu_to_be32(subcap_id);
574+
tpm_buf_append_u32(&buf, TPM_CAP_PROP);
575+
576+
tpm_buf_append_u32(&buf, 4);
577+
tpm_buf_append_u32(&buf, subcap_id);
575578
}
576-
rc = tpm_transmit_cmd(chip, NULL, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE,
579+
rc = tpm_transmit_cmd(chip, NULL, buf.data, PAGE_SIZE,
577580
min_cap_length, 0, desc);
578581
if (!rc)
579-
*cap = tpm_cmd.params.getcap_out.cap;
582+
*cap = *(cap_t *)&buf.data[TPM_HEADER_SIZE + 4];
583+
584+
tpm_buf_destroy(&buf);
580585
return rc;
581586
}
582587
EXPORT_SYMBOL_GPL(tpm_getcap);
583588

584-
#define TPM_ORD_STARTUP cpu_to_be32(153)
589+
#define TPM_ORD_STARTUP 153
585590
#define TPM_ST_CLEAR cpu_to_be16(1)
586591
#define TPM_ST_STATE cpu_to_be16(2)
587592
#define TPM_ST_DEACTIVATED cpu_to_be16(3)
588593
static const struct tpm_input_header tpm_startup_header = {
589-
.tag = TPM_TAG_RQU_COMMAND,
594+
.tag = cpu_to_be16(TPM_TAG_RQU_COMMAND),
590595
.length = cpu_to_be32(12),
591-
.ordinal = TPM_ORD_STARTUP
596+
.ordinal = cpu_to_be32(TPM_ORD_STARTUP)
592597
};
593598

594599
static int tpm_startup(struct tpm_chip *chip, __be16 startup_type)
@@ -737,7 +742,7 @@ EXPORT_SYMBOL_GPL(tpm_get_timeouts);
737742
#define CONTINUE_SELFTEST_RESULT_SIZE 10
738743

739744
static const struct tpm_input_header continue_selftest_header = {
740-
.tag = TPM_TAG_RQU_COMMAND,
745+
.tag = cpu_to_be16(TPM_TAG_RQU_COMMAND),
741746
.length = cpu_to_be32(10),
742747
.ordinal = cpu_to_be32(TPM_ORD_CONTINUE_SELFTEST),
743748
};
@@ -760,13 +765,13 @@ static int tpm_continue_selftest(struct tpm_chip *chip)
760765
return rc;
761766
}
762767

763-
#define TPM_ORDINAL_PCRREAD cpu_to_be32(21)
768+
#define TPM_ORDINAL_PCRREAD 21
764769
#define READ_PCR_RESULT_SIZE 30
765770
#define READ_PCR_RESULT_BODY_SIZE 20
766771
static const struct tpm_input_header pcrread_header = {
767-
.tag = TPM_TAG_RQU_COMMAND,
772+
.tag = cpu_to_be16(TPM_TAG_RQU_COMMAND),
768773
.length = cpu_to_be32(14),
769-
.ordinal = TPM_ORDINAL_PCRREAD
774+
.ordinal = cpu_to_be32(TPM_ORDINAL_PCRREAD)
770775
};
771776

772777
int tpm_pcr_read_dev(struct tpm_chip *chip, int pcr_idx, u8 *res_buf)
@@ -838,15 +843,34 @@ int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf)
838843
}
839844
EXPORT_SYMBOL_GPL(tpm_pcr_read);
840845

841-
#define TPM_ORD_PCR_EXTEND cpu_to_be32(20)
846+
#define TPM_ORD_PCR_EXTEND 20
842847
#define EXTEND_PCR_RESULT_SIZE 34
843848
#define EXTEND_PCR_RESULT_BODY_SIZE 20
844849
static const struct tpm_input_header pcrextend_header = {
845-
.tag = TPM_TAG_RQU_COMMAND,
850+
.tag = cpu_to_be16(TPM_TAG_RQU_COMMAND),
846851
.length = cpu_to_be32(34),
847-
.ordinal = TPM_ORD_PCR_EXTEND
852+
.ordinal = cpu_to_be32(TPM_ORD_PCR_EXTEND)
848853
};
849854

855+
static int tpm1_pcr_extend(struct tpm_chip *chip, int pcr_idx, const u8 *hash,
856+
char *log_msg)
857+
{
858+
struct tpm_buf buf;
859+
int rc;
860+
861+
rc = tpm_buf_init(&buf, TPM_TAG_RQU_COMMAND, TPM_ORD_PCR_EXTEND);
862+
if (rc)
863+
return rc;
864+
865+
tpm_buf_append_u32(&buf, pcr_idx);
866+
tpm_buf_append(&buf, hash, TPM_DIGEST_SIZE);
867+
868+
rc = tpm_transmit_cmd(chip, NULL, buf.data, EXTEND_PCR_RESULT_SIZE,
869+
EXTEND_PCR_RESULT_BODY_SIZE, 0, log_msg);
870+
tpm_buf_destroy(&buf);
871+
return rc;
872+
}
873+
850874
/**
851875
* tpm_pcr_extend - extend pcr value with hash
852876
* @chip_num: tpm idx # or AN&
@@ -859,7 +883,6 @@ static const struct tpm_input_header pcrextend_header = {
859883
*/
860884
int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash)
861885
{
862-
struct tpm_cmd_t cmd;
863886
int rc;
864887
struct tpm_chip *chip;
865888
struct tpm2_digest digest_list[ARRAY_SIZE(chip->active_banks)];
@@ -885,13 +908,8 @@ int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash)
885908
return rc;
886909
}
887910

888-
cmd.header.in = pcrextend_header;
889-
cmd.params.pcrextend_in.pcr_idx = cpu_to_be32(pcr_idx);
890-
memcpy(cmd.params.pcrextend_in.hash, hash, TPM_DIGEST_SIZE);
891-
rc = tpm_transmit_cmd(chip, NULL, &cmd, EXTEND_PCR_RESULT_SIZE,
892-
EXTEND_PCR_RESULT_BODY_SIZE, 0,
893-
"attempting extend a PCR value");
894-
911+
rc = tpm1_pcr_extend(chip, pcr_idx, hash,
912+
"attempting extend a PCR value");
895913
tpm_put_ops(chip);
896914
return rc;
897915
}
@@ -1060,13 +1078,13 @@ int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
10601078
}
10611079
EXPORT_SYMBOL_GPL(wait_for_tpm_stat);
10621080

1063-
#define TPM_ORD_SAVESTATE cpu_to_be32(152)
1081+
#define TPM_ORD_SAVESTATE 152
10641082
#define SAVESTATE_RESULT_SIZE 10
10651083

10661084
static const struct tpm_input_header savestate_header = {
1067-
.tag = TPM_TAG_RQU_COMMAND,
1085+
.tag = cpu_to_be16(TPM_TAG_RQU_COMMAND),
10681086
.length = cpu_to_be32(10),
1069-
.ordinal = TPM_ORD_SAVESTATE
1087+
.ordinal = cpu_to_be32(TPM_ORD_SAVESTATE)
10701088
};
10711089

10721090
/*
@@ -1090,15 +1108,9 @@ int tpm_pm_suspend(struct device *dev)
10901108
}
10911109

10921110
/* for buggy tpm, flush pcrs with extend to selected dummy */
1093-
if (tpm_suspend_pcr) {
1094-
cmd.header.in = pcrextend_header;
1095-
cmd.params.pcrextend_in.pcr_idx = cpu_to_be32(tpm_suspend_pcr);
1096-
memcpy(cmd.params.pcrextend_in.hash, dummy_hash,
1097-
TPM_DIGEST_SIZE);
1098-
rc = tpm_transmit_cmd(chip, NULL, &cmd, EXTEND_PCR_RESULT_SIZE,
1099-
EXTEND_PCR_RESULT_BODY_SIZE, 0,
1100-
"extending dummy pcr before suspend");
1101-
}
1111+
if (tpm_suspend_pcr)
1112+
rc = tpm1_pcr_extend(chip, tpm_suspend_pcr, dummy_hash,
1113+
"extending dummy pcr before suspend");
11021114

11031115
/* now do the actual savestate */
11041116
for (try = 0; try < TPM_RETRY; try++) {
@@ -1149,9 +1161,9 @@ EXPORT_SYMBOL_GPL(tpm_pm_resume);
11491161

11501162
#define TPM_GETRANDOM_RESULT_SIZE 18
11511163
static const struct tpm_input_header tpm_getrandom_header = {
1152-
.tag = TPM_TAG_RQU_COMMAND,
1164+
.tag = cpu_to_be16(TPM_TAG_RQU_COMMAND),
11531165
.length = cpu_to_be32(14),
1154-
.ordinal = TPM_ORD_GET_RANDOM
1166+
.ordinal = cpu_to_be32(TPM_ORD_GET_RANDOM)
11551167
};
11561168

11571169
/**

‎drivers/char/tpm/tpm-sysfs.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
#define READ_PUBEK_RESULT_SIZE 314
2424
#define READ_PUBEK_RESULT_MIN_BODY_SIZE (28 + 256)
25-
#define TPM_ORD_READPUBEK cpu_to_be32(124)
25+
#define TPM_ORD_READPUBEK 124
2626
static const struct tpm_input_header tpm_readpubek_header = {
27-
.tag = TPM_TAG_RQU_COMMAND,
27+
.tag = cpu_to_be16(TPM_TAG_RQU_COMMAND),
2828
.length = cpu_to_be32(30),
29-
.ordinal = TPM_ORD_READPUBEK
29+
.ordinal = cpu_to_be32(TPM_ORD_READPUBEK)
3030
};
3131
static ssize_t pubek_show(struct device *dev, struct device_attribute *attr,
3232
char *buf)

0 commit comments

Comments
 (0)