Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1949024rwb; Fri, 7 Oct 2022 22:56:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6GFMlqP92XBcx1bVBtKz8OMHpA8St0S0O7mJrMWgcQ2EfFtW6bTjbpD9Ss9R+ZRfU5w/GB X-Received: by 2002:a05:6402:2947:b0:451:32a:2222 with SMTP id ed7-20020a056402294700b00451032a2222mr7724314edb.376.1665208578569; Fri, 07 Oct 2022 22:56:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665208578; cv=none; d=google.com; s=arc-20160816; b=fFOa3CBpXR1wWzwCDuMxqAhHq15+JAW6QrWTPnEMo4axKAzz+64KVnVrqXegCuoC87 7oh9GQKpRcF84hUmpMu0S/6YJ4PfLwDIATiGvRQx2NV8ZmM6Y13ep/cOpqlLcVjHEDFi J9FSJ4cFLEBZMC2k8tTN0JrJVP+SFuMkY/tyRS4UGs/CBT2Qoh88J9Sqzjf1LYJLiHbB a2VrsbQfd2VkPixSe5hhC4l2byIoGY3j0cUqmAFKS5LON97ENX3b1NQspbNCBFq9QVTD vdPbI4kBi28eVBx5aup0r/+l+oQOP/skRRAYT3JV9nGmV2olo+TPoxT0yuCG31KVgzkW UwRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fZyGhkN6v94uMjeLHHmigOUC4ezcyeNf8AWMq7EkQlo=; b=uRdI9826OeBQWPVcc0XnmxsO14sKGU9/2I7xBHTNbmyBV2MezsQjRXAJq90SPwMGHE xde9QOnXaVOS+sRgfLFxTp8fishZD6245HYoRmQxIqu9q688r5bSAaLjE+h/GCw2jIcS Kd286rxfNgPfxP6lxEfGUycCMJMqNDpQc2fwNYPt4lUj9W3A8X/6D2yBNc6Qj1yiXQUQ d5czVEfxrPHMFmdfiHnNVlV9uRJqXoHhhB4Gnf63E3hYeehW66R4/F3xipY+Jq1Z/e2s 9rTzWPKdtrvYFAclt8Gi3YQ55Jw3icL/KPp96OkS3zozrFNlMr9j+xRUSQYWinItruBO d/Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UUEjNDNC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020a50d7c6000000b004483a12fba9si3865557edj.210.2022.10.07.22.55.51; Fri, 07 Oct 2022 22:56:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UUEjNDNC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229630AbiJHFqS (ORCPT + 99 others); Sat, 8 Oct 2022 01:46:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbiJHFqP (ORCPT ); Sat, 8 Oct 2022 01:46:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E446676745 for ; Fri, 7 Oct 2022 22:46:14 -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 9DC7EB823A1 for ; Sat, 8 Oct 2022 05:46:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A74EDC433D6; Sat, 8 Oct 2022 05:46:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665207972; bh=nDg21FtewsQFxbiJ9Em2i5TbxM2QihLggVdu6PHLss0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UUEjNDNChNmdBb922klXuDpCzPSre6NtcXXP43X7CtkiX2JEHh12UxnJT2vV41moX 6ulxPqoAWUuJaP4ho3lS29H4F8QY/ofkRMlU8vLtjfFjLcwBFqOc4XVGglrMOmHjAo OU572UYpMKTXrKxIKADViEbXORhKsMTERS09ioAnoY/0qFlZXG0RofSb9ERisAWqUD dpdjlLevmuvvfC7w20FjFmmH71paut5GF5s6/5C9Iy/9fsyd8DLjmdt6ngaIbGiWuY k3YjmUvxLbhz/3hKt90CayfIZStDU7ibliLAGkCXSV3zgrBuSZ9CRy+6+Qep8QWR6Y ueo1XzS9Uh7Nw== Date: Sat, 8 Oct 2022 07:46:07 +0200 From: Christian Brauner To: Tejun Heo Cc: syzbot , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] general protection fault in kernfs_get_inode Message-ID: <20221008054607.fyqzd7oil2ulzf34@wittgenstein> References: <000000000000385cbf05ea3f1862@google.com> <00000000000028a44005ea40352b@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Fri, Oct 07, 2022 at 11:35:49AM -1000, Tejun Heo wrote: > (cc'ing Christian and quoting whole body) > > Christan, I can't repro it here but think what we need is sth like the > following. The problem is that cgroup_is_dead() check in the fork path isn't > enough as the perm check depends on cgrp->procs_file being available but > that is cleared while DYING before DEAD. So, depending on the timing, we can > end up trying to deref NULL pointer in may_write. > > diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c > index 8ad2c267ff471..603b7167450a1 100644 > --- a/kernel/cgroup/cgroup.c > +++ b/kernel/cgroup/cgroup.c > @@ -4934,6 +4934,10 @@ static int cgroup_may_write(const struct cgroup *cgrp, struct super_block *sb) > > lockdep_assert_held(&cgroup_mutex); > > + /*if @cgrp is being removed, procs_file may already be gone */ > + if (!cgrp->procs_file.kn) > + return -ENODEV; > + > inode = kernfs_get_inode(sb, cgrp->procs_file.kn); > if (!inode) > return -ENOMEM; Tejun, thanks for the Cc. Yep, that seems to be the correct analysis. I assume you're turning this into a proper patch, so: Reviewed-by: Christian Brauner (Microsoft)