Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp129920rdb; Thu, 8 Feb 2024 00:50:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJUhSFur3XP05+VvE+xrDaxWv0jSR9o3dZUUu08xejiydYI6gtXBf89wL7X31RjeDByHf/ X-Received: by 2002:a05:6a00:1388:b0:6e0:44ae:6eec with SMTP id t8-20020a056a00138800b006e044ae6eecmr3872799pfg.11.1707382210661; Thu, 08 Feb 2024 00:50:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707382210; cv=pass; d=google.com; s=arc-20160816; b=K/fWGVfd29FhIQVOwzz7Yw0ME0kW/eyL7RJtp4+8BW7ZjF1+eii9P3vtW7NB2Ne++y Rdy+2Tf7arUXegj8wPhfZIbgK/s8Kkrup8AD87zW7484HDAzub0OOs5xs2hEUxvSnJKk +RFf/2SCTmWkKigEaoSJWJ7b5CrI7/ds5OlveZn59NZrq+4hBFaelFQMqSIEtyCvPgxQ df5/rzT5xsbrGtKLv/htpHATYTjZlTlt96Uc1NotwgVz4pAiaAkJSrIyDnAdNeb53RTw 6vo03oaegT+LaxnVR8BDaMYgrXocCqnSHP5ResfJPyoPTI3NHsxAzgsmfJ2F1/iETZME j7Vw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=m5yualySpHoFfZEhuJjtfMU6c4zp55QaGu8LpDOCOJ8=; fh=vE6YN+zHClPh70PFj13uDIEPLjq9qn/3E3nNDM87Xus=; b=A/RFtwgH4fMqlr4ZTrwb2S+BqUe/mq50MDYjSx+G7pZTPZrAZU+yru2KvzMKnRGUvL 35uW50OriZl5uu9ffgy/skxSAoEV6HM4OsA7N1dlWh9gq+LuLSABCwiVJFWuSxlpeXFK uU1Bnglx+8jnP/lAtpPLRTkdhHoi7z6L6bWBDqKHSDYybQOft3oaZhMcfJclRp3rgbSO HGryCy/9f7qKB/Tw5W2PSV9yf1dSKTdosEZH8VhotHjhOySfD7+eXo8/mFpPUO/sUW9e Dnf3bCEhhpwUoa2ofRKHbeSmTBaZM2ebK+FHYN2MJdCa1wBa/2hevIJdbvREXI1dYqWy V6tA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=flkB5vKC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57654-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57654-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUzJ/7dO3W0eQFFw2uWdFT6hNMU3Kqg6PmWRv3FQALZy18dhMstF7cTcw7nCj+kJEYWMBitaV6keRWUe1lBtBOb5k6UYY3JdKH1j035iA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id lo11-20020a056a003d0b00b006e07224f0bdsi1849874pfb.276.2024.02.08.00.50.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:50:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57654-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=flkB5vKC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57654-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57654-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 76702284C81 for ; Thu, 8 Feb 2024 08:49:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2DFE74E27; Thu, 8 Feb 2024 08:45:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="flkB5vKC" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEF3973197; Thu, 8 Feb 2024 08:45:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707381935; cv=none; b=P5SIe56mslZgqf4RR5nwrJDU9Yk1J9q87rR60UE8q21T7MMvb5y4xU+TCseACIZnx+QIc8OcQYwFfoX+TNeDCljTXMMX4PZ4i26Ca1lP0E/+kisWZRrORX02sqxThLQsfUURFOl3zvRDO+cfvuPhSG1zKF7N1BGVRnG7VUHQZsI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707381935; c=relaxed/simple; bh=QcWkvLbuXqKsmCSILThA1RfLwMeDripObvnvLFWiq34=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fDe2rypoyWtpnB06izoJQSLDq47rc6o3uHT2waOB85hlw/BcTJUUZnfYbeUp3EsQTDq0EUcNO5rxyjbhb5E1slsTIchW3Sazk6TiYqp9A765vXVJLh0DLs7RkcMVnVY7uDeFdKCMumFBfiXUhV5RtL7qjQX2wiJkpj5Ilpu9JNs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=flkB5vKC; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A257C433C7; Thu, 8 Feb 2024 08:45:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707381935; bh=QcWkvLbuXqKsmCSILThA1RfLwMeDripObvnvLFWiq34=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=flkB5vKCBQYz/TpY0INSUaOZjllm7VrkDUbKFVgCIc3ASXj/qazrW94Yryh3JnsNX NJlgNNRcRUnXProGsUi8C60pgUya/Fr+EbvRfWtqbhO2YHZE25gcmPGLdWv0WujarZ cWbsO1A+1oAk30b0gsn/JJRxxxx7v+Ya+QMQQeTauB49jBXRvaud7rZaPGDH6v1Sm9 BshS6lbql3Lky3xkzhJ3qkII+o16i592ZP1lJ90hMoELZdsv6nOxN6LrniXK5qTPYr QEA8Dul1ponHXK0/KmqqAqeurIbVE98UbjMLuIfEWXQG0CQZgxl22y8j+OgKOr8sY/ u8EUQhEi+CBGg== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Hannes Reinecke , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 08/10] scsi: aic7xxx: aicasm: Replace snprintf() with the safer scnprintf() variant Date: Thu, 8 Feb 2024 08:44:20 +0000 Message-ID: <20240208084512.3803250-9-lee@kernel.org> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog In-Reply-To: <20240208084512.3803250-1-lee@kernel.org> References: <20240208084512.3803250-1-lee@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit There is a general misunderstanding amongst engineers that {v}snprintf() returns the length of the data *actually* encoded into the destination array. However, as per the C99 standard {v}snprintf() really returns the length of the data that *would have been* written if there were enough space for it. This misunderstanding has led to buffer-overruns in the past. It's generally considered safer to use the {v}scnprintf() variants in their place (or even sprintf() in simple cases). So let's do that. Link: https://lwn.net/Articles/69419/ Link: https://github.com/KSPP/linux/issues/105 Signed-off-by: Lee Jones --- Cc: Hannes Reinecke Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: Lee Jones Cc: linux-scsi@vger.kernel.org --- drivers/scsi/aic7xxx/aicasm/aicasm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm.c b/drivers/scsi/aic7xxx/aicasm/aicasm.c index 8d995186e557a..bc758e78d3c06 100644 --- a/drivers/scsi/aic7xxx/aicasm/aicasm.c +++ b/drivers/scsi/aic7xxx/aicasm/aicasm.c @@ -331,7 +331,7 @@ back_patch() if (cur_instr->patch_label->type != LABEL) { char buf[255]; - snprintf(buf, sizeof(buf), + scnprintf(buf, sizeof(buf), "Undefined label %s", cur_instr->patch_label->name); stop(buf, EX_DATAERR); -- 2.43.0.594.gd9cf4e227d-goog