Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4609150pxj; Wed, 12 May 2021 09:10:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYsUSn4QW670J4xyMmH1qqDo6MUYc4xGdXc5ii2C+kWl5gmU3HPssIM6MKJqKkl8Q1ue5x X-Received: by 2002:a05:6820:100a:: with SMTP id v10mr24890532oor.55.1620835829577; Wed, 12 May 2021 09:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835829; cv=none; d=google.com; s=arc-20160816; b=zvX2SD/LZWrk30jRXzflMWky9El5GR+tJmcWOIln7jJoKeFHetOaqmOh4Ox7vnBO5b 5Ow0W8nFRa28DmOvIowez3afYZqQubhVDxquJ+35+HjU393CvE3U3jRxHEdfW9dFx/p1 z8XG1dcEgMIeqeogM6NBqxvz54Io6gmR42qgaF5fr9M5/jrnFQ9HaNJEljIABiHpCuh8 cJ7OAOBvlHBiVpuMTnUHP9XP4h/+rpF+7FwXQvpk97QlrOjuhTxA6Wv5bfpJcyDn2MFE d8xL7jH8b4+5tE23k8NIVn9ttK7jVP5oJq71xnymEbhgKCE4GvaeKY1UI25UBZT43IZV LtwQ== 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=JOsCQYzPJRhL+Pzx8Af0xTkEQhLhfvj8YJsd4ftzG5k=; b=QtAHwrS+zVyyEtIk3m4p6AccgUdPvNj5wfIz9HPIXirYUH08QF3vrwRCREvmKbttll tDaOtB7jwXP5Y+bIaP2nCgntwjqSsKAmxYeT/TLJSe55Uyn4Afr5KnwKWH6NNqZf3DKt NOoBeqQrnqztjpQJQIuoosKYcE1aYl7IjfJZfoODOwOX/suKOSIRsvGAEKLzBGQQ/YZ5 gCZ82NoLuSCSf6PlnhpRNAeikwa6uk1YP6UWpwmuIhigyiA314FZAtbXv7hv4P+1Gk/p lFhZ8nIIlSACfhjPBHKCB9dTZPhO5LTLDdccxZnEB1M8RgDWQ3ZCCb3qF7irV5tPcFYw Nktw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cwk9Aw3O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u80si317260oia.265.2021.05.12.09.10.15; Wed, 12 May 2021 09:10:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cwk9Aw3O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238468AbhELQFL (ORCPT + 99 others); Wed, 12 May 2021 12:05:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:40914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235591AbhELP2g (ORCPT ); Wed, 12 May 2021 11:28:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2F87E61C2E; Wed, 12 May 2021 15:14:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832444; bh=fMKB6lIpuJEctihMdJJKCAJ85Ls10lFXA3gp3lnT8OI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cwk9Aw3O/XKe6Sbh35hEmjoflz08E5rIgWnBasgIXiXx5wN+CIcXrxXTihuCLnZq2 hbker2fGdk7lPujel9/+POS/7/P7y05ifDnP0Nl19yu1pmGj+Ahhik9+PHa3icJjRK rrLajDoru/OSLCyBbFGRunMcbyCsEaMqGNJjeZUE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , David Howells , Sasha Levin Subject: [PATCH 5.10 282/530] afs: Fix updating of i_mode due to 3rd party change Date: Wed, 12 May 2021 16:46:32 +0200 Message-Id: <20210512144829.077269287@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells [ Upstream commit 6e1eb04a87f954eb06a89ee6034c166351dfff6e ] Fix afs_apply_status() to mask off the irrelevant bits from status->mode when OR'ing them into i_mode. This can happen when a 3rd party chmod occurs. Also fix afs_inode_init_from_status() to mask off the mode bits when initialising i_mode. Fixes: 260a980317da ("[AFS]: Add "directory write" support.") Reported-by: Al Viro Signed-off-by: David Howells Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- fs/afs/inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 1d03eb1920ec..bf44e245d7dc 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -102,13 +102,13 @@ static int afs_inode_init_from_status(struct afs_operation *op, switch (status->type) { case AFS_FTYPE_FILE: - inode->i_mode = S_IFREG | status->mode; + inode->i_mode = S_IFREG | (status->mode & S_IALLUGO); inode->i_op = &afs_file_inode_operations; inode->i_fop = &afs_file_operations; inode->i_mapping->a_ops = &afs_fs_aops; break; case AFS_FTYPE_DIR: - inode->i_mode = S_IFDIR | status->mode; + inode->i_mode = S_IFDIR | (status->mode & S_IALLUGO); inode->i_op = &afs_dir_inode_operations; inode->i_fop = &afs_dir_file_operations; inode->i_mapping->a_ops = &afs_dir_aops; @@ -198,7 +198,7 @@ static void afs_apply_status(struct afs_operation *op, if (status->mode != vnode->status.mode) { mode = inode->i_mode; mode &= ~S_IALLUGO; - mode |= status->mode; + mode |= status->mode & S_IALLUGO; WRITE_ONCE(inode->i_mode, mode); } -- 2.30.2