From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Kees Cook <keescook@chromium.org>,
Nathan Chancellor <nathan@kernel.org>,
Steve French <sfrench@samba.org>,
Paulo Alcantara <pc@manguebit.com>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Tom Talpey <tom@talpey.com>,
linux-cifs@vger.kernel.org, llvm@lists.linux.dev,
Steve French <stfrench@microsoft.com>,
Sasha Levin <sashal@kernel.org>,
samba-technical@lists.samba.org
Subject: [PATCH AUTOSEL 6.1 08/15] smb: Work around Clang __bdos() type confusion
Date: Fri, 2 Feb 2024 13:40:45 -0500 [thread overview]
Message-ID: <20240202184057.541411-8-sashal@kernel.org> (raw)
In-Reply-To: <20240202184057.541411-1-sashal@kernel.org>
From: Kees Cook <keescook@chromium.org>
[ Upstream commit 8deb05c84b63b4fdb8549e08942867a68924a5b8 ]
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 <nathan@kernel.org>
Closes: https://github.com/ClangBuiltLinux/linux/issues/1966 [1]
Link: https://github.com/llvm/llvm-project/issues/77813 [2]
Cc: Steve French <sfrench@samba.org>
Cc: Paulo Alcantara <pc@manguebit.com>
Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Cc: Shyam Prasad N <sprasad@microsoft.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: linux-cifs@vger.kernel.org
Cc: llvm@lists.linux.dev
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/client/cifsencrypt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/smb/client/cifsencrypt.c b/fs/smb/client/cifsencrypt.c
index d0ac2648c0d6..d3d4cf6321fd 100644
--- a/fs/smb/client/cifsencrypt.c
+++ b/fs/smb/client/cifsencrypt.c
@@ -444,7 +444,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
len = cifs_strtoUTF16(user, ses->user_name, len, nls_cp);
UniStrupr(user);
} else {
- memset(user, '\0', 2);
+ *(u16 *)user = 0;
}
rc = crypto_shash_update(ses->server->secmech.hmacmd5,
--
2.43.0
next prev parent reply other threads:[~2024-02-02 18:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 18:40 [PATCH AUTOSEL 6.1 01/15] wifi: cfg80211: fix missing interfaces when dumping Sasha Levin
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 02/15] wifi: mac80211: fix race condition on enabling fast-xmit Sasha Levin
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 03/15] fbdev: savage: Error out if pixclock equals zero Sasha Levin
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 04/15] fbdev: sis: " Sasha Levin
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 05/15] x86/cpu: Add model number for Intel Clearwater Forest processor Sasha Levin
2024-02-18 19:14 ` Pavel Machek
2024-02-22 12:34 ` Sasha Levin
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 06/15] spi: hisi-sfc-v3xx: Return IRQ_NONE if no interrupts were detected Sasha Levin
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 07/15] block: Fix WARNING in _copy_from_iter Sasha Levin
2024-02-02 18:40 ` Sasha Levin [this message]
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 09/15] cifs: translate network errors on send to -ECONNABORTED Sasha Levin
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 10/15] ahci: asm1166: correct count of reported ports Sasha Levin
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 11/15] aoe: avoid potential deadlock at set_capacity Sasha Levin
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 12/15] exec: Distinguish in_execve from in_exec Sasha Levin
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 13/15] ahci: add 43-bit DMA address quirk for ASMedia ASM1061 controllers Sasha Levin
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 14/15] MIPS: reserve exception vector space ONLY ONCE Sasha Levin
2024-02-02 18:40 ` [PATCH AUTOSEL 6.1 15/15] platform/x86: touchscreen_dmi: Add info for the TECLAST X16 Plus tablet Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240202184057.541411-8-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=pc@manguebit.com \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
--cc=sprasad@microsoft.com \
--cc=stable@vger.kernel.org \
--cc=stfrench@microsoft.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.