mirror of
https://git.code.sf.net/p/linux-ima/ima-evm-utils
synced 2025-04-28 22:53:37 +02:00
Prevent reading of inode generation for special files in HMAC signing
Kernel API does not support at the momement reading of inode generation number of special files, so do not do it also when do HMAC signing. Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
This commit is contained in:
parent
fd08fdeeb5
commit
6c0ebe2be6
32
src/evmctl.c
32
src/evmctl.c
@ -1429,8 +1429,8 @@ out:
|
|||||||
static int calc_evm_hmac(const char *file, const char *keyfile, unsigned char *hash)
|
static int calc_evm_hmac(const char *file, const char *keyfile, unsigned char *hash)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int fd, err = -1;
|
int err = -1;
|
||||||
uint32_t generation;
|
uint32_t generation = 0;
|
||||||
HMAC_CTX ctx;
|
HMAC_CTX ctx;
|
||||||
unsigned int mdlen;
|
unsigned int mdlen;
|
||||||
char **xattrname;
|
char **xattrname;
|
||||||
@ -1456,24 +1456,26 @@ static int calc_evm_hmac(const char *file, const char *keyfile, unsigned char *h
|
|||||||
memcpy(evmkey, key, keylen);
|
memcpy(evmkey, key, keylen);
|
||||||
memset(evmkey + keylen, 0, sizeof(evmkey) - keylen);
|
memset(evmkey + keylen, 0, sizeof(evmkey) - keylen);
|
||||||
|
|
||||||
fd = open(file, 0);
|
if (lstat(file, &st)) {
|
||||||
if (fd < 0) {
|
log_err("lstat() failed\n");
|
||||||
log_err("Unable to open %s\n", file);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fstat(fd, &st)) {
|
if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)) {
|
||||||
log_err("fstat() failed\n");
|
/* we cannot at the momement to get generation of special files..
|
||||||
goto out;
|
* kernel API does not support it */
|
||||||
|
int fd = open(file, 0);
|
||||||
|
if (fd < 0) {
|
||||||
|
log_err("Unable to open %s\n", file);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (ioctl(fd, EXT34_IOC_GETVERSION, &generation)) {
|
||||||
|
log_err("ioctl() failed\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(fd, EXT34_IOC_GETVERSION, &generation)) {
|
|
||||||
log_err("ioctl() failed\n");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
log_info("generation: %u\n", generation);
|
log_info("generation: %u\n", generation);
|
||||||
|
|
||||||
list_size = llistxattr(file, list, sizeof(list));
|
list_size = llistxattr(file, list, sizeof(list));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user