Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp980073pxb; Wed, 6 Apr 2022 05:57:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbYSDFU/XYoBrgYq4/J/IRs1pw82ZI3d4peDDh3uZk66Rh4eNe+Wk5noKOeQSu/EuaFGGl X-Received: by 2002:a63:dd13:0:b0:382:59e3:180 with SMTP id t19-20020a63dd13000000b0038259e30180mr7057200pgg.497.1649249820805; Wed, 06 Apr 2022 05:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649249820; cv=none; d=google.com; s=arc-20160816; b=oqNM8g5KbLOE66Uok5QKy+WCLD5AjRtoBtMjflesDm+tZn91gcAPcsUrOT87TiX34+ Zt+yOTIuaCbRZo17GyWtPJq0CQv7E+o/bixwNWNh9ZD2FwmzXHzN2Xlh+tR14XRkK362 47At5kdwvdZPhj2vWkD2RaBKbJOfJ9RRNaL/PkxjHEQtMUZC7xYXTc/6lQ1Y5iZV2oRi +oGAYsLQNhzEYzCVZb/Nn0Le5HHxg7oSE0jz27NdqaUYNqL8Diil0Z9O2Q1EcHnnN6Mb 6aWFjYjKbpD09eObgp7lR/YLrhk6Q62NHVq6QevCDMghIutbqb4z96gRR40fT4tTzA08 oYDw== 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=gVKpmCEk4YbTsg0oKP47QdSUCKSvunPvSnVRoTH2fz4=; b=oetIQNGnMIxKwyUci4bPoOxubIiEdfBabfkVW/MQMbm1e112vXK9ahu95Pxa2UAuRU qzvOpa8BqvBjytI0iwYP6+TzXdyxHtqp/xnZCi/q0XYi4r3WT2VkEmeVD1HMdDNZXDoA fbcoQ9ht0Geju8oQsDUG45h9RmvV0s993vHHrpbgGXAzX5vlelcCz+yCpIAL8rPoQSFG jsT/fysoHFVuodQgL2R2puNak9DFcssj5htA05209DnMi9OubO++bR+vPxArIRdAvpjF qS1E5l2QpcvDwZqQxAYXrT07/VNiOQcg4f+022/CM01pPPrHYDGdULqQQh/AnfD7vdR1 c2Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Koq6UJ5k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b16-20020a170902b61000b00153b2d16475si14187504pls.125.2022.04.06.05.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:57:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Koq6UJ5k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 54654561C4F; Wed, 6 Apr 2022 03:06:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236042AbiDEWLa (ORCPT + 99 others); Tue, 5 Apr 2022 18:11:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356350AbiDEKXi (ORCPT ); Tue, 5 Apr 2022 06:23:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58E97BB92B; Tue, 5 Apr 2022 03:08: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 D3F01B81C89; Tue, 5 Apr 2022 10:08:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46632C385A1; Tue, 5 Apr 2022 10:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649153290; bh=MrLe2UYgNO94N6ATEUfHk2MCCetEx4kGlyIszj4eOj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Koq6UJ5kI9Y81XHFydiX3AZMUD9OhaWpybvah3B55SgQgsHUe/AVzjl5Zo6OgcOXu hU1r3mmeoPrTf82ZEcnIWVG99R7KVsirIMbctmYpKggPW9kuhAks5r7OpGBAR16rZo /LTLtworcOZH+CZQcuPPgxX1UwAKZvIWD+tWnFVU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells , Sasha Levin , syzbot+6e2de48f06cdb2884bfc@syzkaller.appspotmail.com Subject: [PATCH 5.10 171/599] watch_queue: Actually free the watch Date: Tue, 5 Apr 2022 09:27:45 +0200 Message-Id: <20220405070303.930876837@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070258.802373272@linuxfoundation.org> References: <20220405070258.802373272@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: David Howells [ Upstream commit 3d8dcf278b1ee1eff1e90be848fa2237db4c07a7 ] free_watch() does everything barring actually freeing the watch object. Fix this by adding the missing kfree. kmemleak produces a report something like the following. Note that as an address can be seen in the first word, the watch would appear to have gone through call_rcu(). BUG: memory leak unreferenced object 0xffff88810ce4a200 (size 96): comm "syz-executor352", pid 3605, jiffies 4294947473 (age 13.720s) hex dump (first 32 bytes): e0 82 48 0d 81 88 ff ff 00 00 00 00 00 00 00 00 ..H............. 80 a2 e4 0c 81 88 ff ff 00 00 00 00 00 00 00 00 ................ backtrace: [] kmalloc include/linux/slab.h:581 [inline] [] kzalloc include/linux/slab.h:714 [inline] [] keyctl_watch_key+0xec/0x2e0 security/keys/keyctl.c:1800 [] __do_sys_keyctl+0x3c4/0x490 security/keys/keyctl.c:2016 [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] [] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 [] entry_SYSCALL_64_after_hwframe+0x44/0xae Fixes: c73be61cede5 ("pipe: Add general notification queue support") Reported-and-tested-by: syzbot+6e2de48f06cdb2884bfc@syzkaller.appspotmail.com Signed-off-by: David Howells Signed-off-by: Sasha Levin --- kernel/watch_queue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c index 45a8eb90e5fc..a662abccf52c 100644 --- a/kernel/watch_queue.c +++ b/kernel/watch_queue.c @@ -398,6 +398,7 @@ static void free_watch(struct rcu_head *rcu) put_watch_queue(rcu_access_pointer(watch->queue)); atomic_dec(&watch->cred->user->nr_watches); put_cred(watch->cred); + kfree(watch); } static void __put_watch(struct kref *kref) -- 2.34.1