Received: by 10.192.165.148 with SMTP id m20csp2535704imm; Sun, 22 Apr 2018 09:04:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx49hxF0fuEgiylugLIZCD1MrRsGXJVw8f81upB6UjjwGizrFLDKDyzstHNo37PAbCZ2IHxxP X-Received: by 10.98.205.69 with SMTP id o66mr17085064pfg.34.1524413045600; Sun, 22 Apr 2018 09:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524413045; cv=none; d=google.com; s=arc-20160816; b=sz9CgQv4CFJ5bQnz+V/iRUQuPKIcZbkMYeifu72VpWuXnBk06LJQDUSG349c1u30Bk yVu6x9iLzUj526AVB/SLcAthTz5lkOOdq9AZ3GaJ0EToo3M7qcGcEMT2Fv69fh4a1nhf eh5QR3XmMJHlxyoutTK/L6aikX1z3u8DP8OeCTsyUKnfVzQ/rpKg1HcOWKm3pgVG/6gP FGPHdvV/0VBjxK3ueX4092STQgIwSQCI77MmhHjEU/KZuNpPhuhugG2jd+/Q8YgN/rQp fHR9PoojgrYE8MstWuL2di8ISin/VaSA9BQRn0KZ8h1vpx8nXKAtiC3PrkKnZCZpZ+O/ jfag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=qSu2Fgnu/e/msM4SEFFy4JRf7pdb2T/0fS8GCe31MRE=; b=VagwnLryowibC0HH3/JwVeXofoG+enKeG2jIqZPRN/TYBAZQEwj/FVer7fbDi7+HB9 4OQsK5Yvhy636a+YACBUgJdk7NDAnJDx1GMjikZvtmPtBEsUxd8FO4I5Xf2zvXY4HMLt tUBrSkfMYnk1bz/vMe5h+P0gG1FcktP4FFlWnyemL6N91sG3EkUEZJxnGAqiaRp9CdXg SDXVZnSHZXFVNuAfPLrmJhIIu2z0OUymg8ubwbpFGo8St+2gJi4ZKkrSCVp5u9Kz0jod Jh1v33GlOaBwMK6Ag2zjTzFJv9iOME0LYyBIHSUTMCKix8xxIozpZ+rwwGZ4xXQshd1Z LeCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h186si8570201pge.324.2018.04.22.09.03.51; Sun, 22 Apr 2018 09:04:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754090AbeDVN6G (ORCPT + 99 others); Sun, 22 Apr 2018 09:58:06 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46038 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754064AbeDVN6B (ORCPT ); Sun, 22 Apr 2018 09:58:01 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4F2B8CD5; Sun, 22 Apr 2018 13:58:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ronnie Sahlberg , Steve French Subject: [PATCH 4.16 046/196] fix smb3-encryption breakage when CONFIG_DEBUG_SG=y Date: Sun, 22 Apr 2018 15:51:06 +0200 Message-Id: <20180422135106.454575692@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ronnie Sahlberg commit 262916bc69faf90104aa784d55e10760a4199594 upstream. We can not use the standard sg_set_buf() fucntion since when CONFIG_DEBUG_SG=y this adds a check that will BUG_ON for cifs.ko when we pass it an object from the stack. Create a new wrapper smb2_sg_set_buf() which avoids doing that particular check and use it for smb3 encryption instead. Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French CC: Stable Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smb2ops.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -2066,6 +2066,15 @@ fill_transform_hdr(struct smb2_transform inc_rfc1001_len(tr_hdr, orig_len); } +/* We can not use the normal sg_set_buf() as we will sometimes pass a + * stack object as buf. + */ +static inline void smb2_sg_set_buf(struct scatterlist *sg, const void *buf, + unsigned int buflen) +{ + sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf)); +} + static struct scatterlist * init_sg(struct smb_rqst *rqst, u8 *sign) { @@ -2080,16 +2089,16 @@ init_sg(struct smb_rqst *rqst, u8 *sign) return NULL; sg_init_table(sg, sg_len); - sg_set_buf(&sg[0], rqst->rq_iov[0].iov_base + 24, assoc_data_len); + smb2_sg_set_buf(&sg[0], rqst->rq_iov[0].iov_base + 24, assoc_data_len); for (i = 1; i < rqst->rq_nvec; i++) - sg_set_buf(&sg[i], rqst->rq_iov[i].iov_base, + smb2_sg_set_buf(&sg[i], rqst->rq_iov[i].iov_base, rqst->rq_iov[i].iov_len); for (j = 0; i < sg_len - 1; i++, j++) { unsigned int len = (j < rqst->rq_npages - 1) ? rqst->rq_pagesz : rqst->rq_tailsz; sg_set_page(&sg[i], rqst->rq_pages[j], len, 0); } - sg_set_buf(&sg[sg_len - 1], sign, SMB2_SIGNATURE_SIZE); + smb2_sg_set_buf(&sg[sg_len - 1], sign, SMB2_SIGNATURE_SIZE); return sg; }