* [PATCH] cifs: Fix uninitialized variable in set_chmod_dacl()
@ 2020-12-14 11:56 Dan Carpenter
2020-12-14 12:06 ` [EXTERNAL] " Shyam Prasad
2020-12-14 12:16 ` Aurélien Aptel
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2020-12-14 11:56 UTC (permalink / raw)
To: Steve French, Shyam Prasad N; +Cc: linux-cifs, samba-technical, kernel-janitors
Initialize the "nmode" variable earlier to prevent an uninitialized
variable bug when we do "size += setup_special_mode_ACE(pntace, nmode);"
Fixes: 253374f7557e ("cifs: Fix unix perm bits to cifsacl conversion for "other" bits.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
fs/cifs/cifsacl.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index d7a6d0f533bf..8410db328e5e 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -920,6 +920,13 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,
__u64 deny_group_mode = 0;
bool sticky_set = false;
+ /*
+ * We'll try to keep the mode as requested by the user.
+ * But in cases where we cannot meaningfully convert that
+ * into ACL, return back the updated mode, so that it is
+ * updated in the inode.
+ */
+ nmode = *pnmode;
pnndacl = (struct cifs_acl *)((char *)pndacl + sizeof(struct cifs_acl));
if (modefromsid) {
@@ -931,14 +938,6 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,
goto set_size;
}
- /*
- * We'll try to keep the mode as requested by the user.
- * But in cases where we cannot meaningfully convert that
- * into ACL, return back the updated mode, so that it is
- * updated in the inode.
- */
- nmode = *pnmode;
-
if (!memcmp(pownersid, pgrpsid, sizeof(struct cifs_sid))) {
/*
* Case when owner and group SIDs are the same.
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [EXTERNAL] [PATCH] cifs: Fix uninitialized variable in set_chmod_dacl()
2020-12-14 11:56 [PATCH] cifs: Fix uninitialized variable in set_chmod_dacl() Dan Carpenter
@ 2020-12-14 12:06 ` Shyam Prasad
2020-12-14 12:16 ` Aurélien Aptel
1 sibling, 0 replies; 3+ messages in thread
From: Shyam Prasad @ 2020-12-14 12:06 UTC (permalink / raw)
To: Dan Carpenter, Steve French; +Cc: linux-cifs, samba-technical, kernel-janitors
Hi Dan,
Thanks for the catch. This patch is already in for-next branch here:
https://git.samba.org/sfrench/cifs-2.6.git
Can you please pull the latest and verify?
Regards,
Shyam
-----Original Message-----
From: Dan Carpenter <dan.carpenter@oracle.com>
Sent: Monday, December 14, 2020 5:26 PM
To: Steve French <sfrench@samba.org>; Shyam Prasad <Shyam.Prasad@microsoft.com>
Cc: linux-cifs@vger.kernel.org; samba-technical@lists.samba.org; kernel-janitors@vger.kernel.org
Subject: [EXTERNAL] [PATCH] cifs: Fix uninitialized variable in set_chmod_dacl()
Initialize the "nmode" variable earlier to prevent an uninitialized variable bug when we do "size += setup_special_mode_ACE(pntace, nmode);"
Fixes: 253374f7557e ("cifs: Fix unix perm bits to cifsacl conversion for "other" bits.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
fs/cifs/cifsacl.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index d7a6d0f533bf..8410db328e5e 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -920,6 +920,13 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,
__u64 deny_group_mode = 0;
bool sticky_set = false;
+ /*
+ * We'll try to keep the mode as requested by the user.
+ * But in cases where we cannot meaningfully convert that
+ * into ACL, return back the updated mode, so that it is
+ * updated in the inode.
+ */
+ nmode = *pnmode;
pnndacl = (struct cifs_acl *)((char *)pndacl + sizeof(struct cifs_acl));
if (modefromsid) {
@@ -931,14 +938,6 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,
goto set_size;
}
- /*
- * We'll try to keep the mode as requested by the user.
- * But in cases where we cannot meaningfully convert that
- * into ACL, return back the updated mode, so that it is
- * updated in the inode.
- */
- nmode = *pnmode;
-
if (!memcmp(pownersid, pgrpsid, sizeof(struct cifs_sid))) {
/*
* Case when owner and group SIDs are the same.
--
2.29.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cifs: Fix uninitialized variable in set_chmod_dacl()
2020-12-14 11:56 [PATCH] cifs: Fix uninitialized variable in set_chmod_dacl() Dan Carpenter
2020-12-14 12:06 ` [EXTERNAL] " Shyam Prasad
@ 2020-12-14 12:16 ` Aurélien Aptel
1 sibling, 0 replies; 3+ messages in thread
From: Aurélien Aptel @ 2020-12-14 12:16 UTC (permalink / raw)
To: Dan Carpenter, Steve French, Shyam Prasad N
Cc: linux-cifs, kernel-janitors, samba-technical
Hi Dan,
Dan Carpenter via samba-technical <samba-technical@lists.samba.org>
writes:
> Initialize the "nmode" variable earlier to prevent an uninitialized
> variable bug when we do "size += setup_special_mode_ACE(pntace, nmode);"
>
> Fixes: 253374f7557e ("cifs: Fix unix perm bits to cifsacl conversion for "other" bits.")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
The current version of Steve's for-next already sets nmode earlier in
commit 0f22053e811ca ("cifs: Fix unix perm bits to cifsacl conversion
for "other" bits."). I believe this patch can be ignored.
Cheers,
--
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-14 12:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 11:56 [PATCH] cifs: Fix uninitialized variable in set_chmod_dacl() Dan Carpenter
2020-12-14 12:06 ` [EXTERNAL] " Shyam Prasad
2020-12-14 12:16 ` Aurélien Aptel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).