From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5EDF83ED3CE for ; Wed, 8 Jul 2026 09:02:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783501327; cv=none; b=VStNEX7N1oiOkq3YweakUDPAhLb62q70nRCGy64sPqCqVX/H2OAat1sSLi24L3WlTqByWwR+GDHkPc4j/HdZcMJ3SkB5ccWTaNQjuPgAn1Xlp250fJKBNS+OkOD+2efCiGAbNYcEDGU0LKzmffy6sMO68pILy97rDo4Mw39cBEQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783501327; c=relaxed/simple; bh=M1P4/cPSFe+WUlSiXFOFYdixMqAxgBQz5tvO8+L8ULM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UNt7g18kwwyeUF67IahZst/p0z73hu7bb5C+cbz6BJVmO5ZbHNRC71XznWJLftltauzUbRxTaUQJImpzTwyYQv5VxQ/8JCUZXyIifHU+VVs0oEugwBxbcnSAilCiHLriBS4GApYYWCS4lpOfi4aRGUQr0zbDnJcmZr7az8663bg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Y6NUFI4/; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y6NUFI4/" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-38759bcd877so401255a91.2 for ; Wed, 08 Jul 2026 02:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783501326; x=1784106126; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=zJQzme8jzbB96K3QvlmGt0r3KOuvo5Qma1CtSmtIkL0=; b=Y6NUFI4/RyFPywcEmi6jt5TPey6KLqdTPlqU9MQezey4TDnrO4EjwO6zPfvOAv/oco BQ+WDTz4/wwV/ewpbv8/SpnLeUxeVMOsfs7cbiRtqgm6jdCM26OiGVDa7qzxmJ+h/M+T KpjrISxIZDh/MCILPC4afB8rqwWmqnkAa79RCeYj0UONHyW+OV0pBGemcfnlicIlcDLy ZFauA5HCfjaZ1yO9sNu6RZ8MsXRbaRkqKzg3UfANZvpTmCcvrsZIBajx/xV4MMA4E+ta iGAYKv91JIKX/IwuHhIqULBGdGWj/NMUM/AAHix/nQYaxs73gw/P1qbiOXkx8712Ot46 q/lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783501326; x=1784106126; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=zJQzme8jzbB96K3QvlmGt0r3KOuvo5Qma1CtSmtIkL0=; b=RMj7VmmUdKRdF2caM7L21caMorqSrzJmT20L60BuOGgQ0qZoTK9ttRWoB03X2euTxl BVIvb6YGwT5+BlRyX/XlZP7sxhjjD7jVAo5gVtwt6ozx1bkyEctdmY6JV/5rJlggWm38 +Dcm139AkfYmeV2aN8DQQKQLqhdGW7IdExqIdSRxWJVFh8WpjPLcfh9AFTdMcqIaMhjy 6AIKIQ0rWjsaPtMPevbmFATZFuyvoE14b7WHfvBBE2JwGJ6tOXecySE+JH0hWKgTmqFZ vNjn6ZuDVEy2fP4inMFbOWYIrXNPo/pfaT9vPWNTJ1GXraQGFKUhlXADrE2UGAtwVBeT ePnQ== X-Forwarded-Encrypted: i=1; AHgh+RpFudDprFbpThmfZE5C5zVNUILHBFPpGtkK6eCcWDAl9vLyB+yQZtFvkpt/T5G01QNu5Bep1pXROh9/HTA=@vger.kernel.org X-Gm-Message-State: AOJu0Yx53EM6f0T0a+I3il+9Vtdl7su1dUSzNrrklDZCaSiKH214/fQO EQa5IY5spiirsk0VwFVe2JAPfmBpVifArHBVZ1ZpdwZHCI54Jbq7PxjILuXfiSmpX89XJA== X-Gm-Gg: AfdE7cnbCEcqKH66LfkAeSmkjPPSeHoe0AnhZQ5G15mqJpG5i/NQW97V3swen5TqdZG 4NIEtE6DSJUPn3cpg1mGquA6gurXzDpUrnklqGmPtdjhaTnH2acVcOp8WkPtDmhf5ATLQAGPUIX GwVXZ3JSWfatcjL2eyXjDtTZQ5vtEx6KkDIyXbwkxCPV+4VkWLvok/2eha1Kiq82k0uf6SGW16J IRYYlWdMiLapBSHuv4Ifs4QYBKy6F5eoj8V0VCtZyJzvL3HOcSF3F3x1pmibJF66hazBrjb39SB t/ZSQ5FHDlL8kVExGMOJL1ow0dQili1gKZH5J5GwF7fypZku2QWTuO8/0S8M9J7RXICYVKvoTzT Aun6vGJwaBVhWJPCf+lbWFfYATq+eEE20aAWYN7FJJUNWn6bR3bpJfhN3+uhf1lgaKd01tCYEWE JhfkkcbdiVr4zvKeRDBUYt1JuUZscVB9KexY+OttIskVkRw13oi/oOw5dYwxc1UuADjI4nbPGVj q9tklrhpRE2XBbQRZD9aJ8Ts5Ntk8OvNg== X-Received: by 2002:a17:90b:5290:b0:381:6466:7160 with SMTP id 98e67ed59e1d1-38941acc1ddmr1716634a91.26.1783501325649; Wed, 08 Jul 2026 02:02:05 -0700 (PDT) Received: from u2404-VMware-Virtual-Platform.tailf6b5e0.ts.net ([24.4.24.156]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-31174accb0esm19515493eec.30.2026.07.08.02.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 02:02:05 -0700 (PDT) From: Sun Jian To: bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com, shuah@kernel.org, mmullins@fb.com, shung-hsi.yu@suse.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Sun Jian Subject: [PATCH bpf v4 0/2] bpf: Reject negative const offsets for buffer pointers Date: Wed, 8 Jul 2026 02:01:49 -0700 Message-ID: <20260708090151.151729-1-sun.jian.kdev@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Reject negative effective offsets for PTR_TO_TP_BUFFER and PTR_TO_BUF buffer accesses, and add raw tracepoint writable coverage for both load-time rejection and the attach-time max_tp_access path. --- Changes in v4: - Correct the Fixes tag to point to 022ac0750883, where pointer offsets were folded into reg->var_off. - Drop the end > U32_MAX check, which is unreachable after bounding const var_off with BPF_MAX_VAR_OFF while keeping instruction offsets and access sizes bounded. Changes in v3: - Check constant var_off against +/-BPF_MAX_VAR_OFF before computing the effective access range, matching the existing verifier pointer offset convention. - Keep explicit rejection of negative instruction offsets and keep bounded negative constant var_off valid when the effective offset is non-negative. Changes in v2: - Split the kernel fix and selftests into separate patches. - Add an attach-time raw tracepoint writable test that exercises max_tp_access against nbd_send_request's writable size. - Adjust selftest formatting to use the 100 character line width. Tested: - ./test_progs -t verifier_raw_tp_writable - ./test_progs -t raw_tp_writable_reject_nbd_invalid -v - ./test_progs -t raw_tp_writable_test_run v3: https://lore.kernel.org/bpf/20260708040715.116680-1-sun.jian.kdev@gmail.com/ v2: https://lore.kernel.org/bpf/20260707060804.93561-1-sun.jian.kdev@gmail.com/ v1: https://lore.kernel.org/bpf/20260703035137.109608-1-sun.jian.kdev@gmail.com/ Sun Jian (2): bpf: Reject negative const offsets for buffer pointers selftests/bpf: Cover negative raw_tp writable buffer offsets kernel/bpf/verifier.c | 40 +++++++++++-- .../raw_tp_writable_reject_nbd_invalid.c | 58 +++++++++++-------- .../bpf/progs/verifier_raw_tp_writable.c | 16 +++++ 3 files changed, 85 insertions(+), 29 deletions(-) base-commit: 12091470c6b4c1c14b2de12dcbae2ada6cb6d20b -- 2.43.0