From patchwork Sat Apr 15 18:55:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 9682389 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 B8A1A60138 for ; Sat, 15 Apr 2017 18:59:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB94D25223 for ; Sat, 15 Apr 2017 18:59:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A05BF28305; Sat, 15 Apr 2017 18:59:03 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable 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 5224F25223 for ; Sat, 15 Apr 2017 18:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755720AbdDOS6u (ORCPT ); Sat, 15 Apr 2017 14:58:50 -0400 Received: from mail-dm3nam03on0041.outbound.protection.outlook.com ([104.47.41.41]:38016 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755698AbdDOS4w (ORCPT ); Sat, 15 Apr 2017 14:56:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cnexlabs.onmicrosoft.com; s=selector1-cnexlabs-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ck5NEXLuSeMcfIHlorPUueSLsNQwkQAHO15XxGGyYZU=; b=YrilILVJyc6Ne4l/Rb3FwlT4gUVg46qKu1QbDyG0HTK3zGc+rNqy+e9gBYiONS987L6UbI1I9Byl3sWwjV6Zq4IPdGS0K2xjj9Yu23lwbf/f6xfVytrz6+mMPmYcqqXA9KgGcjvSKkLdp+/NaPdPugvzHRcKRKo9T9Q2ZjSbVrA= Authentication-Results: fb.com; dkim=none (message not signed) header.d=none; fb.com; dmarc=none action=none header.from=cnexlabs.com; Received: from skyninja.cnexlabs.com (193.106.164.211) by CY4PR06MB2774.namprd06.prod.outlook.com (10.175.117.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Sat, 15 Apr 2017 18:56:34 +0000 From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: CC: , , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 15/19] lightnvm: convert sprintf into strlcpy Date: Sat, 15 Apr 2017 20:55:49 +0200 Message-ID: <20170415185553.16098-16-matias@cnexlabs.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170415185553.16098-1-matias@cnexlabs.com> References: <20170415185553.16098-1-matias@cnexlabs.com> MIME-Version: 1.0 X-Originating-IP: [193.106.164.211] X-ClientProxiedBy: AM5PR0701CA0069.eurprd07.prod.outlook.com (10.169.145.159) To CY4PR06MB2774.namprd06.prod.outlook.com (10.175.117.142) X-MS-Office365-Filtering-Correlation-Id: 8211df21-716f-4780-ac47-08d4843123f0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:CY4PR06MB2774; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2774; 3:nwKns7fL4StIc/BJ1LZsDaf5b0+AZmtMP5KCjUUv9Uy8P2zu3jvrJXb/7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gYrdHErwcnLGfsVrwp7WQexyr+uAY501Zn4XsOkQaQqDzOPFkAVukX8unoS/6+CsZ4jOVBgQ0ab1u1WnZtQwYq4ww38Nxr9KFGcuR39Kvd3dozPYwEGVMLXvI45tC12lskfBqF/O0rptHVL8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123560025)(201703131423075)(201703061421075)(20161123555025)(6072148); SRVR:CY4PR06MB2774; BCL:0; PCL:0; RULEID:; SRVR:CY4PR06MB2774; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2774; 4:hkEE1ApGjYW51i6EiIHSU+UZDwKD2W0XvSOE2jfTy7Q7PczrrQec6OH9xynLx6ZAQ4IkwOAvVlrKdA3DS0ml7L+A+pVo325F/arq3pQdz3ltQ85uuKVoJCQBzAZBNwNPlZ+xFLlWLPl71h7KakadQ7LgHwEvjHOVNMGjKx50isANU3j70YTcVzcljqje+SqyZT8546NmzNJwuLdWFj69kuMD3rlgVIwsyptWhGKnIyVBXi/Xmbe/IIFwM/9863yGCVMg5xQCwhO85Y6omRoMJPqTfvwXx+MPXJWIiegtTE4hozn2oZq7W20Cs1hD+/J+Lvvb9/cr2JF08veGtArWaBknDBYtwiEbJa4WSH/6scnivAStOObCj+hJbtOlFBMxITDVvvyQ87XQT9ue1MeQRqIQkmB5c41cg4jS05UsvbqXoFAlBd8wRkjZMrO16QNrxYDiUZf2xi4VJb1BMxBeVAt4q9orAVhfnaPsccMoA2R3+49+2iTyQ9ZW+1LHKgXKxy3eipjXi1kcd6dJJqlp2UfO2IRBulzxFSgDnUSAvuGThneEWRIzVZsJ6wwoQlfDl4XIO3q0xO1x9k+7h8Bofd4s+DQq0c+v9SAQxVJyn1cpRi/iPO3qt756Lt9uPv4kJ+Ag0wMWdlATVxukHoFUQloyUYNw8ykhqBBt9ixJo6ggNb8V3IlO6pnc6uN0E8aq X-Forefront-PRVS: 02788FF38E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39400400002)(39450400003)(86362001)(305945005)(1076002)(6916009)(6666003)(25786009)(2950100002)(6486002)(2906002)(3846002)(6116002)(2870700001)(54906002)(189998001)(53936002)(53416004)(107886003)(110136004)(5660300001)(38730400002)(50986999)(76176999)(2351001)(4326008)(66066001)(5820100001)(23676002)(81166006)(47776003)(42186005)(36756003)(33646002)(50226002)(8676002)(129583001)(156123004)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR06MB2774; H:skyninja.cnexlabs.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjA2TUIyNzc0OzIzOmswQTcvaUNXNysxMHBFcFZlVUpXVGZXdkVv?= =?utf-8?B?NUlsU2JWV0NRRThCR2FxR0Y0SitRZHdvUlRoRmVxWGttWW1HaVpiRGlESHFG?= =?utf-8?B?SW0wT2NvUUFpVVFjY21aK1hNMkYvQjlzTDRUZ0svbzdlR3RsWXV5RXR1cFY5?= =?utf-8?B?WnErNWpZU2lpQWdqb2g3N2ZHR21Pa2k0eVcyYXQvaEpRdldlaUE1cW9UdmJO?= =?utf-8?B?aWc4YXV1TGswcXJZR0MxY1lZMmI1TWdoWmtHa0g1c2U4K1pMRUg2ei9uNnB1?= =?utf-8?B?SGN3em9Ba3lEL1V0MXJBbHB2UlBQSlkrT3pYcDFLOWw1NWhQaThUaXpQUGxo?= =?utf-8?B?MlE3aitPenNIaGt1SXdYMFhKZS9SU0tJalI5ZU9SeUtJM3ozdExCaVVwaCsz?= =?utf-8?B?L0tWK3lnL2RLQTBmRTV4OUNUMHVNR3VBVnZCSGRQWEZKQVVIOFQvcmtMdGx4?= =?utf-8?B?N1dxUlJ2R24zUEpyMUZCZy9iRlpPUjNTVVZDeXFiUHBuVUN1U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VBPT0=?= X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2774; 6:d3lRCmvsU36WM70b3HvpaF3LFJxr5JjuSYSGYIqBUi4+PuV5Sta1j+gzH2Bx9PcitCxCLvCDjr3A/rGEKWL5EcoyfHysbUwdYoLRAQKFfbMFqNEb27Myo4qFlIohcicvvEYCN29s11J+7oYeRqy55E+Jt+AEz2jQMV8lgz/sUvcjIVKzFOzDVb0n2AjG9xyFE3YHnWaV1yWzSiv1AbQWFfucPUdl4bEh+gvRdi2lZub5u5S3tYIEmBzkT2BrccPSxJ05RRW0B3vcURipCtwLFJZogSa8LCtvAuNydeNBIiJSiCYJ+RbzFzDClKgb9XO6nhBoDyZahYDIlMK//YW5dTz1CbSiy6MZS0liyDGZGSgfAScYcPXwoYIzB/A2XpnGaGnzQtSYGEV+2tR/xnoQ7Dq1iEkqFztDoUa7ICwUyfl7h1dAnzKVZlWX9hdQ2xUbg7LntlB+gA3wShnA2gRijg==; 5:AFidzjKxFncKFnovDjp/ewz1ifmc7B8emWcdRWsmE/HCeFmuf++SXTGsL2E+YQMPNmZLu4ZQrH/M4eoNIFYVrc76udmfxDW0JEd6kCa0E7F8xYSXbDZ89q6WU6C7f9pSug7XKniWvSYNE/GfDyaQwg==; 24:k5wvOMJ/Qly671HVr0yZgMwBlkVj04jTeSgE1HldNu92x3TQoTGZDfZnO5EjQppndBckvDfUc/zhT/Mno3jggo/Mug0doPzZzlnj1nr4pxU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2774; 7:pKSjYDbphUqDNIQhjpwlBS6boNfK7op9cTD+KcoAyQrksY6W26bXYGfVfE9v7qafkMMwe2DzDsTrNEnHAtZ8KD61ttVG5AmBYa+6S1seLprEJufqtcxFpW8XQkHzKAwHXBnr3HJTfx7Nd7WhG1XOxBvRCHk3/zuE4Uz7yta6Ej8z/VNSUvNdBDiIsXTi5L+oYUPk2nfPAIJf9xyrfEpeqeoJSLwZxq/D9KKboYXkNA/up5XbrKqNjAFF8+0Jgu/zBkZHymQ4EC596Y0a1JPFNDnqcsyR77S7yXLRc9E0fcnun7kTgpoEs4k2XnJQXQRiK105kQKTpKuPQXSsLhFVtg== X-OriginatorOrg: cnexlabs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2017 18:56:34.5571 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR06MB2774 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: Javier González Convert sprintf calls to strlcpy in order to make possible buffer overflow more obvious. Signed-off-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 258007a..2c26af3 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -273,7 +273,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) goto err_disk; blk_queue_make_request(tqueue, tt->make_rq); - sprintf(tdisk->disk_name, "%s", create->tgtname); + strlcpy(tdisk->disk_name, create->tgtname, sizeof(tdisk->disk_name)); tdisk->flags = GENHD_FL_EXT_DEVT; tdisk->major = 0; tdisk->first_minor = 0; @@ -1198,13 +1198,13 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg) list_for_each_entry(dev, &nvm_devices, devices) { struct nvm_ioctl_device_info *info = &devices->info[i]; - sprintf(info->devname, "%s", dev->name); + strlcpy(info->devname, dev->name, sizeof(info->devname)); /* kept for compatibility */ info->bmversion[0] = 1; info->bmversion[1] = 0; info->bmversion[2] = 0; - sprintf(info->bmname, "%s", "gennvm"); + strlcpy(info->bmname, "gennvm", sizeof(info->bmname)); i++; if (i > 31) {