Skip to content

Commit 6c1dd1f

Browse files
committed
Merge tag 'integrity-v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity
Pull integrity updates from Mimi Zohar: - Add a new IMA/EVM maintainer and reviewer - Disable EVM on overlayfs The EVM HMAC and the original file signatures contain filesystem specific metadata (e.g. i_ino, i_generation and s_uuid), preventing the security.evm xattr from directly being copied up to the overlay. Further before calculating and writing out the overlay file's EVM HMAC, EVM must first verify the existing backing file's 'security.evm' value. For now until a solution is developed, disable EVM on overlayfs. - One bug fix and two cleanups * tag 'integrity-v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity: overlay: disable EVM evm: add support to disable EVM on unsupported filesystems evm: don't copy up 'security.evm' xattr MAINTAINERS: Add Eric Snowberg as a reviewer to IMA MAINTAINERS: Add Roberto Sassu as co-maintainer to IMA and EVM KEYS: encrypted: Add check for strsep ima: Remove EXPERIMENTAL from Kconfig ima: Reword IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY
2 parents e9b4c58 + c00f94b commit 6c1dd1f

File tree

8 files changed

+62
-7
lines changed

8 files changed

+62
-7
lines changed

MAINTAINERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7930,6 +7930,7 @@ F: include/uapi/linux/ext4.h
79307930

79317931
Extended Verification Module (EVM)
79327932
M: Mimi Zohar <zohar@linux.ibm.com>
7933+
M: Roberto Sassu <roberto.sassu@huawei.com>
79337934
L: linux-integrity@vger.kernel.org
79347935
S: Supported
79357936
T: git git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git
@@ -10518,7 +10519,9 @@ F: drivers/crypto/inside-secure/
1051810519

1051910520
INTEGRITY MEASUREMENT ARCHITECTURE (IMA)
1052010521
M: Mimi Zohar <zohar@linux.ibm.com>
10522+
M: Roberto Sassu <roberto.sassu@huawei.com>
1052110523
M: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
10524+
R: Eric Snowberg <eric.snowberg@oracle.com>
1052210525
L: linux-integrity@vger.kernel.org
1052310526
S: Supported
1052410527
T: git git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git

fs/overlayfs/super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,7 @@ int ovl_fill_super(struct super_block *sb, struct fs_context *fc)
14541454
* lead to unexpected results.
14551455
*/
14561456
sb->s_iflags |= SB_I_NOUMASK;
1457+
sb->s_iflags |= SB_I_EVM_UNSUPPORTED;
14571458

14581459
err = -ENOMEM;
14591460
root_dentry = ovl_get_root(sb, ctx->upper.dentry, oe);

include/linux/evm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern void evm_inode_post_setxattr(struct dentry *dentry,
3131
const char *xattr_name,
3232
const void *xattr_value,
3333
size_t xattr_value_len);
34+
extern int evm_inode_copy_up_xattr(const char *name);
3435
extern int evm_inode_removexattr(struct mnt_idmap *idmap,
3536
struct dentry *dentry, const char *xattr_name);
3637
extern void evm_inode_post_removexattr(struct dentry *dentry,
@@ -117,6 +118,11 @@ static inline void evm_inode_post_setxattr(struct dentry *dentry,
117118
return;
118119
}
119120

121+
static inline int evm_inode_copy_up_xattr(const char *name)
122+
{
123+
return 0;
124+
}
125+
120126
static inline int evm_inode_removexattr(struct mnt_idmap *idmap,
121127
struct dentry *dentry,
122128
const char *xattr_name)

include/linux/fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,7 @@ extern int send_sigurg(struct fown_struct *fown);
11661166
#define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */
11671167
#define SB_I_IMA_UNVERIFIABLE_SIGNATURE 0x00000020
11681168
#define SB_I_UNTRUSTED_MOUNTER 0x00000040
1169+
#define SB_I_EVM_UNSUPPORTED 0x00000080
11691170

11701171
#define SB_I_SKIP_SYNC 0x00000100 /* Skip superblock at global sync */
11711172
#define SB_I_PERSB_BDI 0x00000200 /* has a per-sb bdi */

security/integrity/evm/evm_main.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@ static int evm_find_protected_xattrs(struct dentry *dentry)
151151
return count;
152152
}
153153

154+
static int is_unsupported_fs(struct dentry *dentry)
155+
{
156+
struct inode *inode = d_backing_inode(dentry);
157+
158+
if (inode->i_sb->s_iflags & SB_I_EVM_UNSUPPORTED) {
159+
pr_info_once("%s not supported\n", inode->i_sb->s_type->name);
160+
return 1;
161+
}
162+
return 0;
163+
}
164+
154165
/*
155166
* evm_verify_hmac - calculate and compare the HMAC with the EVM xattr
156167
*
@@ -181,6 +192,9 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
181192
iint->evm_status == INTEGRITY_PASS_IMMUTABLE))
182193
return iint->evm_status;
183194

195+
if (is_unsupported_fs(dentry))
196+
return INTEGRITY_UNKNOWN;
197+
184198
/* if status is not PASS, try to check again - against -ENOMEM */
185199

186200
/* first need to know the sig type */
@@ -408,6 +422,9 @@ enum integrity_status evm_verifyxattr(struct dentry *dentry,
408422
if (!evm_key_loaded() || !evm_protected_xattr(xattr_name))
409423
return INTEGRITY_UNKNOWN;
410424

425+
if (is_unsupported_fs(dentry))
426+
return INTEGRITY_UNKNOWN;
427+
411428
if (!iint) {
412429
iint = integrity_iint_find(d_backing_inode(dentry));
413430
if (!iint)
@@ -491,15 +508,21 @@ static int evm_protect_xattr(struct mnt_idmap *idmap,
491508
if (strcmp(xattr_name, XATTR_NAME_EVM) == 0) {
492509
if (!capable(CAP_SYS_ADMIN))
493510
return -EPERM;
511+
if (is_unsupported_fs(dentry))
512+
return -EPERM;
494513
} else if (!evm_protected_xattr(xattr_name)) {
495514
if (!posix_xattr_acl(xattr_name))
496515
return 0;
516+
if (is_unsupported_fs(dentry))
517+
return 0;
518+
497519
evm_status = evm_verify_current_integrity(dentry);
498520
if ((evm_status == INTEGRITY_PASS) ||
499521
(evm_status == INTEGRITY_NOXATTRS))
500522
return 0;
501523
goto out;
502-
}
524+
} else if (is_unsupported_fs(dentry))
525+
return 0;
503526

504527
evm_status = evm_verify_current_integrity(dentry);
505528
if (evm_status == INTEGRITY_NOXATTRS) {
@@ -750,6 +773,9 @@ void evm_inode_post_setxattr(struct dentry *dentry, const char *xattr_name,
750773
if (!(evm_initialized & EVM_INIT_HMAC))
751774
return;
752775

776+
if (is_unsupported_fs(dentry))
777+
return;
778+
753779
evm_update_evmxattr(dentry, xattr_name, xattr_value, xattr_value_len);
754780
}
755781

@@ -814,8 +840,12 @@ int evm_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
814840
if (evm_initialized & EVM_ALLOW_METADATA_WRITES)
815841
return 0;
816842

843+
if (is_unsupported_fs(dentry))
844+
return 0;
845+
817846
if (!(ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID)))
818847
return 0;
848+
819849
evm_status = evm_verify_current_integrity(dentry);
820850
/*
821851
* Writing attrs is safe for portable signatures, as portable signatures
@@ -859,10 +889,20 @@ void evm_inode_post_setattr(struct dentry *dentry, int ia_valid)
859889
if (!(evm_initialized & EVM_INIT_HMAC))
860890
return;
861891

892+
if (is_unsupported_fs(dentry))
893+
return;
894+
862895
if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID))
863896
evm_update_evmxattr(dentry, NULL, NULL, 0);
864897
}
865898

899+
int evm_inode_copy_up_xattr(const char *name)
900+
{
901+
if (strcmp(name, XATTR_NAME_EVM) == 0)
902+
return 1; /* Discard */
903+
return -EOPNOTSUPP;
904+
}
905+
866906
/*
867907
* evm_inode_init_security - initializes security.evm HMAC value
868908
*/

security/integrity/ima/Kconfig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,22 +243,22 @@ config IMA_APPRAISE_MODSIG
243243
to accept such signatures.
244244

245245
config IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY
246-
bool "Permit keys validly signed by a built-in or secondary CA cert (EXPERIMENTAL)"
246+
bool "Permit keys validly signed by a built-in, machine (if configured) or secondary"
247247
depends on SYSTEM_TRUSTED_KEYRING
248248
depends on SECONDARY_TRUSTED_KEYRING
249249
depends on INTEGRITY_ASYMMETRIC_KEYS
250250
select INTEGRITY_TRUSTED_KEYRING
251251
default n
252252
help
253253
Keys may be added to the IMA or IMA blacklist keyrings, if the
254-
key is validly signed by a CA cert in the system built-in or
255-
secondary trusted keyrings. The key must also have the
256-
digitalSignature usage set.
254+
key is validly signed by a CA cert in the system built-in,
255+
machine (if configured), or secondary trusted keyrings. The
256+
key must also have the digitalSignature usage set.
257257

258258
Intermediate keys between those the kernel has compiled in and the
259259
IMA keys to be added may be added to the system secondary keyring,
260260
provided they are validly signed by a key already resident in the
261-
built-in or secondary trusted keyrings.
261+
built-in, machine (if configured) or secondary trusted keyrings.
262262

263263
config IMA_BLACKLIST_KEYRING
264264
bool "Create IMA machine owner blacklist keyrings (EXPERIMENTAL)"

security/keys/encrypted-keys/encrypted.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ static int datablob_parse(char *datablob, const char **format,
237237
break;
238238
}
239239
*decrypted_data = strsep(&datablob, " \t");
240+
if (!*decrypted_data) {
241+
pr_info("encrypted_key: decrypted_data is missing\n");
242+
break;
243+
}
240244
ret = 0;
241245
break;
242246
case Opt_load:

security/security.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2623,7 +2623,7 @@ int security_inode_copy_up_xattr(const char *name)
26232623
return rc;
26242624
}
26252625

2626-
return LSM_RET_DEFAULT(inode_copy_up_xattr);
2626+
return evm_inode_copy_up_xattr(name);
26272627
}
26282628
EXPORT_SYMBOL(security_inode_copy_up_xattr);
26292629

0 commit comments

Comments
 (0)