From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21D69C25B08 for ; Fri, 12 Aug 2022 21:04:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235030AbiHLVEr (ORCPT ); Fri, 12 Aug 2022 17:04:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234295AbiHLVEn (ORCPT ); Fri, 12 Aug 2022 17:04:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D716CB440B; Fri, 12 Aug 2022 14:04:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 63FD8B82440; Fri, 12 Aug 2022 21:04:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE55AC433C1; Fri, 12 Aug 2022 21:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660338280; bh=Wu/Fe5PtFXEUQP9G8z5TOGhYqD7CJDN7ROGX/QlPWBw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=U+kryXSh74RjZMPWvB3mUiBaLIVY/1D5u6APiJeXByTIAN51gN0QIpW/1/y5++8yw pHycLKgNWYgeqApN9FUOBvntQFzEIrllqqRUP+WGshYtAjFBNej4psO0XYWR7gSGAS oABaJcZYw+lGRznhvglB4sUIUUGZXanx/jhmGKoC3zUyhghYhCCoFs7X49f6RzjiHP 5X4JPHdzR7TrLucdMrU6fwVRLBOTCqV2se4waPw7addnlYcgT1Zw6bQys4yFwAzUPj hzKqX/B98vYXdmlMhsFsUdsOAgxfai0wAGZDUeJDwRtgelJzvT8afVzANJBkcWN3s5 xuf9A/GzrSQfg== Date: Fri, 12 Aug 2022 14:04:39 -0700 From: Jakub Kicinski To: syzbot Cc: davem@davemloft.net, edumazet@google.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] memory leak in netlink_policy_dump_add_policy Message-ID: <20220812140439.6bb2bb17@kernel.org> In-Reply-To: <0000000000003fcafc05e60e466e@google.com> References: <0000000000003fcafc05e60e466e@google.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/639sy1KJ9WxF2xFSvzLooDv" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --MP_/639sy1KJ9WxF2xFSvzLooDv Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline On Fri, 12 Aug 2022 10:04:26 -0700 syzbot wrote: > Hello, > > syzbot found the following issue on: > > HEAD commit: 4e23eeebb2e5 Merge tag 'bitmap-6.0-rc1' of https://github... > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=165f4f6a080000 > kernel config: https://syzkaller.appspot.com/x/.config?x=3a433c7a2539f51c > dashboard link: https://syzkaller.appspot.com/bug?extid=dc54d9ba8153b216cae0 > compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1443be71080000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11e5918e080000 > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+dc54d9ba8153b216cae0@syzkaller.appspotmail.com Let's see if attaching a patch works... #syz test --MP_/639sy1KJ9WxF2xFSvzLooDv Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-net-genl-fix-error-path-memory-leak-in-policy-dumpin.patch >From 7b3f410d5c49568deffcc8ee9881a7d3de730699 Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Fri, 12 Aug 2022 13:56:48 -0700 Subject: [--remember tree name--] net: genl: fix error path memory leak in policy dumping If construction of the array of policies fails when recording non-first policy we need to unwind. Reported-by: syzbot+dc54d9ba8153b216cae0@syzkaller.appspotmail.com Fixes: 50a896cf2d6f ("genetlink: properly support per-op policy dumping") Signed-off-by: Jakub Kicinski --- net/netlink/genetlink.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index 1afca2a6c2ac..57010927e20a 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -1174,13 +1174,17 @@ static int ctrl_dumppolicy_start(struct netlink_callback *cb) op.policy, op.maxattr); if (err) - return err; + goto err_free_state; } } if (!ctx->state) return -ENODATA; return 0; + +err_free_state: + netlink_policy_dump_free(ctx->state); + return err; } static void *ctrl_dumppolicy_prep(struct sk_buff *skb, -- 2.37.1 --MP_/639sy1KJ9WxF2xFSvzLooDv--