From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 5314C80031 for ; Tue, 1 Dec 2026 15:40:27 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6B1FdDAE020298; Tue, 1 Dec 2026 18:39:14 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6B1FdDAE020298 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="CSUtDoR/" Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6B1FdB4d020291 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 1 Dec 2026 18:39:11 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6B1FdB4d020291 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-c505ee610feso969165766b.2 for ; Tue, 01 Dec 2026 07:39:11 -0800 (PST) X-Gm-Message-State: APuU4Z+3LPSm48qnbW0C7sHflKtxFKvxg+m0G4hTqcKI1lD+1Vfp1bWO 8Pm+1nyrGT5XkXeBFclWx5MywXYR7dWyHdbgqqHTrVZiajWneZg1T9RS19KKh4I4Z46oOF1W2Jd qXOzwzSirLxc652fXFVLIV2hWD3T5NJVWFOgujD7x3Zcb00k24ehcvw== X-Gm-Gg: AZFdTZdLqT06SLvzQQNCZQm+vqjZ4pGArhfNbS+wIVEWlvP7aKjwRb46YanMMNhrR3c 1iA/xEneJkM8656mGQnqy8ypu1R4/yX6POU9G0jjm6NqqqrTneDlQuE9sYqW5Lwoj4jq4XwlBmL 9QVqgxaD2rlDcDKIVNohpyrlet4kh6I3ynxvKl/aagq8ALLRKuVKiLRWZJKa3hP1lf+8MTkYoIO peuu/6QDYZm1WZGB/nqFMa6ZgKxBSKyJrrsnMfjIL642w7cCpe/3sNY+bF0iZoXG70nApp07aTa Jzva1j0qQQGddRS4KjvG7xO/dVPjTnj+KB8vaQV8IGYGbYUlLrYcYkQp1Mq/jHLcKzN/m46b+gP Ycwak5qF5USRvvRl4uGQTQr6p X-Received: by 2002:a17:907:3cc5:b0:c2e:40a0:7978 with SMTP id a640c23a62f3a-c513aace8bbmr2790280066b.9.1796139551034; Tue, 01 Dec 2026 07:39:11 -0800 (PST) X-Received: by 2002:a17:907:3cc5:b0:c2e:40a0:7978 with SMTP id a640c23a62f3a-c513aace8bbmr2790277366b.9.1796139550416; Tue, 01 Dec 2026 07:39:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796139550; cv=none; d=google.com; s=arc-20260327; b=p60iBsVCPDF2YG0qsRdzJXr0H+iz0PPZIzZ7A8XHCkwX9/pfN/M2hh8jU+FeY22Phv 7tI8YqDUQ7aDolWihrz83uPQzcltSDxTVp5dsrd9Mg8dHGAcKaVWUShAAJfXMmm1udC4 fcYLHbHYD18qkM8uP5IADKJqhXREZKmSReqk7LOIFkkQGeGY689je2/RSBss/xR94jGn jMRC7BkGK/zqkQz4PiYjJczQ2vlUGWjDQazqbez/hQzw8CXpAGadanYaa5PtWGsGo/rP nm8GaxBKa5EDlK8Mbn78U4VOdiUV78qB/Z3nHsAV/yXghq07AkcqHh+SFMSBzF42eNst 0SMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=5rWjBrfv6b/K2HCavnZYnA0UsYuKInA/lhfcrMohNLc=; fh=/QSWnKFFIPNLStgUoDwCQRaXnWcMIG7fyKJgHY+VEpU=; b=MqR4Y9PXAwfPk8nVwrbjMD+KpPiVEK6Avj+mDXBk4CQ9/f2HkGovDGPz5kU7NAQHzY eiXqZXeCzHpYCOFX8jXAk9tdv0uG0P7JkmRMHq4OlLW2JhNNszhSJSQZHz/p4Rz4TXFd 4UaBWp70BXC28tGIosEz/ZpcVGcL6XYTSPRq74TtKHQGJroEi50tU1uckJQtu9PcqUFd x2mNHo489N0Rh42uDidSpcBL5q3NSgVe5Iiwo5g+iUi8dsqtz1Z9kft9xrN1q2NwDcg/ 0C4fshhXhp7pCFNOT8QJiwfzl3Q28IOI5Rv66AklmCb4Q0AqZNkId3ddXMl7frjVLwDm 5zMA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b="CSUtDoR/"; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id a640c23a62f3a-c513b0a4862si2339105266b.285.2026.12.01.07.39.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 07:39:10 -0800 (PST) Received-SPF: pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b="CSUtDoR/"; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=5rWjBrfv6b/K2HCavnZYnA0UsYuKInA/lhfcrMohNLc=; b=CSUtDoR/t1eb /96dURrCJIMVyKy7dKkTtQAWK1phtkKJ0FpwLSA/HVZ8DlX2JXFGc/yxJhOcnE/Q+lt77QkI1zH9p m33OzcsFkSjFuGEzkXjzwNHQr/Wu49LPGe8IjIpL67wYok85JthKhbuGJaXtcrR4fWds7Tdx1V3S3 UPcwOMbW20rJtDB1n9MlBur5WC8U1MNKa7DqnBlff0oPPKUjX6veQ4c2Ho9dQbKA7+qDk7YppQMK+ BvGI/vgkfem8QcfNOfYSyYdHr+eIMCn+NPcAf0yml7x/cS5hLZ5AYMb+cBAnUyWygL+rL+lH0rcGq XYRTd8/SiV1Cq4ft8JLsNw==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=LekKit-T14) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xYPvC-0081OE-0O; Tue, 01 Dec 2026 16:37:44 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com Date: Tue, 1 Dec 2026 14:10:26 +0200 Message-ID: <20261201153749.2872789-12-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201153749.2872789-1-eva.kurchatova@virtuozzo.com> References: <20261201153749.2872789-1-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 v2 11/15] ms/bpf: Fix out-of-bounds read of sk_protocol in bpf_sock_destroy() X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Jiayuan Chen [ Upstream commit 01b245ba016d44861690594e10f67e026ce8552f ] sk_protocol lives in struct sock, not in struct sock_common. A timewait or request sock handed to bpf_sock_destroy() by the tcp iterator is neither, so reading sk->sk_protocol runs past the object: ================================================================== BUG: KASAN: slab-out-of-bounds in bpf_sock_destroy+0xc7/0xe0 Read of size 2 at addr ffff8881047d11b4 by task test_progs/428 Tainted: [W]=WARN Call Trace: dump_stack_lvl+0x91/0xf0 print_report+0xd1/0x630 kasan_report+0xf3/0x130 __asan_report_load2_noabort+0x14/0x30 bpf_sock_destroy+0xc7/0xe0 bpf_prog_c3dd61f9d9cd9f37_iter_tcp6_timewait+0x9f/0xb7 bpf_iter_run_prog+0x538/0xde0 bpf_iter_tcp_seq_show+0x26b/0x4b0 bpf_seq_read+0x424/0x1210 vfs_read+0x197/0xe40 ksys_read+0x119/0x240 __x64_sys_read+0x72/0xc0 x64_sys_call+0x647/0x27e0 do_syscall_64+0xe5/0x610 entry_SYSCALL_64_after_hwframe+0x76/0x7e Only check sk_protocol on full socks. tcp_abort() already knows how to deal with TIME_WAIT and NEW_SYN_RECV socks. Also fix the comment, it never matched the code. Fixes: 4ddbcb886268 ("bpf: Add bpf_sock_destroy kfunc") Reported-by: Xiang Mei (Microsoft) Closes: https://lore.kernel.org/bpf/20260702224519.800135-1-xmei5@asu.edu/ Signed-off-by: Jiayuan Chen Reviewed-by: Kuniyuki Iwashima Link: https://lore.kernel.org/r/20260910112634.152195-1-jiayuan.chen@linux.dev Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin (cherry picked from commit a9651704c6fd64590b5ad4fbe7c3768accf95993) https://virtuozzo.atlassian.net/browse/VSTOR-158161 Feature: fix ms/net Signed-off-by: Eva Kurchatova --- net/core/filter.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index e9fe0b118985..c71edc53124c 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -12218,8 +12218,9 @@ __bpf_kfunc_start_defs(); * @sock: Pointer to socket to be destroyed * * Return: - * On error, may return EPROTONOSUPPORT, EINVAL. - * EPROTONOSUPPORT if protocol specific destroy handler is not supported. + * On error, may return EOPNOTSUPP, or whatever the protocol specific + * destroy handler returns. + * EOPNOTSUPP if protocol specific destroy handler is not supported. * 0 otherwise */ __bpf_kfunc int bpf_sock_destroy(struct sock_common *sock) @@ -12231,8 +12232,12 @@ __bpf_kfunc int bpf_sock_destroy(struct sock_common *sock) * Supporting protocols will need to acquire sock lock in the BPF context * prior to invoking this kfunc. */ - if (!sk->sk_prot->diag_destroy || (sk->sk_protocol != IPPROTO_TCP && - sk->sk_protocol != IPPROTO_UDP)) + if (!sk->sk_prot->diag_destroy) + return -EOPNOTSUPP; + + if (sk_fullsock(sk) && + sk->sk_protocol != IPPROTO_TCP && + sk->sk_protocol != IPPROTO_UDP) return -EOPNOTSUPP; return sk->sk_prot->diag_destroy(sk, ECONNABORTED); -- 2.56.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel