From patchwork Tue Jul 25 19:51:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9863105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 386DA6038C for ; Tue, 25 Jul 2017 19:51:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3018F28708 for ; Tue, 25 Jul 2017 19:51:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24F062870E; Tue, 25 Jul 2017 19:51:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 676FE28714 for ; Tue, 25 Jul 2017 19:51:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753441AbdGYTva (ORCPT ); Tue, 25 Jul 2017 15:51:30 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:17886 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753266AbdGYTv1 (ORCPT ); Tue, 25 Jul 2017 15:51:27 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v6PJpKCx017632 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jul 2017 19:51:21 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v6PJpJbr020688 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Jul 2017 19:51:20 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v6PJpJw4032075; Tue, 25 Jul 2017 19:51:19 GMT Received: from mwanda (/197.254.35.146) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 25 Jul 2017 12:51:18 -0700 Date: Tue, 25 Jul 2017 22:51:10 +0300 From: Dan Carpenter To: Adaptec OEM Raid Solutions , Mahesh Rajashekhara Cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 2/2] scsi: aacraid: Off by one NUL terminator Message-ID: <20170725195110.uwrzzkzvrbfqv7ld@mwanda> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170725194955.dd4g6msevoesty4t@mwanda> X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170609 (1.8.3) X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We're putting a NUL terminator one character beyond the end of the struct and that's obviously wrong. On the other hand, I'm not positive this is the correct fix. This change was added deliberately and was mentioned in the changlog of commit b836439faf04 ("aacraid: 4KB sector support"). The relevant section is "Also fix up a name truncation problem". Can someone review this code and figure out the right thing to do? Fixes: b836439faf04 ("aacraid: 4KB sector support") Signed-off-by: Dan Carpenter diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 4591113c49de..22c7461f65c9 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -549,7 +549,7 @@ static void get_container_name_callback(void *context, struct fib * fibptr) if ((le32_to_cpu(get_name_reply->status) == CT_OK) && (get_name_reply->data[0] != '\0')) { char *sp = get_name_reply->data; - sp[sizeof(((struct aac_get_name_resp *)NULL)->data)] = '\0'; + sp[sizeof(((struct aac_get_name_resp *)NULL)->data) - 1] = '\0'; while (*sp == ' ') ++sp; if (*sp) {