Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2425827rwd; Wed, 17 May 2023 09:41:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7OXWQuppgFbfQOoNqMZ7xh9KRYfR+O+UGpo5yN0/bERxzNY7xnFfcfC4F8v9Z0Zbu21pUL X-Received: by 2002:a05:6a20:6a27:b0:101:64b0:e694 with SMTP id p39-20020a056a206a2700b0010164b0e694mr37845825pzk.16.1684341689700; Wed, 17 May 2023 09:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684341689; cv=none; d=google.com; s=arc-20160816; b=CIdSQNXZL3x//gVSDUO9mvHvduxXaikkRsiudq19JMYyhANl1CCqPlGtVAoMYPXnk4 ZbCaUYW5Q01uwNilV/GOnK8o1TxGRzOOFmGtSApbpsxq20sNjuNZDncKdYXp2CCd7sBU MtOmAdc7wPxDqtEoaVeH4jodkN2VCAgRcPFldCmVa7nUjleML0XRmYR40SNyX6Vz96uh 3uB4aNVsDghcZZ5OjpBAIhfVRAceK0xf/49y70lvftPmIG/9/0ruLwssDAy0F+sPV05N IMvITWyAZJ0RhTOxYO9R0KrLz10nPKGn4j5WIOupL0xaoa7Sk0Y03NArjKmfXivXvufv e4vg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=V6ve4mbMhTVqlY5aA6uqD1clj3nrbbL1ZD0I7vrJbmc=; b=y0zkzw4BecnzDeoUmu2aGZB36QK/JwZ+k3kRSb8kpoL8gwJdsqXkXu01VCL4e2D9o5 I1KBm79HBoDovOBCdinQu/cb9HgiCWX6yIIs9ROgsgf3nSOkRlDxgh8HJZ8TluOFX7TW ECrhxjtr1IiWDy0JPZNyAiGVXi1lNIBUXmi6755LQdy9zf6znoeFRxBzXYaMUH4N3uFV xo53UiD1d0j8f7fJxTjbpz2OFVdss2uoWAupNOm3awXZQ26KWTukqCvqkVUcSDdl9g4s hl+7erlOwBR1s00JXbG6TYD6C1cG955qstlxp1k+WERg4tRW9ZkUI2LV7G6fyrB3ZQbC 7Lhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sZJlHjmz; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 y6-20020aa79ae6000000b0064cce871b49si2992038pfp.137.2023.05.17.09.40.54; Wed, 17 May 2023 09:41:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=sZJlHjmz; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 S229649AbjEQQ0t (ORCPT + 99 others); Wed, 17 May 2023 12:26:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbjEQQ0s (ORCPT ); Wed, 17 May 2023 12:26:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3137130; Wed, 17 May 2023 09:26:47 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 8FF0D63D9C; Wed, 17 May 2023 16:26:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83718C433D2; Wed, 17 May 2023 16:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684340807; bh=sU1C7XJg/7VvloWpwX9yx2Ma9fhNOkvoRR16fGxVrx4=; h=From:To:Cc:Subject:Date:From; b=sZJlHjmztkvkLKxHbNj52fhsNhecUqM37bGatmGQxktUqEdItN6NL5LT81V2t091h gPcnMFAc4lv9o6eMpujnLyfiItRFzKYUVq04zMGhsHGW8TlWs6aPW8/qBYsGTQd3bH Yqul0tjCKB1OEQlFvxnj6oyty7r0DvSw62ycW3nV5MfdlkgPfgzublOcRIf2hxfnup wO6fGalPgH4Yha0Fy6jCA5HXWHpPEpcQFbaO9ayWcfJ1QMlfeEWH4TpdoLo2N6cIn9 XdrYaNigaP+qblqjiHbOFziGE0A/8WhqPj7v0QnQB09sTVfVptanFsFJrBRx2ONgce J9jFpKhWTDKag== From: Jeff Layton To: Chuck Lever Cc: Zhi Li , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] nfsd: make a copy of struct iattr before calling notify_change Date: Wed, 17 May 2023 12:26:44 -0400 Message-Id: <20230517162645.254512-1-jlayton@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,T_SCC_BODY_TEXT_LINE 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-nfs@vger.kernel.org notify_change can modify the iattr structure. In particular it can can end up setting ATTR_MODE when ATTR_KILL_SUID is already set, causing a BUG() if the same iattr is passed to notify_change more than once. Make a copy of the struct iattr before calling notify_change. Fixes: 34b91dda7124 NFSD: Make nfsd4_setattr() wait before returning NFS4ERR_DELAY Link: https://bugzilla.redhat.com/show_bug.cgi?id=2207969 Reported-by: Zhi Li Signed-off-by: Jeff Layton --- fs/nfsd/vfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index c4ef24c5ffd0..ad0c5cd900b1 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -538,7 +538,9 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, inode_lock(inode); for (retries = 1;;) { - host_err = __nfsd_setattr(dentry, iap); + struct iattr attrs = *iap; + + host_err = __nfsd_setattr(dentry, &attrs); if (host_err != -EAGAIN || !retries--) break; if (!nfsd_wait_for_delegreturn(rqstp, inode)) -- 2.40.1