linux-stable/drivers
lei he 1bedcf22c0 virtio-crypto: fix memory-leak
Fix memory-leak for virtio-crypto akcipher request, this problem is
introduced by 59ca6c93387d3(virtio-crypto: implement RSA algorithm).
The leak can be reproduced and tested with the following script
inside virtual machine:

#!/bin/bash

LOOP_TIMES=10000

# required module: pkcs8_key_parser, virtio_crypto
modprobe pkcs8_key_parser # if CONFIG_PKCS8_PRIVATE_KEY_PARSER=m
modprobe virtio_crypto # if CONFIG_CRYPTO_DEV_VIRTIO=m
rm -rf /tmp/data
dd if=/dev/random of=/tmp/data count=1 bs=230

# generate private key and self-signed cert
openssl req -nodes -x509 -newkey rsa:2048 -keyout key.pem \
		-outform der -out cert.der  \
		-subj "/C=CN/ST=GD/L=SZ/O=vihoo/OU=dev/CN=always.com/emailAddress=yy@always.com"
# convert private key from pem to der
openssl pkcs8 -in key.pem -topk8 -nocrypt -outform DER -out key.der

# add key
PRIV_KEY_ID=`cat key.der | keyctl padd asymmetric test_priv_key @s`
echo "priv key id = "$PRIV_KEY_ID
PUB_KEY_ID=`cat cert.der | keyctl padd asymmetric test_pub_key @s`
echo "pub key id = "$PUB_KEY_ID

# query key
keyctl pkey_query $PRIV_KEY_ID 0
keyctl pkey_query $PUB_KEY_ID 0

# here we only run pkey_encrypt becasuse it is the fastest interface
function bench_pub() {
	keyctl pkey_encrypt $PUB_KEY_ID 0 /tmp/data enc=pkcs1 >/tmp/enc.pub
}

# do bench_pub in loop to obtain the memory leak
for (( i = 0; i < ${LOOP_TIMES}; ++i )); do
	bench_pub
done

Signed-off-by: lei he <helei.sig11@bytedance.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Message-Id: <20220919075158.3625-1-helei.sig11@bytedance.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2022-09-27 18:30:48 -04:00
..
accessibility
acpi Merge branch 'acpi-processor' into acpi 2022-08-27 14:43:18 +02:00
amba ARM: 9229/1: amba: Fix use-after-free in amba_read_periphid() 2022-08-30 11:12:52 +01:00
android Char/Misc driver fixes for 6.0-rc4 2022-09-02 10:50:08 -07:00
ata ata: libata-eh: Add missing command name 2022-08-16 05:42:51 +09:00
atm atm: idt77252: fix use-after-free bugs caused by tst_timer 2022-08-08 20:51:59 -07:00
auxdisplay
base Revert "driver core: Set fw_devlink.strict=1 by default" 2022-09-15 12:44:56 +02:00
bcma
block xen: branch for v6.0-rc4 2022-09-03 13:23:11 -07:00
bluetooth
bus bus: mhi: host: Fix up null pointer access in mhi_irq_handler 2022-08-29 22:33:46 +05:30
cdrom
char /dev/null: add IORING_OP_URING_CMD support 2022-08-26 11:19:44 -04:00
clk Revert "clk: core: Honor CLK_OPS_PARENT_ENABLE for clk gate ops" 2022-08-31 12:06:46 -07:00
clocksource RISC-V: Add Sstc extension support 2022-08-11 14:41:52 -07:00
comedi
connector
counter counter: 104-quad-8: Fix skipped IRQ lines during events configuration 2022-09-22 14:26:37 +02:00
cpufreq cpufreq: check only freq_table in __resolve_freq() 2022-08-23 20:00:52 +02:00
cpuidle
crypto virtio-crypto: fix memory-leak 2022-09-27 18:30:48 -04:00
cxl
dax devdax: Fix soft-reservation memory description 2022-09-24 18:05:53 -07:00
dca
devfreq
dio
dma dmaengine: zynqmp_dma: Typecast with enum to fix the coverity warning 2022-09-05 11:54:50 +05:30
dma-buf dma-buf/dma-resv: check if the new fence is really later 2022-08-25 13:10:30 +02:00
edac
eisa
extcon
firewire
firmware ARM: SoC fixes for 6.0-rc6 2022-09-22 11:10:11 -07:00
fpga fpga: m10bmc-sec: Fix possible memory leak of flash_buf 2022-09-19 12:58:19 +08:00
fsi
gnss
gpio gpiolib: cdev: Set lineevent_state::irq after IRQ register successfully 2022-09-21 09:32:11 +02:00
gpu Short summary of fixes pull 2022-09-23 13:18:26 +10:00
greybus
hid for-linus-2022083101 2022-08-31 09:54:14 -07:00
hsi
hte
hv Drivers: hv: Never allocate anything besides framebuffer from framebuffer memory region 2022-09-05 17:02:15 +00:00
hwmon hwmon: (asus-ec-sensors) autoload module via DMI data 2022-09-09 10:45:08 -07:00
hwspinlock
hwtracing
i2c i2c: mux: harden i2c_mux_alloc() against integer overflows 2022-09-21 22:12:06 +02:00
i3c
idle
iio iio: light: cm32181: make cm32181_pm_ops static 2022-08-21 18:24:16 +01:00
infiniband RDMA/irdma: Report RNR NAK generation in device caps 2022-09-07 11:22:18 +03:00
input Input updates for v6.0-rc3 2022-09-03 13:09:46 -07:00
interconnect
iommu iommu/vt-d: Check correct capability for sagaw determination 2022-09-21 10:22:54 +02:00
ipack
irqchip irqchip fixes for 6.0, take #1 2022-08-18 17:37:22 +02:00
isdn
leds
macintosh
mailbox
mcb
md block-6.0-2022-08-26 2022-08-26 11:05:54 -07:00
media media: flexcop-usb: fix endpoint type check 2022-09-22 10:40:57 +02:00
memory
memstick
message
mfd
misc misc: fastrpc: increase maximum session count 2022-09-01 16:13:07 +02:00
mmc MMC core: 2022-09-02 15:03:12 -07:00
most
mtd
mux
net Including fixes from wifi, netfilter and can. 2022-09-22 10:58:13 -07:00
nfc nfc: pn533: Fix use-after-free bugs caused by pn532_cmd_timeout 2022-08-22 14:51:30 +01:00
ntb NTB: epf: Allow more flexibility in the memory BAR map method 2022-08-09 17:54:03 -04:00
nubus
nvdimm Merge branch 'for-6.0/dax' into libnvdimm-fixes 2022-09-24 18:14:12 -07:00
nvme block-6.0-2022-09-09 2022-09-09 15:03:08 -04:00
nvmem
of of: fdt: fix off-by-one error in unflatten_dt_nodes() 2022-08-16 11:29:57 -06:00
opp OPP: Fix an un-initialized variable usage 2022-08-16 10:48:08 +05:30
parisc parisc: remove obsolete manual allocation aligning in iosapic 2022-09-15 07:33:26 +02:00
parport
pci Fix of heap data and clang warnings, support for a new Intel NTB device, 2022-08-13 14:00:45 -07:00
pcmcia
peci peci: cpu: Fix use-after-free in adev_release() 2022-08-15 20:31:35 +02:00
perf arm64 fixes for -rc7 2022-09-23 15:28:51 -07:00
phy phy: marvell: phy-mvebu-a3700-comphy: Remove broken reset support 2022-08-30 10:32:33 +05:30
pinctrl pinctrl: ocelot: Fix interrupt controller 2022-09-14 15:00:16 +02:00
platform platform-drivers-x86 for v6.0-2 2022-09-02 10:35:51 -07:00
pnp
power power supply and reset changes for the v6.0 series 2022-08-12 09:37:33 -07:00
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator regulator: Fixes for v6.0 2022-09-08 12:56:20 -04:00
remoteproc virtio: Revert "virtio: find_vqs() add arg sizes" 2022-08-16 01:40:24 -04:00
reset
rpmsg
rtc rtc: spear: set range max 2022-08-09 00:56:41 +02:00
s390 s390 updates for v6.0-rc7 2022-09-24 17:35:42 -07:00
sbus
scsi scsi: mpt3sas: Fix return value check of dma_get_required_mask() 2022-09-15 22:24:28 -04:00
sh
siox
slimbus
soc soc: fsl: select FSL_GUTS driver for DPIO 2022-09-02 11:28:40 +02:00
soundwire soundwire: qcom: fix device status array range 2022-09-01 14:26:44 +05:30
spi spi: Fixes for v6.0 2022-09-08 13:13:47 -04:00
spmi
ssb
staging staging: rtl8712: fix use after free bugs 2022-08-30 17:15:16 +02:00
target SCSI misc on 20220813 2022-08-13 13:41:48 -07:00
tc
tee tee: fix compiler warning in tee_shm_register() 2022-08-25 11:40:06 +02:00
thermal Merge branch 'thermal-core' 2022-08-27 15:07:58 +02:00
thunderbolt USB / Thunderbolt driver fixes and ids for 6.0-rc7 2022-09-23 09:07:08 -07:00
tty serial: sifive: enable clocks for UART when probed 2022-09-22 16:38:18 +02:00
ufs scsi: ufs: core: Reduce the power mode change timeout 2022-08-19 21:34:36 -04:00
uio
usb USB-serial fixes for 6.0-rc7 2022-09-22 15:43:18 +02:00
vdpa vdpa/ifcvf: fix the calculation of queuepair 2022-09-27 18:30:48 -04:00
vfio VFIO fix for v6.0-rc5 2022-09-09 07:44:33 -04:00
vhost virtio: fatures, fixes 2022-08-12 09:50:34 -07:00
video hyperv-fixes for v6.0-rc6 2022-09-12 18:33:55 -04:00
virt kunit: fix Kconfig for build-in tests USB4 and Nitro Enclaves 2022-09-01 13:00:48 -06:00
virtio virtio: kerneldocs fixes and enhancements 2022-08-16 01:40:24 -04:00
vlynq
w1
watchdog
xen xen: branch for v6.0-rc7 2022-09-23 08:31:24 -07:00
zorro
Kconfig
Makefile