From patchwork Tue Jun 25 18:37:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 2778651 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9C4439F245 for ; Tue, 25 Jun 2013 18:37:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A9CE2203E3 for ; Tue, 25 Jun 2013 18:37:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86311203DF for ; Tue, 25 Jun 2013 18:37:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752680Ab3FYSh0 (ORCPT ); Tue, 25 Jun 2013 14:37:26 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:43369 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752186Ab3FYShX (ORCPT ); Tue, 25 Jun 2013 14:37:23 -0400 Received: by mail-pa0-f54.google.com with SMTP id kx10so13054147pab.13 for ; Tue, 25 Jun 2013 11:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/xmw+4b9rLzgV2HCJbO+qABtGsLTAJEEL2EO/ixQM50=; b=BIArYerCTl8NfHBVh9N11x/BgY8BntDShteDOeRTb6UoZMSqo2ZHq9vN8b16+dDp9z A41mrTkI8zH4LXhEr76K0OzDeWRyUd0OWL9VlZe22aUoWELEkneeQtTL3KE91orS5dzp qFB26y56n7GCXw1I2DFXePi9qNMhpY81UInhHGl9oy48j5pB6gIv8quhkYCggI4fjrvt w6K6gjCQUOreOBMxH9+gQFIcRpjj93jpMUBsvOCBhAG5lbzMQoEs3dp40kAtsrc+AWfL TTZeCQzIXUknhhWNEOhxXld9HStVggX5dwTZyKh4GMnEnpLohQzRPsOArERyz/RqM2rM ncNw== MIME-Version: 1.0 X-Received: by 10.68.251.234 with SMTP id zn10mr242775pbc.188.1372185442901; Tue, 25 Jun 2013 11:37:22 -0700 (PDT) Received: by 10.68.128.9 with HTTP; Tue, 25 Jun 2013 11:37:22 -0700 (PDT) In-Reply-To: <20130625134929.29f7a1c3@tlielax.poochiereds.net> References: <1372175077-12846-1-git-send-email-shirishpargaonkar@gmail.com> <20130625134929.29f7a1c3@tlielax.poochiereds.net> Date: Tue, 25 Jun 2013 13:37:22 -0500 Message-ID: Subject: Re: [PATCH] cifs: Handle big endianness in NTLM (ntlmv2) authentication From: Steve French To: Jeff Layton Cc: shirishpargaonkar@gmail.com, stable@kernel.org, linux-cifs@vger.kernel.org Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To remove endian warning on build, I added this (might be easier to merge the patches) @@ -447,7 +447,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, } if (len) { - len = cifs_strtoUTF16((__le16 *)user, ses->user_name, len, nls_cp); + len = cifs_strtoUTF16(user, ses->user_name, len, nls_cp); UniStrupr(user); } else { memset(user, '\0', 2); On Tue, Jun 25, 2013 at 12:49 PM, Jeff Layton wrote: > On Tue, 25 Jun 2013 10:44:37 -0500b > shirishpargaonkar@gmail.com wrote: > >> From: Shirish Pargaonkar >> >> >> This is RH bug 970891 >> Uppercasing of username during calculation of ntlmv2 hash fails >> because UniStrupr function does not handle big endian wchars. >> >> Also fix a comment in the same code to reflect its correct usage. >> >> >> Reported-by: steve >> Signed-off-by: Shirish Pargaonkar >> Cc: >> --- >> fs/cifs/cifs_unicode.h | 2 +- >> fs/cifs/cifsencrypt.c | 2 +- >> 2 files changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/fs/cifs/cifs_unicode.h b/fs/cifs/cifs_unicode.h >> index 4fb0974..bec1137 100644 >> --- a/fs/cifs/cifs_unicode.h >> +++ b/fs/cifs/cifs_unicode.h >> @@ -334,7 +334,7 @@ UniStrupr(register wchar_t *upin) >> >> up = upin; >> while (*up) { /* For all characters */ >> - *up = UniToupper(*up); >> + *up = cpu_to_le16(UniToupper(le16_to_cpu(*up))); >> up++; >> } >> return upin; /* Return input pointer */ >> diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c >> index 71436d1..8b34a73 100644 >> --- a/fs/cifs/cifsencrypt.c >> +++ b/fs/cifs/cifsencrypt.c >> @@ -439,7 +439,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, >> return rc; >> } >> >> - /* convert ses->user_name to unicode and uppercase */ >> + /* convert ses->user_name to unicode */ >> len = ses->user_name ? strlen(ses->user_name) : 0; >> user = kmalloc(2 + (len * 2), GFP_KERNEL); >> if (user == NULL) { > > Looks correct. Nice work tracking that down! > > Reviewed-by: Jeff Layton diff --git a/fs/cifs/cifs_unicode.h b/fs/cifs/cifs_unicode.h index bec1137..fe8d627 100644 --- a/fs/cifs/cifs_unicode.h +++ b/fs/cifs/cifs_unicode.h @@ -327,10 +327,10 @@ UniToupper(register wchar_t uc) /* * UniStrupr: Upper case a unicode string */ -static inline wchar_t * -UniStrupr(register wchar_t *upin) +static inline __le16 * +UniStrupr(register __le16 *upin) { - register wchar_t *up; + register __le16 *up; up = upin; while (*up) { /* For all characters */ diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index 5c89f37..3308759 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c @@ -413,7 +413,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, int rc = 0; int len; char nt_hash[CIFS_NTHASH_SIZE]; - wchar_t *user; + __le16 *user; wchar_t *domain; wchar_t *server;