From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796247885; b=1sMp14jYho+lVxhNz+V8PfZge4BE9cespQXenLJxj91ZHLiQNuOZp5E7VBpmgqo5lklq zZzzZ2r8BzLgtqwEbi/igXX8lqCtsdr8hCp1OXT0XdcqiBGkYlvTcfp9qn1We8iLBzxnT vKQJpHr+b1SNI6H+m91EOmwMDb+thoW3S4QRk86PMTpoUo1Q7i8gc7GfCTVHGLxVV8Cle U+PUdT0KqIihw3ChjREFFpB/+Q/vXaGU5gqN9xpuolxBcvmQug9UynkSNWFWO4I0iEmUR Lv1L9PJ57ZZNOZNjodHOQ7GLQhbr6ppS1TK4j4Kr5lhC0hxulyip6EjhhmefhrrXB8g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796247885; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=c3/7PfUMfB/QUGk40lpY5vt1TGVoeShZZsYSjX6Qubk=; b=D7KcAFdyxvKmvuqUPf8phj4jkpNtJME1rrm/03Fa5mzQObqi/i2sVJg7vu5ubGobpji4 GkOk9ApV+5t1P/wVm9yw47Zvmop9mBQnY0lGsWMi2Oj7reT7Qlc31gwD+3pJYyoPap5uW tGRjfKVME86cgNQXSWZnYEe3QY+pWdzLNr1fKg2hAz9slZx86XdRBAB3yAz7ByAXaJr/J pRIz/bVf5ADPKy4l4Mew3jA2J5o4YVrmSvKbZw8hJIbceDbcrYqrHfpyU2Cy1BqUF/+AB qDoLCn25KsISHTcucuupKAqV/u70qNmeYmEsWK7ZEAfP8I59IGuDmn15o1E/L4EiiXg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LbiNzAyK; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id 194CC606A322; Wed, 2 Dec 2026 21:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LbiNzAyK Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 1B6AF1F00893; Wed, 2 Dec 2026 21:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796247884; bh=c3/7PfUMfB/QUGk40lpY5vt1TGVoeShZZsYSjX6Qubk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=LbiNzAyKfiaB6In8c1qwWcnmQykUJthQsUTEEv6IdyQM79gp3hamSalRNHe6Z4UX7 Ys8G6r9+XVi4SK0KN53AV/UXr8Vl1Pixt5UvLwL49RVbPmH1YNxtfPKtLMaU4JXIqk 28DBvCwIm9+paci8Ve7oN/KZnPXM3sAzPkiWM30klTEzW9+Yiyf8JkGrZ6SgBmVYBj qhDATKGRjs6ylIXwS4f40ZAnR9fuvFRAwqPlYajtVZ9hfAq34JQCFRevS3++bq4sAr izsaow0JORrXEXVEKQ4wFvWDbx5SXX5M+/+cUC/6eu0Blob2opFU1adSfh1RIEfw00 lLK9Fc8jl6xyA== Date: Wed, 2 Dec 2026 23:44:41 +0200 From: Jarkko Sakkinen To: Yingjie Wang Cc: David Howells , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , "keyrings@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH net] keys, dns: Limit the payload dump in dns_resolver_preparse() Message-ID: References: <20261202123156.764901-1-x-professor@outlook.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202123156.764901-1-x-professor@outlook.com> On Wed, Dec 02, 2026 at 12:31:59PM +0000, Yingjie Wang wrote: > With the dns_resolver "debug" module parameter set, > dns_resolver_preparse() prints the whole key payload, using datalen as > the "%*.*s" precision. add_key() accepts payloads of up to 1MiB - 1 > bytes, but vsnprintf() limits the precision to 32767, so a larger > payload hits: > > precision 32768 too large > WARNING: lib/vsprintf.c:2659 at vsnprintf+0x1019/0x12a0, CPU#0: repro/284 > > With panic_on_warn, this panics the kernel. Once debugging is enabled, > any user who can call add_key() can trigger it, because the payload is > preparsed before the key quota is checked. > > Commit 9c438d7a3a52 ("KEYS: DNS: limit the length of option strings") > fixed the same warning for option strings, but the entry trace still > dumps the full payload. > > A printk record is limited to 1024 bytes anyway, so print at most the > first 128 bytes of the payload. Its length is still printed, so the > truncation remains visible. The field width only padded the output > with spaces, so drop it. > > This bug was found by a fuzzer. > > Fixes: d46d494214ca ("KEYS: DNS: Use key preparsing") > Signed-off-by: Yingjie Wang > --- > Tested on top of 4dce97c6c265 (x86_64, KASAN) with debug=1 and add_key() > payloads from 128 bytes to 1MiB - 1 from an unprivileged user. Without > this patch, a 32768-byte payload triggers the warning, and panics the > kernel with panic_on_warn=1. With it, there is no warning at any size, > the trace shows at most 128 bytes followed by the length, and add_key() > returns the same results as before. > > Jarkko's "KEYS: Drop key_type_dead" series (v7) moves the key type into > its own module but does not touch this line; this patch applies on top > of it as well. > > net/dns_resolver/dns_key.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c > index 451247864a63..c12bf47d6363 100644 > --- a/net/dns_resolver/dns_key.c > +++ b/net/dns_resolver/dns_key.c > @@ -121,7 +121,7 @@ dns_resolver_preparse(struct key_preparsed_payload *prep) > goto store_result; > } > > - kenter("'%*.*s',%u", datalen, datalen, data, datalen); > + kenter("'%.*s',%u", min(datalen, 128), data, datalen); > > if (!data || data[datalen - 1] != '\0') > return -EINVAL; > > base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5 > -- > 2.43.0 > Good catch. And these type of changes contribute to e.g., key_type_dead removal a lot because they also "transmutate" patches on a healthy vector. Messy but working code is also quality code IMHO. So no need to disregard value of these changes at all. If e.g., bug fix for instance gets deleted by some bigger change it makes sure that "cuts are better" i.e., they accelarate quality. I don't see anything upimportant in that; or I should stop doing this if I ever think otherwise. Reviewed-by: Jarkko Sakkinen Br, Jarkko