Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1968664rdb; Tue, 5 Sep 2023 10:08:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEemoTgfTN4nDvYKRD2Km3vvt8+YK49DGJlnP9Yb5w1O0PVZh4P6BkIJ8+cewhOMp9bTpDm X-Received: by 2002:a92:cd06:0:b0:34e:e25:b12c with SMTP id z6-20020a92cd06000000b0034e0e25b12cmr11459010iln.0.1693933702322; Tue, 05 Sep 2023 10:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693933702; cv=none; d=google.com; s=arc-20160816; b=t24hjle54Ok+0Cm4YEdICP9qrP4CmuHREkmIVHYh+UEK6fsqg9B0I7O9fE82eb9BLU NcyhuBF7todmClCApM9SS+7GKqTrE0MBSszDenOVFEF2iXyKQq2ooANSCQ0OnsKy0rCg +zj054K+n2hI1pPqwnlE2Uvj4PWxa1+uACf0V2rK7owOx+ucd5DivzPLtKq8tqzYnhNA mfP5on86PPm/ay71bbbMI0nH//0z9iSSQ/zQrwGHoxkRjhW4NzcpcafKHrmo+pQGLZoW rW2RsP8AygygHy23vJAGaci0dsndUhVQIYiJd91mYyW/wyoJpF3pkcgQiDDc2SpT0hmH yZUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=MIvOUjsHbFTKwXaC8oQKcB0Nyti5bqXLenBxPsELmtc=; fh=OK8yi05o+FhUx6Fbhm9aJInDONUD/HmJaMZI2wp/0EA=; b=iSLvcskW2tOZwZOJ2YCHUjZT4Aj2Jwa1sSSQRjLMqh4uuPUF16eBhIJrtJxh+On2cf s7blt9vSPHOr/N+ah3GZcWXCqIWYQMW6s0ZWFHk8PLjmEFw5OyAgecugd6gQanBnVcp0 PDAlbebPx2zm5CVwElblp6DW5RJ4fIkLqIFCYZDlpzgQI97m1hAGpg9RP8GhbxvzjydU eO7/ENE1nbSpLnOP/yDto2Dou505lqWV4u1SwXlYayvrYYAmL4GhscPNWU7o99uzrF0/ tQ9xiseLUtAvsR7oDV92/LG+NfIoQ/g41ABcOCGlfcsWczner/OA+ri19eAlqVdkDA8/ U8cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b0GC0EYl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb5-20020a17090b4a4500b0026816382fdbsi10419786pjb.40.2023.09.05.10.08.06; Tue, 05 Sep 2023 10:08:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b0GC0EYl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234084AbjIEQpR (ORCPT + 99 others); Tue, 5 Sep 2023 12:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350519AbjIEFEK (ORCPT ); Tue, 5 Sep 2023 01:04:10 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09A3CCC5; Mon, 4 Sep 2023 22:04:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 15C2ACE1020; Tue, 5 Sep 2023 05:04:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3746C433C7; Tue, 5 Sep 2023 05:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693890242; bh=rNZ6gSz952FnYbdOwNayc8WW+NGygaXz472YSAOluYk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=b0GC0EYlTsTH7sHYMimcCh/EOaOHV4uGQ7vqQf/HuRw9Qulq+4xw75y80YOFRnkv9 b4LwteX6i6uFW4Fi/ztQKY0pa4fXglePRsstW5agm7HVr4h21wC+8G73P3d1omz09n GGU1bpU3WQG8xLoTtxpVnQnHg6fx0QC3kZW9vs1ru7oUifErFtuAMkxJEKXZ7d4ht6 sryxO7lp4qym/OQ1QPl3o9iWxAJOcuRmQROuIxNSbTxRonsykbGilksIMBUfibE0jK Q7wJoHWgM41x5ogHEVlUfkVJZSQroVIQvuP5b5/gvHNG2/fsm7hFKRlU03NC6GpKOD +ekqiIr73cSXQ== Message-ID: Date: Tue, 5 Sep 2023 14:04:00 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] ata: sata_mv: Fix incorrect string length computation in mv_dump_mem() Content-Language: en-US To: Christophe JAILLET Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-ide@vger.kernel.org References: <1a35e114a3dcc33053ca7cca41cb06b8426d8c40.1693857262.git.christophe.jaillet@wanadoo.fr> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <1a35e114a3dcc33053ca7cca41cb06b8426d8c40.1693857262.git.christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/5/23 04:54, Christophe JAILLET wrote: > snprintf() returns the "number of characters which *would* be generated for > the given input", not the size *really* generated. > > In order to avoid too large values for 'o' (and potential negative values > for "sizeof(linebuf) o") use scnprintf() instead of snprintf(). > > Note that given the "w < 4" in the for loop, the buffer can NOT > overflow, but using the *right* function is always better. > > Signed-off-by: Christophe JAILLET Doesn't this need Fixes and CC stable tags ? > --- > drivers/ata/sata_mv.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c > index d105db5c7d81..45e48d653c60 100644 > --- a/drivers/ata/sata_mv.c > +++ b/drivers/ata/sata_mv.c > @@ -1255,8 +1255,8 @@ static void mv_dump_mem(struct device *dev, void __iomem *start, unsigned bytes) > > for (b = 0; b < bytes; ) { > for (w = 0, o = 0; b < bytes && w < 4; w++) { > - o += snprintf(linebuf + o, sizeof(linebuf) - o, > - "%08x ", readl(start + b)); > + o += scnprintf(linebuf + o, sizeof(linebuf) - o, > + "%08x ", readl(start + b)); > b += sizeof(u32); > } > dev_dbg(dev, "%s: %p: %s\n", -- Damien Le Moal Western Digital Research