Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3119066pxm; Mon, 28 Feb 2022 12:25:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnqvp2SAGzlgcNJj3kAuPjk08sydfiCvIkObPGKPMT5gSQ+OWOj4nY3sX2nP0T2iYtP2Mz X-Received: by 2002:a65:53cb:0:b0:343:8e85:2d81 with SMTP id z11-20020a6553cb000000b003438e852d81mr18970344pgr.44.1646079933415; Mon, 28 Feb 2022 12:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646079933; cv=none; d=google.com; s=arc-20160816; b=qRi/l1/qUxGMpuDJbZYMiLVRlUW9wWxMrAWQmfqdcj7TwtcB6YSIviDYy2j8AiUhYx nd/uD+0vysJfKTSr4vSw7FQWg2rJ3sRHpc4/iBhsgu5BRI2CzCllrFomnfJBaqf7Z+3l 84lLac5LyeQuCDMCbQmIBsh7WA08H0n0ViwZOAj6yKR83FD4AKo7jRMAPqRU5mioudYj 25RYLT2ENxDymh9REYgQcxR6aELbF/Xo1AJA/QTHHR8quBccj7djfAZ3AQxIMZT0O5tt LIOqcVS+cvOP/CfzjGKzy4n+acGiFjOwM76ubEmhoANPgZ+EIB/HS2W19jBY+w+kdVaa EKSA== 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=BZRXL/V0+/Nig5NTuukeL5GkVDocVyjMATqD4d0EtBc=; b=WwiRFjk2wahFsqQYIy7E8156Tx3XcESa3yvNHY8t36Yn12FPVUIq77uKAmIbFxxU4W 4VUfqYQ1FENgNekqyMKjjoVytXC+69Pc8of+ntxPgfh1t4xHC5M6tS3056VMqxQ7Tkyj d2iQ4CiFxxwKNay/nsqeATJjnogEsHdbtgDT0RKsG1dljgPfpSK/WJ4KjcoPEKc7dGyE EUVbraVj9QxdFJfJnHad+C+YoP9wJ50yiWKHgymAAzZwLI4Ez4zIKxiod5xLHgR2jqBT aly2qGzjWr1zv/CLHO6T3rxc+30h/GhnK2ylv8n0RHm3yngNjs58gQZ1x/IwRlPz07Fd VxZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SDOIvfw9; 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 p8-20020a056a000a0800b004f2a6ab0ce4si11689952pfh.5.2022.02.28.12.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:25:33 -0800 (PST) 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=SDOIvfw9; 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 180881E5A5F; Mon, 28 Feb 2022 11:43:57 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238119AbiB1Ref (ORCPT + 99 others); Mon, 28 Feb 2022 12:34:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238137AbiB1Rcy (ORCPT ); Mon, 28 Feb 2022 12:32:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 087B48CD8E; Mon, 28 Feb 2022 09:29:30 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 7A1FD61464; Mon, 28 Feb 2022 17:29:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BF39C340E7; Mon, 28 Feb 2022 17:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069361; bh=917T7g5NADCLUB+jfAC4t5c2Tgf/uZE24UZy1cRKwXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SDOIvfw9I+TKnJKiHY0zBYpjsihrlWaqFTZrk+a5pQLV8DhbEV/nwqTyxnNHnyLMe AQ9uDuQYO3YfnyqOgGpzGBQZ2K883DkXqFZkzvdELRlT6q7jZ9nV2n1nFfpRup2Frg 4xeystAAwqfQeGkvAYkzl/mI6bSSfTJL7Fmd2zJI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , "Steven Rostedt (Google)" Subject: [PATCH 4.19 27/34] tracefs: Set the group ownership in apply_options() not parse_options() Date: Mon, 28 Feb 2022 18:24:33 +0100 Message-Id: <20220228172210.660509352@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172207.090703467@linuxfoundation.org> References: <20220228172207.090703467@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.4 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=unavailable 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: Steven Rostedt (Google) commit 851e99ebeec3f4a672bb5010cf1ece095acee447 upstream. Al Viro brought it to my attention that the dentries may not be filled when the parse_options() is called, causing the call to set_gid() to possibly crash. It should only be called if parse_options() succeeds totally anyway. He suggested the logical place to do the update is in apply_options(). Link: https://lore.kernel.org/all/20220225165219.737025658@goodmis.org/ Link: https://lkml.kernel.org/r/20220225153426.1c4cab6b@gandalf.local.home Cc: stable@vger.kernel.org Acked-by: Al Viro Reported-by: Al Viro Fixes: 48b27b6b5191 ("tracefs: Set all files to the same group ownership as the mount option") Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- fs/tracefs/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -265,7 +265,6 @@ static int tracefs_parse_options(char *d if (!gid_valid(gid)) return -EINVAL; opts->gid = gid; - set_gid(tracefs_mount->mnt_root, gid); break; case Opt_mode: if (match_octal(&args[0], &option)) @@ -292,7 +291,9 @@ static int tracefs_apply_options(struct inode->i_mode |= opts->mode; inode->i_uid = opts->uid; - inode->i_gid = opts->gid; + + /* Set all the group ids to the mount option */ + set_gid(sb->s_root, opts->gid); return 0; }