ipc: limit next_id allocation to the valid ID range
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 ipc: limit next_id allocation to the valid ID range
From: Linpu Yu <[email protected]>
The checkpoint/restore sysctl path can request the next SysV IPC id through ids->next_id. ipc_idr_alloc() currently forwards that request to idr_alloc() with an open-ended upper bound.
If the valid tail of the SysV IPC id space is full, the allocation can spill beyond ipc_mni. The returned SysV IPC id still uses the normal index encoding, so later lookup and removal can target the wrong slot. This leaves the real IDR entry behind and breaks the IDR state for the object.
Prevent that by bounding the requested allocation to ipc_mni so the checkpoint/restore path fails once the valid range is exhausted.
--- ipc/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ipc/util.c +1 -1
@@ -253,7 +253,7 @@ static inline int ipc_idr_alloc(struct ipc_ids *ids, struct kern_ipc_perm *new) }else { new->seq =ipcid_to_seqx (next_id); idx =idr_alloc (&ids->ipcs_idr, new,ipcid_to_idx (next_id), -0 ,GFP_NOWAIT ); + ipc_mni,GFP_NOWAIT ); }if (idx >=0 ) new->id = (new->seq <<ipcmni_seq_shift ()) + idx;
Signature · 1 line
2.43.0