All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFT PATCH] isdn: capi: Add check for controller count in detach_capi_ctr()
@ 2022-07-01 23:50 Soumya Negi
  2022-07-02  8:14 ` Pavel Skripkin
  0 siblings, 1 reply; 5+ messages in thread
From: Soumya Negi @ 2022-07-01 23:50 UTC (permalink / raw)
  To: Shuah Khan, Pavel Skripkin; +Cc: linux-kernel-mentees

Fixes Syzbot bug:
https://syzkaller.appspot.com/bug?id=14f4820fbd379105a71fdee357b0759b90587a4e

This patch checks whether any ISDN devices are registered before unregistering
a CAPI controller(device). Without the check, the controller struct capi_str
results in out-of-bounds access bugs to other CAPI data strucures in
detach_capri_ctr() as seen in the bug report.

Reported-by: syzbot+9d567e08d3970bfd8271@syzkaller.appspotmail.com

Signed-off-by: Soumya Negi <soumya.negi97@gmail.com>
---
 drivers/isdn/capi/kcapi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
index 18de41a266eb..6175ff7ec749 100644
--- a/drivers/isdn/capi/kcapi.c
+++ b/drivers/isdn/capi/kcapi.c
@@ -563,6 +563,9 @@ int detach_capi_ctr(struct capi_ctr *ctr)
 
 	mutex_lock(&capi_controller_lock);
 
+	if (ncontrollers == 0)
+		goto unlock_out;
+
 	ctr_down(ctr, CAPI_CTR_DETACHED);
 
 	if (capi_controller[ctr->cnr - 1] != ctr) {
-- 
2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-07 19:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-01 23:50 [RFT PATCH] isdn: capi: Add check for controller count in detach_capi_ctr() Soumya Negi
2022-07-02  8:14 ` Pavel Skripkin
2022-07-02  9:37   ` Soumya Negi
2022-07-05  3:03     ` Soumya Negi
2022-07-07 19:51       ` Shuah Khan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.