From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C84F32C21E8 for ; Mon, 24 Aug 2026 04:24:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787545453; cv=none; b=SdbFZrABGoLlPePKZc3W1CZPZn0op05/YNGCKeGIdUm7PoYgduI4G/f5fOb4qjculLsu/V8Kg43AgVWKFOD82C8POM1mGvmbECVKLqybEEZ3UiKMXtOwjVreA7RYVM4rf/hpMFLgCAepPjlpojVfMY/2fIJCYdf7CbuhV5s3u7I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787545453; c=relaxed/simple; bh=V+65gZNol3eMSEfsGahqGg+kYaOCqN1HKp5IV706/j0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Uki7MfIRzDhfR1fzA4p/CLynbhCpe4TATD/KUzPt/32CRKpeCC0blZl1UqXLvVZDUgFeF++np13EMas+6w3KiIis6uZ6vhwMt/bGEdJeJffHH3bA9P8DYEPf7mq5owwwuly7IfCCrVL80BNKnX79usjjURgDvKSTy/4BnpjbAUA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QuJh/yHa; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QuJh/yHa" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-3900e39d935so2999852a91.0 for ; Sun, 23 Aug 2026 21:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787545451; x=1788150251; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=bqNiZdWXV7bYYqGPKkQOy+Ipc3gwKbWL87ZMdy1MYWI=; b=QuJh/yHa1WUKY7LlxElB6ykGwYaH0SAe6HJw0UBYkPe/fqvlgE/7ru4UsmbBF6PX3F 33dkSEvwnxMVG7GivMCvVG2aucJSPbDgBu1C0WqbfDxsJPHpPH0T+rq/YmZGmWIgWyrM KjEriQO23TmNxHum7Ni98UaOEI9GsERNxMzOT5YrgbrVu3U7Stc26emDWosD7ejYxR1l aqxxQN3I5j1QgMEbRio84y+/4ylCZYZrtJb7UwwLvjuSpvf/1VLJJ2ft/siVScYJ3gQt 4IZAWtdQBRpQ9KpIeNm+Qcu/2nF2Yuorahh8f2aHWOCDDQuYP4ZaeSOmTSANgEjDlFZT t+dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787545451; x=1788150251; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bqNiZdWXV7bYYqGPKkQOy+Ipc3gwKbWL87ZMdy1MYWI=; b=MoK8YdVMBFWq6XT1asDCyRkHEjnaZxBuzwwcZojqRLXLSmNVz862Z6e5uExzIgnKbc 7RHdSDtfJXjQEQpwB/0he7XawROo1YVpjFxXhVuDiI4Bfdbukbj20O3rTxv32QCgjLoU 1sBtWkh+bZd4xdhbK/Te5IiZD1/Jv8MiP2vtnhClRkHQwglrSwSsRPOj9ukuoS988sz9 xQkjwazFEQCWuSa48NsYPHJH55qwZAOtJB7aDHom/zYbhuyUdCkTkFOHtHyJBtPS9jrB GQzzo7gATtf1NigJmYGT6dk9h33UpM22PV1WpjCYRL/eUY5xrhvwvHMMIt9pGRJ3YmsU KcUQ== X-Forwarded-Encrypted: i=1; AHgh+RpObjt7k3X+WovMXq7/pECzeGn7X25uD9xqA3BN73wtuY7a8PGuim/5UUMy9qfa5KXZWWXFrcc22sXrWhM=@vger.kernel.org X-Gm-Message-State: AFuF++lpXrSYaX4UFJ8/Jpu8eJ3fGd4G7FEKUxYbe6iUhrbUujtzeSD7 dv0yz5ORbsbFD5qAlkZRrAZSFQoWbcNun6G1thZG6Kp59Z252ix2N1t9 X-Gm-Gg: AR+sD118VlO8R5ZpgYjQUOQb6QNIK60nHxD6g849mUVhmUsFYog3RG1G6lYBCQzrLwR gRcYa8eL90nwqtzM+OesaqtW1gRsWylslCMwMqvz6txF7N4KwWj4fewxoXS+v86c1kvPYud+B5l aHKjSc6BMFo6ml0DY6p0sETRGsGQqea6+/sHSd/zR8VoHrP7n9V7Goes1v+T5Q6mJ4gIoZSBCCO gM3mYZyCRBn64zvVhgwOu3BhsAJp58wwDYG9f0nkLazFC4v/r7v6R2PNelWDZbzSgQMQlFgdlLg 4G3IfEU92jsi2sdxHErxfbhNwlkyTt7hXtfNbAQYss9rNQsYu1XeiTioclk4qlvbEVOl9OjpGXC GiPt+54YQo3XBX4CQxLbIOIDYSLE/mJBPgTnc6nxs8wBOQLkbIvkDY2yu2OKxWMt8jsmLJKopGD Ev5gIwLlFfvitWlmK5uQH0yV6o38fqB0DlTjfMll8qYX3RpavDEcHbzxyssvPeXH9SHkeaIbjQ X-Received: by 2002:a17:90b:3a8d:b0:395:4de0:b78f with SMTP id 98e67ed59e1d1-395dee528b7mr24857428a91.1.1787545450669; Sun, 23 Aug 2026 21:24:10 -0700 (PDT) Received: from ancienth-X870E-Nova-WiFi ([125.186.72.2]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-395e4968623sm8225732a91.4.2026.08.23.21.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2026 21:24:10 -0700 (PDT) From: Daehyeon Ko <4ncienth@gmail.com> To: Christian Brauner Cc: Al Viro , NeilBrown , Manfred Spraul , Andrew Morton , Jan Kara , linux-kernel@vger.kernel.org Subject: [PATCH] ipc/mqueue: release notification resources during inode eviction Date: Mon, 24 Aug 2026 13:23:59 +0900 Message-ID: <20260824042359.925145-1-4ncienth@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit mqueue_flush_file() removes an mq_notify() registration only when the closing task belongs to the thread group stored in notify_owner. A task in a separate thread group created with CLONE_FILES can register SIGEV_THREAD notification and exit without closing the shared file table. If another thread group then unlinks and last-closes the queue, ->flush() skips the registration and inode eviction loses the only pointers to its resources. The orphaned registration permanently retains the notification skb, its netlink socket, a pid reference and a user namespace reference. An unprivileged process can repeat the sequence with new queues and sockets. No inode users remain during eviction. Remove any stale registration there after dropping info->lock, since netlink_sendskb() may release the final socket reference. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Daehyeon Ko <4ncienth@gmail.com> --- A reproducer and regression selftest are available on request. Tested on x86_64 KASAN at the stated base. The unpatched oracle reproduced 3/3 and the patched oracle passed 3/3, with no KASAN report, WARNING splat, Oops or panic. ipc/mqueue.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ipc/mqueue.c b/ipc/mqueue.c index d1dd36a651b0..d1a1965c9811 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -528,6 +528,13 @@ static void mqueue_evict_inode(struct inode *inode) list_add_tail(&msg->m_list, &tmp_msg); kfree(info->node_cache); spin_unlock(&info->lock); + /* + * A shared file table can let the notification owner exit without + * running ->flush(). No users of the inode remain during eviction, so + * tear down any stale notification after dropping info->lock because + * netlink_sendskb() may release the final socket reference. + */ + remove_notification(info); list_for_each_entry_safe(msg, nmsg, &tmp_msg, m_list) { list_del(&msg->m_list); base-commit: 4352b8aee98005853aa63f57d6377282de17a33f -- 2.54.0