Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp669369pxy; Thu, 22 Apr 2021 10:34:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuVLcIt6el8Emts9SWwHqhCxTRSyIUoTsKmjdREuHd4+INNmtAFdmDutDaT49FEqwLblUx X-Received: by 2002:aa7:cfd3:: with SMTP id r19mr5304834edy.317.1619112865198; Thu, 22 Apr 2021 10:34:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619112865; cv=none; d=google.com; s=arc-20160816; b=0NvMK+nOPeikj0tv/EXmETCymfFEaQkAQ85IPc4LSVzQni4+3hZxWG6lYG8JYPxZpb B9Kookjd9xRSkPPd09gRooKUcEov3ltdN9rztRHEAQ0ZG/9mAwowyxcMsFZu1ikq4ssf Z9PTqp+fXcCpVZW7DxrUF+2kMKpD2xSlSzY0X1BRNcG6c77/zLp1/5cVdRIS8GTv/3ER LcyuwGMTFYSQZhAkraoRhSSCNyk8eFgj0N89v+MnLDndVB9xxUrSrdxuobaL8rHMT3g3 X5WsKuoQwfE39qARyPcWmanJnFbEyqIhm/yKc8s5kDS2ZLiWeHTaKbzXVNZoNf5PjRhB obXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=I/YmwGgVpTKnUTlEVEqJiYxIEePo+0BELVy4bJsdeZs=; b=iMyTAJ2VykPN5p+3iw08VqZXSY0+tiuvTLsyGWedBuhPcHU1ir/t+df7e5bVTBb1R5 abH2GTyIB7UO6vv/cEjHQlm/XvwYRazWPdVS5wxLr8Jk2yd8YG6Uj6H+wDathdNIaRdS CcBM9xqCCEP/Qof1+etkk0iIfO4qfBy1TmDvS2rB/l1Ra5yhG67L9pGMVArbQIBUHJQj spZl6JPuzu6bey2oB0fUpXgxEJvWcaK2Yek3GRw1SgMpwa7jrKaNmsbjoOEct4HjjlZs Ah83nkMrfnT9AbD34P7r9bZREr6mqiWLpP2WwxgY7gCBc9RZfIWdCguTKQd82pC6z9xn A7iA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si2644193ejx.658.2021.04.22.10.34.02; Thu, 22 Apr 2021 10:34:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236716AbhDVRbL (ORCPT + 99 others); Thu, 22 Apr 2021 13:31:11 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:41150 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239023AbhDVRay (ORCPT ); Thu, 22 Apr 2021 13:30:54 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 33FFBC3842; Thu, 22 Apr 2021 17:30:19 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at emo04-pco.easydns.vpn Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo04-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ErfpVt9ZJzcN; Thu, 22 Apr 2021 17:30:18 +0000 (UTC) Received: from mail.gonehiking.org (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) by mailout.easymail.ca (Postfix) with ESMTPA id 38B7AC3757; Thu, 22 Apr 2021 17:30:11 +0000 (UTC) Received: from [192.168.1.4] (internal [192.168.1.4]) by mail.gonehiking.org (Postfix) with ESMTP id F2D1A3EE3E; Thu, 22 Apr 2021 11:30:10 -0600 (MDT) Subject: Re: [PATCH v2 2/5] scsi: BusLogic: Avoid unbounded `vsprintf' use To: "Maciej W. Rozycki" , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Christoph Hellwig , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Khalid Aziz Message-ID: <55356910-b46e-cfab-bb67-fc364ebf5740@gonehiking.org> Date: Thu, 22 Apr 2021 11:30:10 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/20/21 12:01 PM, Maciej W. Rozycki wrote: > Existing `blogic_msg' invocations do not appear to overrun its internal > buffer of a fixed length of 100, which would cause stack corruption, but > it's easy to miss with possible further updates and a fix is cheap in > performance terms, so limit the output produced into the buffer by using > `vscnprintf' rather than `vsprintf'. > > Signed-off-by: Maciej W. Rozycki > --- > Changes from v1: > > - use `vscnprintf' instead of `vsnprintf' for the correct character count. > --- > drivers/scsi/BusLogic.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > linux-buslogic-vscnprintf.diff > Index: linux-macro-ide/drivers/scsi/BusLogic.c > =================================================================== > --- linux-macro-ide.orig/drivers/scsi/BusLogic.c > +++ linux-macro-ide/drivers/scsi/BusLogic.c > @@ -3588,7 +3588,7 @@ static void blogic_msg(enum blogic_msgle > int len = 0; > > va_start(args, adapter); > - len = vsprintf(buf, fmt, args); > + len = vscnprintf(buf, sizeof(buf), fmt, args); > va_end(args); > if (msglevel == BLOGIC_ANNOUNCE_LEVEL) { > static int msglines = 0; > Acked-by: Khalid Aziz