linux/drivers
Jason A. Donenfeld 514f587340 random: check for signals after page of pool writes
commit 1ce6c8d68f upstream.

get_random_bytes_user() checks for signals after producing a PAGE_SIZE
worth of output, just like /dev/zero does. write_pool() is doing
basically the same work (actually, slightly more expensive), and so
should stop to check for signals in the same way. Let's also name it
write_pool_user() to match get_random_bytes_user(), so this won't be
misused in the future.

Before this patch, massive writes to /dev/urandom would tie up the
process for an extremely long time and make it unterminatable. After, it
can be successfully interrupted. The following test program can be used
to see this works as intended:

  #include <unistd.h>
  #include <fcntl.h>
  #include <signal.h>
  #include <stdio.h>

  static unsigned char x[~0U];

  static void handle(int) { }

  int main(int argc, char *argv[])
  {
    pid_t pid = getpid(), child;
    int fd;
    signal(SIGUSR1, handle);
    if (!(child = fork())) {
      for (;;)
        kill(pid, SIGUSR1);
    }
    fd = open("/dev/urandom", O_WRONLY);
    pause();
    printf("interrupted after writing %zd bytes\n", write(fd, x, sizeof(x)));
    close(fd);
    kill(child, SIGTERM);
    return 0;
  }

Result before: "interrupted after writing 2147479552 bytes"
Result after: "interrupted after writing 4096 bytes"

Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-05-30 09:33:45 +02:00
..
accessibility speakup-dectlk: Restore pitch setting 2022-02-16 12:54:30 +01:00
acpi ACPI: sysfs: Fix BERT error region memory mapping 2022-05-30 09:33:23 +02:00
amba amba: Make the remove callback return void 2022-04-08 14:40:02 +02:00
android binder: fix handling of error during copy 2022-01-27 10:54:06 +01:00
ata ata: pata_marvell: Check the 'bmdma_addr' beforing reading 2022-04-27 13:53:54 +02:00
atm atm: eni: Add check for dma_map_single 2022-03-23 09:13:27 +01:00
auxdisplay auxdisplay: ht16k33: Fix frame buffer device blanking 2021-11-18 14:04:24 +01:00
base firmware_loader: use kernel credentials when reading firmware 2022-05-18 10:23:46 +02:00
bcma bcma: Fix memory leak for internally-handled cores 2021-09-15 09:50:45 +02:00
block drbd: remove usage of list iterator variable after loop 2022-05-25 09:17:54 +02:00
bluetooth Bluetooth: btmtksdio: Fix kernel oops in btmtksdio_interrupt 2022-04-08 14:40:22 +02:00
bus bus: sunxi-rsb: Fix the return value of sunxi_rsb_device_create() 2022-05-09 09:05:04 +02:00
cdrom
char random: check for signals after page of pool writes 2022-05-30 09:33:45 +02:00
clk clk: at91: generated: consider range when calculating best rate 2022-05-25 09:17:58 +02:00
clocksource clocksource: acpi_pm: fix return value of __setup handler 2022-04-08 14:40:03 +02:00
connector
counter counter: stm32-lptimer-cnt: remove iio counter abi 2022-01-27 10:54:08 +01:00
cpufreq cpufreq: fix memory leak in sun50i_cpufreq_nvmem_probe 2022-05-09 09:05:03 +02:00
cpuidle cpuidle: Fix kobject memory leaks in error paths 2021-11-18 14:04:05 +01:00
crypto crypto: qcom-rng - fix infinite loop on requests not multiple of WORD_SZ 2022-05-25 09:17:56 +02:00
dax dax: make sure inodes are flushed before destroy cache 2022-04-08 14:40:16 +02:00
dca
devfreq PM / devfreq: Add missing error code in devfreq_add_device() 2021-07-14 16:56:11 +02:00
dio
dma dma: at_xdmac: fix a missing check on list iterator 2022-04-27 13:53:55 +02:00
dma-buf udmabuf: validate ubuf->pagecount 2022-04-08 14:40:12 +02:00
edac EDAC/synopsys: Read the error count from the correct register 2022-04-27 13:53:54 +02:00
eisa
extcon extcon: intel-mrfld: Sync hardware and software state on init 2021-07-19 09:45:00 +02:00
firewire firewire: core: extend card->lock in fw_core_handle_bus_reset 2022-05-12 12:25:32 +02:00
firmware firmware: arm_scmi: Fix sorting of retrieved clock rates 2022-04-20 09:23:10 +02:00
fpga fpga: machxo2-spi: Fix missing error code in machxo2_write_complete() 2021-09-30 10:11:04 +02:00
fsi fsi: Aspeed: Fix a potential double free 2022-04-08 14:40:23 +02:00
gnss
gpio gpio: mvebu/pwm: Refuse requests with inverted polarity 2022-05-25 09:18:00 +02:00
gpu drm/dp/mst: fix a possible memory leak in fetch_monitor_name() 2022-05-25 09:17:56 +02:00
greybus greybus: svc: fix an error handling bug in gb_svc_hello() 2022-04-08 14:39:50 +02:00
hid HID: i2c-hid: fix GET/SET_REPORT for unnumbered reports 2022-04-08 14:40:15 +02:00
hsi HSI: core: Fix return freed object in hsi_new_client 2022-01-27 10:54:12 +01:00
hv random: remove unused irq_flags argument from add_interrupt_randomness() 2022-05-30 09:33:27 +02:00
hwmon hwmon: (f71882fg) Fix negative temperature 2022-05-18 10:23:45 +02:00
hwspinlock
hwtracing amba: Make the remove callback return void 2022-04-08 14:40:02 +02:00
i2c i2c: mt7621: fix missing clk_disable_unprepare() on error in mtk_i2c_probe() 2022-05-25 09:18:01 +02:00
i3c
ide
idle
iio iio:imu:bmi160: disable regulator in error path 2022-05-09 09:05:00 +02:00
infiniband RDMA/siw: Fix a condition race issue in MPA request processing 2022-05-12 12:25:39 +02:00
input Input: ili210x - fix reset timing 2022-05-25 09:18:01 +02:00
interconnect treewide: Change list_sort to use const pointers 2021-09-30 10:11:04 +02:00
iommu iommu/vt-d: Calculate mask for non-aligned flushes 2022-05-12 12:25:30 +02:00
ipack ipack: ipoctal: fix module reference leak 2021-10-06 15:56:01 +02:00
irqchip irqchip/gic, gic-v3: Prevent GSI to SGI translations 2022-04-13 21:01:11 +02:00
isdn isdn: hfcpci: check the return value of dma_set_mask() in setup_hw() 2022-03-16 14:15:57 +01:00
leds leds: trigger: audio: Add an activate callback to ensure the initial brightness is set 2021-09-15 09:50:36 +02:00
lightnvm lightnvm: disable the subsystem 2022-05-09 09:04:56 +02:00
macintosh
mailbox mailbox: imx: fix wakeup failure from freeze mode 2022-04-08 14:40:41 +02:00
mcb mcb: fix error handling in mcb_alloc_bus() 2021-09-30 10:11:00 +02:00
md dm: interlock pending dm_io and dm_wait_for_bios_completion 2022-05-12 12:25:45 +02:00
media media: vim2m: initialize the media device earlier 2022-05-30 09:33:23 +02:00
memory memory: renesas-rpc-if: Fix HF/OSPI data transfer in Manual Mode 2022-05-09 09:05:02 +02:00
memstick memstick: jmb38x_ms: use appropriate free function in jmb38x_ms_alloc_host() 2021-11-18 14:04:07 +01:00
message
mfd mfd: asic3: Add missing iounmap() on error asic3_mfd_probe 2022-04-08 14:40:23 +02:00
misc kgdbts: fix return value of __setup handler 2022-04-08 14:40:28 +02:00
mmc mmc: rtsx: add 74 Clocks in power on flow 2022-05-12 12:25:46 +02:00
most most: fix control-message timeouts 2021-11-18 14:03:51 +01:00
mtd mtd: rawnand: Fix return value check of wait_for_completion_timeout 2022-05-09 09:05:02 +02:00
mux
net lib/crypto: blake2s: move hmac construction into wireguard 2022-05-30 09:33:26 +02:00
nfc nfc: nfcmrvl: main: reorder destructive operations in nfcmrvl_nci_unregister_dev to avoid bugs 2022-05-12 12:25:36 +02:00
ntb ntb: intel: fix port config status offset for SPR 2022-03-08 19:09:32 +01:00
nubus
nvdimm nvdimm/region: Fix default alignment for small regions 2022-04-08 14:40:26 +02:00
nvme nvme-multipath: fix hang when disk goes live over reconnect 2022-05-25 09:17:53 +02:00
nvmem nvmem: core: set size for sysfs bin file 2022-01-27 10:54:22 +01:00
of of: base: Improve argument length mismatch error 2022-01-27 10:54:28 +01:00
opp opp: Fix return in _opp_add_static_v2() 2021-11-18 14:04:22 +01:00
oprofile
parisc parisc: Fix CPU affinity for Lasi, WAX and Dino chips 2022-04-13 21:01:03 +02:00
parport parport: remove non-zero check on count 2021-09-18 13:40:34 +02:00
pci PCI/PM: Avoid putting Elo i2 PCIe Ports in D3cold 2022-05-25 09:17:55 +02:00
pcmcia pcmcia: fix setting of kthread task states 2022-01-27 10:54:03 +01:00
perf arm_pmu: Validate single/group leader events 2022-04-27 13:53:55 +02:00
phy phy: ti: Add missing pm_runtime_disable() in serdes_am654_probe 2022-05-09 09:05:01 +02:00
pinctrl pinctrl: pinctrl-aspeed-g6: remove FWQSPID group in pinctrl 2022-05-25 09:17:56 +02:00
platform platform/chrome: cros_ec_debugfs: detach log reader wq from devm 2022-05-25 09:17:54 +02:00
pnp
power power: supply: axp288-charger: Set Vhold to 4.4V 2022-04-13 21:00:57 +02:00
powercap
pps
ps3
ptp ptp: replace snprintf with sysfs_emit 2022-04-13 21:00:55 +02:00
pwm pwm: lpc18xx-sct: Initialize driver data and hardware before pwmchip_add() 2022-04-08 14:40:23 +02:00
rapidio
ras
regulator regulator: wm8994: Add an off-on delay for WM8994 variant 2022-04-20 09:23:22 +02:00
remoteproc remoteproc: qcom_q6v5_mss: Fix some leaks in q6v5_alloc_memory_region 2022-04-08 14:40:26 +02:00
reset reset: tegra-bpmp: Restore Handle errors in BPMP response 2022-04-27 13:53:52 +02:00
rpmsg rpmsg: char: Fix race between the release of rpmsg_eptdev and cdev 2022-02-01 17:25:43 +01:00
rtc rtc: mc146818-lib: Fix the AltCentury for AMD platforms 2022-05-25 09:17:54 +02:00
s390 s390/lcs: fix variable dereferenced before check 2022-05-18 10:23:44 +02:00
sbus
scsi scsi: qla2xxx: Fix missed DMA unmap for aborted commands 2022-05-25 09:18:00 +02:00
sfi
sh maple: fix wrong return value of maple_bus_init(). 2021-11-26 10:39:12 +01:00
siox
slimbus slimbus: qcom: Fix IRQ check in qcom_slim_probe 2022-05-18 10:23:47 +02:00
soc soc: ti: wkup_m3_ipc: Fix IRQ check in wkup_m3_ipc_probe 2022-04-08 14:40:07 +02:00
soundwire soundwire: intel: fix wrong register name in intel_shim_wake 2022-04-08 14:40:24 +02:00
spi spi: atmel-quadspi: Fix the buswidth adjustment between spi-mem and controller 2022-04-27 13:53:57 +02:00
spmi
ssb ssb: Fix error return code in ssb_bus_scan() 2021-07-14 16:56:21 +02:00
staging staging: rtl8723bs: prevent ->Ssid overflow in rtw_wx_set_scan() 2022-05-30 09:33:22 +02:00
target scsi: target: tcmu: Fix possible page UAF 2022-04-20 09:23:21 +02:00
tc
tee optee: use driver internal tee_context for some rpc 2022-03-02 11:42:47 +01:00
thermal thermal: int340x: Fix attr.show callback prototype 2022-05-09 09:05:07 +02:00
thunderbolt thunderbolt: Runtime PM activate both ends of the device link 2022-01-27 10:54:14 +01:00
tty serial: 8250_mtk: Fix register address for XON/XOFF character 2022-05-18 10:23:47 +02:00
uio
usb usb: gadget: fix race when gadget driver register via ioctl 2022-05-25 09:17:51 +02:00
vdpa vdpa/mlx5: should verify CTRL_VQ feature exists for MQ 2022-04-08 14:39:47 +02:00
vfio amba: Make the remove callback return void 2022-04-08 14:40:02 +02:00
vhost Fix double fget() in vhost_net_set_backend() 2022-05-25 09:17:55 +02:00
video video: fbdev: udlfb: properly check endpoint type 2022-05-09 09:05:00 +02:00
virt
virtio virtio: acknowledge all features before access 2022-03-16 14:16:02 +01:00
visorbus visorbus: fix error return code in visorchipset_init() 2021-07-14 16:56:41 +02:00
vlynq
vme
w1 w1: w1_therm: fixes w1_seq for ds28ea00 sensors 2022-04-13 21:01:01 +02:00
watchdog watchdog: rti-wdt: Add missing pm_runtime_disable() in probe function 2022-04-08 14:40:41 +02:00
xen xen/gnttab: fix gnttab_end_foreign_access() without page specified 2022-03-11 12:11:54 +01:00
zorro
Kconfig
Makefile