Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp770pxy; Tue, 20 Apr 2021 11:02:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQRgXe2cWSjwtNt3r+beI3u8Kp8Pc6mAYKGhg3gMZsqy/mWLa2uMcT+cLGAGo8O/f6zaFS X-Received: by 2002:a17:90a:bb02:: with SMTP id u2mr6315170pjr.175.1618941767164; Tue, 20 Apr 2021 11:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618941767; cv=none; d=google.com; s=arc-20160816; b=n2UP/fP2jxGuDkT7R1ySHSfCUARZNXUd4pHVk5Xjb5jfHmpgmj9LQAWQN/LAA56e20 9htQP+DFdCxcr2ab/rWVDOWDiLzwHzooTMSAKAIjLOWvt3nN+QwqeloRamJYFDTSpyq6 7Vh7RVBE0e+0SKoAZxkTf4PlVzbfX9ABmuF1BKcf/lGwejvDRpeMSf/I9HY28XfE4+oA 0AXhkNivlKQR1h3qlm0Ox2QwSRv+bpm7GoJm6SJJDODVUNP3V5sPlWM5EI5Zsnq7z2ju 90N9oc5nmz3+Fh1wLrQ/YWS+1vtOzkkieo/T6hGYsP/7vxoWnS3SRmM26lJDwkAb6w2s 7PXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=se6K4pv8xIGgzgyDju2Z2OWaig6lpY3ObHxVLHPknuY=; b=ZM53/ET/XLXW0N5BtX5BLVPWFjVVlqzUsmLjhwykjFhoRbJeNtcZS1OWqaMuAbtBqE PJCrWYoYpw2tXO925IghG2ahaW1IY9ciMB2KPlWVCtYdZJxW9pZ4yaMNdkwF/uxFp6Uo gdpINgAVli8UxhOtwz8teEJKSvm7Oo0FzIR48K+B9qNGom1ooIRvh7P1exkQKBx6a2qe /iTo4eQ+GkGrSWU0peutPCYc8QM7Zru1m/+SCmZs1TMPq/lJth2IjvD+WxEoO9+3ilBN WTK1AKbfXb4B8MyPErZI4JQRu2YqC0Lr9shP6AWPF8Yf9XcfoSL1fpapZN3GP/g2iFH4 GzLg== 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 m136si3438791pga.183.2021.04.20.11.02.34; Tue, 20 Apr 2021 11:02:47 -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 S233534AbhDTSCZ (ORCPT + 99 others); Tue, 20 Apr 2021 14:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233523AbhDTSCY (ORCPT ); Tue, 20 Apr 2021 14:02:24 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::4]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E1000C06174A; Tue, 20 Apr 2021 11:01:52 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 481BB92009E; Tue, 20 Apr 2021 20:01:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 4161092009B; Tue, 20 Apr 2021 20:01:52 +0200 (CEST) Date: Tue, 20 Apr 2021 20:01:52 +0200 (CEST) From: "Maciej W. Rozycki" To: Khalid Aziz , "James E.J. Bottomley" , "Martin K. Petersen" cc: Christoph Hellwig , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] scsi: BusLogic: Avoid unbounded `vsprintf' use In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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;