watch_queue: fix IOC_WATCH_QUEUE_SET_SIZE alloc error paths
PATCH v2 1/1 watch_queue: fix IOC_WATCH_QUEUE_SET_SIZE alloc error paths
The watch_queue_set_size() allocation error paths return the ret value set via the prior pipe_resize_ring() call, which will always be zero.
As a result, IOC_WATCH_QUEUE_SET_SIZE callers such as "keyctl watch" fail to detect kernel wqueue->notes allocation failures and proceed to KEYCTL_WATCH_KEY, with any notifications subsequently lost.
---
Version 2:
- document "keyctl watch" behaviour with this bug
kernel/watch_queue.c | 1 + 1 file changed, 1 insertion(+)
kernel/watch_queue.c +1 -0
@@ -273,6 +273,7 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)if (ret <0 ) goto error; + ret = -ENOMEM ; pages =kcalloc (sizeof (struct page *), nr_pages,GFP_KERNEL );if (!pages) goto error;
Signature · 1 line
2.35.3
Christian Brauner
maintainerFrom: Christian Brauner (Microsoft) <[email protected]>
Quoted 8 lines · David Disseldorp
The
watch_queue_set_size()allocation error paths return the ret value set via the priorpipe_resize_ring()call, which will always be zero.As a result,
IOC_WATCH_QUEUE_SET_SIZEcallers such as "keyctl watch" fail to detect kernelwqueue->notesallocation failures and proceed toKEYCTL_WATCH_KEY, with any notifications subsequently lost.[...]
Unless someone got to it before me, I've now picked this up:
[1/1] watch_queue: fix IOC_WATCH_QUEUE_SET_SIZE alloc error paths
commit: 03e1d60e177eedbd302b77af4ea5e21b5a7ade31
Thanks!
Christian