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=1796329874; b=IBnjbvQndXuSNF0e4PjXWcPUpoyA1oF4X7fpTUo3Vy2t+Not1I5uG8bkcTyQVQRLJUeP tERmn8BLl0s2DmEzwpRsdBtm5FFtN+DvBdY745BESn8/PIT52kRGxD9UNq7DmmpU+JNb3 y9r//LzKRQKEj+W1Jmx9P1v+wWlCOoR5F4EZ90s3QkRwHc3hZlUJOYevfAza6mSiGS6B9 NVuhMkxqgN82f7Kh6RxYJE3xMagB0cZwnZuyhpqC3RDzlM2kd0WdFKcP0T8dXKaxjI+JF s5FqSSwLbic6kIqe67txfSbN/D22FtqgNSjtWpDnwjyznm23tw0asCBturJRzKiKoCA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796329874; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=krVoUKjV186bsrPmhFr3ns/PSdmSQzqAfqNKEdjhWls=; b=cqQVWeIBUx0LGRkwL1iEA85XIootWS+Pp8ZXxzY9HNt4VxbulnxGM6KCFvpt276vz3sh mI7H8OSSXl70kfAw+DMbD4HuBdRhsSAeZfFJhkqHSoYFT6jABqWwpHhIBwIZ0PKa8x6hV io/6r5NuWgvTWO078/vBCvDgIbSKUBRgQPzUeVhdwzDLlarC0x6Pkld/T9/Q/AuxKIS91 YWm85JsEtcLboJjVLRLeH2J/pdA4y/WOjRSrBFZRakEvjqDAiXWXwtav7/FYO8ZG5HdfO B9z7AEzsrYeugLoN2xnFeq9/yacTtkeM5qRE22K20ddoUFUD2af7RW7VXliMY+QxteA== 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=kk5xefJ0; 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 ESMTPS id 2910A606A322 for ; Thu, 3 Dec 2026 20:31:14 +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=kk5xefJ0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E79F91F000CE; Thu, 3 Dec 2026 20:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796329874; bh=krVoUKjV186bsrPmhFr3ns/PSdmSQzqAfqNKEdjhWls=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=kk5xefJ01/kuZqCHxv6d3f8VegocRaFDekxyGb/UuxhsM5NoJXDouDNChBig4NsZb wQGldZCFcKqTXnidLgCynTRK9qtkkNmVgUINp+V0OqiGiqZEz4TLEx18+QzwFi+HVW jsPs7Qr1Gn2GFLKHLyO0IwcAEt0zqMsuVPGf12A9GCG3+5CSnBh5UeNDwI/V6zvjje bZzNyCGhTxpopufwMFao8hvHp7mxZG96Tdkn3OUHwTFKC4I006UHX2ySXW/edidbpO R4rftu1+Y1Kqdukp6frbp9LbUk4KKjn6ziGA9ARVqVL1BxlpALM+2krpB3+b7+ZeUi c4Esl8JfVCGdw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf-next 1/4] bpf: Keep the lowest offset of a stack pointer that moves up Reply-To: sashiko-reviews@lists.linux.dev To: "Alexei Starovoitov" , bpf@vger.kernel.org In-Reply-To: <20261203195823.4058490-2-alexei.starovoitov@gmail.com> References: <20261203195823.4058490-1-alexei.starovoitov@gmail.com> <20261203195823.4058490-2-alexei.starovoitov@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 20:31:13 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] bpf: record_stack_access() and fill_from_stack() miss narrowed fills below V -- commit a30553fe2082bb3349a0b621d201a327d7a706aa Author: Alexei Starovoitov bpf: Keep the lowest offset of a stack pointer that moves up This commit adds a lower-bound level (off_cnt =3D -1) to the arg_track latt= ice in kernel/bpf/liveness.c so stack pointers that move up past four offsets restrict register fills to slots at or above the lowest seen offset. > diff --git a/kernel/bpf/liveness.c b/kernel/bpf/liveness.c > index 93f8d16864965..628f6f2d407eb 100644 > --- a/kernel/bpf/liveness.c > +++ b/kernel/bpf/liveness.c [ ... ] > @@ -1682,9 +1705,10 @@ static int record_stack_access(struct bpf_verifier= _env *env, > =20 > if (!info.size) > return 0; > - if (arg->off_cnt =3D=3D 0) { > + if (arg->off_cnt <=3D 0) { > if (info.may_read) { > - err =3D mark_stack_read_all(env, instance, frame, insn_idx, !info.byt= es_only); > + err =3D mark_stack_read_all(env, instance, frame, insn_idx, > + !info.bytes_only && !arg->off_cnt); > if (err) > return err; > } > @@ -1693,9 +1717,12 @@ static int record_stack_access(struct bpf_verifier= _env *env, > if (err) > return err; > } > - return 0; > + if (!arg->off_cnt) > + return 0; > + /* The main pass can widen the range below the bound. It finds bytes t= here. */ > + info.size =3D U32_MAX; > } > - for (i =3D 0; i < arg->off_cnt; i++) { > + for (i =3D 0; i < abs(arg->off_cnt); i++) { > err =3D record_stack_access_off(instance, arg, i, info, frame, insn_id= x); > if (err) > return err; [Severity: Medium] Can a widened stack pointer still perform a register fill below the lower bound? In a loop leftover, join_range() can widen a PTR_TO_STACK downward to -BPF_MAX_VAR_OFF + 1, which stays within the comparison range of is_branch_taken(). Comparing it for equality against another same-frame PTR_TO_STACK at a constant offset below arg->off[0] lets is_scalar_branch_taken() -> scalars_refine_cond_op() narrow var_off back to that constant, so check_stack_read() dispatches to check_stack_read_fixed_off(). Because mark_stack_read_all() clears fill when arg->off_cnt < 0, __clean_func_state() degrades a spilled pointer in that slot to STACK_MISC under allow_ptr_leaks, causing a regression where valid programs fail verification with -EACCES. fill_from_stack() has the same issue for spilled PTR_TO_STACK values below off[0]: skipping those slots leaves downstream accesses through the filled pointer without FM_LIVE_BEFORE marks, so __clean_func_state() poisons the target slot with STACK_POISON. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203195823.4058= 490-1-alexei.starovoitov@gmail.com?part=3D1