Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1968154ima; Thu, 25 Oct 2018 07:42:58 -0700 (PDT) X-Google-Smtp-Source: AJdET5eASJ5pgPsZaGcEEybICH7gkXreylngd8GMez5vRb0QyGNRleQDCMTp0zYje/2p1bshbj3o X-Received: by 2002:a17:902:5590:: with SMTP id g16-v6mr1852556pli.28.1540478578265; Thu, 25 Oct 2018 07:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540478578; cv=none; d=google.com; s=arc-20160816; b=afx5J7Wom2hh89A/VO6/lwOo/nv+VloMTUMgIXmQxAQd9MpyGqH9Ay32qWggi5jED2 Zq/L7tFNUidPcWZjhuNlTSvDShPKbwdiIrtJPpC+ywUcvE6PL+DVvOiAR6td9wzBAvBP E3xeuo8JLfp30PSwO0fdN5hX2i/ohCpIFOv7pzZpJAfatpP4b8jDkn1oomo7q//WEIkS Cd02VVl3Q/PU0yNJ7w7mQULnmD0DTu1jrDrksrFnLUTkNXvbZFTTDIElikOBR7EV2NHe at41gUFOp4DoJGXX9k1ZD9sYRpCMM2wnznRqg5NPeRqUyhBhMlJAtmCVDYZQdx23LrCc /ZAQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9qn1JXrmalHHOMKNVravzeacV4GusupgDjS8HH8P0YA=; b=fP3kJXb6jcuVXwjm409tuyKI4Q9ViMJgj5qSYVdnzUJMEQtK+bwUFwaKEqnvjGI3TY ueB10UpqtY2zGnw/P3G2545wpoA3DirbgiMI6AXqUqJLb7gK4lrBNJQuhLRs5DIbdy4x qrt7D2nanOgs+1kuSfRTWcdeKOuASuY8ybtJ0p7gJQL7EVclM5IMjUgomAaCkvT7nIet Z+PWyEbkxYF8qIkSUftf3X0VsfJkIYDs58FaEopCMdIWHrTJcGTApPPL6LjMGklhvNZH xF+TvGjKXmVcqxTM/O1IgtD+bvScwMyB9fvpVQijU0bQSPWJWf0ZTcwjak8sBlUp87UD Coww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DMIm+sAD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6-v6si871960pgv.565.2018.10.25.07.42.42; Thu, 25 Oct 2018 07:42:58 -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=DMIm+sAD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728926AbeJYWsU (ORCPT + 99 others); Thu, 25 Oct 2018 18:48:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:56922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728919AbeJYWsS (ORCPT ); Thu, 25 Oct 2018 18:48:18 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A6C0520854; Thu, 25 Oct 2018 14:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540476922; bh=SbngomlX9o96OXBRAGaak/c/3XUg6WWxxcIvJhG/xnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DMIm+sADkSTsRA/itSdwEGAHaDL4dRnDx46VTzhJlzIjKSvl0pD2/bb3x2LpAifeE rFxT0Zvg7swLd/ky8Kw8geRMn841aeOtaAux07SaEsPUfTGIaSJUYrptrZBRZDreDh yJcz+n2RvD8OSNP66NhChAkKj/6KKl41WNPagLOc= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Eric Biggers , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL 4.9 39/98] elevator: fix truncation of icq_cache_name Date: Thu, 25 Oct 2018 10:13:24 -0400 Message-Id: <20181025141423.213774-39-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141423.213774-1-sashal@kernel.org> References: <20181025141423.213774-1-sashal@kernel.org> 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: Eric Biggers [ Upstream commit 9bd2bbc01d17ddd567cc0f81f77fe1163e497462 ] 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 Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- 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 e7f358d2e5fc..eaa58c0f894b 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h @@ -102,7 +102,7 @@ struct elevator_type struct module *elevator_owner; /* 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; }; -- 2.17.1