From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=178.21.23.139 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795966449; b=nRNMNdq3ot7dMVm7/96XGLH2wjs91MPfbQSiYLzJO175ZrE9IWkdZGBmVVH7V6qAUYry 2EAe38a/uSHGkLfvPMukxyle4DPpEnSNWm3EpUb8e9bspeL8xhNIaaZzWs1esgMvUsAQk I9SwrbEL8S0nP1HQKfqvwTwYkHLlo7+/yyDsPWaBuFKs7XxGwVdAWcibg4z5JokZkkSTt bJbdKiCFD0iJizsf68Ut0cgjpy8q46zfV7B7f9FlmsVT/ZonYkfSt3Z2YyShlhnaFLvYI 84WnjV8p6dfWqqFjelz8LmmLk8ewTu6SV9HQX9cn2A43SJaSoBKeGe2FxCs52N7awKQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795966449; h=DMARC-Filter:Received:X-Virus-Scanned:Received:DKIM-Signature: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=G+hlVErRpi5AFkBWdwkoe5yJsIpA9TlvKBjPDeriWUI=; b=nyrrg8lqLkNPkgEUSoyivLaSoQcK+c0PDy1pkrkJ2be1e4yS5VEdPJogTZOSdP0PeCg8 Idr3BOEcAqf2N0kZqBhYkFOBy5sA+RQhdgM9W4R5TBgUx7cR8fORUdSodU+tTgmaj6cHw 9HpDzTcG+Sx/NFmpy5bBfGUevSygtIU/lE236LrBtVdiRNT+OJxfd5A9v8mbolBgJGd9A ZXghxPNN/CjbN3oafT3yyGIcFYjlKhlZp1ioeRH4KEg8mdYwPrBVMjx++OxsW8GTN+nrw ZqnOtT6pBa8256zQ85oGZftj+iY5adwpLDVnJ2ZcLCPaGFzJSDFaZm5Gxx3jg3djETw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass header.d=disroot.org header.i=@disroot.org header.a=rsa-sha256 header.s=mail header.b=fCgXq0JR; arc=none smtp.remote-ip=178.21.23.139 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3076F606A31C for ; Sun, 29 Nov 2026 15:34:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3076F606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=disroot.org header.i=@disroot.org header.a=rsa-sha256 header.s=mail header.b=fCgXq0JR Received: from mail01.layka.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id C570E80730; Sun, 29 Nov 2026 16:34:05 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id KBDTD0b26yEL; Sun, 29 Nov 2026 16:34:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1795966445; bh=SejWURRB0o5dzDOs/0xTZNsTTugs754DvaTRPJG0Ads=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=fCgXq0JR3+tjnBRQ67pj2rV9uO/0RX7qQjwEpxWAcRtpYT45rO9Vm7E6MFB/YEN5v 8DzRArMpCf/fLVKcGaOOo4yT3X0D90FcW8Q7Z3xhE/gFxN7hQcflmKxK70aIkRZ8C7 i6dpMMp9/sCDkdL2cULSZZg0pdiO+hI+Udu8Nf38xbtsfRHEYefWXNrGeWqeKNSmlb XIdJ9mrZC99EF0O1Hc8P+hFkh1LmManbrvmbHYHUrWyflKbyHOdYBfjOOrxVSH4Hwx 7RrCp4lU/R4l5JaUvNdslnfHeyYBQcCZI+ev0vI0A6KBtDQHH3y/X6Om/kZEmnHmD2 YqB3veAWsAtuQ== Message-ID: <8d7f4311-4664-4410-9010-4ebd9baa7365@disroot.org> Date: Sun, 29 Nov 2026 15:33:52 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH sched_ext/for-7.4-fixes] sched_ext: Fix kernel OOB memory read in scx_bpf_x_bstr kfuncs To: Andrea Righi Cc: sched-ext@lists.linux.dev, tj@kernel.org, void@manifault.com, changwoo@igalia.com, linux-kernel@vger.kernel.org References: <20261129093555.3890002-1-maghasi@disroot.org> Content-Language: en-US From: Masoud Aghasi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 29/11/2026 14:11, Andrea Righi wrote: > Hi Masoud, > > On Sun, Nov 29, 2026 at 09:35:55AM +0000, Masoud Aghasi wrote: >> For scx_bpf_exit_bstr(), scx_bpf_error_bstr(), scx_bpf_dump_bstr() >> and scx_bpf_sub_kill_bstr() kfuncs, fmt parameter is defined as a >> dynamic string pointer which could be of any length. This causes a >> kernel out-of-bound memory read inside the bpf_bprintf_prepare() >> for loop, when passing strings with lengths higher than INT_MAX. > > Actually I think the OOB doesn't require a string longer than INT_MAX, > the verifier only checks one byte of fmt, so an unterminated buffer can > also overrun in the initial strnchr(), before reaching the loop. We > should probably clarify this in the description. > > And, as reported by Sashiko, ___fmt needs to be const, otherwise the > existing wrappers fail verification. Please also fix the kernel-doc > parameter names. > > Thanks, > -Andrea > Hi Andrea, thanks for the review. Yes, you are right about the OOB read of strings shorter than INT_MAX, without __str suffix. I will add these changes to the V2.