From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E25C40149E for ; Thu, 12 Mar 2026 19:11:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773342709; cv=none; b=p2d7T6lqH7d7oVd1KOktJPjZ4nzdVnEtbjNWAOfnewfGG15fc3MqJvqCzBhOMCqNtTbJKZAK+8Km3b6izR+Q3jHBZN5fqoiK6R/2LdPyQ6qZ/RxvnrDrI7RLIRLKqZ0wa2EDXj3faVHWn2Fv36zkiRwhc2yQCL0RoeiTmOJ0B9I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773342709; c=relaxed/simple; bh=8ozz4uX3VG7ubKIGiEygr7D5oPi9gmvKVCXRz56Np/4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KGjNeSbF3BNJBFEjhZyYGadJatrtAeK9z87Iw3qr1pgAnUowtoS56MBGDVhC9H5LMt0MnFB6VqYnA6/vkNrEFAWcpZBa3wmVRQsBZ97SeaUDcKKPQm6agXA+AxrjXpD2f6AD0nSkYw56g+VAopcDwF64X0Ekqirq1hHisJTTZfU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DYPe+GOw; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DYPe+GOw" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5a1273de95aso1918615e87.0 for ; Thu, 12 Mar 2026 12:11:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773342706; x=1773947506; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+pyq/Z2cW6Oq5zvXs1uq6RW2e5g+Ci/r6rp/HxH6Mjk=; b=DYPe+GOw+pzfT93KT5GOTQ6fnxFWSaum/ytTv6wNpBjKWizgSBBl49cNcUr/4bIK5K Fbd6MBfuxHHPUhNQ4gdWNnzUPKemvxHMJYzmdNM+KjImSGPI9kPUal5KoviGQRoaQryQ 2g0RiNGHHAsisOeadbY3JbUIZR5V6olKijqhvtyGMqAhsDTAHV6wGXchK0rn2owxTRro FoypZj8lD8LPQCT45suNU+bn5PLvFpdysM07AwBskHAWFH0vHMPJ19fxBX7V0Cj6hGVK bgoPUYq4Z1ko1lvJORGdmG2pRk85zB1NjwZ1aPW7Aq6wPVVEukvt0Sj5LKuBZ99Z+PUA sMLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773342706; x=1773947506; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+pyq/Z2cW6Oq5zvXs1uq6RW2e5g+Ci/r6rp/HxH6Mjk=; b=D/DuLjpzlhlU3RWCkCmC+ZkESadb05jxmk6CbhhfNqtOoe3rcvp87BGHxt0MvGrdc4 1J402Df+ImJvQQzExsY5TEjL5vaR/tFzfGGb+2oWiNRV5vJwTesKSPuqqX2hkAEPLXIu 04yqUDgzEVrL/D7jT57XXbg4QCS+7IWbE+BsiKL1AbxSbbRgyIdO+4uKeXu+hQnIRIN9 Ik9b2xvfTUpHRTMPI4yUl02HWpVyFNTstent50DzVIYWOwRt5LN7puOgissD043546Ob DwXxDQWbKK3UhNPRXCXgqYmQhi2or1zxcWjdxjHJD6fesMvwe8Or4ggxpgm3IXSzJNSf SONg== X-Forwarded-Encrypted: i=1; AJvYcCXXVJmAdRUQvvdWSfwCRbjmHMIFCqM3yC1gPhXT5+GJxIWra+L5hEMLova1bIXA1roV6Fb85DWW0Meqhqw=@vger.kernel.org X-Gm-Message-State: AOJu0YwYe4of+vWRvV2t5lsxuwTDwoc3ZXvaunHIMCPb17fxJb2uP5pe S8zafn66hHM51GpcSCUtAnOYWeh6Gfe+SjORf8HdDTm3c6SxXFbWyuuy X-Gm-Gg: ATEYQzwFZ+QCN34lufI0CL/gThyc6hP7o4CvL2oNgD76fzBLSZ64dHKSObdmqn2omkU UHRk42ypXuya4EF44UzxZapL9AXq5SMAFzH7/8OhxQzBFo0paiqvrhOz91vkla9FsOl8+OKJ3S5 A/28QYU1DF+QQJI7AWbjYrtDPhRoph5X37krDJuY3exQhwMM5ZVyCfH6a97TjW/xRnTHo71hr7K d0b5JWi7twlkkgx3W7QkIU2nIGgkCK23HWyzzuVxhrJf3U7qKjyGyCEhHG9s6QA2eGrrjLJeMEC EpdbYdLpdJNPoucV3WkqlyGM/jOhGV3TL7oL9sMA3BEUqaCIKEUaY1RXzl8oQEF2hq++84/TEhK hEekCtDhoL2/VvKAcThvQMzI8mY6YlnuZxX/JL+9OicQOu2nFSnU7ybqgZ+Cz1jrRT+zo5qatPx QGPVLzXLZ1s3v3Wk93eWPBUwbEb5eIFjPbkrPpYoYPAEKAc+W1Wk9cE8cwgDEB5K7MuiXyWPk= X-Received: by 2002:a05:6512:1413:b0:5a1:3561:de7d with SMTP id 2adb3069b0e04-5a162b39c97mr153329e87.41.1773342706113; Thu, 12 Mar 2026 12:11:46 -0700 (PDT) Received: from ubuntu.. (static.159.107.27.37.clients.your-server.de. [37.27.107.159]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a156375198sm1112249e87.88.2026.03.12.12.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2026 12:11:45 -0700 (PDT) From: Josh Law X-Google-Original-From: Josh Law To: Masami Hiramatsu , Andrew Morton Cc: Josh Law , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH v2 3/3] lib/bootconfig: fix snprintf truncation check in xbc_node_compose_key_after() Date: Thu, 12 Mar 2026 19:11:43 +0000 Message-Id: <20260312191143.28719-4-objecting@objecting.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260312191143.28719-1-objecting@objecting.org> References: <20260312191143.28719-1-objecting@objecting.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Josh Law snprintf() returns the number of characters that would have been written excluding the NUL terminator. Output is truncated when the return value is >= the buffer size, not just > the buffer size. When ret == size, the current code takes the non-truncated path, advancing buf by ret and reducing size to 0. This is wrong because the output was actually truncated (the last character was replaced by NUL). Fix by using >= so the truncation path is taken correctly. Signed-off-by: Josh Law --- lib/bootconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bootconfig.c b/lib/bootconfig.c index 62b4ed7a0ba6..b0ef1e74e98a 100644 --- a/lib/bootconfig.c +++ b/lib/bootconfig.c @@ -316,7 +316,7 @@ int __init xbc_node_compose_key_after(struct xbc_node *root, depth ? "." : ""); if (ret < 0) return ret; - if (ret > size) { + if (ret >= size) { size = 0; } else { size -= ret; -- 2.34.1