From patchwork Thu Oct 4 00:01:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10625409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D845215E8 for ; Thu, 4 Oct 2018 00:01:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C333D28D8C for ; Thu, 4 Oct 2018 00:01:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5EA728DE0; Thu, 4 Oct 2018 00:01:56 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 6803B28D8C for ; Thu, 4 Oct 2018 00:01:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726182AbeJDGwc (ORCPT ); Thu, 4 Oct 2018 02:52:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:49396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbeJDGwc (ORCPT ); Thu, 4 Oct 2018 02:52:32 -0400 Received: from ebiggers-linuxstation.kir.corp.google.com (unknown [104.132.51.88]) (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 4405B21473; Thu, 4 Oct 2018 00:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1538611315; bh=/dhpyFL9Kt+eTm7kGmV6aOqQxh6cP+coma/+Qam/t5U=; h=From:To:Subject:Date:From; b=eVg5TIE1xJCL8Kn/ylrPeLdI9HFTbzA+9zS3SObecBFzxsVKV3aWv8pbZcHtQgC+n K6FkRFAO1wwbuconjgBdEjqn7nxIYj+UMw+8pVIp/Z/cS2ft6sAh+ZIs9JZkdKXZri KKMfEe9m53adyoMuf8h3HkD6YZUcTvS06rGtDNnY= From: Eric Biggers To: linux-integrity@vger.kernel.org, Mimi Zohar , Dmitry Kasatkin Subject: [PATCH v2] ima: fix showing large 'violations' or 'runtime_measurements_count' Date: Wed, 3 Oct 2018 17:01:06 -0700 Message-Id: <20181004000106.153693-1-ebiggers@kernel.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog MIME-Version: 1.0 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers The 12 character temporary buffer is not necessarily long enough to hold a 'long' value. Increase it. Signed-off-by: Eric Biggers --- security/integrity/ima/ima_fs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c index ae9d5c766a3ce..4b50fe9c18edd 100644 --- a/security/integrity/ima/ima_fs.c +++ b/security/integrity/ima/ima_fs.c @@ -42,14 +42,15 @@ static int __init default_canonical_fmt_setup(char *str) __setup("ima_canonical_fmt", default_canonical_fmt_setup); static int valid_policy = 1; -#define TMPBUFLEN 12 + static ssize_t ima_show_htable_value(char __user *buf, size_t count, loff_t *ppos, atomic_long_t *val) { - char tmpbuf[TMPBUFLEN]; + /* temporary buffer that is plenty long enough */ + char tmpbuf[32]; ssize_t len; - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val)); + len = scnprintf(tmpbuf, sizeof(tmpbuf), "%li\n", atomic_long_read(val)); return simple_read_from_buffer(buf, count, ppos, tmpbuf, len); }