Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp653657pxb; Fri, 16 Apr 2021 14:57:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn2RV0gMeu8u0vmxGICBgdvWdVzkkfofua89cJYVRCJIK00SVNL+ri2xieAnTp/27oFUoW X-Received: by 2002:a63:cb42:: with SMTP id m2mr980324pgi.140.1618610226256; Fri, 16 Apr 2021 14:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618610226; cv=none; d=google.com; s=arc-20160816; b=mz1NOggW3xtbadOTEA95Ju6/K/HYNmbRY4HzWJYJa0vBv+FDzzKx9tD4JDU2F1jFcC ce3EmpaVu30cXMSo37tyOwD8TybfJ4ou9tJVawGxkq1evIpTUcE01ih+geIL7fsvjucK DDRNYArMlyr+4CtSkf3zcJBV8ycltyVnAlfTpqSE8BJzM4ER4MtJP5Mv2I0usNbCUbAD 4UCkvhs0uOsTORmXjVWZFI15ffjFxmrJaxQtV1ZlN1wmgoBi+4AH6Vr6yjWDj0jVSadQ aXZcBXDYzA/LC7b7cM+mk3kHALw5zoyFJGJv2rlYRNCy5Pp4DND2B68Oc2pjJ6YHaQS8 ibCw== 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=eJXCrBIUnlzyE85xMnMHYGRBoj3xjsvvrpisSP0jhhI=; b=IFfiBa5yb69hZuU33lrvUjwf8GS0dCXznFVF6qs+6fYqT++FmTgi9SLKfhqDTlT6fU /CacBsZ3MDjX/crD+3BNG3dZ/9Blv8LUwXIuvBu/LSzdt2r4tRpuVdSnKGiybSUHUy9C fNBXSlPQIarpmLHlZ2LxsDB4RYN2FLXcGVJTrW/g8Ls5XvwjWa708jCc3J4XqtPZqeIX xZRoka6L1YxX9cjT0eZvODyyHmHnv2qoYsq4lW6MHEW2kbHKmYzJVEi/SUVsowNPIIVs 4jclpMloWxhPLj4KWH4mv947x2zRKRhuRirdwlBuerEZ6RggTNB8LAsy8IMgdsj6taqa jcRg== 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 i15si7610192pgj.431.2021.04.16.14.56.53; Fri, 16 Apr 2021 14:57:06 -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 S239483AbhDPTy6 (ORCPT + 99 others); Fri, 16 Apr 2021 15:54:58 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:46018 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236393AbhDPTy5 (ORCPT ); Fri, 16 Apr 2021 15:54:57 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 5A0F623B7E; Fri, 16 Apr 2021 19:54:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at emo06-pco.easydns.vpn Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo06-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JH0B0m67ZeMM; Fri, 16 Apr 2021 19:54:32 +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 58B7E239DB; Fri, 16 Apr 2021 19:54:25 +0000 (UTC) Received: from [192.168.1.4] (internal [192.168.1.4]) by mail.gonehiking.org (Postfix) with ESMTP id 31CA03EE4F; Fri, 16 Apr 2021 13:54:24 -0600 (MDT) Subject: Re: [PATCH 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: <1dd4eb71-05e5-6da4-bfec-01883d1ac7b3@gonehiking.org> Date: Fri, 16 Apr 2021 13:54:24 -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/14/21 4:39 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 > `vsnprintf' rather than `vsprintf'. > > Signed-off-by: Maciej W. Rozycki > --- > drivers/scsi/BusLogic.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > linux-buslogic-vsnprintf.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 = vsnprintf(buf, sizeof(buf), fmt, args); > va_end(args); > if (msglevel == BLOGIC_ANNOUNCE_LEVEL) { > static int msglines = 0; > As Maciej explained in other email that snprintf() does null-terminate the string, I think this change is fine. Acked-by: Khalid Aziz