From patchwork Sat Jun 3 03:35:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 9763831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1D75E602B6 for ; Sat, 3 Jun 2017 03:38:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2A9128347 for ; Sat, 3 Jun 2017 03:38:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E50A4285E9; Sat, 3 Jun 2017 03:38:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88BE128347 for ; Sat, 3 Jun 2017 03:38:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751150AbdFCDiW (ORCPT ); Fri, 2 Jun 2017 23:38:22 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33218 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750707AbdFCDiW (ORCPT ); Fri, 2 Jun 2017 23:38:22 -0400 Received: by mail-pf0-f196.google.com with SMTP id f27so14519120pfe.0 for ; Fri, 02 Jun 2017 20:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nJ81l2ruJSAixyzk5yZlwM21fAYxOXtWFDQ9Vmejpjg=; b=MScLevdBgA70daXSKShIUWZDAwOL2VTweA0/RY61lgpV3Y/iZaAKA0dEwoJZ3kOMBc 96xpBEHDVqRgERtXxWJjYJFqyZxIgigLHbY8k5AThHXnhlqMIctzM97IFXL/btwC7753 R0fGH5M/XYsBdK9g3ArwaC9YGbgw0Dqe5TbIhD9XuNb8gz7Un0xluIcVCVr71qVzhNLG H4g8e+uUaY0p+PqgcmFacKO5ckjdIEg+1EsltKyAqqWqKpIayPMGCfr79y9QpYZFLtLS CZx76ufc2ijadP+bFVFTqs3Wald6eb2QwhS1c7OnTy2GbM/CXa6DP6qauIpgddX+1jwE DqjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nJ81l2ruJSAixyzk5yZlwM21fAYxOXtWFDQ9Vmejpjg=; b=hkD73HpFZarZUAa762U4TTZSzw4ekxTB/w/YSmvcuBtdW6VHf78fBjaHCmQGPQSR5f O3gs1a8H5cK2eos9VujZcYVSQ5WwqMIBau7zLZ1l+tx3TRGdYn+5wO5l5a/xLni0pZ/t /5Z4Jq6zbMzah03xReAPwH5JzG8DVseDLJjPEMRccuXJIxLy/+C02h51lOp8ghWRS+J0 rol+XqRh12z+QIvzvkYv6mtjRiFcRiSVvJNLA3XxRS7FOFQunJUta/MRtM77D9cg5kRa muDGU0C7KKR8JOeUWo1gFDy49KF+cP88uVN7xHPPr0z4yIbsG1NjhBH3nk5pE/+zucmq 1WyQ== X-Gm-Message-State: AODbwcAm2CNfmVB33eDdSJcdffBqIcisHsWw6PIybaEU8JAqz0TKv16J VIiLMvtfVK3Sjt0Ln2E= X-Received: by 10.84.217.70 with SMTP id e6mr3259813plj.130.1496461101214; Fri, 02 Jun 2017 20:38:21 -0700 (PDT) Received: from localhost.localdomain (c-73-239-167-150.hsd1.wa.comcast.net. [73.239.167.150]) by smtp.gmail.com with ESMTPSA id b14sm28690360pga.12.2017.06.02.20.38.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 20:38:20 -0700 (PDT) From: Eric Biggers To: linux-block@vger.kernel.org Cc: Eric Biggers Subject: [PATCH] elevator: fix truncation of icq_cache_name Date: Fri, 2 Jun 2017 20:35:51 -0700 Message-Id: <20170603033551.17261-1-ebiggers3@gmail.com> X-Mailer: git-send-email 2.13.0 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers gcc 7.1 reports the following warning: block/elevator.c: In function ‘elv_register’: block/elevator.c:898:5: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] "%s_io_cq", e->elevator_name); ^~~~~~~~~~ block/elevator.c:897:3: note: ‘snprintf’ output between 7 and 22 bytes into a destination of size 21 snprintf(e->icq_cache_name, sizeof(e->icq_cache_name), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "%s_io_cq", e->elevator_name); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The bug is that the name of the icq_cache is 6 characters longer than the elevator name, but only ELV_NAME_MAX + 5 characters were reserved for it --- so in the case of a maximum-length elevator name, the 'q' character in "_io_cq" would be truncated by snprintf(). Fix it by reserving ELV_NAME_MAX + 6 characters instead. Signed-off-by: Eric Biggers Reviewed-by: Bart Van Assche --- include/linux/elevator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/elevator.h b/include/linux/elevator.h index 9ec5e22846e0..0e306c5a86d6 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h @@ -153,7 +153,7 @@ struct elevator_type #endif /* managed by elevator core */ - char icq_cache_name[ELV_NAME_MAX + 5]; /* elvname + "_io_cq" */ + char icq_cache_name[ELV_NAME_MAX + 6]; /* elvname + "_io_cq" */ struct list_head list; };