From patchwork Fri Apr 11 15:09:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nam Cao X-Patchwork-Id: 880388 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF3C71F461D; Fri, 11 Apr 2025 15:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744384195; cv=none; b=Tyc+4k8O2rhbUoLi6uNuCgXa5FYYmNq5U8eVAWd3H+pX95bPzlnxGqV1nHn/Fe3SRu5HRKWmTKoU8b/lTzKuOkv8/Hq8pVR+LrqvWms2Onyr22dR+yjybp6gt5tdFBZ+MnX8z1UdZW1EH3Z0AekDawGoVTrX45if0ei+Og+4b/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744384195; c=relaxed/simple; bh=d76UNAhJL2/CvDF5iXg10Cq43S1hVRfl9792k5Y/A0U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k+K4fzTyF8MIfgqkYezQbGGiOCnwyTJV+04RXD5QfbbI4a54G75hsBC/hg8UiTyv0tmYCTv+g4AOv0jrgm2PT39F8xiPG57whVGNGQLWNuIRn7GQ7A3yAjG+WAcZi5074ctJX8et24NLctaJcwN4h6qE2NBwpYqS2vhCO2WHmFc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kAFYGY1g; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sdqL+MEy; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kAFYGY1g"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sdqL+MEy" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1744384192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s+on7q0d2sKsDinQinkGf21gwhzzeN5z9itT+eLeiG8=; b=kAFYGY1gu6Y1HDzU+BWH7JTJVf/lZgE9f2YKBKE4fD3C08q5v9cZI+Umc0oI4YzfR/ukfM 2b7XUYFIg4HybLgsZd/+Nhuaoaym8W5PrXQiMRh9sLdvavZi+wf0JOt3O6KPvwZ34uLvxH HPYNPxTebFKKVpPxAwZfkldY/R3XUjuYu3bXLzYSGb+abaKQBsyZmwAs8+CCCVD0KQOGXH B3u3Wci5ldL2sidJ4TgoR+tgRU+tGV4qbEUaL+CQjmNswaFUSQ1BQswW2qG2PiOedsyh6k 03bJzilk1pwzOF3wiYvL/LbQH1mCxnhfAGkwDQPdV27FYk9eof7z5TDWWL8Aeg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1744384192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s+on7q0d2sKsDinQinkGf21gwhzzeN5z9itT+eLeiG8=; b=sdqL+MEyxoyCN2Wg6HKr3EESb75s7XE21+l21rQ/EQdtjWjihyhKNkYUyPrAwYjUXMIRzm Wi8KZSJK7mIEzhAw== To: Christian Brauner Cc: Shuah Khan , John Ogness , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Nam Cao Subject: [PATCH v2 1/3] selftests: coredump: Properly initialize pointer Date: Fri, 11 Apr 2025 17:09:41 +0200 Message-Id: <4fb9b6fb3e0040481bacc258c44b4aab5c4df35d.1744383419.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The buffer pointer "line" is not initialized. This pointer is passed to getline(). It can still work if the stack is zero-initialized, because getline() can work with a NULL pointer as buffer. But this is obviously broken. This bug shows up while running the test on a riscv64 machine. Fix it by properly initializing the pointer. Fixes: 15858da53542 ("selftests: coredump: Add stackdump test") Signed-off-by: Nam Cao --- tools/testing/selftests/coredump/stackdump_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/coredump/stackdump_test.c b/tools/testing/selftests/coredump/stackdump_test.c index 137b2364a082..c23cf95c3f6d 100644 --- a/tools/testing/selftests/coredump/stackdump_test.c +++ b/tools/testing/selftests/coredump/stackdump_test.c @@ -138,10 +138,12 @@ TEST_F(coredump, stackdump) ASSERT_NE(file, NULL); /* Step 4: Make sure all stack pointer values are non-zero */ + line = NULL; for (i = 0; -1 != getline(&line, &line_length, file); ++i) { stack = strtoull(line, NULL, 10); ASSERT_NE(stack, 0); } + free(line); ASSERT_EQ(i, 1 + NUM_THREAD_SPAWN);