Skip to content

Commit 4cf0ccd

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: fix control flow issues in sid_to_id()
Addresses-Coverity reported Control flow issues in sid_to_id() /fs/ksmbd/smbacl.c: 277 in sid_to_id() 271 272 if (sidtype == SIDOWNER) { 273 kuid_t uid; 274 uid_t id; 275 276 id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]); >>> CID 1506810: Control flow issues (NO_EFFECT) >>> This greater-than-or-equal-to-zero comparison of an unsigned value >>> is always true. "id >= 0U". 277 if (id >= 0) { 278 /* 279 * Translate raw sid into kuid in the server's user 280 * namespace. 281 */ 282 uid = make_kuid(&init_user_ns, id); Addresses-Coverity: ("Control flow issues") Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 4ffd526 commit 4cf0ccd

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

fs/ksmbd/smbacl.c

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -274,38 +274,34 @@ static int sid_to_id(struct user_namespace *user_ns,
274274
uid_t id;
275275

276276
id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]);
277-
if (id >= 0) {
278-
/*
279-
* Translate raw sid into kuid in the server's user
280-
* namespace.
281-
*/
282-
uid = make_kuid(&init_user_ns, id);
283-
284-
/* If this is an idmapped mount, apply the idmapping. */
285-
uid = kuid_from_mnt(user_ns, uid);
286-
if (uid_valid(uid)) {
287-
fattr->cf_uid = uid;
288-
rc = 0;
289-
}
277+
/*
278+
* Translate raw sid into kuid in the server's user
279+
* namespace.
280+
*/
281+
uid = make_kuid(&init_user_ns, id);
282+
283+
/* If this is an idmapped mount, apply the idmapping. */
284+
uid = kuid_from_mnt(user_ns, uid);
285+
if (uid_valid(uid)) {
286+
fattr->cf_uid = uid;
287+
rc = 0;
290288
}
291289
} else {
292290
kgid_t gid;
293291
gid_t id;
294292

295293
id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]);
296-
if (id >= 0) {
297-
/*
298-
* Translate raw sid into kgid in the server's user
299-
* namespace.
300-
*/
301-
gid = make_kgid(&init_user_ns, id);
302-
303-
/* If this is an idmapped mount, apply the idmapping. */
304-
gid = kgid_from_mnt(user_ns, gid);
305-
if (gid_valid(gid)) {
306-
fattr->cf_gid = gid;
307-
rc = 0;
308-
}
294+
/*
295+
* Translate raw sid into kgid in the server's user
296+
* namespace.
297+
*/
298+
gid = make_kgid(&init_user_ns, id);
299+
300+
/* If this is an idmapped mount, apply the idmapping. */
301+
gid = kgid_from_mnt(user_ns, gid);
302+
if (gid_valid(gid)) {
303+
fattr->cf_gid = gid;
304+
rc = 0;
309305
}
310306
}
311307

0 commit comments

Comments
 (0)