Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2361693ybi; Sun, 9 Jun 2019 09:52:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZ/8JaID7o4qufQ8jGdf4npQgmSRDDgo0VIw7H6uULlKeef3BdSasYviE6caNqU8A3zXiW X-Received: by 2002:a65:5685:: with SMTP id v5mr12329123pgs.184.1560099155607; Sun, 09 Jun 2019 09:52:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560099155; cv=none; d=google.com; s=arc-20160816; b=USRx/vk16i4h116Rc2XpJh9yx4iHOoKlMZFw7D5pE6LbuVeXznQ6SNsBO/SbUgLiPC kqB0ScYcIfmiv3s6l+OoNTPaQRPT3eSAR98AE9Ymp8JzjkkiYjQEVTD9TYF9RIj9nmUx KIpHLIg+JKCJh0Le9vv+TZAEE6p0h0ajxEAhA/84RQco6wpTewBINO4EW2JOdUeQC9b4 ru3JH6XLVxLC1kxOfh6RHhlPvxE0WD9wcfMDLkKJL4MTQhQprQLxFTzy39CyFg75kjC4 h71Y7X3XL+hfuN85m/MczeS98No/m+8pHh/KS7E6Kx2u3mgpMkO04BwRRNqEaaKE8GNC JxLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CCMgV2Ng2hnCUr34uaWIzTQU7ofuuuS2Evf4EUYUg3o=; b=zRCizN64XpOsEkg5jHIGxJcTLFuZ9X+tJIPUsZzWhA2AgfE13yqX9KfalayZxDJEH5 CqIE/unbotTDdcXxMhabyG4jy/g2BfiVI8Rh9NbM1YhWcib9xXGVtPabfwpi8BnPzX/J y6sHb9tZWl2r9z5ijrkQlCXXEjJxIt6msqH1al17YAiBEUyrSAq4K0P0sYekCegbkS0R YOJRr0FWk5ljqe6lUWYO+333/2wDeBD9twlYPmrO8PmXuteoEql5ksWoLRQQ71dEsHni 0iScBivqmZnQ42jCvlU8lWbheX7rE5tYVAQBv0cDql6IyINOjdVLzGlpYKExHk/d36XF 3xbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Oo3gHVpe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7si7294030pgr.399.2019.06.09.09.52.19; Sun, 09 Jun 2019 09:52:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Oo3gHVpe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731573AbfFIQtq (ORCPT + 99 others); Sun, 9 Jun 2019 12:49:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:49386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731562AbfFIQtp (ORCPT ); Sun, 9 Jun 2019 12:49:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 833922070B; Sun, 9 Jun 2019 16:49:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560098985; bh=ywlPNhe9q6s7xmSEoV4kIeU8IFY4qdBlUrpk7UcgrWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oo3gHVpeN9E58Ffe4iH8ueGzAoMlFDV4HgQ1ng7+7wxKuFMVfp3GKk3Utv8DrJsro TLcZ6NuIvbjmtTgZrfHLruhy8H7C6+gRnP61sTZW6w7vSRob2OcPu+w5njpc0/9Bed HI0Mo2OAdMVYoK3Grc1/PJAZEDplZbrzdBdZ14QM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter Subject: [PATCH 4.19 36/51] test_firmware: Use correct snprintf() limit Date: Sun, 9 Jun 2019 18:42:17 +0200 Message-Id: <20190609164129.496329390@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190609164127.123076536@linuxfoundation.org> References: <20190609164127.123076536@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter commit bd17cc5a20ae9aaa3ed775f360b75ff93cd66a1d upstream. The limit here is supposed to be how much of the page is left, but it's just using PAGE_SIZE as the limit. The other thing to remember is that snprintf() returns the number of bytes which would have been copied if we had had enough room. So that means that if we run out of space then this code would end up passing a negative value as the limit and the kernel would print an error message. I have change the code to use scnprintf() which returns the number of bytes that were successfully printed (not counting the NUL terminator). Fixes: c92316bf8e94 ("test_firmware: add batched firmware tests") Signed-off-by: Dan Carpenter Cc: stable Signed-off-by: Greg Kroah-Hartman --- lib/test_firmware.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/lib/test_firmware.c +++ b/lib/test_firmware.c @@ -223,30 +223,30 @@ static ssize_t config_show(struct device mutex_lock(&test_fw_mutex); - len += snprintf(buf, PAGE_SIZE, + len += scnprintf(buf, PAGE_SIZE - len, "Custom trigger configuration for: %s\n", dev_name(dev)); if (test_fw_config->name) - len += snprintf(buf+len, PAGE_SIZE, + len += scnprintf(buf+len, PAGE_SIZE - len, "name:\t%s\n", test_fw_config->name); else - len += snprintf(buf+len, PAGE_SIZE, + len += scnprintf(buf+len, PAGE_SIZE - len, "name:\tEMTPY\n"); - len += snprintf(buf+len, PAGE_SIZE, + len += scnprintf(buf+len, PAGE_SIZE - len, "num_requests:\t%u\n", test_fw_config->num_requests); - len += snprintf(buf+len, PAGE_SIZE, + len += scnprintf(buf+len, PAGE_SIZE - len, "send_uevent:\t\t%s\n", test_fw_config->send_uevent ? "FW_ACTION_HOTPLUG" : "FW_ACTION_NOHOTPLUG"); - len += snprintf(buf+len, PAGE_SIZE, + len += scnprintf(buf+len, PAGE_SIZE - len, "sync_direct:\t\t%s\n", test_fw_config->sync_direct ? "true" : "false"); - len += snprintf(buf+len, PAGE_SIZE, + len += scnprintf(buf+len, PAGE_SIZE - len, "read_fw_idx:\t%u\n", test_fw_config->read_fw_idx); mutex_unlock(&test_fw_mutex);