From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C28B2566; Tue, 15 Jul 2025 13:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752585827; cv=none; b=LN5qm0WQeFTAphIXU/08GE/Sn/P9rxn4z4vd5Rw8ljVTYti/OOT7ahoturYMKqGrfR1p0oT31LrvqL0QOpH/Ut8kJUHi5y3U6y372LkqtEpShnvC7pkXaKkzkDtXJZi+HvIQv41qlOyNRPTcI8xxnZHXe4k75yN8FJx8bIomsRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752585827; c=relaxed/simple; bh=+ZOpCyhHPdIrD6Ef4ayvAlBu9iO5vo/fTW6xeJtiDNE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D6JsSRsVJrSUuUe8YqKwwQ2vhQHKrj47vIg6j3fbO8Uh74gOR4hTy/nUY9giXIRvQXPkdZAogVMFWBn397Yb35RuXE77ZNl68UP0/+YgSJYWxQ85SKPVtjXqKzIIJUVxo/FFK2KeBYd9pcfCntZxvxfRWs/RMG4Da3LiLNvljmE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UqlVgHRL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="UqlVgHRL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F50FC4CEE3; Tue, 15 Jul 2025 13:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1752585827; bh=+ZOpCyhHPdIrD6Ef4ayvAlBu9iO5vo/fTW6xeJtiDNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UqlVgHRLy08xQA0err5yVSW+HM8hgOQzorX/JVT1Jfdt8ffUaJJukKBiv4fmpZ9uK C46CZ4U1wMCFH3VAH4GZnZ55uPUyA/vV029o496AbRgMSltfeTCn7Z1OM086E6BZzM ba9IeP9oTorjMe21u/bXWtuS2k92TieeRTonr/Pk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kuniyuki Iwashima , Simon Horman , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 023/109] atm: clip: Fix memory leak of struct clip_vcc. Date: Tue, 15 Jul 2025 15:12:39 +0200 Message-ID: <20250715130759.808769641@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250715130758.864940641@linuxfoundation.org> References: <20250715130758.864940641@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kuniyuki Iwashima [ Upstream commit 62dba28275a9a3104d4e33595c7b3328d4032d8d ] ioctl(ATMARP_MKIP) allocates struct clip_vcc and set it to vcc->user_back. The code assumes that vcc_destroy_socket() passes NULL skb to vcc->push() when the socket is close()d, and then clip_push() frees clip_vcc. However, ioctl(ATMARPD_CTRL) sets NULL to vcc->push() in atm_init_atmarp(), resulting in memory leak. Let's serialise two ioctl() by lock_sock() and check vcc->push() in atm_init_atmarp() to prevent memleak. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Reviewed-by: Simon Horman Link: https://patch.msgid.link/20250704062416.1613927-3-kuniyu@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/atm/clip.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/atm/clip.c b/net/atm/clip.c index 8059b7d1fb931..14b485f725d0c 100644 --- a/net/atm/clip.c +++ b/net/atm/clip.c @@ -645,6 +645,9 @@ static struct atm_dev atmarpd_dev = { static int atm_init_atmarp(struct atm_vcc *vcc) { + if (vcc->push == clip_push) + return -EINVAL; + mutex_lock(&atmarpd_lock); if (atmarpd) { mutex_unlock(&atmarpd_lock); @@ -669,6 +672,7 @@ static int atm_init_atmarp(struct atm_vcc *vcc) static int clip_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { struct atm_vcc *vcc = ATM_SD(sock); + struct sock *sk = sock->sk; int err = 0; switch (cmd) { @@ -689,14 +693,18 @@ static int clip_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) err = clip_create(arg); break; case ATMARPD_CTRL: + lock_sock(sk); err = atm_init_atmarp(vcc); if (!err) { sock->state = SS_CONNECTED; __module_get(THIS_MODULE); } + release_sock(sk); break; case ATMARP_MKIP: + lock_sock(sk); err = clip_mkip(vcc, arg); + release_sock(sk); break; case ATMARP_SETENTRY: err = clip_setentry(vcc, (__force __be32)arg); -- 2.39.5