[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iKxC5KiqZ-NS7qkgX-6qcUYBJVsdbesXwrAOKTh=oJyZg@mail.gmail.com>
Date: Wed, 24 Jan 2024 11:42:54 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: kovalev@...linux.org
Cc: pablo@...filter.org, laforge@...monks.org, davem@...emloft.net,
kuba@...nel.org, pabeni@...hat.com, osmocom-net-gprs@...ts.osmocom.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org, nickel@...linux.org,
oficerovas@...linux.org, dutyrok@...linux.org
Subject: Re: [PATCH 1/1] gtp: fix use-after-free and null-ptr-deref in gtp_genl_dump_pdp()
On Wed, Jan 24, 2024 at 11:14 AM <kovalev@...linux.org> wrote:
>
> From: Vasiliy Kovalev <kovalev@...linux.org>
>
> After unloading the module, an instance continues to exist that accesses
> outdated memory addresses.
>
> To prevent this, the dump_pdp_en flag has been added, which blocks the
> dump of pdp contexts by a false value. And only after these checks can
> the net_generic() function be called.
>
> These errors were found using the syzkaller program:
>
> Syzkaller hit 'general protection fault in gtp_genl_dump_pdp' bug.
> gtp: GTP module loaded (pdp ctx size 104 bytes)
> gtp: GTP module unloaded
> general protection fault, probably for non-canonical address
> 0xdffffc0000000001:0000 [#1] SMP KASAN NOPTI
> KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
> CPU: 0 PID: 2782 Comm: syz-executor139 Not tainted 5.10.200-std-def-alt1 #1
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-alt1
> RIP: 0010:gtp_genl_dump_pdp+0x1b1/0x790 [gtp]
> ...
> Call Trace:
> genl_lock_dumpit+0x6b/0xa0 net/netlink/genetlink.c:623
> netlink_dump+0x575/0xc70 net/netlink/af_netlink.c:2271
> __netlink_dump_start+0x64e/0x910 net/netlink/af_netlink.c:2376
> genl_family_rcv_msg_dumpit+0x2b8/0x310 net/netlink/genetlink.c:686
> genl_family_rcv_msg net/netlink/genetlink.c:780 [inline]
> genl_rcv_msg+0x450/0x5a0 net/netlink/genetlink.c:800
> netlink_rcv_skb+0x150/0x440 net/netlink/af_netlink.c:2497
> genl_rcv+0x29/0x40 net/netlink/genetlink.c:811
> netlink_unicast_kernel net/netlink/af_netlink.c:1322 [inline]
> netlink_unicast+0x54e/0x800 net/netlink/af_netlink.c:1348
> netlink_sendmsg+0x914/0xe00 net/netlink/af_netlink.c:1916
> sock_sendmsg_nosec net/socket.c:651 [inline]
> __sock_sendmsg+0x159/0x190 net/socket.c:663
> ____sys_sendmsg+0x712/0x870 net/socket.c:2376
> ___sys_sendmsg+0xf8/0x170 net/socket.c:2430
> __sys_sendmsg+0xea/0x1b0 net/socket.c:2459
> do_syscall_64+0x33/0x40 arch/x86/entry/common.c:46
> entry_SYSCALL_64_after_hwframe+0x62/0xc7
> RIP: 0033:0x7f2ea16c2d49
>
> Fixes: 94a6d9fb88df ("gtp: fix wrong condition in gtp_genl_dump_pdp()")
> Signed-off-by: Vasiliy Kovalev <kovalev@...linux.org>
> ---
> drivers/net/gtp.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
> index 477b4d4f860bd3..3fc4639711cd83 100644
> --- a/drivers/net/gtp.c
> +++ b/drivers/net/gtp.c
> @@ -1675,6 +1675,8 @@ static int gtp_genl_get_pdp(struct sk_buff *skb, struct genl_info *info)
> return err;
> }
>
> +static bool dump_pdp_en;
> +
Hmm, it seems there is a missing try_module_get() somewhere...
__netlink_dump_start() does one, so perhaps we reach __netlink_dump_start()
with a NULL in control->module ?
Powered by blists - more mailing lists