From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) (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 E2E4326E142 for ; Tue, 19 May 2026 12:44:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779194645; cv=none; b=QtlsFBjXqpbmbSr2zNgNtkZRxzUMnILWrx/zmoF9dOWwWkNJc0PW2goPNCD6lrNqEOiu2XoPDEOqAJ0mUgUd8MzB2NpkaijTAJe7Z5iHW00gyEansemXNYK6kA5w/uG4WWDZDFpqpvnWztByKylWlpKOaXOLZ/WK+HcBATDA6fU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779194645; c=relaxed/simple; bh=K9qLjm4ecbgy6HL5Z0R2S6Op7PXkS0JayoU2VjzCsag=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nYQhFkvdOCMH8WAIR6voBGeftCI6c1UQ+LUqgqKQ7oOuTMMRUkfw8vyDzO8rpxgV9EHq323V2q4d+NNdtiqfw8/k7B7GU1clQXXlDH+rweWBjWaShOkU5Y/wjTYImgtEQMqls51z37qLEk4HZ2PFa1ENmeJTbF1SpOl0zc2/QCQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=skYY1MMx; arc=none smtp.client-ip=95.215.58.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="skYY1MMx" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779194640; 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; bh=/uQICVciDdiUqy0k5NSTrW6t1pqNY/k5F43+RODbbQ4=; b=skYY1MMxKcBJUALkqGeIkrilMOTJQIj/s9av41+msco+v16fv6A3SL74DQW6mq4KNqvgOt Q9DDs76YT9dYN+FnPQ2Y2++YCdCnmuuqZnxV7xSrBjCVkNrEO7MrXJru82OEIle40BFG8Z cWOrgeWsggk4uu5Q66E/bjeRyve9r1M= From: Kaitao Cheng To: akpm@linux-foundation.org, pmladek@suse.com, rostedt@goodmis.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, senozhatsky@chromium.org Cc: linux-kernel@vger.kernel.org, Kaitao Cheng Subject: [PATCH 3/3] lib/vsprintf: Require exact hash_pointers mode matches Date: Tue, 19 May 2026 20:43:04 +0800 Message-ID: <20260519124304.45503-1-kaitao.cheng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Kaitao Cheng hash_pointers= accepts a small set of mode strings, but the parser uses strncmp() with the length of each valid mode. That accepts values with trailing garbage, such as hash_pointers=autobots or hash_pointers=nevermind, as valid aliases for auto and never. Use strcmp() so that only the documented mode strings are accepted. Invalid values will continue to fall back to auto through the existing unknown-mode path. Signed-off-by: Kaitao Cheng --- lib/vsprintf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 6b1213d070b4..f08ca856b03f 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -2361,13 +2361,13 @@ static int __init hash_pointers_mode_parse(char *str) if (!str) { pr_warn("Hash pointers mode empty; falling back to auto.\n"); hash_pointers_mode = HASH_PTR_AUTO; - } else if (strncmp(str, "auto", 4) == 0) { + } else if (strcmp(str, "auto") == 0) { pr_info("Hash pointers mode set to auto.\n"); hash_pointers_mode = HASH_PTR_AUTO; - } else if (strncmp(str, "never", 5) == 0) { + } else if (strcmp(str, "never") == 0) { pr_info("Hash pointers mode set to never.\n"); hash_pointers_mode = HASH_PTR_NEVER; - } else if (strncmp(str, "always", 6) == 0) { + } else if (strcmp(str, "always") == 0) { pr_info("Hash pointers mode set to always.\n"); hash_pointers_mode = HASH_PTR_ALWAYS; } else { -- 2.50.1 (Apple Git-155)