All of lore.kernel.org
 help / color / mirror / Atom feed
* Fix posix 311 symlink creation mode
@ 2023-01-11 11:42 Volker Lendecke
  2023-01-11 13:57 ` Paulo Alcantara
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Volker Lendecke @ 2023-01-11 11:42 UTC (permalink / raw)
  To: linux-cifs

[-- Attachment #1: Type: text/plain, Size: 133 bytes --]

Hi!

Attached find a patch that fixes an uninitialized memory read when
creating symlinks using the smb311 posix extensions.

Volker

[-- Attachment #2: posix-symlink.diff --]
[-- Type: text/x-diff, Size: 971 bytes --]

From 482fa85ef97505626b6b146155834e6bc36012fa Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl@samba.org>
Date: Wed, 11 Jan 2023 12:37:58 +0100
Subject: [PATCH] cifs: Fix uninitialized memory read for smb311 posix symlink
 create

If smb311 posix is enabled, we send the intended mode for file
creation in the posix create context. Instead of using what's there on
the stack, create the mfsymlink file with 0644.

Signed-off-by: Volker Lendecke <vl@samba.org>
---
 fs/cifs/link.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index bd374feeccaa..a5a097a69983 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -428,6 +428,7 @@ smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
 	oparms.disposition = FILE_CREATE;
 	oparms.fid = &fid;
 	oparms.reconnect = false;
+	oparms.mode = 0644;
 
 	rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL,
 		       NULL, NULL);
-- 
2.30.2


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

* Re: Fix posix 311 symlink creation mode
  2023-01-11 11:42 Fix posix 311 symlink creation mode Volker Lendecke
@ 2023-01-11 13:57 ` Paulo Alcantara
  2023-01-11 16:21 ` Steve French
  2023-01-12 13:25 ` David Disseldorp
  2 siblings, 0 replies; 8+ messages in thread
From: Paulo Alcantara @ 2023-01-11 13:57 UTC (permalink / raw)
  To: Volker.Lendecke, linux-cifs

Volker Lendecke <Volker.Lendecke@sernet.de> writes:

> Attached find a patch that fixes an uninitialized memory read when
> creating symlinks using the smb311 posix extensions.
>
> Volker
> From 482fa85ef97505626b6b146155834e6bc36012fa Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl@samba.org>
> Date: Wed, 11 Jan 2023 12:37:58 +0100
> Subject: [PATCH] cifs: Fix uninitialized memory read for smb311 posix symlink
>  create
>
> If smb311 posix is enabled, we send the intended mode for file
> creation in the posix create context. Instead of using what's there on
> the stack, create the mfsymlink file with 0644.
>
> Signed-off-by: Volker Lendecke <vl@samba.org>
> ---
>  fs/cifs/link.c | 1 +
>  1 file changed, 1 insertion(+)

Looks good to me.  Thanks!

Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>

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

* Re: Fix posix 311 symlink creation mode
  2023-01-11 11:42 Fix posix 311 symlink creation mode Volker Lendecke
  2023-01-11 13:57 ` Paulo Alcantara
@ 2023-01-11 16:21 ` Steve French
  2023-01-11 16:51   ` Volker Lendecke
  2023-01-12 13:25 ` David Disseldorp
  2 siblings, 1 reply; 8+ messages in thread
From: Steve French @ 2023-01-11 16:21 UTC (permalink / raw)
  To: Volker.Lendecke; +Cc: linux-cifs

Should this be 0777 instead of 0644?

I noticed the man page for symlink says:

     "On Linux, the permissions of an ordinary symbolic link are not
       used in any operations; the permissions are always 0777 (read,
       write, and execute for all user categories), and can't be
       changed."

On Wed, Jan 11, 2023 at 6:14 AM Volker Lendecke
<Volker.Lendecke@sernet.de> wrote:
>
> Hi!
>
> Attached find a patch that fixes an uninitialized memory read when
> creating symlinks using the smb311 posix extensions.
>
> Volker



-- 
Thanks,

Steve

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

* Re: Fix posix 311 symlink creation mode
  2023-01-11 16:21 ` Steve French
@ 2023-01-11 16:51   ` Volker Lendecke
  2023-01-11 17:04     ` Tom Talpey
  2023-01-11 20:18     ` Steve French
  0 siblings, 2 replies; 8+ messages in thread
From: Volker Lendecke @ 2023-01-11 16:51 UTC (permalink / raw)
  To: Steve French; +Cc: linux-cifs

Am Wed, Jan 11, 2023 at 10:21:07AM -0600 schrieb Steve French:
> Should this be 0777 instead of 0644?
> 
> I noticed the man page for symlink says:
> 
>      "On Linux, the permissions of an ordinary symbolic link are not
>        used in any operations; the permissions are always 0777 (read,
>        write, and execute for all user categories), and can't be
>        changed."

I thought about that as well. If you "ls -l" such a symlink once
created, it will show as 0777, probably the client does it
somehow. The problem however is that if you create it with 0777
server-side, everybody can mess with that file that the client view as
a symlink. That's why I thought that 0644 is the best approximation.

Regards, Volker

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

* Re: Fix posix 311 symlink creation mode
  2023-01-11 16:51   ` Volker Lendecke
@ 2023-01-11 17:04     ` Tom Talpey
  2023-01-11 20:18     ` Steve French
  1 sibling, 0 replies; 8+ messages in thread
From: Tom Talpey @ 2023-01-11 17:04 UTC (permalink / raw)
  To: Volker.Lendecke, Steve French; +Cc: linux-cifs

On 1/11/2023 11:51 AM, Volker Lendecke wrote:
> Am Wed, Jan 11, 2023 at 10:21:07AM -0600 schrieb Steve French:
>> Should this be 0777 instead of 0644?
>>
>> I noticed the man page for symlink says:
>>
>>       "On Linux, the permissions of an ordinary symbolic link are not
>>         used in any operations; the permissions are always 0777 (read,
>>         write, and execute for all user categories), and can't be
>>         changed."
> 
> I thought about that as well. If you "ls -l" such a symlink once
> created, it will show as 0777, probably the client does it
> somehow. The problem however is that if you create it with 0777
> server-side, everybody can mess with that file that the client view as
> a symlink. That's why I thought that 0644 is the best approximation.

Yeah, because this is an mfsymlink, which is really just a file with
specific contents, you might even argue 0444 is safest.

Definitely not 0777.

Tom.

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

* Re: Fix posix 311 symlink creation mode
  2023-01-11 16:51   ` Volker Lendecke
  2023-01-11 17:04     ` Tom Talpey
@ 2023-01-11 20:18     ` Steve French
  1 sibling, 0 replies; 8+ messages in thread
From: Steve French @ 2023-01-11 20:18 UTC (permalink / raw)
  To: Volker.Lendecke; +Cc: CIFS, Paulo Alcantara, Tom Talpey

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

On Wed, Jan 11, 2023 at 10:51 AM Volker Lendecke
<Volker.Lendecke@sernet.de> wrote:
>
> Am Wed, Jan 11, 2023 at 10:21:07AM -0600 schrieb Steve French:
> > Should this be 0777 instead of 0644?
> >
> > I noticed the man page for symlink says:
> >
> >      "On Linux, the permissions of an ordinary symbolic link are not
> >        used in any operations; the permissions are always 0777 (read,
> >        write, and execute for all user categories), and can't be
> >        changed."
>
> I thought about that as well. If you "ls -l" such a symlink once
> created, it will show as 0777, probably the client does it
> somehow. The problem however is that if you create it with 0777
> server-side, everybody can mess with that file that the client view as
> a symlink. That's why I thought that 0644 is the best approximation.
>
> Regards, Volker



-- 
Thanks,

Steve

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

* Re: Fix posix 311 symlink creation mode
  2023-01-11 11:42 Fix posix 311 symlink creation mode Volker Lendecke
  2023-01-11 13:57 ` Paulo Alcantara
  2023-01-11 16:21 ` Steve French
@ 2023-01-12 13:25 ` David Disseldorp
  2023-01-12 15:59   ` Steve French
  2 siblings, 1 reply; 8+ messages in thread
From: David Disseldorp @ 2023-01-12 13:25 UTC (permalink / raw)
  To: Volker Lendecke; +Cc: linux-cifs, Steve French

Hi Volker,

On Wed, 11 Jan 2023 12:42:52 +0100, Volker Lendecke wrote:

> If smb311 posix is enabled, we send the intended mode for file
> creation in the posix create context. Instead of using what's there on
> the stack, create the mfsymlink file with 0644.
> 
> Signed-off-by: Volker Lendecke <vl@samba.org>

Good catch. I think this deserves a Fixes tag as per
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#using-reported-by-tested-by-reviewed-by-suggested-by-and-fixes
E.g.
Fixes: ce558b0e17f8a ("smb3: Add posix create context for smb3.11 posix mounts")
Preferably also with "Cc: stable@vger.kernel.org" for applicable
backports.

oparms.mode appears to be uninitialized in cifs_create_mf_symlink()
(#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY) and various other codepaths
but isn't currently used further down the call chain... This looks like
an accident waiting to happen.

Cheers, David

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

* Re: Fix posix 311 symlink creation mode
  2023-01-12 13:25 ` David Disseldorp
@ 2023-01-12 15:59   ` Steve French
  0 siblings, 0 replies; 8+ messages in thread
From: Steve French @ 2023-01-12 15:59 UTC (permalink / raw)
  To: David Disseldorp; +Cc: Volker Lendecke, linux-cifs

updated

On Thu, Jan 12, 2023 at 7:24 AM David Disseldorp <ddiss@suse.de> wrote:
>
> Hi Volker,
>
> On Wed, 11 Jan 2023 12:42:52 +0100, Volker Lendecke wrote:
>
> > If smb311 posix is enabled, we send the intended mode for file
> > creation in the posix create context. Instead of using what's there on
> > the stack, create the mfsymlink file with 0644.
> >
> > Signed-off-by: Volker Lendecke <vl@samba.org>
>
> Good catch. I think this deserves a Fixes tag as per
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html#using-reported-by-tested-by-reviewed-by-suggested-by-and-fixes
> E.g.
> Fixes: ce558b0e17f8a ("smb3: Add posix create context for smb3.11 posix mounts")
> Preferably also with "Cc: stable@vger.kernel.org" for applicable
> backports.
>
> oparms.mode appears to be uninitialized in cifs_create_mf_symlink()
> (#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY) and various other codepaths
> but isn't currently used further down the call chain... This looks like
> an accident waiting to happen.
>
> Cheers, David



-- 
Thanks,

Steve

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

end of thread, other threads:[~2023-01-12 16:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11 11:42 Fix posix 311 symlink creation mode Volker Lendecke
2023-01-11 13:57 ` Paulo Alcantara
2023-01-11 16:21 ` Steve French
2023-01-11 16:51   ` Volker Lendecke
2023-01-11 17:04     ` Tom Talpey
2023-01-11 20:18     ` Steve French
2023-01-12 13:25 ` David Disseldorp
2023-01-12 15:59   ` Steve French

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.