Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] smb: client: fix chmod(2) regression with ATTR_READONLY
@ 2025-02-16 21:02 Paulo Alcantara
  2025-02-16 23:20 ` Steve French
  0 siblings, 1 reply; 4+ messages in thread
From: Paulo Alcantara @ 2025-02-16 21:02 UTC (permalink / raw)
  To: smfrench; +Cc: linux-cifs, Horst Reiterer

When the user sets a file or directory as read-only (e.g. ~S_IWUGO),
the client will set the ATTR_READONLY attribute by sending an
SMB2_SET_INFO request to the server in cifs_setattr_{,nounix}(), but
cifsInodeInfo::cifsAttrs will be left unchanged as the client will
only update the new file attributes in the next call to
{smb311_posix,cifs}_get_inode_info() with the new metadata filled in
@data parameter.

Commit a18280e7fdea ("smb: cilent: set reparse mount points as
automounts") mistakenly removed the @data NULL check when calling
is_inode_cache_good(), which broke the above case as the new
ATTR_READONLY attribute would end up not being updated on files with a
read lease.

Fix this by updating the inode whenever we have cached metadata in
@data parameter.

Reported-by: Horst Reiterer <horst.reiterer@fabasoft.com>
Closes: https://lore.kernel.org/r/85a16504e09147a195ac0aac1c801280@fabasoft.com
Fixes: a18280e7fdea ("smb: cilent: set reparse mount points as automounts")
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
---
 fs/smb/client/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 214240612549..616149c7f0a5 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -1421,7 +1421,7 @@ int cifs_get_inode_info(struct inode **inode,
 	struct cifs_fattr fattr = {};
 	int rc;
 
-	if (is_inode_cache_good(*inode)) {
+	if (!data && is_inode_cache_good(*inode)) {
 		cifs_dbg(FYI, "No need to revalidate cached inode sizes\n");
 		return 0;
 	}
@@ -1520,7 +1520,7 @@ int smb311_posix_get_inode_info(struct inode **inode,
 	struct cifs_fattr fattr = {};
 	int rc;
 
-	if (is_inode_cache_good(*inode)) {
+	if (!data && is_inode_cache_good(*inode)) {
 		cifs_dbg(FYI, "No need to revalidate cached inode sizes\n");
 		return 0;
 	}
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] smb: client: fix chmod(2) regression with ATTR_READONLY
  2025-02-16 21:02 Paulo Alcantara
@ 2025-02-16 23:20 ` Steve French
  0 siblings, 0 replies; 4+ messages in thread
From: Steve French @ 2025-02-16 23:20 UTC (permalink / raw)
  To: Paulo Alcantara; +Cc: linux-cifs, Horst Reiterer

tentatively merged into cifs-2.6.git for-next pending more testing and review

On Sun, Feb 16, 2025 at 3:02 PM Paulo Alcantara <pc@manguebit.com> wrote:
>
> When the user sets a file or directory as read-only (e.g. ~S_IWUGO),
> the client will set the ATTR_READONLY attribute by sending an
> SMB2_SET_INFO request to the server in cifs_setattr_{,nounix}(), but
> cifsInodeInfo::cifsAttrs will be left unchanged as the client will
> only update the new file attributes in the next call to
> {smb311_posix,cifs}_get_inode_info() with the new metadata filled in
> @data parameter.
>
> Commit a18280e7fdea ("smb: cilent: set reparse mount points as
> automounts") mistakenly removed the @data NULL check when calling
> is_inode_cache_good(), which broke the above case as the new
> ATTR_READONLY attribute would end up not being updated on files with a
> read lease.
>
> Fix this by updating the inode whenever we have cached metadata in
> @data parameter.
>
> Reported-by: Horst Reiterer <horst.reiterer@fabasoft.com>
> Closes: https://lore.kernel.org/r/85a16504e09147a195ac0aac1c801280@fabasoft.com
> Fixes: a18280e7fdea ("smb: cilent: set reparse mount points as automounts")
> Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
> ---
>  fs/smb/client/inode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
> index 214240612549..616149c7f0a5 100644
> --- a/fs/smb/client/inode.c
> +++ b/fs/smb/client/inode.c
> @@ -1421,7 +1421,7 @@ int cifs_get_inode_info(struct inode **inode,
>         struct cifs_fattr fattr = {};
>         int rc;
>
> -       if (is_inode_cache_good(*inode)) {
> +       if (!data && is_inode_cache_good(*inode)) {
>                 cifs_dbg(FYI, "No need to revalidate cached inode sizes\n");
>                 return 0;
>         }
> @@ -1520,7 +1520,7 @@ int smb311_posix_get_inode_info(struct inode **inode,
>         struct cifs_fattr fattr = {};
>         int rc;
>
> -       if (is_inode_cache_good(*inode)) {
> +       if (!data && is_inode_cache_good(*inode)) {
>                 cifs_dbg(FYI, "No need to revalidate cached inode sizes\n");
>                 return 0;
>         }
> --
> 2.48.1
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] smb: client: fix chmod(2) regression with ATTR_READONLY
@ 2025-02-19 10:04 Reiterer, Horst
  2025-02-19 13:49 ` Paulo Alcantara
  0 siblings, 1 reply; 4+ messages in thread
From: Reiterer, Horst @ 2025-02-19 10:04 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara; +Cc: linux-cifs@vger.kernel.org

Hi,

thanks, Steve and Paulo! Considering the severity (chmod does not take effect anymore) and the fact that this regression was caused by dropping a condition in two lines of code that is merely being restored by the fix (basically, it's a partial revert), is there any way to prioritize this change as there's no production-ready workaround? It's difficult to avoid updating to 6.6+ at this point.

Cheers,

Horst Reiterer

-----Ursprüngliche Nachricht-----
Von: Steve French <smfrench@gmail.com> 
Gesendet: Montag, 17. Februar 2025 00:20
An: Paulo Alcantara <pc@manguebit.com>
Cc: linux-cifs@vger.kernel.org; Reiterer, Horst <horst.reiterer@fabasoft.com>
Betreff: Re: [PATCH] smb: client: fix chmod(2) regression with ATTR_READONLY

tentatively merged into cifs-2.6.git for-next pending more testing and review

On Sun, Feb 16, 2025 at 3:02 PM Paulo Alcantara <pc@manguebit.com> wrote:
>
> When the user sets a file or directory as read-only (e.g. ~S_IWUGO), 
> the client will set the ATTR_READONLY attribute by sending an 
> SMB2_SET_INFO request to the server in cifs_setattr_{,nounix}(), but 
> cifsInodeInfo::cifsAttrs will be left unchanged as the client will 
> only update the new file attributes in the next call to
> {smb311_posix,cifs}_get_inode_info() with the new metadata filled in 
> @data parameter.
>
> Commit a18280e7fdea ("smb: cilent: set reparse mount points as
> automounts") mistakenly removed the @data NULL check when calling 
> is_inode_cache_good(), which broke the above case as the new 
> ATTR_READONLY attribute would end up not being updated on files with a 
> read lease.
>
> Fix this by updating the inode whenever we have cached metadata in 
> @data parameter.
>
> Reported-by: Horst Reiterer <horst.reiterer@fabasoft.com>
> Closes: 
> https://lore.kernel.org/r/85a16504e09147a195ac0aac1c801280@fabasoft.co
> m
> Fixes: a18280e7fdea ("smb: cilent: set reparse mount points as 
> automounts")
> Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
> ---
>  fs/smb/client/inode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index 
> 214240612549..616149c7f0a5 100644
> --- a/fs/smb/client/inode.c
> +++ b/fs/smb/client/inode.c
> @@ -1421,7 +1421,7 @@ int cifs_get_inode_info(struct inode **inode,
>         struct cifs_fattr fattr = {};
>         int rc;
>
> -       if (is_inode_cache_good(*inode)) {
> +       if (!data && is_inode_cache_good(*inode)) {
>                 cifs_dbg(FYI, "No need to revalidate cached inode sizes\n");
>                 return 0;
>         }
> @@ -1520,7 +1520,7 @@ int smb311_posix_get_inode_info(struct inode **inode,
>         struct cifs_fattr fattr = {};
>         int rc;
>
> -       if (is_inode_cache_good(*inode)) {
> +       if (!data && is_inode_cache_good(*inode)) {
>                 cifs_dbg(FYI, "No need to revalidate cached inode sizes\n");
>                 return 0;
>         }
> --
> 2.48.1
>


--
Thanks,

Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] smb: client: fix chmod(2) regression with ATTR_READONLY
  2025-02-19 10:04 [PATCH] smb: client: fix chmod(2) regression with ATTR_READONLY Reiterer, Horst
@ 2025-02-19 13:49 ` Paulo Alcantara
  0 siblings, 0 replies; 4+ messages in thread
From: Paulo Alcantara @ 2025-02-19 13:49 UTC (permalink / raw)
  To: Reiterer, Horst, Steve French; +Cc: linux-cifs@vger.kernel.org

"Reiterer, Horst" <horst.reiterer@fabasoft.com> writes:

> thanks, Steve and Paulo! Considering the severity (chmod does not take effect anymore) and the fact that this regression was caused by dropping a condition in two lines of code that is merely being restored by the fix (basically, it's a partial revert), is there any way to prioritize this change as there's no production-ready workaround? It's difficult to avoid updating to 6.6+ at this point.
>

It has been marked for -stable, so it's expected that stable team will
pick it up for v6.6+ once the fix is released in v6.14-rc4.  If for some
reason they miss it, I'll ping them to make sure it goes into the stable
trees.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-19 13:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19 10:04 [PATCH] smb: client: fix chmod(2) regression with ATTR_READONLY Reiterer, Horst
2025-02-19 13:49 ` Paulo Alcantara
  -- strict thread matches above, loose matches on Subject: below --
2025-02-16 21:02 Paulo Alcantara
2025-02-16 23:20 ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox