mirror of
https://git.proxmox.com/git/mirror_ubuntu-kernels.git
synced 2025-11-16 04:24:44 +00:00
Remove support for the "Crypto usage statistics" feature (CONFIG_CRYPTO_STATS). This feature does not appear to have ever been used, and it is harmful because it significantly reduces performance and is a large maintenance burden. Covering each of these points in detail: 1. Feature is not being used Since these generic crypto statistics are only readable using netlink, it's fairly straightforward to look for programs that use them. I'm unable to find any evidence that any such programs exist. For example, Debian Code Search returns no hits except the kernel header and kernel code itself and translations of the kernel header: https://codesearch.debian.net/search?q=CRYPTOCFGA_STAT&literal=1&perpkg=1 The patch series that added this feature in 2018 (https://lore.kernel.org/linux-crypto/1537351855-16618-1-git-send-email-clabbe@baylibre.com/) said "The goal is to have an ifconfig for crypto device." This doesn't appear to have happened. It's not clear that there is real demand for crypto statistics. Just because the kernel provides other types of statistics such as I/O and networking statistics and some people find those useful does not mean that crypto statistics are useful too. Further evidence that programs are not using CONFIG_CRYPTO_STATS is that it was able to be disabled in RHEL and Fedora as a bug fix (https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/2947). Even further evidence comes from the fact that there are and have been bugs in how the stats work, but they were never reported. For example, before Linux v6.7 hash stats were double-counted in most cases. There has also never been any documentation for this feature, so it might be hard to use even if someone wanted to. 2. CONFIG_CRYPTO_STATS significantly reduces performance Enabling CONFIG_CRYPTO_STATS significantly reduces the performance of the crypto API, even if no program ever retrieves the statistics. This primarily affects systems with a large number of CPUs. For example, https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2039576 reported that Lustre client encryption performance improved from 21.7GB/s to 48.2GB/s by disabling CONFIG_CRYPTO_STATS. It can be argued that this means that CONFIG_CRYPTO_STATS should be optimized with per-cpu counters similar to many of the networking counters. But no one has done this in 5+ years. This is consistent with the fact that the feature appears to be unused, so there seems to be little interest in improving it as opposed to just disabling it. It can be argued that because CONFIG_CRYPTO_STATS is off by default, performance doesn't matter. But Linux distros tend to error on the side of enabling options. The option is enabled in Ubuntu and Arch Linux, and until recently was enabled in RHEL and Fedora (see above). So, even just having the option available is harmful to users. 3. CONFIG_CRYPTO_STATS is a large maintenance burden There are over 1000 lines of code associated with CONFIG_CRYPTO_STATS, spread among 32 files. It significantly complicates much of the implementation of the crypto API. After the initial submission, many fixes and refactorings have consumed effort of multiple people to keep this feature "working". We should be spending this effort elsewhere. Acked-by: Ard Biesheuvel <ardb@kernel.org> Acked-by: Corentin Labbe <clabbe@baylibre.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
214 lines
5.7 KiB
C
214 lines
5.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
|
/*
|
|
* Crypto user configuration API.
|
|
*
|
|
* Copyright (C) 2011 secunet Security Networks AG
|
|
* Copyright (C) 2011 Steffen Klassert <steffen.klassert@secunet.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along with
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*/
|
|
|
|
#ifndef _UAPI_LINUX_CRYPTOUSER_H
|
|
#define _UAPI_LINUX_CRYPTOUSER_H
|
|
|
|
#include <linux/types.h>
|
|
|
|
/* Netlink configuration messages. */
|
|
enum {
|
|
CRYPTO_MSG_BASE = 0x10,
|
|
CRYPTO_MSG_NEWALG = 0x10,
|
|
CRYPTO_MSG_DELALG,
|
|
CRYPTO_MSG_UPDATEALG,
|
|
CRYPTO_MSG_GETALG,
|
|
CRYPTO_MSG_DELRNG,
|
|
CRYPTO_MSG_GETSTAT, /* No longer supported, do not use. */
|
|
__CRYPTO_MSG_MAX
|
|
};
|
|
#define CRYPTO_MSG_MAX (__CRYPTO_MSG_MAX - 1)
|
|
#define CRYPTO_NR_MSGTYPES (CRYPTO_MSG_MAX + 1 - CRYPTO_MSG_BASE)
|
|
|
|
#define CRYPTO_MAX_NAME 64
|
|
|
|
/* Netlink message attributes. */
|
|
enum crypto_attr_type_t {
|
|
CRYPTOCFGA_UNSPEC,
|
|
CRYPTOCFGA_PRIORITY_VAL, /* __u32 */
|
|
CRYPTOCFGA_REPORT_LARVAL, /* struct crypto_report_larval */
|
|
CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */
|
|
CRYPTOCFGA_REPORT_BLKCIPHER, /* struct crypto_report_blkcipher */
|
|
CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */
|
|
CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */
|
|
CRYPTOCFGA_REPORT_RNG, /* struct crypto_report_rng */
|
|
CRYPTOCFGA_REPORT_CIPHER, /* struct crypto_report_cipher */
|
|
CRYPTOCFGA_REPORT_AKCIPHER, /* struct crypto_report_akcipher */
|
|
CRYPTOCFGA_REPORT_KPP, /* struct crypto_report_kpp */
|
|
CRYPTOCFGA_REPORT_ACOMP, /* struct crypto_report_acomp */
|
|
CRYPTOCFGA_STAT_LARVAL, /* No longer supported, do not use. */
|
|
CRYPTOCFGA_STAT_HASH, /* No longer supported, do not use. */
|
|
CRYPTOCFGA_STAT_BLKCIPHER, /* No longer supported, do not use. */
|
|
CRYPTOCFGA_STAT_AEAD, /* No longer supported, do not use. */
|
|
CRYPTOCFGA_STAT_COMPRESS, /* No longer supported, do not use. */
|
|
CRYPTOCFGA_STAT_RNG, /* No longer supported, do not use. */
|
|
CRYPTOCFGA_STAT_CIPHER, /* No longer supported, do not use. */
|
|
CRYPTOCFGA_STAT_AKCIPHER, /* No longer supported, do not use. */
|
|
CRYPTOCFGA_STAT_KPP, /* No longer supported, do not use. */
|
|
CRYPTOCFGA_STAT_ACOMP, /* No longer supported, do not use. */
|
|
__CRYPTOCFGA_MAX
|
|
|
|
#define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
|
|
};
|
|
|
|
struct crypto_user_alg {
|
|
char cru_name[CRYPTO_MAX_NAME];
|
|
char cru_driver_name[CRYPTO_MAX_NAME];
|
|
char cru_module_name[CRYPTO_MAX_NAME];
|
|
__u32 cru_type;
|
|
__u32 cru_mask;
|
|
__u32 cru_refcnt;
|
|
__u32 cru_flags;
|
|
};
|
|
|
|
/* No longer supported, do not use. */
|
|
struct crypto_stat_aead {
|
|
char type[CRYPTO_MAX_NAME];
|
|
__u64 stat_encrypt_cnt;
|
|
__u64 stat_encrypt_tlen;
|
|
__u64 stat_decrypt_cnt;
|
|
__u64 stat_decrypt_tlen;
|
|
__u64 stat_err_cnt;
|
|
};
|
|
|
|
/* No longer supported, do not use. */
|
|
struct crypto_stat_akcipher {
|
|
char type[CRYPTO_MAX_NAME];
|
|
__u64 stat_encrypt_cnt;
|
|
__u64 stat_encrypt_tlen;
|
|
__u64 stat_decrypt_cnt;
|
|
__u64 stat_decrypt_tlen;
|
|
__u64 stat_verify_cnt;
|
|
__u64 stat_sign_cnt;
|
|
__u64 stat_err_cnt;
|
|
};
|
|
|
|
/* No longer supported, do not use. */
|
|
struct crypto_stat_cipher {
|
|
char type[CRYPTO_MAX_NAME];
|
|
__u64 stat_encrypt_cnt;
|
|
__u64 stat_encrypt_tlen;
|
|
__u64 stat_decrypt_cnt;
|
|
__u64 stat_decrypt_tlen;
|
|
__u64 stat_err_cnt;
|
|
};
|
|
|
|
/* No longer supported, do not use. */
|
|
struct crypto_stat_compress {
|
|
char type[CRYPTO_MAX_NAME];
|
|
__u64 stat_compress_cnt;
|
|
__u64 stat_compress_tlen;
|
|
__u64 stat_decompress_cnt;
|
|
__u64 stat_decompress_tlen;
|
|
__u64 stat_err_cnt;
|
|
};
|
|
|
|
/* No longer supported, do not use. */
|
|
struct crypto_stat_hash {
|
|
char type[CRYPTO_MAX_NAME];
|
|
__u64 stat_hash_cnt;
|
|
__u64 stat_hash_tlen;
|
|
__u64 stat_err_cnt;
|
|
};
|
|
|
|
/* No longer supported, do not use. */
|
|
struct crypto_stat_kpp {
|
|
char type[CRYPTO_MAX_NAME];
|
|
__u64 stat_setsecret_cnt;
|
|
__u64 stat_generate_public_key_cnt;
|
|
__u64 stat_compute_shared_secret_cnt;
|
|
__u64 stat_err_cnt;
|
|
};
|
|
|
|
/* No longer supported, do not use. */
|
|
struct crypto_stat_rng {
|
|
char type[CRYPTO_MAX_NAME];
|
|
__u64 stat_generate_cnt;
|
|
__u64 stat_generate_tlen;
|
|
__u64 stat_seed_cnt;
|
|
__u64 stat_err_cnt;
|
|
};
|
|
|
|
/* No longer supported, do not use. */
|
|
struct crypto_stat_larval {
|
|
char type[CRYPTO_MAX_NAME];
|
|
};
|
|
|
|
struct crypto_report_larval {
|
|
char type[CRYPTO_MAX_NAME];
|
|
};
|
|
|
|
struct crypto_report_hash {
|
|
char type[CRYPTO_MAX_NAME];
|
|
unsigned int blocksize;
|
|
unsigned int digestsize;
|
|
};
|
|
|
|
struct crypto_report_cipher {
|
|
char type[CRYPTO_MAX_NAME];
|
|
unsigned int blocksize;
|
|
unsigned int min_keysize;
|
|
unsigned int max_keysize;
|
|
};
|
|
|
|
struct crypto_report_blkcipher {
|
|
char type[CRYPTO_MAX_NAME];
|
|
char geniv[CRYPTO_MAX_NAME];
|
|
unsigned int blocksize;
|
|
unsigned int min_keysize;
|
|
unsigned int max_keysize;
|
|
unsigned int ivsize;
|
|
};
|
|
|
|
struct crypto_report_aead {
|
|
char type[CRYPTO_MAX_NAME];
|
|
char geniv[CRYPTO_MAX_NAME];
|
|
unsigned int blocksize;
|
|
unsigned int maxauthsize;
|
|
unsigned int ivsize;
|
|
};
|
|
|
|
struct crypto_report_comp {
|
|
char type[CRYPTO_MAX_NAME];
|
|
};
|
|
|
|
struct crypto_report_rng {
|
|
char type[CRYPTO_MAX_NAME];
|
|
unsigned int seedsize;
|
|
};
|
|
|
|
struct crypto_report_akcipher {
|
|
char type[CRYPTO_MAX_NAME];
|
|
};
|
|
|
|
struct crypto_report_kpp {
|
|
char type[CRYPTO_MAX_NAME];
|
|
};
|
|
|
|
struct crypto_report_acomp {
|
|
char type[CRYPTO_MAX_NAME];
|
|
};
|
|
|
|
#define CRYPTO_REPORT_MAXSIZE (sizeof(struct crypto_user_alg) + \
|
|
sizeof(struct crypto_report_blkcipher))
|
|
|
|
#endif /* _UAPI_LINUX_CRYPTOUSER_H */
|