Recent versions of Clang gets confused about the possible size of the
"user" allocation, and CONFIG_FORTIFY_SOURCE ends up emitting a
warning[1]:
repro.c:126:4: warning: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Wattribute-warning]
126 | __write_overflow_field(p_size_field, size);
| ^
for this memset():
int len;
__le16 *user;
...
len = ses->user_name ? strlen(ses->user_name) : 0;
user = kmalloc(2 + (len * 2), GFP_KERNEL);
...
if (len) {
...
} else { memset(user, '\0', 2);
}
While Clang works on this bug[2], switch to using a direct assignment,
which avoids memset() entirely which both simplifies the code and silences
the false positive warning. (Making "len" size_t also silences the
warning, but the direct assignment seems better.)
Reported-by: Nathan Chancellor <email address hidden>
Closes: https://github.com/ClangBuiltLinux/linux/issues/1966 [1]
Link: https://github.com/llvm/llvm-project/issues/77813 [2]
Cc: Steve French <email address hidden>
Cc: Paulo Alcantara <email address hidden>
Cc: Ronnie Sahlberg <email address hidden>
Cc: Shyam Prasad N <email address hidden>
Cc: Tom Talpey <email address hidden>
Cc: <email address hidden>
Cc: <email address hidden>
Signed-off-by: Kees Cook <email address hidden>
Signed-off-by: Steve French <email address hidden>
(backported from commit 8deb05c84b63b4fdb8549e08942867a68924a5b8)
Signed-off-by: Tim Gardner <email address hidden>
Acked-by: John Cabaj <email address hidden>
Acked-by: Philip Cox <email address hidden>
Signed-off-by: Tim Gardner <email address hidden>
iface_last_update was an unused field when it was introduced.
Later, when we had periodic update of server interface list,
this field was used regularly to decide when to update next.
However, with the new logic of updating the interfaces, it
becomes crucial that this field be updated whenever
parse_server_interfaces runs successfully.
This change updates this field when either the server does
not support query of interfaces; so that we do not query
the interfaces repeatedly. It also updates the field when
the function reaches the end.
Fixes: aa45dadd34e4 ("cifs: change iface_list from array to sorted linked list")
Signed-off-by: Shyam Prasad N <email address hidden>
Signed-off-by: Steve French <email address hidden>
(backported from commit 78e727e58e54efca4c23863fbd9e16e9d2d83f81)
Signed-off-by: Tim Gardner <email address hidden>
Acked-by: John Cabaj <email address hidden>
Acked-by: Philip Cox <email address hidden>
Signed-off-by: Tim Gardner <email address hidden>