git: ad22ba2b9f3b - main - if: Remove unnecessary validation in the SIOCSIFNAME handler

Mark Johnston markj at FreeBSD.org
Wed May 12 17:09:34 UTC 2021


The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=ad22ba2b9f3b6ff5d85be14627d3a59ca389f5e4

commit ad22ba2b9f3b6ff5d85be14627d3a59ca389f5e4
Author:     Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-05-12 14:05:37 +0000
Commit:     Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-05-12 16:52:06 +0000

    if: Remove unnecessary validation in the SIOCSIFNAME handler
    
    A successful copyinstr() call guarantees that the returned string is
    nul-terminated.  Furthermore, the removed check would harmlessly compare
    an uninitialized byte with '\0' if the new name is shorter than
    IFNAMESIZ - 1.
    
    Reported by:    KMSAN
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
---
 sys/net/if.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/sys/net/if.c b/sys/net/if.c
index e18ed3e275ac..f615d82636be 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -2653,11 +2653,6 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
 			return (error);
 		if (new_name[0] == '\0')
 			return (EINVAL);
-		if (new_name[IFNAMSIZ-1] != '\0') {
-			new_name[IFNAMSIZ-1] = '\0';
-			if (strlen(new_name) == IFNAMSIZ-1)
-				return (EINVAL);
-		}
 		if (strcmp(new_name, ifp->if_xname) == 0)
 			break;
 		if (ifunit(new_name) != NULL)


More information about the dev-commits-src-main mailing list