Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp977282pxb; Wed, 6 Apr 2022 05:51:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTKJJ52vQpSEze574pxyIAyQMNiZAn+fJyt+hfgB8ac/719og0nHDGJMhhz0fFhNwI5zI2 X-Received: by 2002:a63:a804:0:b0:398:e7d7:29ab with SMTP id o4-20020a63a804000000b00398e7d729abmr6861501pgf.138.1649249510648; Wed, 06 Apr 2022 05:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649249510; cv=none; d=google.com; s=arc-20160816; b=e6hAszRl3k9/Z3qwCHaOTDg+Y6oVCrJXWqlkjcshV/ZGw6a/R+dCydUdDvcQy5jrKx tF90fh04OPDtVCXAMfgp5sx8Ti86v3uw4A20M5sdja3+8GCU/vw97tjDN7jJ6I9N/FEQ 7g2RRbxEp0yTYEWWah2gNMMjh4rhRv52XAS92YPLSpPCwoiCboLcExJIVg1GSCeMLbLw 8WXCHdDw4PWl33eb4IlJdc1Q64fqCANJfTR8ZQeKxzP4BiXmAxbZqv7pjGd43Y/GoZuH YMJ5Ne3EqTNsiTPiiZ9810bc3aYWwW8N06P2Bvh3R6749SSwnECK+y0W+149jBwZbwh7 fQxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0aTgztzqM9zg/s7zIB1Eay/XY5eE7dTnCkRFDcPLEIk=; b=WrGuGsbug+UURdKymYxB+Jue0xCeau7dTIScGLAz2+Tibfsiro3NuZqRpjWhBaw+JF djSTT9LyT8gCoE1UVvSCX6HpOA/wo5Y/RRpQUiLX1ZAtmWfQgmxOMPTCNOVQYm/XVtR1 7beblCXzqqIlhlUii0CF5WXzv/QKkx2UEzi84NNkB3Z1o01ONu6VGuZ/6soyGcfxhksz qkjkKS0qDrOx2gV2s2R4bBgr8KySbBKoWHaixFbWBjzaVvpSRrhKUqS1NRhUgF+cSa09 lP6MMXpSeq7X2z36Sefy+Ju+TeeMOxpNSbzutUXKUKYEBb9c12Ym0wizBoC52EX2acY6 zeig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Vb8a/aUI"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g11-20020a65580b000000b003842921930bsi16425951pgr.808.2022.04.06.05.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:51:50 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Vb8a/aUI"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4DC6A419DA8; Wed, 6 Apr 2022 02:49:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1575846AbiDEXJ0 (ORCPT + 99 others); Tue, 5 Apr 2022 19:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354090AbiDEKLf (ORCPT ); Tue, 5 Apr 2022 06:11:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EE9B49245; Tue, 5 Apr 2022 02:57:13 -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 D2E1FB817D3; Tue, 5 Apr 2022 09:57:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35CFFC385A1; Tue, 5 Apr 2022 09:57:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152630; bh=GkMbuM0N3bx8zk89Q8KBknMKfuJoWp/romGhKcSfTfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vb8a/aUIJwZv5XdqafCXu11kyW1oY9nqHqr783vO2+U5T1L+VLKug7Hj0uPfPjNp9 hXPCe+2uiLH4gXit5YxXw9J6dMQtZxKpySIVZFQ50SrTdI8ppuU4mdgFeQex5Mr71k pYbrE+J4y2GtbCIORYFUtv9yv7NwT1FDeaidlITs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+25ea042ae28f3888727a@syzkaller.appspotmail.com, Eric Dumazet , David Howells , Jann Horn , Linus Torvalds Subject: [PATCH 5.15 846/913] watch_queue: Free the page array when watch_queue is dismantled Date: Tue, 5 Apr 2022 09:31:48 +0200 Message-Id: <20220405070405.188001686@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet commit b490207017ba237d97b735b2aa66dc241ccd18f5 upstream. Commit 7ea1a0124b6d ("watch_queue: Free the alloc bitmap when the watch_queue is torn down") took care of the bitmap, but not the page array. BUG: memory leak unreferenced object 0xffff88810d9bc140 (size 32): comm "syz-executor335", pid 3603, jiffies 4294946994 (age 12.840s) hex dump (first 32 bytes): 40 a7 40 04 00 ea ff ff 00 00 00 00 00 00 00 00 @.@............. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: kmalloc_array include/linux/slab.h:621 [inline] kcalloc include/linux/slab.h:652 [inline] watch_queue_set_size+0x12f/0x2e0 kernel/watch_queue.c:251 pipe_ioctl+0x82/0x140 fs/pipe.c:632 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl fs/ioctl.c:860 [inline] __x64_sys_ioctl+0xfc/0x140 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] Reported-by: syzbot+25ea042ae28f3888727a@syzkaller.appspotmail.com Fixes: c73be61cede5 ("pipe: Add general notification queue support") Signed-off-by: Eric Dumazet Signed-off-by: David Howells Cc: Jann Horn Link: https://lore.kernel.org/r/20220322004654.618274-1-eric.dumazet@gmail.com/ Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- kernel/watch_queue.c | 1 + 1 file changed, 1 insertion(+) --- a/kernel/watch_queue.c +++ b/kernel/watch_queue.c @@ -373,6 +373,7 @@ static void __put_watch_queue(struct kre for (i = 0; i < wqueue->nr_pages; i++) __free_page(wqueue->notes[i]); + kfree(wqueue->notes); bitmap_free(wqueue->notes_bitmap); wfilter = rcu_access_pointer(wqueue->filter);