From patchwork Fri Jul 14 12:07:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 107798 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp894773obm; Fri, 14 Jul 2017 05:15:11 -0700 (PDT) X-Received: by 10.98.201.75 with SMTP id k72mr4848048pfg.99.1500034511641; Fri, 14 Jul 2017 05:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500034511; cv=none; d=google.com; s=arc-20160816; b=lFuYgWV4blobgZ4rkGZrl/BnB2mX712rXRYG5oG3B+CS+L7sZ3qRLcBn9Lb9Qk4mgT NNNLjYYq6dZOaBmm0g54TdlDoRHWsJgCH+e1JnTsHok6z4IdiPD1oM/EHWTEn10dM539 LxKVeqGCEfPpg2J3ach4cz6b/MffuxywDNic4WoK/vNIT8+qeK+78FWfFtwGEoDL6RIl wUe6NPKwA6s3KRRGNCRutKFD7Hdduq3fZ0ugAPsuhQhjA2xIz61VxaRZjYv5NAiNGxta A+pS58+K5kwjpJWu/RrP1Ad1Q6W46wVN6zqYAFcq56sD7DjQVMwkGnBQo/m0HeZSGhkj dx7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=OjI+kFHpm8PnvsbblbYl3MYJrY7WbN9wbokYJJ2fr00=; b=TYp5Q3EbR+D9BP2HhXCNw2ISEkjGJIZRU+D3C7N7EMaVObZ8b+RD5uhqOsf8PaPeYO hgVc8GFVKonbssTSDc/GiKXiB0m0e2jKLj0a2VSU3/7V+yGldN97/FWA4tDR82xCzr2o pRRfvHcyEUGwYI1qY4tsgsgfs1rgI3uExWVrqLhgAR+0I/feA38DuxSTawegVIKU8GBQ hpSffHpSIoKJ/7sXIVzqCE8DnHKw24eYCx1Bbd4vRtiCpukfq091W8S8dVEZFGnvxUnz ZgdJN+6P1LKq6hFTBcHcxAJL5OurRmRzlXoin7LwiJ1MsZy2OTgTi9+SgAiRqEQMEIw3 VvfA== ARC-Authentication-Results: i=1; mx.google.com; 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 i14si6123201pgn.378.2017.07.14.05.15.11; Fri, 14 Jul 2017 05:15:11 -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; 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 S932278AbdGNMOn (ORCPT + 25 others); Fri, 14 Jul 2017 08:14:43 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:62281 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754032AbdGNMOk (ORCPT ); Fri, 14 Jul 2017 08:14:40 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0MUEV8-1d6B743evC-00Qxlt; Fri, 14 Jul 2017 14:13:21 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, David Howells Cc: Greg Kroah-Hartman , Linus Torvalds , Guenter Roeck , akpm@linux-foundation.org, netdev@vger.kernel.org, "David S . Miller" , "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org, x86@kernel.org, Arnd Bergmann , James Morris , linux-cachefs@redhat.com Subject: [PATCH 21/22] fscache: fix fscache_objlist_show format processing Date: Fri, 14 Jul 2017 14:07:13 +0200 Message-Id: <20170714120720.906842-22-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170714120720.906842-1-arnd@arndb.de> References: <20170714120720.906842-1-arnd@arndb.de> X-Provags-ID: V03:K0:YFZAzTJTor7ESab3x/y3CyF9Q0zEzuiRH9Ykov65kfR3TBb9zUd vVqKVFgW1jv4QCOOlXlH6EZSRpLhZHHhMd7LEGHfLTrbO2E+moOVlnsDqK5NKhsU9hE8km1 8uiMAmVC2j2i8d9eN4PgLGZxDKIo0jkoMDedxvX+Et6LE7pJygNR3ZyOqZTkq1mXpmKk6q6 NCihx9jYG+hBLkcxrN2BQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:mA5l/ZB/hlo=:ufIqD9IA8RqJFDyMte9BQf 3EWLpdMT57DBQhD7uqriIn3QNIpkNIRLlBbvCggp6NmLUKT87ENkFF107WPs365c5QmJgEmh8 zUcjjqm42upAPXhZGQhsNLa80SY+S99hR9h6Q14rCtLkSqZTKJfRhHE4UyvZQJG8smt847GAE axni8LB2rfMH3IEb0D2J74i5whbcblgtwzamVx700yazrC7fxpI+kkaj9vLamRikqSo6kZ3jS Zk1K5SV0g20SKH2awp+EKcABof4T22M58Qu+EnzWgiqTEnxHky61n796jp91hfBA5sj6CGH7y 9Q+kAwv81XB5pwNs/MnyetLSVJFFpIpjOCwHtm1BLrWcCezSRE4hk2ngUsVbJV6D9MVTv+TFp NW7Oa1JlfHYkCnTyZmJlVfRrYzYMTFHpOtuPzWUd5NFmFc+Wo/+eJCZtrrlmrXMDUQLPQ6hVr nluYs/iJ+WEsgdU9DDjn9oMNvCB1HKU0vSMcXoTJhCvFKRAf+Q2/5I3rkLv43whDaimI3qL03 2VjQs63eEpYIMTAueEK1g8nZLEcRrwvRMlUho/O4Avw3BDEI4hTZrxOEci/Px77dODC9drwR0 jOpIHq6jGRkwz85bFKGyg5IQcx8tjZ1ZRAo00DE+9snEg9SCCa1MaI8BUMKRVrHbTB8phdCoW k6fukTwOX5//tKUkLhWd6QaE7/1W1ifnfPDgAGSP8h7+y5yDFsH/kTLeJ/Iq9xImIFtAHxl8b gZYuksucjUt4slRZ2n3qUSPoFAdnlgoi6/lHWw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc points out a minor bug in the handling of unknown cookie types, which could result in a string overflow when the integer is copied into a 3-byte string: fs/fscache/object-list.c: In function 'fscache_objlist_show': fs/fscache/object-list.c:265:19: error: 'sprintf' may write a terminating nul past the end of the destination [-Werror=format-overflow=] sprintf(_type, "%02u", cookie->def->type); ^~~~~~ fs/fscache/object-list.c:265:4: note: 'sprintf' output between 3 and 4 bytes into a destination of size 3 This is currently harmless as no code sets a type other than 0 or 1, but it makes sense to use snprintf() here to avoid overflowing the array if that changes. Signed-off-by: Arnd Bergmann --- fs/fscache/object-list.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.9.0 diff --git a/fs/fscache/object-list.c b/fs/fscache/object-list.c index 67f940892ef8..b5ab06fabc60 100644 --- a/fs/fscache/object-list.c +++ b/fs/fscache/object-list.c @@ -262,7 +262,8 @@ static int fscache_objlist_show(struct seq_file *m, void *v) type = "DT"; break; default: - sprintf(_type, "%02u", cookie->def->type); + snprintf(_type, sizeof(_type), "%02u", + cookie->def->type); type = _type; break; }