From patchwork Tue Jun 25 19:06:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 2779601 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 43394C0AB1 for ; Tue, 25 Jun 2013 19:06:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E84B3201B0 for ; Tue, 25 Jun 2013 19:06:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 00A0220187 for ; Tue, 25 Jun 2013 19:06:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752422Ab3FYTGc (ORCPT ); Tue, 25 Jun 2013 15:06:32 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:36158 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753136Ab3FYTGS (ORCPT ); Tue, 25 Jun 2013 15:06:18 -0400 Received: by mail-pd0-f176.google.com with SMTP id t12so1076762pdi.35 for ; Tue, 25 Jun 2013 12:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=1mOAUeLWRFPMfGH1pTcxfIw+3qDQ6BjnWToarWJmZHA=; b=FB7lNH0CSi5lxdhQCF44ms55UGWqAXZtAVbtMwgM3JhnukvbFDUl/jrOBoS2KFxyGq TqEoSDQCZNW7WuEOKYGI3zxWWYgQ88GFQxjGexhh/qXivg2ApmN+fx+BOSeDd/YUq0vn 4PZGY9DzvYfqn99JY308yLAsLbazA2OyYj+4Pi8SFsKJvB8CZifsNpLZcl3+IeD9ttO4 PTQilN9vLFGvHdVZJBeMU4yEfGmUlnlsVqm3jr+/zfT/59ZohsHSpAo20RRP/q+8oWSs 1xl6p1xsAYZUJFyFl1YV+1xyn6MpXFlhEwk7W1h85RyY+1Lce7WIvdcQtK1w+q7HzmO4 aVAA== MIME-Version: 1.0 X-Received: by 10.66.7.100 with SMTP id i4mr1064199paa.210.1372187178078; Tue, 25 Jun 2013 12:06:18 -0700 (PDT) Received: by 10.68.128.9 with HTTP; Tue, 25 Jun 2013 12:06:18 -0700 (PDT) Date: Tue, 25 Jun 2013 14:06:18 -0500 Message-ID: Subject: [PATCH] cifs: Handle big endianness in NTLM (ntlmv2) authentication [V2] From: Steve French To: shirishpargaonkar@gmail.com Cc: 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 From 157074c6c81e0fa3e7976d2bf39dd865edcce38e Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 25 Jun 2013 14:03:16 -0500 Subject: [PATCH] [CIFS] Handle big endianness in NTLM (ntlmv2) authentication 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. [To make it easier for stable (rather than require 2nd patch) fixed this patch of Shirish's to remove endian warning generated by sparse -- steve f.] Reported-by: steve Signed-off-by: Shirish Pargaonkar Cc: Reviewed-by: Jeff Layton Signed-off-by: Steve French --- fs/cifs/cifs_unicode.h | 8 ++++---- fs/cifs/cifsencrypt.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) @@ -438,7 +438,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) { @@ -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); diff --git a/fs/cifs/cifs_unicode.h b/fs/cifs/cifs_unicode.h index 4fb0974..fe8d627 100644 --- a/fs/cifs/cifs_unicode.h +++ b/fs/cifs/cifs_unicode.h @@ -327,14 +327,14 @@ 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 */ - *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 30bea6b..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;