Message ID | 20240123234731.work.358-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-36193-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp671150dyi; Tue, 23 Jan 2024 15:47:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEiPpV0hDbQIDu/gt3tT9QvFqoTX4Px9Q+YHn7OhttXwLUCp5qu9Ixwri6JkUd2tUwFDOe X-Received: by 2002:a05:6214:19c7:b0:67e:d89f:e392 with SMTP id j7-20020a05621419c700b0067ed89fe392mr2185921qvc.11.1706053679229; Tue, 23 Jan 2024 15:47:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706053679; cv=pass; d=google.com; s=arc-20160816; b=0GwdCTXBhzb2Gz4CX8PT2Bhu9d1cGOnw8bltlCrNWCg2boLL1WYQOhTRIhvpvCmBjj iYS4x1lt2UirfJqok4WrMyeZPm+hfceJ6BQaRI9R6YMJhDSLiErhaDXJNt+CKAHqWEmV frGFh7oL73AQcgZ++Xg+hR81TOHTwMNjyIMpvq9IbjSDceuIsuWqsG5r4ULQGSt26nfT 5L6C9kFsBQpWv0uGSYyI09lN90NbmX/ixRNpicDSUd4Age8bfnIwlmNeUHNaH0tZv2C1 Ow2Io5KAPW5+6Bsu660ygL7h5OgknN+vvUeleMIhmtLMB/sg03u4onP/e6M0EPw/Ftqn r+Jw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Byey+oL1IfCOxjCaYQp1J8nG8dIGW6Zh+MZe1d2CaXE=; fh=RPWdO3/E50AxeOPycnbOgsyXaxn4XnWvyF1/TvM1rsE=; b=BXZ3QP9g99FckmD5PlOJWgkIp53ptHLvBL0cudUpbGct/NlqLHi2UEhONFtVUjtuz2 +A9XFzwDLQFHE2Hm4B7ry1STvBd74EydHK29thYouJu0OhodzONrAiNFAiZ1wJLCWSDz 1DrfkgN8tdMPyTb4GQ2hnEXOmndldv/RZzGrPPVjzq8fjAL6qTIRiqEurwOF4NZolen4 ZZrqK7o+XiNZKRCmadNIo7mRIB1p2sx3GLGtyhmilPnn2ArIe4gie+y8fo62rGWvnneN zXsxpOgkM4fmNKV3Vz/dE1ZI3DH4xZ1FqHqD0VlZi2nfVWvA5Mj+3Nuogziy34mGTrxA fceQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BgKIvB0k; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-36193-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36193-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j13-20020a0ce00d000000b0068191db76fdsi9010276qvk.262.2024.01.23.15.47.59 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 15:47:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36193-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BgKIvB0k; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-36193-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36193-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0AC101C25733 for <ouuuleilei@gmail.com>; Tue, 23 Jan 2024 23:47:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D64395576B; Tue, 23 Jan 2024 23:47:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="BgKIvB0k" Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B5F854279 for <linux-kernel@vger.kernel.org>; Tue, 23 Jan 2024 23:47:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706053661; cv=none; b=uc7gGU094WIJgf36NZ2JjRUCsNfgQ0BZ0WYgYOk8X0q4JYSJMb63KzqF6HxAU38wxMKVRJqeOKWyuMANKTNDzCKBOy2p3SRHDl4zCwW6p9YrQdxaLVsbRpFbke9aqZUMsff7TW8oeeIWOiCqkNezbD9KYKA+qAQk7sZEUzFAm/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706053661; c=relaxed/simple; bh=IeM0NmFIQcW0aOz8Y2fNy6aqOUIg9hjVHd/pk89b+u4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=CDyMZRBBaS8vythGrBHJfnTwOIiAp5LKW/47px6ZMIQ15bWMQsQ8rAYTpG6HYblaUM1Pbtrxb60IrpqvROogzu552qSDVSMXh/ganmeNEoKQEweopdK1RMZ8GRvF+0GBeCxurU7Ub9tYHUh9tW9XUZ41+Jg86EdMWO930l4xtpM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=BgKIvB0k; arc=none smtp.client-ip=209.85.161.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-599c38cd9f5so14752eaf.1 for <linux-kernel@vger.kernel.org>; Tue, 23 Jan 2024 15:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1706053657; x=1706658457; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Byey+oL1IfCOxjCaYQp1J8nG8dIGW6Zh+MZe1d2CaXE=; b=BgKIvB0kP8XICzMS7BlfoiQW9n+pKJTu3lCT72ATyFujZfkNyvK2FqAsBDpsnu8hqR xTW28AIETzozfCR+lHVLxZzhAVa6p4SuJypS3GuDU8ekry2h1x49fvOMQ1SLENbf+gsR QD0OI+MxBZXv+CDMam/9MTHMGGR5Q7iKJ+kAg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706053657; x=1706658457; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Byey+oL1IfCOxjCaYQp1J8nG8dIGW6Zh+MZe1d2CaXE=; b=WFfve6R20hE0Me1GXu646MY97c9+N3SsCbNtW0XQxWznw8iCohqcexytW6PV5jKl61 Wt8NefcTwtl38gk99DfTN+U875qX392Ecxa81YtsbmYdpfcoUER1CwcpsuZPRvJilCZM fO6eHEqKFGRocGhkG3IYThu+8zXbGow4SrxazjHerEJklv50nvFyqiwX0fn1gPZydNYT 1tgI2eTdxfTDA3YiJWC0KyR0e4A81oGV6s4aBdsAMo1tfxRv7L6PmTFoz4Xr4BjeRLl0 reBCsK44OdtGXI/OI3/7B+acOFOAnc70AxptLr31oarjrgV0zvjl7rgmJc1QlGOl2qHD YgCg== X-Gm-Message-State: AOJu0YyT1YYuaeK4VEPA0VZhr8umEoD7T4SM7oGgA0oE2Ih6/JXCT55X suREnjR/xh0fGb7wkbeo9Iph9jB62dORdHlkqvm3Zz/ZXJnXHbAC09sjiwqHVw== X-Received: by 2002:a05:6359:45a4:b0:176:4aae:5fe8 with SMTP id no36-20020a05635945a400b001764aae5fe8mr4864506rwb.27.1706053657198; Tue, 23 Jan 2024 15:47:37 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id t19-20020a056a0021d300b006d9be753ac7sm12184383pfj.108.2024.01.23.15.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 15:47:36 -0800 (PST) From: Kees Cook <keescook@chromium.org> To: Steve French <sfrench@samba.org> Cc: Kees Cook <keescook@chromium.org>, Nathan Chancellor <nathan@kernel.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, Nick Desaulniers <ndesaulniers@google.com>, Bill Wendling <morbo@google.com>, Justin Stitt <justinstitt@google.com>, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] smb: Work around Clang __bdos() type confusion Date: Tue, 23 Jan 2024 15:47:34 -0800 Message-Id: <20240123234731.work.358-kees@kernel.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2056; i=keescook@chromium.org; h=from:subject:message-id; bh=IeM0NmFIQcW0aOz8Y2fNy6aqOUIg9hjVHd/pk89b+u4=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlsFAWkLxmekOiD6JMUP2NjwIMzfRNEuzHrOIKn KJgVAqyQBOJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZbBQFgAKCRCJcvTf3G3A JuU0D/4r8yMRZ45F/ySlkdZZlrkq438nNjdyWMLfNMt2htoNEKNPRn09MNQuqxbSnbnts/ZfNIo cnmUeq9KPtd5hVOfp5tt9k4XQgSxWmUcJ6ppjbpqthGZ3qgrSmPnbUKc6yT/t8sotWOsK/dCR45 Uoq9+7rgk0/Wtnak25xEEuyDhKkzg/BZ7PKc1fDE7H0FH2pURSFLHct+1Wxaw8ITTSj8IVMFM+L rbtW75C4011Nx4ud1zOiqO01n9qloHWomiAWrLdtCh29hKW4WWIjaJAmrhr8sWSGlTU+303dByG xjQxfD9VxFZcjkPgQjXtu2WNp5Rw53ZsDc71Z0v5/4JS6JNYb3lbTjxuM4sX7QQzjIGUCYtVcEp iTrN73BalurOaP6BHceFb/h7fgzpxiYHeez+wUx2KceNnSJKZHe9cxVl450EKObYhXCe0mz252V kgVlZcH00bBKy5uW3uamI1O0Yjd1z3P8wabDNB5ftOkMdoO3Bl8w494D1dMWZyw9JHlI8QpikH4 pEAPi3np3UmHkcO/FRCFYOXmxWVG2eGht4qL39RAcfG3r2e1MFR+rMi5zgEBr+uf6WXVWFwPDCT XnpVxywkBgftxAv4RcanaHhm7gbn1w3TW3ZIAr4LvzM8eFuVQ8UOXLHbEnaOX0f/nPrYZjJQ/uf DC9OTKa J6Kyq2pA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788926942621064402 X-GMAIL-MSGID: 1788926942621064402 |
Series |
smb: Work around Clang __bdos() type confusion
|
|
Commit Message
Kees Cook
Jan. 23, 2024, 11:47 p.m. UTC
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>
---
fs/smb/client/cifsencrypt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Wed, 24 Jan 2024 at 00:47, Kees Cook <keescook@chromium.org> wrote: > > 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> > --- > 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 ef4c2e3c9fa6..6322f0f68a17 100644 > --- a/fs/smb/client/cifsencrypt.c > +++ b/fs/smb/client/cifsencrypt.c > @@ -572,7 +572,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; Is 'user' guaranteed to be 16-bit aligned? > } > > rc = crypto_shash_update(ses->server->secmech.hmacmd5, > -- > 2.34.1 > >
On Thu, Jan 25, 2024 at 01:19:19PM +0100, Ard Biesheuvel wrote: > On Wed, 24 Jan 2024 at 00:47, Kees Cook <keescook@chromium.org> wrote: > > > > 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> > > --- > > 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 ef4c2e3c9fa6..6322f0f68a17 100644 > > --- a/fs/smb/client/cifsencrypt.c > > +++ b/fs/smb/client/cifsencrypt.c > > @@ -572,7 +572,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; > > Is 'user' guaranteed to be 16-bit aligned? It's the first two bytes of a kmalloced address range, which I'm nearly certain will be sanely aligned, as those allocs are commonly used for holding structs, etc. -Kees
On Thu, 25 Jan 2024 at 19:00, Kees Cook <keescook@chromium.org> wrote: > > On Thu, Jan 25, 2024 at 01:19:19PM +0100, Ard Biesheuvel wrote: > > On Wed, 24 Jan 2024 at 00:47, Kees Cook <keescook@chromium.org> wrote: > > > > > > 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> > > > --- > > > 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 ef4c2e3c9fa6..6322f0f68a17 100644 > > > --- a/fs/smb/client/cifsencrypt.c > > > +++ b/fs/smb/client/cifsencrypt.c > > > @@ -572,7 +572,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; > > > > Is 'user' guaranteed to be 16-bit aligned? > > It's the first two bytes of a kmalloced address range, which I'm nearly > certain will be sanely aligned, as those allocs are commonly used for > holding structs, etc. > Ah yes, this kmalloc() was carefully hidden in the commit log :-)
diff --git a/fs/smb/client/cifsencrypt.c b/fs/smb/client/cifsencrypt.c index ef4c2e3c9fa6..6322f0f68a17 100644 --- a/fs/smb/client/cifsencrypt.c +++ b/fs/smb/client/cifsencrypt.c @@ -572,7 +572,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,