Skip to contentSkip to conversation

security: remove redundant assignment to variable rc

PATCH Applied Colin Ian King 4 participants 5 messages Nov 12, 2024 – Jan 5, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 security: remove redundant assignment to variable rc

In the case where rc is equal to EOPNOTSUPP it is being reassigned a new value of zero that is never read. The following continue statement loops back to the next iteration of the lsm_for_each_hook loop and rc is being re-assigned a new value from the call to getselfattr. The assignment is redundant and can be removed.

---
 security/security.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
security/security.c +1 -3
index 09664e09fec9..6147f27ea92a 100644
@@ -4139,10 +4139,8 @@ int security_getselfattr(unsigned int attr, struct lsm_ctx __user *uctx,
 		if (base)
 			uctx = (struct lsm_ctx __user *)(base + total);
 		rc = scall->hl->hook.getselfattr(attr, uctx, &entrysize, flags);
-		if (rc == -EOPNOTSUPP) {
-			rc = 0;
+		if (rc == -EOPNOTSUPP)
 			continue;
-		}
 		if (rc == -E2BIG) {
 			rc = 0;
 			left = 0;
Signature · 1 line
2.39.5
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Colin Ian King

In the case where rc is equal to EOPNOTSUPP it is being reassigned a new value of zero that is never read. The following continue statement loops back to the next iteration of the lsm_for_each_hook loop and rc is being re-assigned a new value from the call to getselfattr. The assignment is redundant and can be removed.

(long as it doesn't go to stable :)

Quoted 22 lines
---
 security/security.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
security/security.c +1 -3
index 09664e09fec9..6147f27ea92a 100644
@@ -4139,10 +4139,8 @@ int security_getselfattr(unsigned int attr, struct lsm_ctx __user *uctx,
 		if (base)
 			uctx = (struct lsm_ctx __user *)(base + total);
 		rc = scall->hl->hook.getselfattr(attr, uctx, &entrysize, flags);
-		if (rc == -EOPNOTSUPP) {
-			rc = 0;
+		if (rc == -EOPNOTSUPP)
 			continue;
-		}
 		if (rc == -E2BIG) {
 			rc = 0;
 			left = 0;
Signature · 1 line
2.39.5
#2 lore raw
Quoted 7 lines · Serge E. Hallyn
Quoted 6 lines · Colin Ian King

In the case where rc is equal to EOPNOTSUPP it is being reassigned a new value of zero that is never read. The following continue statement loops back to the next iteration of the lsm_for_each_hook loop and rc is being re-assigned a new value from the call to getselfattr. The assignment is redundant and can be removed.

Quoted 6 lines
Quoted 1 line

(long as it doesn't go to stable :)

There is a tag for fixes which would break stable.

Cc <[email protected]> # reason goes here, and must be present

But this isn't a fix and it wouldn't break stable so probably that's not appropriate.

regards,
dan carpenter

maintainer
#3 lore raw
Quoted 15 lines · Dan Carpenter
Quoted 7 lines · Serge E. Hallyn
Quoted 6 lines · Colin Ian King

In the case where rc is equal to EOPNOTSUPP it is being reassigned a new value of zero that is never read. The following continue statement loops back to the next iteration of the lsm_for_each_hook loop and rc is being re-assigned a new value from the call to getselfattr. The assignment is redundant and can be removed.

Quoted 6 lines
Quoted 1 line

(long as it doesn't go to stable :)

Quoted 6 lines

There is a tag for fixes which would break stable.

Cc <[email protected]> # reason goes here, and must be present

But this isn't a fix and it wouldn't break stable so probably that's not appropriate.

I've also talked with the stable kernel folks and they no longer automatically pull any LSM commits with a 'Fixes:' tag. LSM commits need to be explicitly marked with the stable CC for them to be pulled into the stable trees.

Signature · 1 line
paul-moore.com
maintainer Applied
#4 lore raw
In reply to Colin Ian King
Quoted 7 lines · On Nov 12, 2024 Colin Ian King <[email protected]> wrote:

In the case where rc is equal to EOPNOTSUPP it is being reassigned a new value of zero that is never read. The following continue statement loops back to the next iteration of the lsm_for_each_hook loop and rc is being re-assigned a new value from the call to getselfattr. The assignment is redundant and can be removed.

Quoted 5 lines
---
 security/security.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Merged to lsm/dev, thanks.

--
paul-moore.com