From patchwork Mon Jan 26 16:48:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 5711321 Return-Path: X-Original-To: patchwork-v9fs-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 16C4BC058D for ; Mon, 26 Jan 2015 16:48:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B3392013A for ; Mon, 26 Jan 2015 16:48:44 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 529DB2012B for ; Mon, 26 Jan 2015 16:48:43 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YFmq4-0001EY-Dh; Mon, 26 Jan 2015 16:48:36 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YFmq2-0001EL-FG for v9fs-developer@lists.sourceforge.net; Mon, 26 Jan 2015 16:48:34 +0000 X-ACL-Warn: Received: from mailout2.w1.samsung.com ([210.118.77.12]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-MD5:128) (Exim 4.76) id 1YFmpy-0003vJ-OW for v9fs-developer@lists.sourceforge.net; Mon, 26 Jan 2015 16:48:34 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NIS005K3MVFD9C0@mailout2.w1.samsung.com> for v9fs-developer@lists.sourceforge.net; Mon, 26 Jan 2015 16:52:27 +0000 (GMT) X-AuditID: cbfec7f4-b7f126d000001e9a-d3-54c66f469713 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 57.01.07834.64F66C45; Mon, 26 Jan 2015 16:45:58 +0000 (GMT) Received: from localhost.localdomain ([106.109.129.143]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NIS000ZCMOK8Z50@eusync2.samsung.com>; Mon, 26 Jan 2015 16:48:23 +0000 (GMT) From: Andrey Ryabinin To: linux-kernel@vger.kernel.org Date: Mon, 26 Jan 2015 19:48:16 +0300 Message-id: <1422290896-25042-1-git-send-email-a.ryabinin@samsung.com> X-Mailer: git-send-email 2.2.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGJMWRmVeSWpSXmKPExsVy+t/xK7pu+cdCDHqWmlts+/WIzeLx63ks FnPOt7BYzJ21id3i8q45bBb3pt9mtTi2QMxi2++NzBYf/65ic+D02LLyJpPHzll32T2m3dvE 5PHg0GYWj90LPjN59G1ZxejRu3Uhm8fnTXIBHFFcNimpOZllqUX6dglcGXubr7IUzGKvmNN+ g7mBsZGti5GTQ0LARGLKjd8sELaYxIV764HiXBxCAksZJSYc/8YM4fQxSRw5voMVpIpNQE/i 36ztYN0iAgoSm3ufsYIUMQscZJLYt/UKO0hCWMBR4vyVvUwgNouAqkTT/bdgcV4BN4mv8z8A NXAArZOTuPAxfgIj9wJGhlWMoqmlyQXFSem5hnrFibnFpXnpesn5uZsYIWH1ZQfj4mNWhxgF OBiVeHgnTDwaIsSaWFZcmXuIUYKDWUmEVzr3WIgQb0piZVVqUX58UWlOavEhRiYOTqkGxpo4 Dbu9fk8qQrZHvgmzWShgu86pLsXP9lWnbr6AguuU/B9/kiTT1s9bvy2KMdeeazPPY5NDFvwL /y25tId7m88cmd2rDfPPO66I8zcTbUm/cOr6ouMJq9/uOum25MutK4/mPrzA0smyRHLGg4vh bDF2+xiEnPJDGhTeyVp/ajc4c7eKddUpfSWW4oxEQy3mouJEAL1EVY8JAgAA X-Spam-Score: -0.0 (/) X-Headers-End: 1YFmpy-0003vJ-OW Cc: Latchesar Ionkov , Eric Van Hensbergen , netdev@vger.kernel.org, Andrey Ryabinin , v9fs-developer@lists.sourceforge.net, Ron Minnich , "David S. Miller" Subject: [V9fs-developer] [PATCH] net/9p: fix format string in p9_mount_tag_show() X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using "%s" for non-NULL terminated string is quite dangerous, since this causes reading out of bounds. chan->tag is non-NULL terminated, so precision must be specified for printing it. Fixes: 86c8437383ac ("net/9p: Add sysfs mount_tag file for virtio 9P device") Signed-off-by: Andrey Ryabinin --- net/9p/trans_virtio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index daa749c..f0d5f90 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -504,7 +504,8 @@ static ssize_t p9_mount_tag_show(struct device *dev, vdev = dev_to_virtio(dev); chan = vdev->priv; - return snprintf(buf, chan->tag_len + 1, "%s", chan->tag); + return snprintf(buf, chan->tag_len + 1, "%.*s", + chan->tag_len, chan->tag); } static DEVICE_ATTR(mount_tag, 0444, p9_mount_tag_show, NULL);