From patchwork Thu Feb 8 08:44:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 198218 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp29384dyd; Thu, 8 Feb 2024 00:48:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0aHHzvGSmqyWgFP/xZXw0k88nFrZTqyBPZGDh5bLcIbu2JpZCEivWAC4WIEzjkUH0xi00 X-Received: by 2002:a81:7604:0:b0:604:175d:734c with SMTP id r4-20020a817604000000b00604175d734cmr7772003ywc.9.1707382084853; Thu, 08 Feb 2024 00:48:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707382084; cv=pass; d=google.com; s=arc-20160816; b=NHElLwvimXjb11kckWHa9qe5xhOtuhXBRmIWfFCySts9PS+Pv/k9/4jD7Eq/6eZ3NX EC2CLaWjZOcVux2P4uYbwlPc7rDX14T6n+Q+c1oTbyd9nTYgNiEMvqdYMN5ECcwn+9Pj MdxiPxfmLtLL5+KHezneyU/xMhoegl9dn95822I9Dye4yF52LytqO8FsGLDp4MMaqaIF YE9vc02Coxquzrznm5dZkJdp8tBHvufSolvzEZqjX47ttN8nUnm308ByNoLmDyjuP9Ol bN/5KdPy4xNNMlAPsoYp9tEc4WSXQmrovYGHtpNq0DdU/Kcw+yFzwEsevZdjgRzd7C25 Zb7w== 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=vZnYln2f9Jr5Go51fq1pQjBRVBd+l+TYTcdqcPD19Fg=; fh=LPv8QpWX+qh1umJcD6gOvPu7OaUjtzW+N6oxIDolJ8M=; b=C0vYuXMYddyA/OsMj0cJHcUBpjeJQbi98JsILiZF80CGoXWhBvtab0/s+HKg8eYqiz s9lEwl6qGkCn9vz0JSULuHaDh64LpFJSqZni10w042PktFGx18e1uFi0mJJ6TWA6efrw pFjX2Zb+kY6VYyfqc+ml3o3UEvATwFTF5SmL8M1Ch+BBVKTqLcGJViSj2zNN4++kTE+n wjMe83SUrh14HVRNnzkKOq9eIxMlbmnVSvieODbIWx/VxqYcqhZKmXqeAPldgYswmpVU AIQQ7Bfel956cneWV+f0LgbANbRHiLxssg6ZgN/gJVdtqd0JeZme70woXibMOEiqAx72 fvCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KU3PEYfL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57647-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57647-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCV9FLbhaqTy8LHklcPo9p2SBOqJElVvt2UwWRkpZ5lDmjWxf9Yl2BlgAtkaRZE3QEJwblaH3xkzMKuK3dTxUTa0PJQxvA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g14-20020ac8480e000000b0042c40ef044csi2487019qtq.808.2024.02.08.00.48.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:48:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57647-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KU3PEYfL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57647-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57647-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9ED2F1C24DB3 for ; Thu, 8 Feb 2024 08:48:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B10826DCEA; Thu, 8 Feb 2024 08:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KU3PEYfL" 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 C02CC6BFD4; Thu, 8 Feb 2024 08:45:24 +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=1707381924; cv=none; b=JmzeBzGis5wlIITSZ5K6Z6J2Gv7NOhObLPPd5hiKKpLUv3rzKjm7KDse/vIU6nvakgKa4ZEoMCyiWLKOBMmJ2JhGISEr3jVufmdZoeI2ucn2x1KB7iJi1gRvtTwiQuyCXJG8g0fvDvtQyVkOOU+xNBQj38tBatTs3s3we/zqxp4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707381924; c=relaxed/simple; bh=wv1edZDay1984m0Qu877d4pMp2VycX7eTW+TWnSEgGQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=liiQnLPXN9ko834KsN6N1YGPOCWVBHCbEiFzGawf2aTbK4ps9TK4P0+jYmoZqcER6hARLjvJo0Ls7Aa2NmIPEhTqX1/Wis4ED3jaUb7JvKonklqrrRLeSk9ocLSKbVfjCnkRX3YpT4y7m9r7OrlUgbxgFVmPbRrYQWO6XbfJOyY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KU3PEYfL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A033BC433F1; Thu, 8 Feb 2024 08:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707381923; bh=wv1edZDay1984m0Qu877d4pMp2VycX7eTW+TWnSEgGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KU3PEYfLT6P4J4Z+OLwcXn2yaoKj9oYGZt/jp0y6WWO8GaVbkWKi3tykEDq7QtCPC jlsBBIPRRHQHaZ1E1EkEsy51RAFNNuuY+NPszom6UcRh30mblvuBOgH9aoSgeK9P4v KzPpm0ApERis84nYdrb/0rI5ASwBIKDrxNpCf5pGtMp9qcBVgXYXRiF+DCK4zo6yjq cNyOveBeuFvaXZGwbzKDZHTFHkDPeXrGuLZfKz3Nks1XvKAmRFiiuSJT6L8O7eapPB D1yfoYzw2DgSfYelyXJjm46z6ehLXMNmW7EUAml+pHfg3PgZWQ3vzDcCGYDpl2RJlQ 2nGJSsnDocs7w== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Adam Radford , Joel Jacobson , de Melo , Andre Hedrick Subject: [PATCH 01/10] scsi: 3w-xxxx: Trivial: Remove trailing whitespace Date: Thu, 8 Feb 2024 08:44:13 +0000 Message-ID: <20240208084512.3803250-2-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790319876772099412 X-GMAIL-MSGID: 1790319876772099412 Since 5a602de99797b ("Add .editorconfig file for basic formatting") my editor has been forced to remove trailing whitespace from any file it saves. Instead of fighting this recent kernel default, let's start chipping away at fixing the issues. Signed-off-by: Lee Jones Reviewed-by: Kees Cook --- Cc: Adam Radford Cc: Joel Jacobson Cc: de Melo Cc: Andre Hedrick --- drivers/scsi/3w-xxxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 2c0fb6da0e608..13ddc97f5a623 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -1099,7 +1099,7 @@ static int tw_initconnection(TW_Device_Extension *tw_dev, int message_credits) command_packet->request_id = request_id; command_packet->status = 0x0; command_packet->flags = 0x0; - command_packet->byte6.message_credits = message_credits; + command_packet->byte6.message_credits = message_credits; command_packet->byte8.init_connection.response_queue_pointer = 0x0; command_que_value = tw_dev->command_packet_physical_address[request_id]; From patchwork Thu Feb 8 08:44:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 198220 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp29581dyd; Thu, 8 Feb 2024 00:48:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWGQQ/v/yl//ybQBjQODc5T8tX2XzXurz67sUrUlaGMKtZSLyxt1tn6iEOOJh1VNOJAU5qVZnaZsMauqWem9/nr/Q8OAg== X-Google-Smtp-Source: AGHT+IE1jtyAg1izDKiPe2cUXgMZO4JfJpFxobCWefXC3Qh4FwnXmFAAUIUne+qZoAsrTtuTKvRe X-Received: by 2002:a17:906:4b:b0:a37:cea1:256d with SMTP id 11-20020a170906004b00b00a37cea1256dmr6657755ejg.0.1707382122835; Thu, 08 Feb 2024 00:48:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707382122; cv=pass; d=google.com; s=arc-20160816; b=HFvcoUFioR9PGVQskPZ4YR1nFq/o3JQhwEL+KPz9JU+tSiM22u7xFu7jsARzWSIzzb erMR6HILtUOI1fCWIjnBgn7Kn4P3ciHsKPOT/gwdcaa03SXjEVhByXridAdDtbRb/gZz Y3F/+npfzUWQd21PskofWRSYZVAyQjVfVKlzZ7X7dWt9qI/Pmq1BWk/biq+Fumnu943L Fgl4l2eus/baJ915O7YwwgnPWh6uOfZ5C5ttth9UJ56IO35wZZcrVWRg3Bitp7yHXhE8 RCbNvRHGEcXn/RjkvnBcIkOlEi8rz/EMWs3E3BDpIXlk1w39rbdKm9abFaPBwjALSCeu w5hA== 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=S6FwrwZJQflpfpGFiVed9niSM7LeqtmwsIVupKv1WgQ=; fh=ruFd85zxFN3g3kcCqz/B7OHDGrm7MgHdxjQsaz9fAqg=; b=yYHQe8fMGlKzXMiYpKBk1IifSYXL0yAvVj7KREYIZxqrmJRt066LpYSQv6T7LJPpd6 j+z1e3gBedBi6z5r3FbxlGVudh/IzM9XfAUZWK4N/XOOEZnTQcjFEamHRRuFnZw9PoDA Nk3a8ho6HDAC1ImpfViBfK8VjfLhQtICqQqJo9bkXmn7ZEwJsjYopazw/XRB8t3qD/Jw oEHvWuKFyzQR4XwgsrI10I5fmqIwKA5ab33KYfptf7cDPGSBRkqwOUWVCa7/gyHDiq9z 6NVaYYzG7j3zQQ5HlxEVdOggEcMQf63vq1ubmG7VRNy1IAZWiSQBCfsv658t/2sDncvt 5Zbw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pgoENIZx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57648-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57648-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWwZjZTzmdFVZBmIblcpHbtRvngLBB0yXJnO0Fy+FUuC6PBxPgI63OjtmvgkkGKptWwrnv3bC2GbZ44E8j/u0j1kG2zzA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id oq27-20020a170906cc9b00b00a385292c5easi1839337ejb.247.2024.02.08.00.48.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:48:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57648-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pgoENIZx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57648-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57648-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 478AB1F2505D for ; Thu, 8 Feb 2024 08:48:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C43796F532; Thu, 8 Feb 2024 08:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pgoENIZx" 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 93E236D1AB; Thu, 8 Feb 2024 08:45:25 +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=1707381925; cv=none; b=I/sf50vDrgytaV9UgceEUCV0V+fCZzEKYS9+/8VrKMAXX8DlK1fJdSdOB1tMaGSog9S0FTq6i5Fa2kqSZo6bsx+O1dOuTot+pBYh79/J2wehg5ZJvY+iPbztpe76lJl+LmL/t/7VU4/CxL9cNVcajiSd447CLd684vzi3eqXAGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707381925; c=relaxed/simple; bh=gBFO/9DVXohiBgwRjVJTNp1nlX5W18BmmjuIIQEzyeg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DM2nzGmYalmZEH4krDHQtXJ1iF1wJjtTxrnyc0AcvHWNPgBffSl/6BvI9bB8uurrESlIXhhyuVuTVzdcP0bvj3Ufska2Re2Gc8R9B92UT7X0hd9EzDRhDCUUDPBbINg6Jy2UuKdi+7MdH/rN0dNSDcTiKcjfz2y3jnZ9G8j70zw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pgoENIZx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F2CDC43394; Thu, 8 Feb 2024 08:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707381925; bh=gBFO/9DVXohiBgwRjVJTNp1nlX5W18BmmjuIIQEzyeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pgoENIZxGJWTBQr7a7M7KnxHYBZyDq62VZ7lmpu16WXA74+4Efb2hoqvNpFpcFZ3Y P6EYi93XV9UL3Ltc7te1XnhET3poLKQGwMYKHdPsNGyiPX/yufOFw66ZbWmMEamkkR CAFcoEPrX65+rBoWG6TMNMfEJ8yV3Vo27urGiQpjRLQ4fJuDvlM+bBVapwUbO2kb8i 50Zuk8MLN4o9bO9Fy2HWNlfk9n32B/Fk0PgFIRn9DThq1CQ4qDp7XgrTpyD/gapmT2 0dgo1HXY3KO+1zK0wn69R8jVXpVELFqMxxd0e3dlIhnG5LFgx7jHSW46ReDsjDeqcK x0g+QKJ73Fftg== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Richard Hirst Subject: [PATCH 02/10] scsi: 53c700: Trivial: Remove trailing whitespace Date: Thu, 8 Feb 2024 08:44:14 +0000 Message-ID: <20240208084512.3803250-3-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790319916709731745 X-GMAIL-MSGID: 1790319916709731745 Since 5a602de99797b ("Add .editorconfig file for basic formatting") my editor has been forced to remove trailing whitespace from any file it saves. Instead of fighting this recent kernel default, let's start chipping away at fixing the issues. Signed-off-by: Lee Jones Reviewed-by: Kees Cook --- Cc: Richard Hirst --- drivers/scsi/53c700.c | 102 +++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 85439e976143b..1aa933485719a 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -4,7 +4,7 @@ * * Copyright (C) 2001 by James.Bottomley@HansenPartnership.com **----------------------------------------------------------------------------- -** +** ** **----------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ * * The 700 is the lowliest of the line, it can only do async SCSI. * The 700-66 can at least do synchronous SCSI up to 10MHz. - * + * * The 700 chip has no host bus interface logic of its own. However, * it is usually mapped to a location with well defined register * offsets. Therefore, if you can determine the base address and the @@ -61,7 +61,7 @@ * consistent memory allocation. * * Version 2.5 - * + * * More Compatibility changes for 710 (now actually works). Enhanced * support for odd clock speeds which constrain SDTR negotiations. * correct cacheline separation for scsi messages and status for @@ -70,7 +70,7 @@ * * Version 2.4 * - * Added support for the 53c710 chip (in 53c700 emulation mode only---no + * Added support for the 53c710 chip (in 53c700 emulation mode only---no * special 53c710 instructions or registers are used). * * Version 2.3 @@ -190,7 +190,7 @@ static char *NCR_700_condition[] = { "DISCONNECT_MSG RECEIVED", "MSG_OUT", "DATA_IN", - + }; static char *NCR_700_fatal_messages[] = { @@ -260,7 +260,7 @@ NCR_700_offset_period_to_sxfer(struct NCR_700_Host_Parameters *hostdata, static inline __u8 NCR_700_get_SXFER(struct scsi_device *SDp) { - struct NCR_700_Host_Parameters *hostdata = + struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)SDp->host->hostdata[0]; return NCR_700_offset_period_to_sxfer(hostdata, @@ -416,7 +416,7 @@ NCR_700_detect(struct scsi_host_template *tpnt, int NCR_700_release(struct Scsi_Host *host) { - struct NCR_700_Host_Parameters *hostdata = + struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)host->hostdata[0]; if (hostdata->noncoherent) @@ -449,7 +449,7 @@ NCR_700_identify(int can_disconnect, __u8 lun) * Inputs : host - SCSI host */ static inline int NCR_700_data_residual (struct Scsi_Host *host) { - struct NCR_700_Host_Parameters *hostdata = + struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)host->hostdata[0]; int count, synchronous = 0; unsigned int ddir; @@ -461,16 +461,16 @@ NCR_700_data_residual (struct Scsi_Host *host) { count = ((NCR_700_readb(host, DFIFO_REG) & 0x3f) - (NCR_700_readl(host, DBC_REG) & 0x3f)) & 0x3f; } - + if(hostdata->fast) synchronous = NCR_700_readb(host, SXFER_REG) & 0x0f; - + /* get the data direction */ ddir = NCR_700_readb(host, CTEST0_REG) & 0x01; if (ddir) { /* Receive */ - if (synchronous) + if (synchronous) count += (NCR_700_readb(host, SSTAT2_REG) & 0xf0) >> 4; else if (NCR_700_readb(host, SSTAT1_REG) & SIDL_REG_FULL) @@ -500,7 +500,7 @@ sbcl_to_string(__u8 sbcl) ret[0]='\0'; for(i=0; i<8; i++) { - if((1<state != NCR_700_SLOT_FREE) /* should panic! */ printk(KERN_ERR "BUSY SLOT ON FREE LIST!!!\n"); - + hostdata->free_list = slot->ITL_forw; slot->ITL_forw = NULL; @@ -546,11 +546,11 @@ find_empty_slot(struct NCR_700_Host_Parameters *hostdata) slot->state = NCR_700_SLOT_BUSY; slot->flags = 0; hostdata->command_slot_count++; - + return slot; } -STATIC void +STATIC void free_slot(struct NCR_700_command_slot *slot, struct NCR_700_Host_Parameters *hostdata) { @@ -560,7 +560,7 @@ free_slot(struct NCR_700_command_slot *slot, if(slot->state == NCR_700_SLOT_FREE) { printk(KERN_ERR "53c700: SLOT %p is FREE!!!\n", slot); } - + slot->resume_offset = 0; slot->cmnd = NULL; slot->state = NCR_700_SLOT_FREE; @@ -654,7 +654,7 @@ NCR_700_internal_bus_reset(struct Scsi_Host *host) STATIC void NCR_700_chip_setup(struct Scsi_Host *host) { - struct NCR_700_Host_Parameters *hostdata = + struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)host->hostdata[0]; __u8 min_period; __u8 min_xferp = (hostdata->chip710 ? NCR_710_MIN_XFERP : NCR_700_MIN_XFERP); @@ -694,11 +694,11 @@ NCR_700_chip_setup(struct Scsi_Host *host) } else { NCR_700_writeb(BURST_LENGTH_8 | hostdata->dmode_extra, host, DMODE_700_REG); - NCR_700_writeb(hostdata->differential ? + NCR_700_writeb(hostdata->differential ? DIFF : 0, host, CTEST7_REG); if(hostdata->fast) { /* this is for 700-66, does nothing on 700 */ - NCR_700_writeb(LAST_DIS_ENBL | ENABLE_ACTIVE_NEGATION + NCR_700_writeb(LAST_DIS_ENBL | ENABLE_ACTIVE_NEGATION | GENERATE_RECEIVE_PARITY, host, CTEST8_REG); } else { @@ -731,7 +731,7 @@ NCR_700_chip_setup(struct Scsi_Host *host) NCR_700_writeb(ASYNC_DIV_3_0 | hostdata->dcntl_extra, host, DCNTL_REG); hostdata->sync_clock = hostdata->clock*2; hostdata->sync_clock /= 3; - + } else if(hostdata->clock > 37 && hostdata->clock <= 50) { /* sync divider 1, async divider 2 */ DEBUG(("53c700: sync 1 async 2\n")); @@ -764,7 +764,7 @@ NCR_700_chip_setup(struct Scsi_Host *host) STATIC void NCR_700_chip_reset(struct Scsi_Host *host) { - struct NCR_700_Host_Parameters *hostdata = + struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)host->hostdata[0]; if(hostdata->chip710) { NCR_700_writeb(SOFTWARE_RESET_710, host, ISTAT_REG); @@ -774,7 +774,7 @@ NCR_700_chip_reset(struct Scsi_Host *host) } else { NCR_700_writeb(SOFTWARE_RESET, host, DCNTL_REG); udelay(100); - + NCR_700_writeb(0, host, DCNTL_REG); } @@ -790,7 +790,7 @@ NCR_700_chip_reset(struct Scsi_Host *host) * ACK) so that the routine returns correctly to resume its activity * */ STATIC __u32 -process_extended_message(struct Scsi_Host *host, +process_extended_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata, struct scsi_cmnd *SCp, __u32 dsp, __u32 dsps) { @@ -816,15 +816,15 @@ process_extended_message(struct Scsi_Host *host, spi_offset(starget) = offset; spi_period(starget) = period; - + if(NCR_700_is_flag_set(SCp->device, NCR_700_DEV_PRINT_SYNC_NEGOTIATION)) { spi_display_xfer_agreement(starget); NCR_700_clear_flag(SCp->device, NCR_700_DEV_PRINT_SYNC_NEGOTIATION); } - + NCR_700_set_flag(SCp->device, NCR_700_DEV_NEGOTIATED_SYNC); NCR_700_clear_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION); - + NCR_700_writeb(NCR_700_get_SXFER(SCp->device), host, SXFER_REG); @@ -841,7 +841,7 @@ process_extended_message(struct Scsi_Host *host, resume_offset = hostdata->pScript + Ent_SendMessageWithATN; } break; - + case A_WDTR_MSG: printk(KERN_INFO "scsi%d: (%d:%d), Unsolicited WDTR after CMD, Rejecting\n", host->host_no, pun, lun); @@ -1121,7 +1121,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, SCp = scsi_host_find_tag(SDp->host, hostdata->msgin[2]); if(unlikely(SCp == NULL)) { - printk(KERN_ERR "scsi%d: (%d:%d) no saved request for tag %d\n", + printk(KERN_ERR "scsi%d: (%d:%d) no saved request for tag %d\n", host->host_no, reselection_id, lun, hostdata->msgin[2]); BUG(); } @@ -1180,7 +1180,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, slot->cmnd->cmd_len); - + } } else if(dsps == A_RESELECTED_DURING_SELECTION) { @@ -1193,10 +1193,10 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, __u8 reselection_id = NCR_700_readb(host, SFBR_REG); struct NCR_700_command_slot *slot; - + /* Take out our own ID */ reselection_id &= ~(1<this_id); - + /* I've never seen this happen, so keep this as a printk rather * than a debug */ printk(KERN_INFO "scsi%d: (%d:%d) RESELECTION DURING SELECTION, dsp=%08x[%04x] state=%d, count=%d\n", @@ -1222,7 +1222,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, slot->state = NCR_700_SLOT_QUEUED; } hostdata->cmd = NULL; - + if(reselection_id == 0) { if(hostdata->reselection_id == 0xff) { printk(KERN_ERR "scsi%d: Invalid reselection during selection!!\n", host->host_no); @@ -1233,7 +1233,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, reselection_id = hostdata->reselection_id; } } else { - + /* convert to real ID */ reselection_id = bitmap_to_number(reselection_id); } @@ -1251,7 +1251,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, * a return here will re-run the queued command slot * that may have been interrupted by the initial selection */ DEBUG((" SELECTION COMPLETED\n")); - } else if((dsps & 0xfffff0f0) == A_MSG_IN) { + } else if((dsps & 0xfffff0f0) == A_MSG_IN) { resume_offset = process_message(host, hostdata, SCp, dsp, dsps); } else if((dsps & 0xfffff000) == 0) { @@ -1304,7 +1304,7 @@ process_selection(struct Scsi_Host *host, __u32 dsp) /* Take out our own ID */ id &= ~(1<this_id); - if(id != 0) + if(id != 0) break; udelay(5); } @@ -1322,7 +1322,7 @@ process_selection(struct Scsi_Host *host, __u32 dsp) struct NCR_700_command_slot *slot = (struct NCR_700_command_slot *)SCp->host_scribble; DEBUG((" ID %d WARNING: RESELECTION OF BUSY HOST, saving cmd %p, slot %p, addr %x [%04x], resume %x!\n", id, hostdata->cmd, slot, dsp, dsp - hostdata->pScript, resume_offset)); - + switch(dsp - hostdata->pScript) { case Ent_Disconnect1: case Ent_Disconnect2: @@ -1344,7 +1344,7 @@ process_selection(struct Scsi_Host *host, __u32 dsp) case Ent_Finish2: process_script_interrupt(A_GOOD_STATUS_AFTER_STATUS, dsp, SCp, host, hostdata); break; - + default: slot->state = NCR_700_SLOT_QUEUED; break; @@ -1547,7 +1547,7 @@ NCR_700_intr(int irq, void *dev_id) /* clear all the negotiated parameters */ __shost_for_each_device(SDp, host) NCR_700_clear_flag(SDp, ~0); - + /* clear all the slots and their pending commands */ for(i = 0; i < NCR_700_COMMAND_SLOTS_PER_HOST; i++) { struct scsi_cmnd *SCp; @@ -1556,7 +1556,7 @@ NCR_700_intr(int irq, void *dev_id) if(slot->state == NCR_700_SLOT_FREE) continue; - + SCp = slot->cmnd; printk(KERN_ERR " failing command because of reset, slot %p, cmnd %p\n", slot, SCp); @@ -1620,7 +1620,7 @@ NCR_700_intr(int irq, void *dev_id) data_transfer += residual; if(data_transfer != 0) { - int count; + int count; __u32 pAddr; SGcount--; @@ -1680,7 +1680,7 @@ NCR_700_intr(int irq, void *dev_id) NCR_700_scsi_done(hostdata, SCp, DID_ERROR<<16); } - + /* NOTE: selection interrupt processing MUST occur * after script interrupt processing to correctly cope * with the case where we process a disconnect and @@ -1718,7 +1718,7 @@ NCR_700_intr(int irq, void *dev_id) DEBUG(("Attempting to resume at %x\n", resume_offset)); NCR_700_clear_fifo(host); NCR_700_writel(resume_offset, host, DSP_REG); - } + } /* There is probably a technical no-no about this: If we're a * shared interrupt and we got this interrupt because the * other device needs servicing not us, we're still going to @@ -1732,7 +1732,7 @@ NCR_700_intr(int irq, void *dev_id) * position we left off */ int j = (i + hostdata->saved_slot_position) % NCR_700_COMMAND_SLOTS_PER_HOST; - + if(hostdata->slots[j].state != NCR_700_SLOT_QUEUED) continue; if(NCR_700_start_command(hostdata->slots[j].cmnd)) { @@ -1752,7 +1752,7 @@ NCR_700_intr(int irq, void *dev_id) static int NCR_700_queuecommand_lck(struct scsi_cmnd *SCp) { - struct NCR_700_Host_Parameters *hostdata = + struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0]; __u32 move_ins; struct NCR_700_command_slot *slot; @@ -1852,7 +1852,7 @@ static int NCR_700_queuecommand_lck(struct scsi_cmnd *SCp) default: printk(KERN_ERR "53c700: Unknown command for data direction "); scsi_print_command(SCp); - + move_ins = 0; break; case DMA_NONE: @@ -1937,7 +1937,7 @@ STATIC int NCR_700_host_reset(struct scsi_cmnd * SCp) { DECLARE_COMPLETION_ONSTACK(complete); - struct NCR_700_Host_Parameters *hostdata = + struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0]; scmd_printk(KERN_INFO, SCp, @@ -1975,9 +1975,9 @@ STATIC void NCR_700_set_period(struct scsi_target *STp, int period) { struct Scsi_Host *SHp = dev_to_shost(STp->dev.parent); - struct NCR_700_Host_Parameters *hostdata = + struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)SHp->hostdata[0]; - + if(!hostdata->fast) return; @@ -1994,11 +1994,11 @@ STATIC void NCR_700_set_offset(struct scsi_target *STp, int offset) { struct Scsi_Host *SHp = dev_to_shost(STp->dev.parent); - struct NCR_700_Host_Parameters *hostdata = + struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)SHp->hostdata[0]; int max_offset = hostdata->chip710 ? NCR_710_MAX_OFFSET : NCR_700_MAX_OFFSET; - + if(!hostdata->fast) return; @@ -2031,7 +2031,7 @@ NCR_700_slave_alloc(struct scsi_device *SDp) STATIC int NCR_700_slave_configure(struct scsi_device *SDp) { - struct NCR_700_Host_Parameters *hostdata = + struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)SDp->host->hostdata[0]; /* to do here: allocate memory; build a queue_full list */ From patchwork Thu Feb 8 08:44:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 198219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp29547dyd; Thu, 8 Feb 2024 00:48:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUmVtH12DXQxM7ZJYGvcnfPB9YfIZiTHDJvUMO76HlugvdCXAHzYb24U3MB0ooGw2jhreJWo9p2UI8qvGhTmgJPpTvgfw== X-Google-Smtp-Source: AGHT+IG3yNlTHsVqd/cH8h+bJkPLdLrteBln6BC54ZjH9bVqs8dY/bCI6iM2QnT8VshEcn+3sS+V X-Received: by 2002:a17:906:568b:b0:a37:c159:60a8 with SMTP id am11-20020a170906568b00b00a37c15960a8mr5972917ejc.29.1707382117024; Thu, 08 Feb 2024 00:48:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707382117; cv=pass; d=google.com; s=arc-20160816; b=K+2oLlF5j7GD66RDnCiFFgl9bxQkwWVbQHVyb9E/drSEW7Pyp7b/IFY1+Le8li8F9u u96r64burJqecQsq3pxQnab6Jfv2VPybSwrDgxwDc5MlQ4qmQZonR5k9sc1JW3pd2isW xkTxLujntRf8rJk4GdIxJf8KQ9CpitUU6Skpl316SpEQm/oeeHuqi+pCDe7cJcgXbKpM tLLMez79tdsRj5DYJSQwqesaQnqwvDvmSn/yI2Y5HtldcAErAa1nawsQQLZSQXGFL4mH 3oMUbMMeZ5b4oUV5t3At1KtmUEG13zckGqiqheLZJG6tbL2iZxfp5mH+WSYXkkxyxJiI ZJYg== 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=rc3fAsCWezLJC68KWVm5cxEpthBi0zdruh2dyo/t5xo=; fh=WZEW32myFhsTZExiLS2a3bvVIGwlX4a+MR9MxmnDOM0=; b=0Q8V69REeoOuc5FgyRD02zu9gPRExaYc83T8hQs1+XDzIxSRm8EYmcVpc4PTNCwfEK g9doXW4bkQUt1gZGVHHlUCho5vRuwnek43SVMsGxpPgFRP5gyz4aKrUzX8+p6nblOHYk L14eqg2/Uu1q7xEx+D5GAS7fa9iVyUeT9w9yw+RFuqPtQws/zbv0AAl3FdiskjdsQEB3 NBfNW9/a/j3dpERN8xapAHu50iS+XIxvhIU9h77MyIFtubNwsNIHOn7PrBMW6QWvP2rw 2JTYGkhR1aHuQkJ6/cDRwNtBy0leV67tyjxlS8L0l4cEroPqps3FM77IDU076IxbNMul GZYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j4F5tGSr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57649-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57649-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXPk25ptUo8I1lTiTYs6Vrfw83EQ5WChljoOjbkpYDFKRXKMKqAQkf++uX+vA0GqmhfAwTvctlEKSPApyxTh087JnDdZw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lz19-20020a170906fb1300b00a3baa7d59f4si335230ejb.25.2024.02.08.00.48.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:48:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57649-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j4F5tGSr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57649-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57649-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 726B11F24FDA for ; Thu, 8 Feb 2024 08:48:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 57A116D1C4; Thu, 8 Feb 2024 08:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j4F5tGSr" 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 93B786D1AA; Thu, 8 Feb 2024 08:45:27 +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=1707381927; cv=none; b=gOj0INfpeSWwWToc24QmiiDLry8NlBiAQEY9hMeaBwKD3OKIJBil3JSbgy/7dYKYO8p/dEziCugKyqpMUkwcuK2tGUU9FZapljN+uUpUa5voYuvApDVyWFdClDtP4W3/GrnGQSy1myvwmfeKRfYLb+/Zscj92ewnAQbe5nlIai4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707381927; c=relaxed/simple; bh=kPQEC7JNk1nG41qzG8wfP+IddSOveAbpNnPvKYhI/4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DmON6N66CxrLyQPExgsS1GkXVS0XCKK33xy4iG8FEYdtMLpnT+vEytHQK9GHTkPBvhvGcHriXJL+qaOI10BvgQQFnoBnL0VsJTMeAUSxzTzLUcvCNgM6Pna2RgERmqAvpCItbmFMDWy+4q6lECHYZs8u565QrL0GpOWYnN8zK6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j4F5tGSr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B7CAC43142; Thu, 8 Feb 2024 08:45:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707381927; bh=kPQEC7JNk1nG41qzG8wfP+IddSOveAbpNnPvKYhI/4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j4F5tGSrD6ALzwj7JwdKg6N+UE+nGeZW0wCkS9VI3EkJV0qqDGxmuGDBKLgCPQXMK iXxeiPa/3/f5uaaaYz5302sabTiuOhOzBQ3WAaWPU5L3nrmQ7mLMjgeE5b6/rSNHZg iOBrDaxlgdQvVyy39RRyZJxP7KnzZULipwN0HI4I836QMXbIwPxkcnvyE3dMNuAKcv /N26Y1C+rCx8iia2dw6Yw1F7QLX21WKuKtqvIEz7S8E7EIR6k7+GxMV4cUwMjHV3Hw MG2SyFuKMKPvNh/hYb4GI3gdbqqybdhXR1QuIXORcwlsinZAWiR9G7QXQ+uigjISdb 7dioSC5x11JAg== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Finn Thain , Michael Schmitz , "James E.J. Bottomley" , "Martin K. Petersen" , drew@colorado.edu, Tnx to , linux-scsi@vger.kernel.org Subject: [PATCH 03/10] scsi: NCR5380: Replace snprintf() with the safer scnprintf() variant Date: Thu, 8 Feb 2024 08:44:15 +0000 Message-ID: <20240208084512.3803250-4-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790319910615855997 X-GMAIL-MSGID: 1790319910615855997 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 Reviewed-by: Kees Cook --- Cc: Finn Thain Cc: Michael Schmitz Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: drew@colorado.edu Cc: Tnx to Cc: linux-scsi@vger.kernel.org --- drivers/scsi/NCR5380.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index cea3a79d538e4..ea565e843c765 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -421,14 +421,14 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags) if (!hostdata->work_q) return -ENOMEM; - snprintf(hostdata->info, sizeof(hostdata->info), - "%s, irq %d, io_port 0x%lx, base 0x%lx, can_queue %d, cmd_per_lun %d, sg_tablesize %d, this_id %d, flags { %s%s%s}", - instance->hostt->name, instance->irq, hostdata->io_port, - hostdata->base, instance->can_queue, instance->cmd_per_lun, - instance->sg_tablesize, instance->this_id, - hostdata->flags & FLAG_DMA_FIXUP ? "DMA_FIXUP " : "", - hostdata->flags & FLAG_NO_PSEUDO_DMA ? "NO_PSEUDO_DMA " : "", - hostdata->flags & FLAG_TOSHIBA_DELAY ? "TOSHIBA_DELAY " : ""); + scnprintf(hostdata->info, sizeof(hostdata->info), + "%s, irq %d, io_port 0x%lx, base 0x%lx, can_queue %d, cmd_per_lun %d, sg_tablesize %d, this_id %d, flags { %s%s%s}", + instance->hostt->name, instance->irq, hostdata->io_port, + hostdata->base, instance->can_queue, instance->cmd_per_lun, + instance->sg_tablesize, instance->this_id, + hostdata->flags & FLAG_DMA_FIXUP ? "DMA_FIXUP " : "", + hostdata->flags & FLAG_NO_PSEUDO_DMA ? "NO_PSEUDO_DMA " : "", + hostdata->flags & FLAG_TOSHIBA_DELAY ? "TOSHIBA_DELAY " : ""); NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); NCR5380_write(MODE_REG, MR_BASE); From patchwork Thu Feb 8 08:44:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 198221 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp29659dyd; Thu, 8 Feb 2024 00:48:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWiWbHmH4Nz7kur6PPl5Bx4n4C0CtQy1AtBnaVH7uRko2Cbb4eDThDr4XSsFJbGi1TWoBA5sIlgEnnT6AmKzdX/KFmhXQ== X-Google-Smtp-Source: AGHT+IGiPNAYVUnNf+XqNe7q1cYc53Vi9In70AOCaX7oWJOaviiY7NC4ADTSAJAhGdvLX8cMFBfT X-Received: by 2002:a05:6214:248c:b0:68c:cc45:7981 with SMTP id gi12-20020a056214248c00b0068ccc457981mr166688qvb.16.1707382139125; Thu, 08 Feb 2024 00:48:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707382139; cv=pass; d=google.com; s=arc-20160816; b=hyocBy+dkWGRF9XCLmh63C3MoCOEIzTAXdAkdLMJREDgi7If/zx1QY+tXFxh9bgfQS IMjVqARDGm0bJanIT4pBhZJjKtG8wAQdUrq3opiC/6YjO8EY0unseCIsttJdWHAsbk2c b40nIo6XydvGcRStbdJ6vVkicCBSUTV6wardt+OpJQdDwNke4loD/kAX1Ydz2I4deU4W i9/tzixEIHLX0fVURRSHvOeSKbYgy8E21CodyRKrG4w1dPaSPkPCtBwe1RInWP2efmPU Ta/1I3P3v+sCLi+8RYDHx/IN2DFLR+dbM6NYoFSafCiL31G/WRa3Cn4TRwXXVvBuKVhZ fGWQ== 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=wKrfMKAf/RQ4uwfLT6Wt4S7atsp9vd0IUxVezxMctnI=; fh=F3HyceY4cY/UUg81gXGsUiNQddee3Om6FG9xEZ+kr4w=; b=Uf/N4iQ9zfsNzTUOrdQ8DhvWVjy8FskidmmtQmkd35JNRb3cKNnnumz9w0SpVTj+j0 2Kt0GtQWzwyMJ9TWI7Yh4GIA6ZKh8L0dshYg0FkjO+6jzQslVCpHzW6DsNYGEciUKPcp +KksiCgAMomhYQMZktE0hhhRr6iW9vKKJxuN9mKtBJndkn0zO4y0852S83hPTaYQqU4H 0ac9j89RsNC6q/mjeCLgA8CtIDPnZWg+u1OFI8um1QgPNOKIZ5thuyLScb+8xA60kPij Zl85XnZVRzjSJs11BzS25mogVV1tQK7Ly0mGPQ72ivE09DkBWRbydQgj3BpuvWZRipi+ 5Ebg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MNxilidQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57650-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57650-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWitVu75IRutTM+K5b7AfTa7YiUvBl0k0nOC3ASx4OcpoE8D0kt4Fw4mGbNf+v03q2d1+nOvxtiUtugcvWc2bZtNtxgEw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i17-20020a056214031100b0068c3a96d43dsi2750288qvu.218.2024.02.08.00.48.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:48:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57650-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MNxilidQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57650-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57650-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D58B41C24B5F for ; Thu, 8 Feb 2024 08:48:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7892A71B3E; Thu, 8 Feb 2024 08:45:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MNxilidQ" 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 061A76F50E; Thu, 8 Feb 2024 08:45:29 +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=1707381929; cv=none; b=PuxU7Pxv8ALkJrMwC54G/g7fmS8kZSFVl/gmehvS2cPweZNg4BHkWC7nRgtuw7/xCWA9pXR9nCeiCVn29ZnycXpWdcwF9uR1B1NLLrOVEWz1Ave+kGxlO+DIkIizH9SQYYmk/Sh1yQ+rYBYSYH7INXwBFGaUuXZEnj6Beg9xMcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707381929; c=relaxed/simple; bh=Z2CP+O5Bv9LbkXXAh5F8xDT7ZCfBYn4Mn2nqmn37ldw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qYDKVCT2vptlHlrH7QLbHOwo6FAmqL9d9/BxBKk+35znhSBiNNRl2NIEFDOC2sZDM0LKk72Oeqf47l/bSBBGqqD458/YszqNlXm8lH4jFFv9zMoyRv/G9c3RvwiD2ecf+L8QIx26pd3BwpaMFzyWn6JeTleHjh27OS0H93R4UZI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MNxilidQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 721C2C43394; Thu, 8 Feb 2024 08:45:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707381928; bh=Z2CP+O5Bv9LbkXXAh5F8xDT7ZCfBYn4Mn2nqmn37ldw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MNxilidQzOvdSPg22Q6azfmgMcS4E2C/rBzHDGxIpkSY0f83QhtuhCxMwfxhldgwD LLbe9tmty92PjuqBCqdNdX07LGA02ZVepLkQPlqK4Pfzcr65X1l/8FBnE2oNX+TwhX /N85C1wBdDetTek4BewQukeCTSDFf17sBn9sZBWRiYR5Z+gRMj5Hj3MrA1TOD42KQ7 UUPKr5jWJqoEIbhv7mP45UDHfVqoJYLDp0sXWqYoYuIpBghDBjSgDSC4V3w9skguj7 RzgIZMAGtlAcIXi69/qOqKosBgbeQwHSbLBRT2IpItV/g9NnoEItd1iny1Cfk6lgmP jmNIqcBhhhSdg== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , "PMC-Sierra, Inc" , linux-scsi@vger.kernel.org Subject: [PATCH 04/10] scsi: aacraid: linit: Remove snprintf() from sysfs call-backs and replace with sysfs_emit() Date: Thu, 8 Feb 2024 08:44:16 +0000 Message-ID: <20240208084512.3803250-5-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790319933860086521 X-GMAIL-MSGID: 1790319933860086521 Since snprintf() has the documented, but still rather strange trait of returning the length of the data that *would have been* written to the array if space were available, rather than the arguably more useful length of data *actually* written, it is usually considered wise to use something else instead in order to avoid confusion. In the case of sysfs call-backs, new wrappers exist that do just that. Link: https://lwn.net/Articles/69419/ Link: https://github.com/KSPP/linux/issues/105 Signed-off-by: Lee Jones Reviewed-by: Kees Cook --- Cc: Adaptec OEM Raid Solutions Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: "PMC-Sierra, Inc" Cc: linux-scsi@vger.kernel.org --- drivers/scsi/aacraid/linit.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 68f4dbcfff492..69526e2bd2e78 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -558,11 +558,9 @@ static ssize_t aac_show_raid_level(struct device *dev, struct device_attribute * struct scsi_device *sdev = to_scsi_device(dev); struct aac_dev *aac = (struct aac_dev *)(sdev->host->hostdata); if (sdev_channel(sdev) != CONTAINER_CHANNEL) - return snprintf(buf, PAGE_SIZE, sdev->no_uld_attach - ? "Hidden\n" : + return sysfs_emit(buf, sdev->no_uld_attach ? "Hidden\n" : ((aac->jbod && (sdev->type == TYPE_DISK)) ? "JBOD\n" : "")); - return snprintf(buf, PAGE_SIZE, "%s\n", - get_container_type(aac->fsa_dev[sdev_id(sdev)].type)); + return sysfs_emit(buf, "%s\n", get_container_type(aac->fsa_dev[sdev_id(sdev)].type)); } static struct device_attribute aac_raid_level_attr = { @@ -1195,10 +1193,9 @@ static ssize_t aac_show_model(struct device *device, ++cp; while (*cp == ' ') ++cp; - len = snprintf(buf, PAGE_SIZE, "%s\n", cp); + len = sysfs_emit(buf, "%s\n", cp); } else - len = snprintf(buf, PAGE_SIZE, "%s\n", - aac_drivers[dev->cardtype].model); + len = sysfs_emit(buf, "%s\n", aac_drivers[dev->cardtype].model); return len; } @@ -1214,12 +1211,11 @@ static ssize_t aac_show_vendor(struct device *device, char *cp = sup_adap_info->adapter_type_text; while (*cp && *cp != ' ') ++cp; - len = snprintf(buf, PAGE_SIZE, "%.*s\n", + len = sysfs_emit(buf, "%.*s\n", (int)(cp - (char *)sup_adap_info->adapter_type_text), sup_adap_info->adapter_type_text); } else - len = snprintf(buf, PAGE_SIZE, "%s\n", - aac_drivers[dev->cardtype].vname); + len = sysfs_emit(buf, "%s\n", aac_drivers[dev->cardtype].vname); return len; } @@ -1230,7 +1226,7 @@ static ssize_t aac_show_flags(struct device *cdev, struct aac_dev *dev = (struct aac_dev*)class_to_shost(cdev)->hostdata; if (nblank(dprintk(x))) - len = snprintf(buf, PAGE_SIZE, "dprintk\n"); + len = sysfs_emit(buf, "dprintk\n"); #ifdef AAC_DETAILED_STATUS_INFO len += scnprintf(buf + len, PAGE_SIZE - len, "AAC_DETAILED_STATUS_INFO\n"); @@ -1258,7 +1254,7 @@ static ssize_t aac_show_kernel_version(struct device *device, int len, tmp; tmp = le32_to_cpu(dev->adapter_info.kernelrev); - len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n", + len = sysfs_emit(buf, "%d.%d-%d[%d]\n", tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff, le32_to_cpu(dev->adapter_info.kernelbuild)); return len; @@ -1272,7 +1268,7 @@ static ssize_t aac_show_monitor_version(struct device *device, int len, tmp; tmp = le32_to_cpu(dev->adapter_info.monitorrev); - len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n", + len = sysfs_emit(buf, "%d.%d-%d[%d]\n", tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff, le32_to_cpu(dev->adapter_info.monitorbuild)); return len; @@ -1286,7 +1282,7 @@ static ssize_t aac_show_bios_version(struct device *device, int len, tmp; tmp = le32_to_cpu(dev->adapter_info.biosrev); - len = snprintf(buf, PAGE_SIZE, "%d.%d-%d[%d]\n", + len = sysfs_emit(buf, "%d.%d-%d[%d]\n", tmp >> 24, (tmp >> 16) & 0xff, tmp & 0xff, le32_to_cpu(dev->adapter_info.biosbuild)); return len; @@ -1296,7 +1292,7 @@ static ssize_t aac_show_driver_version(struct device *device, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", aac_driver_version); + return sysfs_emit(buf, "%s\n", aac_driver_version); } static ssize_t aac_show_serial_number(struct device *device, @@ -1322,15 +1318,13 @@ static ssize_t aac_show_serial_number(struct device *device, static ssize_t aac_show_max_channel(struct device *device, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", - class_to_shost(device)->max_channel); + return sysfs_emit(buf, "%d\n", class_to_shost(device)->max_channel); } static ssize_t aac_show_max_id(struct device *device, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", - class_to_shost(device)->max_id); + return sysfs_emit(buf, "%d\n", class_to_shost(device)->max_id); } static ssize_t aac_store_reset_adapter(struct device *device, @@ -1360,7 +1354,7 @@ static ssize_t aac_show_reset_adapter(struct device *device, tmp = aac_adapter_check_health(dev); if ((tmp == 0) && dev->in_reset) tmp = -EBUSY; - len = snprintf(buf, PAGE_SIZE, "0x%x\n", tmp); + len = sysfs_emit(buf, "0x%x\n", tmp); return len; } From patchwork Thu Feb 8 08:44:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 198222 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp29720dyd; Thu, 8 Feb 2024 00:49:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWa+8JyCc36pr0C05yYTXS+7p5FYVrwLfrApNxH+KXx5BGDSf2uULJiW42jCBD3RVumqgy1YFsbySqsn4uGWkareisK1g== X-Google-Smtp-Source: AGHT+IFjL6GdBx6uyb0moQRTCkdUYzC/RY2vGdcKWlsBAV/X0ngYz0m0SFu2L10FtOSL7u/P/rnc X-Received: by 2002:a05:620a:146b:b0:783:bd6c:90cd with SMTP id j11-20020a05620a146b00b00783bd6c90cdmr8226176qkl.19.1707382149740; Thu, 08 Feb 2024 00:49:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707382149; cv=pass; d=google.com; s=arc-20160816; b=KDoU8yiR9CROTR0XgydI/qocdUkn5fRvBACNeAEQJSigqzX+0PAbgqSzNtkm43QFmd ZXz2pD0O0qmkUH329uYO6muFgW9gQsEur4/UNOdqFL1qn1v/p7PVIH4T3IJmRA7xaTXT lsMlh3ABDwcd2MqXxdSqCPHtZ5WOoMhx0mR8BzPEjfr/pWS5BcDIqsV4XJf/FuKMP4hS b/Ee7gyCWmyYnWEq+8IbxepR7Ep88Cp3ZIdpVQ1gev6PY30QLSRkPobTJrNqp7igAd8J FbSjdRNTa5TuPYnYj+qWiJeq3wgtxKeaekMAm5wwRMrGan/z1NmFUeoEMyVOVr1xVS3E UGZA== 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=ny1xiES2tA7iZVwWz/G2MQXhuXl8bE5zRYAQeMS3tPc=; fh=zKpnmFsriq6SzhGDeliA+9Vvsg1QlaMgokR6EOlwyDU=; b=FFrwODXfOKtsXR54T3KPNJ7CW3M0NIdMh6gHcYvLnQZ9TKZe+8v+/eFy/aFjrl11FW abm7JQl1BGw0wGlW0WOuk+Zmuz7fMYpwb7Y4dVBjpTK3JNxbMhR+0FQFMKpr0mrPqz4b bD02ihQGX6cgIt6Bkz97fROlIqlAut3BrzXWG3gYeu6kl/IziJpzFLEwLZ6ZA/bLHQ5z 6nrJCJzgBk4XSjzF5kabJEr72OwB9qpswL3fmSBeUCBb36rPu9axJqzVoubhj677HisM 32sYlxbKrPrXEkT7Ll5IMzag9H6o+30U0dzcnMHdpxozRkh4hfCzoFPhBJg0PG5fWe9V wBVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oj59yN2b; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57651-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57651-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUjm0Py50Gx/qOuue1HKg9iaJvH+zcFVI9NETdu7liNcV7ig4HiFqNyGhlF3d+VslCPbQZD4jqzA4lqf4gj305EDXmTNQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s14-20020ae9f70e000000b007832941b17csi2790447qkg.173.2024.02.08.00.49.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:49:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57651-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oj59yN2b; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57651-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57651-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 870061C24C49 for ; Thu, 8 Feb 2024 08:49:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4E0171B51; Thu, 8 Feb 2024 08:45:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Oj59yN2b" 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 BD9E76F50B; Thu, 8 Feb 2024 08:45:30 +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=1707381930; cv=none; b=pRNvSYdpR6WtHe0ixlMojdHwOLJw2ek08pdHY5Gh/THdpAHUK0RktIrMgFf4ETHlQvyCHYMf0eYDQwP6ccsLhYhAPHOVHcO47NPJcyVbhzRRdxCO/7xqPIvqELZ0TfzyOcYK1d/Z+m7/6g0mXEg1AsCfNK9zopYMVjv7taI6kRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707381930; c=relaxed/simple; bh=POI6uCurjz7K0SS0gUH7C3Dj3W11IBfcHS/B+rMzmkI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MzKDprN1HdM+KjIMnES3wfAaXrhCWSlkBmRcPwwVZw9/u8IcUpH6K1vPXoVcp7QdC+67ffTUJJJoqHccse8M3njbSqeJCH8e+DF5U2RsRHSwnl5KNwOH7OQycsLSUV43WqbMp/tD/LGNY5ReMtcRSS2D43o0Hjd4mg/NbVmXItY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Oj59yN2b; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35D6BC43390; Thu, 8 Feb 2024 08:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707381930; bh=POI6uCurjz7K0SS0gUH7C3Dj3W11IBfcHS/B+rMzmkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oj59yN2bU3sJBgizsn6x4fu41c/QIs6ntSTGN6Z6dvCS6XlPGrpVhwSHlXNhm9jYA BBwC+V2MHkoX+xdCMOcKeEIgSyivDMoGE33cZyG8h5dsmw80W5L7ddNrgWnq+JOGOY hVto3EU37cOv/sJvJH7tQRWIIqxk9tMHVc0myon3u/a8NBRPOaPeZVHf3dGTA/3YYl RzeI1rmPJ/BZHLFQx9+ctK99WAV7ebDzgMq9h7lQULRsUzX6IvJzq3SpsaZ8uOUMzL TkZe+CbIPCDJmesRHbtfmWSdsLeR2vbt0ClkeMbRGCnu0VDW4/w3fLJIgkg53EXybs pXeitHIQV0JkQ== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , "PMC-Sierra, Inc" , linux-scsi@vger.kernel.org Subject: [PATCH 05/10] scsi: aacraid: linit: Replace snprintf() with the safer scnprintf() variant Date: Thu, 8 Feb 2024 08:44:17 +0000 Message-ID: <20240208084512.3803250-6-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790319945431497037 X-GMAIL-MSGID: 1790319945431497037 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: Adaptec OEM Raid Solutions Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: "PMC-Sierra, Inc" Cc: linux-scsi@vger.kernel.org --- drivers/scsi/aacraid/linit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 69526e2bd2e78..0e47d9c4cff23 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -583,7 +583,7 @@ static ssize_t aac_show_unique_id(struct device *dev, if (sdev_channel(sdev) == CONTAINER_CHANNEL) memcpy(sn, aac->fsa_dev[sdev_id(sdev)].identifier, sizeof(sn)); - return snprintf(buf, 16 * 2 + 2, + return scnprintf(buf, 16 * 2 + 2, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n", sn[0], sn[1], sn[2], sn[3], sn[4], sn[5], sn[6], sn[7], @@ -1302,13 +1302,13 @@ static ssize_t aac_show_serial_number(struct device *device, int len = 0; if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0) - len = snprintf(buf, 16, "%06X\n", + len = scnprintf(buf, 16, "%06X\n", le32_to_cpu(dev->adapter_info.serial[0])); if (len && !memcmp(&dev->supplement_adapter_info.mfg_pcba_serial_no[ sizeof(dev->supplement_adapter_info.mfg_pcba_serial_no)-len], buf, len-1)) - len = snprintf(buf, 16, "%.*s\n", + len = scnprintf(buf, 16, "%.*s\n", (int)sizeof(dev->supplement_adapter_info.mfg_pcba_serial_no), dev->supplement_adapter_info.mfg_pcba_serial_no); From patchwork Thu Feb 8 08:44:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 198223 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp29875dyd; Thu, 8 Feb 2024 00:49:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU4NWE6P0AmnEK+JB3pN4OtykQuL5mB7xGLPFFrBX1wyqdFb+RskwPjXzbbRGCgSO9gY5omrY97tilT5Nxp6EK3f48JlA== X-Google-Smtp-Source: AGHT+IGnualld4rQnFf+DrTyiQ9RNGS7rUjc8Txou0MYlu9/pBPDQiHEEkyLD3psjzMXfL3EFHzh X-Received: by 2002:a05:6214:e4b:b0:68c:8ae6:d810 with SMTP id o11-20020a0562140e4b00b0068c8ae6d810mr3602467qvc.0.1707382177574; Thu, 08 Feb 2024 00:49:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707382177; cv=pass; d=google.com; s=arc-20160816; b=dhqJTtP2Uh5bPx8ZI7LZ6I3f1yQyAU70BI3KgMohLuaURXwKkPtGC2dNeEUbeBQswH Mbx1SEffMm7u3A4QfKsubrZEL7E4v2v1LGnMrfEZbEzP+ywnYG8ys6ipZsMfafHtfnnb v2Wg8X94nAzBKe1+9x+ntYsasd6cP+0KEcjz3bjo9luDN1u6JmbWFimen1P93kAVJacw 0oa+MXBPgT/moodho4jfFC6aqjnjzxLNyhDiCX4TLbUAfQNP/6lW0QaSzkrReZNCUz+d 2rBEbVlNB7I4Jv5vv3JjbGpC3g/ooxYUhDNMokUxIASBV2LI6+Eq9NO5zXXJDGIuChIc WfTA== 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=l0L8ciZwLC3c25nf4Mp4T1utbUQPGcw4aR9MOKxycvA=; fh=vG8ABflLYnZktqLqTWKYh3lfW/mdLyXwaPFwkeyE47E=; b=OtskPa1zE69L1hgjr8NdmGEFQEHAK2TZANJDgybwTujt1HdHjKDhmMz1XU9XIBep0e hcFr48/a1SrNGKlFwYB3ziubvSqOS6WtVWF7Kpn7wHgHMyIyHD4nRG51Agpte6cQAvk4 EAZ0W5irVHgkGrT8SbEsIQxBeyeQAKK7zAEoLTq4q0brqadrHQyG75dP0mBsbR9gUYhW AuQKOkzvIuzOrEfgC9tVAj4ksRxJjuIhnleY/ybHbNZsLXuVYsR2IZlzN9mfCyTuiG0B W693wWDQCa/MXXNYPV76HtEfi9nuPkcnwkQtWg4hAJ7Kf0S+81qYVtKWIEQNDI5hZu4G gnmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JYv3wWWf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57652-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57652-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWWFWdB6Lzc/X3JOrzqtSboNFISIJ406B7vs6gFsIxXYcUF1A+2kFequAq87k9tQT+odCxLSSWM2wiLPlGVmz48CVk9WA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id di2-20020ad458e2000000b0068c405e6bc6si2868381qvb.271.2024.02.08.00.49.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:49:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57652-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JYv3wWWf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57652-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57652-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5CF951C24ECA for ; Thu, 8 Feb 2024 08:49:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F35E6E2A8; 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="JYv3wWWf" 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 7DC7371B4D; Thu, 8 Feb 2024 08:45:32 +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=1707381933; cv=none; b=mBW3B3d6pI8fMVCqMGsEJ1yCBoWlnRRpAhNhmUckW6SKupjNUijJkYQxxs39wFTbEFdyitu/mLXzWpCxKKlsk7uwoXybugGl/0xrnX8Rb2jRCG2hcjfldQEREL4NdFwbK4iihNJ4WiFjD9c+gpicmKEgotfOD9xJ2VLKEtRJx5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707381933; c=relaxed/simple; bh=PbzPd7ROc5va5PvBniGi9yT6iZxcViGR7FsGtUiYZPQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ax340BOOpImeQx4RMtE5KZ8gORbhvmtEyCceuXWAQwz3GV7QtcS30zAWS+bcRwBA5XxycrFrx15NGfQn+J5vBYHk+TDHnePeltwPi1rdUfYYr1ZqmmbiKz9P3eYhzaqEmtjPrdyiUiG2gb9k7RacFeGdEGDdUh2zy8MvBFhXLJw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JYv3wWWf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECCBEC43394; Thu, 8 Feb 2024 08:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707381932; bh=PbzPd7ROc5va5PvBniGi9yT6iZxcViGR7FsGtUiYZPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JYv3wWWfitgg/S4wiWCNHUkrl6YEq7UHvBTMANfUjrWE6exn3/m3eE4TUhkWPXN+Y rRCC2FVaAkQZqV1mHCuFnaHh1E4JzU8l38xR/iT/qXy3v/vrN2OxQVG3lrZhMJjvCx o4T+oxyev2+cxar+vWyjTi6fPg7ODFt8JIJFQLVx0HGBORpVmo99miUmNAWAEXz00J mMdCOBIQwXoI84M6/sfhzlFbrNwoOdvX9cGpijg9bbVq5vEsPeuulOXxkJeOp03YD5 OMN6+cLmOLws/InUorErs1VlC3zfGGKrspeOEalGaY6iN4L2ycp8QkTyggjGOJ6JbQ S9VvuxHfX7/Ug== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 06/10] scsi: aha1542: Replace snprintf() with the safer scnprintf() variant Date: Thu, 8 Feb 2024 08:44:18 +0000 Message-ID: <20240208084512.3803250-7-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790319974127765906 X-GMAIL-MSGID: 1790319974127765906 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 Reviewed-by: Kees Cook --- Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org --- drivers/scsi/aha1542.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 9503996c63256..b5ec7887801a5 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c @@ -772,7 +772,7 @@ static struct Scsi_Host *aha1542_hw_init(const struct scsi_host_template *tpnt, goto unregister; if (sh->dma_channel != 0xFF) - snprintf(dma_info, sizeof(dma_info), "DMA %d", sh->dma_channel); + scnprintf(dma_info, sizeof(dma_info), "DMA %d", sh->dma_channel); shost_printk(KERN_INFO, sh, "Adaptec AHA-1542 (SCSI-ID %d) at IO 0x%x, IRQ %d, %s\n", sh->this_id, base_io, sh->irq, dma_info); if (aha1542->bios_translation == BIOS_TRANSLATION_25563) From patchwork Thu Feb 8 08:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 198224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp29927dyd; Thu, 8 Feb 2024 00:49:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzMiD3KF677R1arOoxerD5lA7qvLGJtoIjD9UeVYtUMi9ce9KNxW2cSgQBKSlwh1LWqVk2 X-Received: by 2002:a17:906:d88:b0:a38:5388:80f8 with SMTP id m8-20020a1709060d8800b00a38538880f8mr3928426eji.54.1707382189030; Thu, 08 Feb 2024 00:49:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707382189; cv=pass; d=google.com; s=arc-20160816; b=Slcv6Hrr1kECdnSQWSPgB1ZBPQ7bnPQVmVXSjlvnd1uqZ2eMBgvdlHZO59w2ZXUwgb adpeWMSSREfkE0MgZRmZCbXuhYRHXTNK40ilylwWmvRtkdAy9As85yuORlbsBUZPUgDV okz1q+H8QWlQ4MbBxv8ryiRNFJNr7pEVGKMuxefX5EJys6hlaNqtdd2hNLeLCWcnqo/F rb8iD6VLYOtGz8Ru5zWOUjRfM8KIOpB6UF9dBF23/7eLM7JeSZLUzFqU//cXRiwL+jPL nHPwIfbMjQIc2LoBeLPTCavzimrGy3ZZHt7aKfar2Qs04dEQdNrYfQQrCqBB2JOaVz0C ct7Q== 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=RYDnia5mAZzPGfWDpoSxXSTN06iHnrTDoq02oMhJ2jA=; fh=2NnQNe5WKZXwBSHaYDqdZc9n0Zdq0xoiHC7DYnrhtw0=; b=d8XXVLw6elc0hJUo94jbSmP0LKW68SZdy+uQzyuo3Bd1cTxOMoE14crevIaKDAun1T O++Y7cFuuqEXGMum76sdDIAmn4uiSHM4qIiimbc3KNRZMwfYm1sHaHv0c64mjTnJG/hQ qQkZZlXi9k9Vl2F4gu8bj3q7O2ACpnx+yiLVD9wgOKeTKsFMLKcPMz87jO0cP6ayCfyZ 0YYxqC21tTz1FZxFi8WYoWiGj0icC0eDoM2epYy/8zaYlT2R8BS99lZXEgDa+bHDo85Q +bINxYhvb1igBeQPSPGjkQmEWUR7aJVE9tRBnoD61n3budXM/niNhIikGx8P7vGwt1K0 4yWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nY08ObA9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57653-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57653-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXDSfxJ5T7cc7G2JwVyIaZZ6vLqV/iBymubMSnLnhoDURXfhEmZD2gJO6FgK5OuvSfSPwvUfs3XBHn6L9WgDEkFB9yfyA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g26-20020a1709063b1a00b00a38611a83fdsi1926969ejf.558.2024.02.08.00.49.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:49:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57653-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nY08ObA9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57653-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57653-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9E89C1F250F3 for ; Thu, 8 Feb 2024 08:49:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED86C71B4D; 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="nY08ObA9" 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 355D271B58; Thu, 8 Feb 2024 08:45:33 +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=1707381934; cv=none; b=iBQOgW5CcxPy1nLu58I3GFl8OCwbtmc/Lk7VrKJqOGM4TO615LPMpiz7nOjxtAkJ2n0oH48XiBbIK79A1efMpd5q/6wK7teAiFWs9pph174Sz6K1cG2lpe3a7j7NRI1H4o0AVvuy+IsF9k0LKt/K+8clJMf+cwZIgzT4LuofA2g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707381934; c=relaxed/simple; bh=WGjy4Cm0cEOn+F+u0AjX0H2bpY30XTKx3DCJD60T9WI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KsCRccDtfe1zXF6GNw22OxvLl5aJsaA+Yi7Io+lsoXYDV2PNSH8bV34MQiH9EyJN7183KkeVgBR0hsbioF9iZLKwbASYL1eSrOugjat2XjT4sXVKo7R4/lWvzelhp+U/v0/xGoxgHu2GZZgDncsjiYSH7YUck6asCgAeMnbkqR4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nY08ObA9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69997C433F1; Thu, 8 Feb 2024 08:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707381933; bh=WGjy4Cm0cEOn+F+u0AjX0H2bpY30XTKx3DCJD60T9WI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nY08ObA9mT1r7BdDI4+PYZMJ5u34xPUmGzv18dfsF8Em8732jTJOMbNbTyoN87pF9 fc8fw9r6k5sKza1jJjXSIT5b/1FhiNa9UvFTNwCYHUVBjFyPU3R7BrVKPfOvtyyVZO to0fM5gFUcrWWbx7m5NaeEa0mxxzeRg/xWziXcGG7XbyIwkt4M4nT78CcLTMOca3e3 z6vd+9tRfdOHtqKky+XLcZDol0BzBUbyqoMoVtt52FCv/dRhqR/3z6OtBi1laxffHx BshFNRs59+jDW671Jzz16Zxz50WXaAoYuCER6s2pj42+1x8utsSZXLmnGiVE9EoBYw 5c41mD3T6eUaQ== 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 07/10] scsi: aic7xxx: aicasm: Trivial: Remove trailing whitespace Date: Thu, 8 Feb 2024 08:44:19 +0000 Message-ID: <20240208084512.3803250-8-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790319986117000979 X-GMAIL-MSGID: 1790319986117000979 Removing out of need rather than want. I wish to make proper changes to this file, but my editor is insistent on removing whitespace on save. Rather than go down the rabbit hole of debugging my editor right now, I'd rather stay productive. So, out it comes! EDIT: Found it. Looks like 5a602de99797b ("Add .editorconfig file for basic formatting") now forces editors to trim whitespace. Signed-off-by: Lee Jones Reviewed-by: Kees Cook --- Cc: Hannes Reinecke Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org --- drivers/scsi/aic7xxx/aicasm/aicasm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm.c b/drivers/scsi/aic7xxx/aicasm/aicasm.c index cd692a4c5f857..8d995186e557a 100644 --- a/drivers/scsi/aic7xxx/aicasm/aicasm.c +++ b/drivers/scsi/aic7xxx/aicasm/aicasm.c @@ -132,7 +132,7 @@ main(int argc, char *argv[]) /* Set Sentinal scope node */ sentinal = scope_alloc(); sentinal->type = SCOPE_ROOT; - + includes_search_curdir = 1; appname = *argv; regfile = NULL; @@ -553,7 +553,7 @@ output_listing(char *ifilename) if (func_values == NULL) stop("Could not malloc", EX_OSERR); - + func_values[0] = 0; /* FALSE func */ func_count--; @@ -561,13 +561,13 @@ output_listing(char *ifilename) * Ask the user to fill in the return values for * the rest of the functions. */ - - + + for (cur_func = SLIST_FIRST(&patch_functions); cur_func != NULL && SLIST_NEXT(cur_func, links) != NULL; cur_func = SLIST_NEXT(cur_func, links), func_count--) { int input; - + fprintf(stdout, "\n(%s)\n", cur_func->symbol->name); fprintf(stdout, "Enter the return value for " @@ -751,7 +751,7 @@ cs_alloc() if (new_cs == NULL) stop("Unable to malloc critical_section object", EX_SOFTWARE); memset(new_cs, 0, sizeof(*new_cs)); - + TAILQ_INSERT_TAIL(&cs_tailq, new_cs, links); return new_cs; } @@ -766,7 +766,7 @@ scope_alloc() stop("Unable to malloc scope object", EX_SOFTWARE); memset(new_scope, 0, sizeof(*new_scope)); TAILQ_INIT(&new_scope->inner_scope); - + if (SLIST_FIRST(&scope_stack) != NULL) { TAILQ_INSERT_TAIL(&SLIST_FIRST(&scope_stack)->inner_scope, new_scope, scope_links); From patchwork Thu Feb 8 08:44:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 198226 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp30152dyd; Thu, 8 Feb 2024 00:50:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgP206ors4W3ArIXuCG3wSiK76XDZM3VVQJlK5SwgscBd82+xbZ79jRGDcChITTiI8QBZ6 X-Received: by 2002:a17:902:f68f:b0:1d8:e1c0:1bb8 with SMTP id l15-20020a170902f68f00b001d8e1c01bb8mr2846907plg.27.1707382225793; Thu, 08 Feb 2024 00:50:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707382225; cv=pass; d=google.com; s=arc-20160816; b=QwtSUI4Ea3fBGZBbgxYeGAeTh4pXFi3kIrITZh/6uXXvnJZYkLHWofxf3cGOFNGER8 DZdLFGztVce1Wg3PDSy9YiXIkEiXQQ1CjA8KkCAxSSnGqzIirxopWoWQImmT+W1thRHx o7o4VfZ8Fn2UXoThkuvl2VS+y0oAg6hCCl4AyHENjae6g68Yc5Aee1VQ5nfM5fLzkNpv rsP/mqB3N57Zhtmrenwdg5HnJ8531tHwSERhC8ymEDIIKI+BtaRcbwAQL+KpbS94JIKb sFbSzXLDjSJY7aeQEPbuN81zahXzn5U1Y6pAZhT42CnHAWCHQoH/gPYgktncxa4tPiGg qRQg== 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=yUfz2Tw7N2QmDgDwlLirB+vVu0bMBELts3XPkpcNMSM=; b=mzEl+Bgu2Y31wVeJUiaITOdGzW9whmLvf8pI8dU9DSvffdicqfsFQNb7NiOHGdZsVh h+8vrhnn7bWU/kDUHQRCfvTpm7T4jVkD4tH3+1QsYuxVJBHJmniC45MlEw9Btwp6WZkC 6ZEKZjQSffr0kvlWwco9vWW8Mf/Kul/a3MZIWfvf59d+217IfMj23NwiyP0kHWFxiCmW p2LrzaOAfCeXmsVo+NHT9t0hg33QqgHJwxVq/Cbk6XgtfrnirADTBEbMzAZsco/PLAtu e/VmJRg9+BLXm+EVqwH9OLL1Rr+Hw1pBavf/lDMYcNJRKS9i1RpWm8DV3OsMrMuRPp4d lk5g==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57654-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWW+3vAmoLw+Ki7aFFvQhkhPNUY7tc/FSOofrAiy3aLZOsVuhAuqofAoiWFP9SguAXVI54LZbGKzWKaOBpYEhld7pTTaQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id im23-20020a170902bb1700b001d953f4021csi3381246plb.196.2024.02.08.00.50.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:50:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57654-ouuuleilei=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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57654-ouuuleilei=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 6B759281FDE for ; Thu, 8 Feb 2024 08:50:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8D6E74E31; Thu, 8 Feb 2024 08:45:38 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790320024491996681 X-GMAIL-MSGID: 1790320024491996681 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 Reviewed-by: Kees Cook --- 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); From patchwork Thu Feb 8 08:44:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 198225 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp30137dyd; Thu, 8 Feb 2024 00:50:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/Aiir1+UluPQpOHYUgRUPvfKFkeXkMmab8me9sS/fme9oh9xg+6NJOyzHGyhfU5/GTl2e X-Received: by 2002:a17:906:6d4f:b0:a3b:a489:2b54 with SMTP id a15-20020a1709066d4f00b00a3ba4892b54mr887303ejt.34.1707382223547; Thu, 08 Feb 2024 00:50:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707382223; cv=pass; d=google.com; s=arc-20160816; b=K8kHT7ytPPCVk4UqELDerFmb3RHUW7ZVdbQPQWq+U8XfYQjpIIx6T/VVXrjp736HPf 8gYuCleVUywwOB6RzvD9RBNBnki43TuDRs9E3Sjql0X5HYzza1o8VIIqvhAvWMEYnn6u oO/d1PIdtQ3KxJQPpWCsZ/sD/6vTUpkzDgozxlpKRcfyiSfC2r1RhZC6gH3Tjr3zI5eB KNzxmgOt5vTCatdFBG+eT/SAhJagl3P0d2OsRZUrXpCXX7I+INZKLLJylk+XK+60ve8G Z132ykSXwWqYYi4hKPlZ0S/YiXQj1aEODEBc4ssIby7DyERsyxIQJBr/67u/8Zfjti1A tfmA== 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=kKDoKRMxVZ3NchU/uxigCs7qj01UcQxlRGmJ/+pW4GU=; fh=l3dfug1ptwYOkq8iHvabEhGOuWwuMlOi6z2RGQs1wTg=; b=Lr2DZdSlZ8cZTvmehfdSCcmrndkzM6ZoD0QxTejk8pwRtBvtRil6fa3fxTxQMLzs9m hPXX311/RKRrcG9dLyMb5gdhW30c69Te6Bs8CZAh6DlblCUNcmLz/bGY2NqzFBaZLR/c AiFV97CmNmTid9tXXlpDYNJMbeC1w4jz7ozVjF8VZbaQ5KTJlu7l4t5v6Bj/cpRNAE11 D7rtuZdEslX70O9aQCXRS/6pnekyIJo8dy+hzk5xEAcAXz6x7A8d4Tb7DME5S4AlGCc2 +PZtFfYybYiUafwiC8r+M85jEcoSM5mla2I1QlMBOcVMwObQjnzcnds4o0GK4ccMLWUA CNRg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J+AyC1IJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57655-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57655-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWG/nis+bQmu7HeD3EWNHSfitUftnizEKrVtEZpl3uST5bm3ulHBsqPfKPsGXUiacz8Ks3D+n1Eql7K7PRxZvBnabAW0w== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id va12-20020a17090711cc00b00a3861826fbdsi1882289ejb.1017.2024.02.08.00.50.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:50:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57655-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J+AyC1IJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57655-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57655-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2AD0B1F25092 for ; Thu, 8 Feb 2024 08:50:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6016171B58; Thu, 8 Feb 2024 08:45:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="J+AyC1IJ" 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 702AC76026; Thu, 8 Feb 2024 08:45:37 +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=1707381937; cv=none; b=hhjbRqxB40t4BvmfYSTN/D582LT6/uvh1HD7WeffP0D25EX09pQCL2JEtu1YJisjeBw0fqVKrmi0sdTUIvnFm0HlEkF796H/UA1n012sFuXhI5lqenfaZuBXuN39AhzFOVBBCiMb+tdjAP4Y5YL88fnK+peuEt8eDBoQ7135rTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707381937; c=relaxed/simple; bh=lMT5ds09tPKnvt5Z0XoIWL0MTp/63mQAtpaTLMS6Bp8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FvMA2J2qSZEdw0hZErbGteyrLrWJhalxQRYfJk6vLMB/tkvzTBTgddfdaBOeoH/wcJOfc+imY0JRhPeg8auWB2BclF9yYdK7Mp5N3R/fziVbzt2Mn1w16QwIv59GE2rcdFpaPLBvA037rIPF0vM0VZxqjZnIXc8IxjVibrYNB9c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J+AyC1IJ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CEFEC43399; Thu, 8 Feb 2024 08:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707381937; bh=lMT5ds09tPKnvt5Z0XoIWL0MTp/63mQAtpaTLMS6Bp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J+AyC1IJGKuoOUKM5zUpx63JFqLmK3QCBMLMNCt2a87u7tEU2INr5mCviZhYP0aY4 jE+FZIXhMhOtL29JNAm/HuvP83u7gFMWthjuqXFRePQ2ccCLhWzb0P61wzQQGncLvY Wq+d7cvzmlMBf3QGUprdbxancpf64qlSJ+G+LbUosm8B8m6hhaqb0ZG2qC7L2uwgBa jRFgq2L8l84PNrXWXGck3eqqxs1MuTR8RRwAPmgdmAUOJIZzh8bixKKsR47yefhpKQ FS+pCBiRWxQMQxdOlSMZvgoXMhzs/81weorCR11zGzY79j2ctTvt+MoDfrj5gcDC09 +oCg4Lw/QFfYA== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" , John Garry , Luben Tuikov , linux-scsi@vger.kernel.org Subject: [PATCH 09/10] scsi: aic94xx: Remove snprintf() from sysfs call-backs and replace with sysfs_emit() Date: Thu, 8 Feb 2024 08:44:21 +0000 Message-ID: <20240208084512.3803250-10-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790320022385807681 X-GMAIL-MSGID: 1790320022385807681 Since snprintf() has the documented, but still rather strange trait of returning the length of the data that *would have been* written to the array if space were available, rather than the arguably more useful length of data *actually* written, it is usually considered wise to use something else instead in order to avoid confusion. In the case of sysfs call-backs, new wrappers exist that do just that. Link: https://lwn.net/Articles/69419/ Link: https://github.com/KSPP/linux/issues/105 Signed-off-by: Lee Jones Reviewed-by: Kees Cook --- Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: John Garry Cc: Luben Tuikov Cc: linux-scsi@vger.kernel.org --- drivers/scsi/aic94xx/aic94xx_init.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c index 8a3340d8d7ad4..c976e4b77c71e 100644 --- a/drivers/scsi/aic94xx/aic94xx_init.c +++ b/drivers/scsi/aic94xx/aic94xx_init.c @@ -264,8 +264,7 @@ static ssize_t asd_show_dev_rev(struct device *dev, struct device_attribute *attr, char *buf) { struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); - return snprintf(buf, PAGE_SIZE, "%s\n", - asd_dev_rev[asd_ha->revision_id]); + return sysfs_emit(buf, "%s\n", asd_dev_rev[asd_ha->revision_id]); } static DEVICE_ATTR(aic_revision, S_IRUGO, asd_show_dev_rev, NULL); @@ -273,7 +272,7 @@ static ssize_t asd_show_dev_bios_build(struct device *dev, struct device_attribute *attr,char *buf) { struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", asd_ha->hw_prof.bios.bld); + return sysfs_emit(buf, "%d\n", asd_ha->hw_prof.bios.bld); } static DEVICE_ATTR(bios_build, S_IRUGO, asd_show_dev_bios_build, NULL); @@ -281,7 +280,7 @@ static ssize_t asd_show_dev_pcba_sn(struct device *dev, struct device_attribute *attr, char *buf) { struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); - return snprintf(buf, PAGE_SIZE, "%s\n", asd_ha->hw_prof.pcba_sn); + return sysfs_emit(buf, "%s\n", asd_ha->hw_prof.pcba_sn); } static DEVICE_ATTR(pcba_sn, S_IRUGO, asd_show_dev_pcba_sn, NULL); @@ -452,7 +451,7 @@ static ssize_t asd_show_update_bios(struct device *dev, if (asd_ha->bios_status != FLASH_IN_PROGRESS) asd_ha->bios_status = FLASH_OK; - return snprintf(buf, PAGE_SIZE, "status=%x %s\n", + return sysfs_emit(buf, "status=%x %s\n", flash_error_table[i].err_code, flash_error_table[i].reason); } @@ -937,7 +936,7 @@ static int asd_scan_finished(struct Scsi_Host *shost, unsigned long time) static ssize_t version_show(struct device_driver *driver, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", ASD_DRIVER_VERSION); + return sysfs_emit(buf, "%s\n", ASD_DRIVER_VERSION); } static DRIVER_ATTR_RO(version); From patchwork Thu Feb 8 08:44:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 198227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp30195dyd; Thu, 8 Feb 2024 00:50:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWUAH+7jV3CQii4x1ClW+wCCe924auAFUvzQHJs/182jLupmYnRm3ILRoymcURmkHFMNKUlZ1Px+A9x1tprx1J7Lvma3Q== X-Google-Smtp-Source: AGHT+IHwpbsrGp2LEfljzH9EoR6eyQShazMtudVeZrjvjwMzkh241v1vmnrvnx/7hRj3sYLjzwoh X-Received: by 2002:a17:906:3781:b0:a35:356a:f601 with SMTP id n1-20020a170906378100b00a35356af601mr6104424ejc.34.1707382232367; Thu, 08 Feb 2024 00:50:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707382232; cv=pass; d=google.com; s=arc-20160816; b=Xud2Q6M41QGSPLkSNPehJ7EeK75xMQ5v5Xo8WkXmVLZApL7eT51Q7nAICj6ZsNYpN1 +TCRZgMQtyqXt1sTatUBbtICacmOa4DNCTEPhj+r8uQHm0mhp6pqjWpzTIHEGenA6vCJ gAntCzeMEx5k86mXsCnS8UoNrjXInTRmpi8hWL6txz/4Bhm04I5NEPIqFpWT/Q8Z1HJv /4Z7hJeMR2eRnXM8LnNbFsgiNHzYtz9c3m70AGMf6FZsSSfAn70/iIQFO9id+ysZAg2K 4S4nlplWEDoluMHsCfCsgJvelsLgHNofwxsyE3Nkli/URLPAQ7jq8LDyyV8AriExmtY0 8NnA== 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=ouG5/6QWgY5hhonhTipC1Ga/LRF52tfc4TAum/aLP6w=; fh=BpqF5Cb0Y2Y/cjxHfHXxNzQ5pRkRfZsRy8u3ZEhWSys=; b=CJZgLu+ejWVO6/7EpYFPDQkr0wJ3+6gHfng0NclpjWp0HORyGdIhT1ITHFmy5U3Oi5 Wz9Z1t0XSgmxRbeX3UvIzm4XWzrcrkWnaKOIPlLGfN5egZK7d58Ib+K3xBWOz6goZK5m uzqaqfrb+nVRT0h5gFM0OWiY7zBCPyYTpGCUk/qIIhz6ywRcNQnfEBT7fnQB6fhXPMII ZFsSiYWK8hvabrtC26Q8ythqLNSOb35HrVVp/T1BnAb4CqM8yG4PCjYa3ltXSKDZ8wlc gBMwcBVp9WjQOvlNkmQxU4q5A04yaqMiiuuiRQbY9GgZixDZKF2Rn6dDo8bK5BeCXpaN Ixcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LOEmzCzg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57656-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57656-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCU6HmN466wq3UOtctO/oG0HNrqyxKXzDtH57I/y/HlYI0sBlHBfTJgHdu7O2l3XmHV+W52BUkix6Jd8+ceco9NCW+fPUg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id va12-20020a17090711cc00b00a3861826fbdsi1882289ejb.1017.2024.02.08.00.50.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:50:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57656-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LOEmzCzg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57656-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57656-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id B48131F2504A for ; Thu, 8 Feb 2024 08:50:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6B656D1D5; Thu, 8 Feb 2024 08:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LOEmzCzg" 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 C056E74E2A; Thu, 8 Feb 2024 08:45:38 +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=1707381938; cv=none; b=XvpprrpUgadia5CVM1NSfbgfarfEg2WH3gAFQsQQQ/RMtNqLK9CMP09m9oZfyaSzCDTQUCw8UC82r1TDvo6ejO9arz3C8Uah3zWxuBqIEkbYXwvjwKav66MOquzOCS5knTWGAjwg0A3uhAGOkQe7A2LOs2rOJq/r2Vc/UI7eNyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707381938; c=relaxed/simple; bh=qmbHfN/f8YgSLjrFL2hPNhuDBX1LYqccIkoXslfVQ1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rRrK3aks/8IQLgXXaD9OhBbxitdQf8znf7J0WXTZz27P6djHe7VX4KzeiHhR87JYXwX1iZZSF+Is6sNxEnKZXHVoI+GYwbuTYKZzGCT5Dhu4aNM3vUk2t7bYT/pDC7+ZNkQql88yrraDSq3eNIvbqzcB3qvuj7z64a8IhLnjIv0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LOEmzCzg; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E6F1C433B1; Thu, 8 Feb 2024 08:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707381938; bh=qmbHfN/f8YgSLjrFL2hPNhuDBX1LYqccIkoXslfVQ1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LOEmzCzgxxjlFn+1XmC8QqhwKpmjJFNJilrBiaaa5pcylqyqEEg8E4wf2GwOCaUU9 fegkkGzEwK1cmtc+QpLPwbHg96F2C7Ie9tVls5Ah66PKkdfldLMY9XXQaNy+MNK3dQ TzGwHdq/qNrgG/Cr+pjuxFRRm9NPhHiumqhc+QF3WTcRiCnwaCytOg2fObaVSrBmY3 ox5G+HNe7WQOAeVbl057M+XYrRXShmn+DlS41O5L/tlxnFXemnFTuln958Q11MuV1e mbJcvIB59oJizF3UieAN2VSxFeZK+qYR8l+ueWh663SQ/ZO+NG9tBSATUUryXlpqrB XKnFiJpyUgDUQ== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" , support@areca.com.tw, linux-scsi@vger.kernel.org Subject: [PATCH 10/10] scsi: arcmsr: Remove snprintf() from sysfs call-backs and replace with sysfs_emit() Date: Thu, 8 Feb 2024 08:44:22 +0000 Message-ID: <20240208084512.3803250-11-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790320031809253581 X-GMAIL-MSGID: 1790320031809253581 Since snprintf() has the documented, but still rather strange trait of returning the length of the data that *would have been* written to the array if space were available, rather than the arguably more useful length of data *actually* written, it is usually considered wise to use something else instead in order to avoid confusion. In the case of sysfs call-backs, new wrappers exist that do just that. Link: https://lwn.net/Articles/69419/ Link: https://github.com/KSPP/linux/issues/105 Signed-off-by: Lee Jones Reviewed-by: Kees Cook --- Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: support@areca.com.tw Cc: linux-scsi@vger.kernel.org --- drivers/scsi/arcmsr/arcmsr_attr.c | 40 ++++++++----------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c index baeb5e7956902..c430c835503be 100644 --- a/drivers/scsi/arcmsr/arcmsr_attr.c +++ b/drivers/scsi/arcmsr/arcmsr_attr.c @@ -258,9 +258,7 @@ static ssize_t arcmsr_attr_host_driver_version(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, - "%s\n", - ARCMSR_DRIVER_VERSION); + return sysfs_emit(buf, "%s\n", ARCMSR_DRIVER_VERSION); } static ssize_t @@ -270,9 +268,7 @@ arcmsr_attr_host_driver_posted_cmd(struct device *dev, struct Scsi_Host *host = class_to_shost(dev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - atomic_read(&acb->ccboutstandingcount)); + return sysfs_emit(buf, "%4d\n", atomic_read(&acb->ccboutstandingcount)); } static ssize_t @@ -282,9 +278,7 @@ arcmsr_attr_host_driver_reset(struct device *dev, struct Scsi_Host *host = class_to_shost(dev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->num_resets); + return sysfs_emit(buf, "%4d\n", acb->num_resets); } static ssize_t @@ -294,9 +288,7 @@ arcmsr_attr_host_driver_abort(struct device *dev, struct Scsi_Host *host = class_to_shost(dev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->num_aborts); + return sysfs_emit(buf, "%4d\n", acb->num_aborts); } static ssize_t @@ -306,9 +298,7 @@ arcmsr_attr_host_fw_model(struct device *dev, struct device_attribute *attr, struct Scsi_Host *host = class_to_shost(dev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%s\n", - acb->firm_model); + return sysfs_emit(buf, "%s\n", acb->firm_model); } static ssize_t @@ -319,9 +309,7 @@ arcmsr_attr_host_fw_version(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%s\n", - acb->firm_version); + return sysfs_emit(buf, "%s\n", acb->firm_version); } static ssize_t @@ -332,9 +320,7 @@ arcmsr_attr_host_fw_request_len(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->firm_request_len); + return sysfs_emit(buf, "%4d\n", acb->firm_request_len); } static ssize_t @@ -345,9 +331,7 @@ arcmsr_attr_host_fw_numbers_queue(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->firm_numbers_queue); + return sysfs_emit(buf, "%4d\n", acb->firm_numbers_queue); } static ssize_t @@ -358,9 +342,7 @@ arcmsr_attr_host_fw_sdram_size(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->firm_sdram_size); + return sysfs_emit(buf, "%4d\n", acb->firm_sdram_size); } static ssize_t @@ -371,9 +353,7 @@ arcmsr_attr_host_fw_hd_channels(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->firm_hd_channels); + return sysfs_emit(buf, "%4d\n", acb->firm_hd_channels); } static DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL);