From patchwork Thu Oct 12 18:43:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 152118 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1430571vqb; Thu, 12 Oct 2023 11:44:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvoS0X8pUnJ7SXvJk9S5UMfKecoFbq5D0EyPq5umkibuYqlW8IkhNatL1r+ttGJd3YTYAJ X-Received: by 2002:a17:902:f54e:b0:1c2:c60:8387 with SMTP id h14-20020a170902f54e00b001c20c608387mr27569932plf.0.1697136242215; Thu, 12 Oct 2023 11:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697136242; cv=none; d=google.com; s=arc-20160816; b=w8hJwOJn0YkjNfQGh1LEw2z9TalRVoZIyJjzjvQcuUixPM3AKuWMTYUf5CYbIAI/2b UVckeJbz/GG3gdAP0y9FPcUDoHaFhnSdBCSrHNZkgOwluXUTn7QQosw5PKC7Gw8N/b33 mbU/a4el41weI/M/ncVkbM0IgcjI47xfCWduIGlEYzGmRc1mSgDPnnWz8No/KHRH8JtN jj679ZaMzNAHgJQrcdfU9aSIVEeHBaPL5zeaY5+IcnBTKuRHKPZ5GAc2LFsdAKmkEI9W MHP8xXx9G7SJTGtV/myJf8Qf6i1BuxIyhNfVm8WZ3MPaEiua7zYUmAQGoPlkhlC9RKIG JBJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=p4IJk1jfPpuOdOgu2MQ79rc62trZiN8Vjveo+Rkj3n8=; fh=AzCX//G+255O8a10y5F1hb1p6OqztEaGEunIxgTrW/w=; b=HwDurKeR8qiGw32aZv1y3K0MBpkhUpxZIqQt265YYi0cPhyJomCHepWoIrY2rlFABL deWSc0Sdgpm2QCQPvqaQ7R+KmYTH1gOvTY39b1RRCIryTQwKZ9ftN4otsKfS49KxSByr AMyq8xDm0viNjtuDdQDC/1n47XAzCNvsw//Jr/TE0Dewe+Pg3W84mg3T6u0fbteY+aru BOdt5SMMpmv1gqkLE4r9IGL+NA1bT1ysSqyumJmm/sK6JYB9gYfh1HPugzYSwgvwcNo/ f+ygdavssRFa/CAjrbHVWhiGqG3CPryDh3PHj4yYa+S5AHQAQ7uVDlfvsH1SDhhDiNeh uyBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AKlfPe08; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=uXdWhs3z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id w2-20020a170902e88200b001bc17ab8d6esi2963943plg.530.2023.10.12.11.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 11:44:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AKlfPe08; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=uXdWhs3z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6608F822D0AF; Thu, 12 Oct 2023 11:44:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442012AbjJLSnx (ORCPT + 19 others); Thu, 12 Oct 2023 14:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441821AbjJLSnw (ORCPT ); Thu, 12 Oct 2023 14:43:52 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABC1283; Thu, 12 Oct 2023 11:43:50 -0700 (PDT) Date: Thu, 12 Oct 2023 18:43:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697136229; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p4IJk1jfPpuOdOgu2MQ79rc62trZiN8Vjveo+Rkj3n8=; b=AKlfPe08Yy4RsKr4WM2S3srzCwWroJ9Ia6/m7q+ozav+tOhuh0An18eiiAA3++NnikGsS7 eDkPnmV6JbElCr0+/nTuiQvEqZjrUaEQ/X1ol7gg2g+TCHh54NPkrNX+zadgYNJOe50BxY kDrdQJQIfLiPqnsvR1XzD1dTOsPQK+hfVtT5KinupYLJjUwoOqU429EURKbvTn3Er5Lfph fdqgLFHttslPMO7rqJK2rjRIPu/Z1TjmyQ+MUtToqB6daT/veQA4Eu8cGHb4LA9Ynvk6K9 senVMjyAGQi146PI3lVFrRbtfBJ0uUzXvuFYB/GXWtK8wirmOSsl562Cxj5yvg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697136229; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p4IJk1jfPpuOdOgu2MQ79rc62trZiN8Vjveo+Rkj3n8=; b=uXdWhs3zJjoS98UVypG+XxK78H+hUwUtvjLaiD9BP4FqE3mdi97hDK2KO7/ia7Z7MMA4vt U9VJD2muECZ6goAA== From: "tip-bot2 for Lucy Mielke" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] locking/lockdep: Fix string sizing bug that triggers a format-truncation compiler-warning Cc: Lucy Mielke , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: MIME-Version: 1.0 Message-ID: <169713622853.3135.11510940240910538539.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 12 Oct 2023 11:44:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779576332538412677 X-GMAIL-MSGID: 1779576332538412677 The following commit has been merged into the locking/core branch of tip: Commit-ID: ac8b60be078abebc3ab8836f3f0ecac6980e0b4f Gitweb: https://git.kernel.org/tip/ac8b60be078abebc3ab8836f3f0ecac6980e0b4f Author: Lucy Mielke AuthorDate: Thu, 12 Oct 2023 12:44:32 +02:00 Committer: Ingo Molnar CommitterDate: Thu, 12 Oct 2023 20:37:59 +02:00 locking/lockdep: Fix string sizing bug that triggers a format-truncation compiler-warning On an allyesconfig, with "treat warnings as errors" unset, GCC emits these warnings: kernel/locking/lockdep_proc.c:438:32: Warning: Format specifier '%lld' may be truncated when writing 1 to 17 bytes into a region of size 15 [-Wformat-truncation=] kernel/locking/lockdep_proc.c:438:31: Note: Format directive argument is in the range [-9223372036854775, 9223372036854775] kernel/locking/lockdep_proc.c:438:9: Note: 'snprintf' has output between 5 and 22 bytes into a target of size 15 In seq_time(), the longest s64 is "-9223372036854775808"-ish, which converted to the fixed-point float format is "-9223372036854775.80": 21 bytes, plus termination is another byte: 22. Therefore, a larger buffer size of 22 is needed here - not 15. The code was safe due to the snprintf(). Fix it. Signed-off-by: Lucy Mielke Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/ZSfOEHRkZAWaQr3U@fedora.fritz.box --- kernel/locking/lockdep_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c index 15fdc7f..e2bfb1d 100644 --- a/kernel/locking/lockdep_proc.c +++ b/kernel/locking/lockdep_proc.c @@ -440,7 +440,7 @@ static void snprint_time(char *buf, size_t bufsiz, s64 nr) static void seq_time(struct seq_file *m, s64 time) { - char num[15]; + char num[22]; snprint_time(num, sizeof(num), time); seq_printf(m, " %14s", num);