From patchwork Wed Jul 8 12:02:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 235085 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp370975ilg; Wed, 8 Jul 2020 05:04:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytPQ6tMMJh7gg7wphhvN6pbEYZiea5OigtyAqIOnXHl6nsfIdX/Fimab9efgjAi94CRMpe X-Received: by 2002:a17:906:328d:: with SMTP id 13mr52274115ejw.71.1594209843712; Wed, 08 Jul 2020 05:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594209843; cv=none; d=google.com; s=arc-20160816; b=iZuf6gjsyKTRx9Iul2a5NdaZ1Q50bplFweyx3jNoOhxMarvmMHw9OsvxpI6fiTa4kH qM3rcQazPUEYYH3yT+sN8syr71xWvQ6puQNu7KPuD3w+EBVBM2Durmx6Ng1uDsA1jN1j aWvcjuOAhMlXjCITBSsW1ZA0HVugA1sxHQUGHq82rv59CkK9rwNTiu8md48Z+SrP22P0 p6lfKDbnEBqbJKEWERn52yizKpye7D8717NUCnSrnjFWOgA6dzMIVC+Sf6M+ExNPXZ7v Dbp6uyR0MDtIunquGlX43rhORbC9TjN4j9bI1vRo2CM5SKZnGLZxevcrBh345qEi9Ur3 Xp3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sZwSMA5UIb7oM9+D5j+l12KsCqeP4op1hhjOFtyL2ps=; b=CLRJGf9HWJ5Jh/5MlCx0u9mI3YV9vZLRhLdAZCKP+rZIUoPSswOGt9bBA+YbKhGemg CnR5aPzjlRbZUiCjzcrpnJS+ukhKMqGsIi1Y7Ve6l/rdpl4KBtirfTWWtCDcOcPXvzmP i2LAvWUXtK0VVtntn4m+NEll3VjFO81TAJY02XJ3HL3TgJojPmgOcx8qwmTEr57d2ZIS RYcahOQKP1E5KnqcoY+WMmKUz0f4pq+G/dYcZOkHFP4upYoKDqSHVC4QCw/4r3SlNWeT uvPpgJaX7QittIVEuykXxT5ntbLdvP5M0SoDmr3expWGlCubL+rnU8Y+HL8Bqb8KAXvT XU2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wYVP4yTr; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v18si16679272edy.249.2020.07.08.05.04.03 for ; Wed, 08 Jul 2020 05:04:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wYVP4yTr; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728933AbgGHMEB (ORCPT ); Wed, 8 Jul 2020 08:04:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729122AbgGHMCu (ORCPT ); Wed, 8 Jul 2020 08:02:50 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A227AC08E6DC for ; Wed, 8 Jul 2020 05:02:49 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id s10so48633707wrw.12 for ; Wed, 08 Jul 2020 05:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sZwSMA5UIb7oM9+D5j+l12KsCqeP4op1hhjOFtyL2ps=; b=wYVP4yTrdIb3gPXKLBwSIe8aCHTr6bqSOLL6eZHfT2SvX4q7eX66ukJezKlb3lJqzz CMDoawaoFMDHzHmDGUCKQ6z7g/1iBWboIw+C6XhatxXuamWkI+POzEoQS8TVmKkIoHjn lDqKVIY9a1/orsCpupEsEuTM39RugV8ru6SmhANSET57A7VpxrvkQJ+SE2M2lcl2jD0b n2EXTHaIJfjG7vIhxcWdJTpZqeBDEtlI96662m8C4+2T7wWh/+pZOhrRQB1snq6rGvuy ldFuM1a634U11GCgiL8GLL8ONxQ1GezKf3CdyRcJet9PeWu1yxrI1x04pzhr6hv//mrS SmrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sZwSMA5UIb7oM9+D5j+l12KsCqeP4op1hhjOFtyL2ps=; b=i56wROMmpppp9KqXicCHXXSHR0DyMEVvFSreLC8QnQCjEHTWdTa2uAsH4WVjAgLsGg CA//nCS/S1aQr/3KDRf2gEBYioz4pSCy+Cdk5MAJGcHPzP7HAUc77BJkTl9Nb09JhMdw vqa537BLAeIPSCmgpr0ME2NSXZRC2PNlFugM+N7suaB41BJtsmtLO/iE0QODAJMiwa4x XBC8DMH5F/dcmwhOyJALajtCX7ddzubJWAjkzBkM2J/ba+Thov0VNSC3UzyKdG92turT nydf54i/D45fBX3nnSzXXGAo4dkU/5oC9Ov21JCIrAYBIfTAU05zZjpadrwK6Ihbvool lp/w== X-Gm-Message-State: AOAM5331ENgS9eybv+hYwxwccJ0dhHA8apsoPHup8i/d5bNI2vwuMhBb sx1sncPzfwo91woErbQO17pkow== X-Received: by 2002:a5d:6412:: with SMTP id z18mr56966206wru.310.1594209767822; Wed, 08 Jul 2020 05:02:47 -0700 (PDT) Received: from localhost.localdomain ([2.27.35.206]) by smtp.gmail.com with ESMTPSA id m62sm3964997wmm.42.2020.07.08.05.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 05:02:47 -0700 (PDT) From: Lee Jones To: jejb@linux.ibm.com, martin.petersen@oracle.com Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, Lee Jones , support@areca.com.tw Subject: [PATCH 16/30] scsi: arcmsr: arcmsr_hba: Make room for the trailing NULL, even if it is over-written Date: Wed, 8 Jul 2020 13:02:07 +0100 Message-Id: <20200708120221.3386672-17-lee.jones@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200708120221.3386672-1-lee.jones@linaro.org> References: <20200708120221.3386672-1-lee.jones@linaro.org> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Ensure we do not copy the final one (which is not overwitten). Fixes the following W=1 kernel build warning(s): In file included from include/linux/bitmap.h:9, from include/linux/nodemask.h:95, from include/linux/mmzone.h:17, from include/linux/gfp.h:6, from include/linux/umh.h:4, from include/linux/kmod.h:9, from include/linux/module.h:16, from drivers/scsi/arcmsr/arcmsr_hba.c:47: In function ‘strncpy’, inlined from ‘arcmsr_handle_virtual_command’ at drivers/scsi/arcmsr/arcmsr_hba.c:3055:3: include/linux/string.h:297:30: warning: ‘__builtin_strncpy’ output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation] 297 | #define __underlying_strncpy __builtin_strncpy | ^ include/linux/string.h:307:9: note: in expansion of macro ‘__underlying_strncpy’ 307 | return __underlying_strncpy(p, q, size); | ^~~~~~~~~~~~~~~~~~~~ In function ‘strncpy’, inlined from ‘arcmsr_handle_virtual_command’ at drivers/scsi/arcmsr/arcmsr_hba.c:3053:3: include/linux/string.h:297:30: warning: ‘__builtin_strncpy’ output truncated before terminating nul copying 16 bytes from a string of the same length [-Wstringop-truncation] 297 | #define __underlying_strncpy __builtin_strncpy | ^ include/linux/string.h:307:9: note: in expansion of macro ‘__underlying_strncpy’ 307 | return __underlying_strncpy(p, q, size); | ^~~~~~~~~~~~~~~~~~~~ In function ‘strncpy’, inlined from ‘arcmsr_handle_virtual_command’ at drivers/scsi/arcmsr/arcmsr_hba.c:3051:3: include/linux/string.h:297:30: warning: ‘__builtin_strncpy’ output truncated before terminating nul copying 8 bytes from a string of the same length [-Wstringop-truncation] 297 | #define __underlying_strncpy __builtin_strncpy | ^ include/linux/string.h:307:9: note: in expansion of macro ‘__underlying_strncpy’ 307 | return __underlying_strncpy(p, q, size); | ^~~~~~~~~~~~~~~~~~~~ Cc: support@areca.com.tw Signed-off-by: Lee Jones --- drivers/scsi/arcmsr/arcmsr_hba.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.25.1 diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index 1c252934409c7..5feed135eb26c 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -3031,7 +3031,7 @@ static void arcmsr_handle_virtual_command(struct AdapterControlBlock *acb, { switch (cmd->cmnd[0]) { case INQUIRY: { - unsigned char inqdata[36]; + unsigned char inqdata[37]; char *buffer; struct scatterlist *sg; @@ -3048,16 +3048,16 @@ static void arcmsr_handle_virtual_command(struct AdapterControlBlock *acb, /* ISO, ECMA, & ANSI versions */ inqdata[4] = 31; /* length of additional data */ - strncpy(&inqdata[8], "Areca ", 8); + strncpy(&inqdata[8], "Areca ", 9); /* Vendor Identification */ - strncpy(&inqdata[16], "RAID controller ", 16); + strncpy(&inqdata[16], "RAID controller ", 17); /* Product Identification */ - strncpy(&inqdata[32], "R001", 4); /* Product Revision */ + strncpy(&inqdata[32], "R001", 5); /* Product Revision */ sg = scsi_sglist(cmd); buffer = kmap_atomic(sg_page(sg)) + sg->offset; - memcpy(buffer, inqdata, sizeof(inqdata)); + memcpy(buffer, inqdata, sizeof(inqdata) - 1); sg = scsi_sglist(cmd); kunmap_atomic(buffer - sg->offset);