From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BFA0ECA5FFF for ; Mon, 5 Oct 2026 15:04:18 +0000 (UTC) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id AF8E13E9DBB for ; Mon, 5 Oct 2026 17:04:16 +0200 (CEST) Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id D0BBB3E6B3F for ; Mon, 5 Oct 2026 17:04:02 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 058B71A00672 for ; Mon, 5 Oct 2026 17:04:01 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D0FDA21C7E; Mon, 5 Oct 2026 15:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1791212637; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=p/vmzbHWAxqDgVSH77+i4ZLxcta35IAGLN4r47WML1U=; b=T6YUqUUOYy57n5SPcASf0Q9SgI/S5qpOHqbOJT0cPFuELxOxJko+DFa4e6lNs/l+S+fGbM 5l2fLZyhnu7TU0EE+2UtVjtOsnAXdbqZV6RTQmv/JbudpHYqb2K2UT7eqZg4l5gW5BAV/m NFQSxnCdY4RUxK6qcmRRmcHZr2OpFRA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1791212637; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=p/vmzbHWAxqDgVSH77+i4ZLxcta35IAGLN4r47WML1U=; b=lj18N13BRfUf57TXtR2dCJBqJRK1CM/hTUVPhnqgiIGwLC5w7EkGEpzARFcRrybbLZHAly Pb/gTlFZl8RUbvDA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1791212632; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=p/vmzbHWAxqDgVSH77+i4ZLxcta35IAGLN4r47WML1U=; b=Hk/lY6TUYRNNcEp/E1orms1yfurtQvjwzPGfFR4M8ji0mlKXYYNzn8ojefvKTdIEq2oDy9 jGGuLiuC1OpvHARiFDJY2khA+ABriZTDQk4qlVSzR+/n8u9rHAESKIMLKKQYeuiqM5ELyX DqDDSq/abTrDvyyj55NVNHZkwso17gU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1791212632; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=p/vmzbHWAxqDgVSH77+i4ZLxcta35IAGLN4r47WML1U=; b=ZDH+sG//m9W2UxLVa2hGuBLA0azWqVJpI77YT00axhm7xwH14n2XDmqcsZuIXhC6kft9n4 o4v/t89kD/hBofBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8016F13688; Mon, 5 Oct 2026 15:03:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id /f06Fli8w2raWgAAD6G6ig (envelope-from ); Mon, 05 Oct 2026 15:03:52 +0000 Date: Mon, 5 Oct 2026 17:04:04 +0200 From: Cyril Hrubis To: Andrea Cervesato Message-ID: References: <20261005-fix_core_lib_deepseek-v1-0-fec334ce8e80@suse.com> <20261005-fix_core_lib_deepseek-v1-2-fec334ce8e80@suse.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20261005-fix_core_lib_deepseek-v1-2-fec334ce8e80@suse.com> X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; TO_DN_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[yuki.lan:mid, suse.com:email, suse.cz:email, imap1.dmz-prg2.suse.org:helo] X-Virus-Scanned: clamav-milter 1.0.9 at in-3.smtp.seeweb.it X-Virus-Status: Clean Subject: Re: [LTP] [PATCH 02/15] ujson: writer: Fix OOB read on invalid UTF-8 X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux Test Project Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-bounces+ltp=archiver.kernel.org@lists.linux.it Sender: "ltp" Hi! > ujson_utf8_next_chsz() returns -1 on invalid UTF-8 sequences. > Because i is unsigned (size_t), adding -1 moves i back by one byte. > When i > 0, the loop steps back to the previous character and then > forward onto the invalid byte again, looping forever. When i == 0 > (invalid byte at the start of the string or right after an escaped > character), i wraps to SIZE_MAX, causing out-of-bounds reads in > subsequent iterations and during output flushing. Stop and set an > error when an invalid UTF-8 byte sequence is encountered. > > Fixes: c50a0e0751c8 ("libs: Vendor ujson library") > Signed-off-by: Andrea Cervesato > --- > libs/ujson/ujson_writer.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libs/ujson/ujson_writer.c b/libs/ujson/ujson_writer.c > index c86a3b2af..b5da494d1 100644 > --- a/libs/ujson/ujson_writer.c > +++ b/libs/ujson/ujson_writer.c > @@ -114,6 +114,10 @@ static inline int out_esc_str(ujson_writer *self, const char *val) > > do { > next_chsz = ujson_utf8_next_chsz(val, i); > + if (next_chsz < 0) { > + err(self, "Invalid UTF-8 sequence"); > + return 1; > + } Reviewed-by: Cyril Hrubis We should really get the fix into the ujson library as well. -- Cyril Hrubis chrubis@suse.cz -- Mailing list info: https://lists.linux.it/listinfo/ltp