From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm2-f12.google.com (mail-wm2-f12.google.com [74.125.225.140]) (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 31D3439AD34 for ; Tue, 29 Sep 2026 08:16:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.140 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790669791; cv=none; b=V0UYwKPxjEGmy+XFxK8+Lqmws8cLElwDs8FQPiQjuB/HpYFA5Kmpfebua3xBPgoqKj6uH+vx6eXSCGW+3VLF1x+pHyiIBcrx6BQ0+J12t8OkNkIENs0u7jQcIMCjYgZZb7nAshKlF4jTbQJ16uWzxzaj9r6bmgZSozRL88oL1sI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790669791; c=relaxed/simple; bh=Sz1JmCKBZu7fltXb2NbvPIDp3GGnx7GfjB0icQIxMP4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=EyPRpC9DKCX2WSDsGix4ZYpgigJuqPClrXScLOKcPcTBGDTYIyam3OnetW1RpgIwfTfMU3A7NVQxCHL0j7MKknAQyAkpZTsqaj/SUk1CjhKgjstwI9NnKLTMH9krJcYAj6PntrQ9ZckVOvAYbibI6MmLKQSfYEuWpcbZ8CFbhgM= 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=Y8rcy+m6; arc=none smtp.client-ip=74.125.225.140 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="Y8rcy+m6" Received: by mail-wm2-f12.google.com with SMTP id 5b1f17b1804b1-49ffb83bf7aso23212885e9.2 for ; Tue, 29 Sep 2026 01:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790669788; x=1791274588; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=DneU6OYsM/0OepyIfW6Zz603NV6AMxXwLJIXPeol2ys=; b=Y8rcy+m652p0mlgwK7oPpdOWivZQ2H6f+qakgFL1LKSn+jsQXBkM8kbsxCJr6ikgCQ sjq28b0++Hhszwkr7JMMycq3oIGsLVAY9+TilfzGoDcZlNhqROpLuABymg7EHr3qVuvT QWQM/wFi/0ncEOkgRzf0YvF91NIwsU7Xt69RcPWVx8Q+3O1L7SG/UJfesalkc+JHrSC3 oQvSB/FW+ZDdJ2cjIapKv2JbGr4DmHC9B6RxWjSAfWECccXo6grEVAQ0URpc2iLlFoOI VEbF6l6RsKpMFBBnam0r1wUOu9yT+EIzMBVY44j9Vmt+G24/LxWq4VtHKkd8k+ojroIb 57eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790669788; x=1791274588; h=content-transfer-encoding:content-type: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=DneU6OYsM/0OepyIfW6Zz603NV6AMxXwLJIXPeol2ys=; b=D9YC5BfMDnU6AnCVEdSPQSvvm6GeZMiQDkPzuSfM0He/3S35/H6ThVmL42G6RFbrD8 Duyx8G25aKKjkIzX5tnfopK1gZgJYJkRYd8ohuldVXY6TxBmIJTwNb3/WwFxhe+soemA Z6fHWWxHjbugQzJ4fPgKmmH4u1bZhzX4WjndQx6Neywy24ytHuO74AZ2WkhCbcdwEWxx 78ise3XnSQWPJiT0wL5rGR1FlQhjmFpZFbXl/DsmK8Gr+zzY26Du8eL3YIYVMK0TNe68 jI1+RzphFiJw50+a55Xk5EAzVdNb65+nWHr9eBBnGaypgKsf3vYGTFTdfquez+YRrYCR xJrw== X-Forwarded-Encrypted: i=1; AKwUvByNH1dvRNcnhbW7wGRJ6ix+odNJ+RnlSgoCtLjTlozKKOajrTcCtOZKpMYWxQS/yzcsKqKDfpWtSeeY/60=@vger.kernel.org X-Gm-Message-State: AFuF++nWgYMRcBoBaoAjUMgVAvp/km5ZRitlJFPM2o24SB+bQAa8BDm6 X+HwxJ4FU9wJ4bdsW0zCFwXNnmJmYrufqKgXc/9U4v3RFcOPSXuU2DzSdGfRCz3SQRCD6g== X-Gm-Gg: AYBFou1VT1qbnB2uP/XQ6duHDJZXUMgyAoILrFac/aFhrMhdg1nVAjeCo9dlK2ccLFy xLw5PKjg+jpWT68gkJVzMpnzpiw39smUh1RABK3QlTnUyyJfSbUwsrp0fAJKCjz61u3wPBui3Dl KFLSow1RIRKTRQXDkvF63l5WVDWQNdGVSNDa2FZ8F4SbiXLsjTic1f0yv+fvVdr1dRBE0+WtHAE gs9abyjcHibpZHIWEDpHH5Z5c9iIp63EeTkeppkH8ZxDth2w0WKUDXlC9CQ/IN7Rq7Mha2aNuS3 OncYmmLvlP/qOoycYT9rhBr8RveukeNae6HsAh4iNORqqmpBvIdm64Lj1o+9c+VoOyistvHrZws KwHAeauFqFdUczbT6j2GvdV/IW6k36gk5cBE0SMR47k76QOmuO8GX0A19F1C1xPI5LguX6KNq4M yK3DQ74vtU1rNsbJfyEAg0SaT5cvP5XarqLOTAHsrMVPNBkIlkT+x2nS25UPmaCY5EcNGb0SYHK S6Ps/Y= X-Received: by 2002:a05:600c:310b:b0:49f:bd3c:bc18 with SMTP id 5b1f17b1804b1-49fe66f4c72mr267527685e9.19.1790669788138; Tue, 29 Sep 2026 01:16:28 -0700 (PDT) Received: from metepc ([46.197.185.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a00d453badsm38333395e9.2.2026.09.29.01.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2026 01:16:27 -0700 (PDT) From: =?UTF-8?q?=C3=96mer=20Mete=20Kaya?= To: ast@kernel.org, daniel@iogearbox.net Cc: 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, ihor.solodrai@linux.dev, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?=C3=96mer=20Mete=20Kaya?= , syzbot+fd7e415d891073b83e1f@syzkaller.appspotmail.com Subject: [PATCH bpf v2] bpf: Fix missing migration protection in __rhtab_map_lookup_and_delete_batch() Date: Tue, 29 Sep 2026 11:10:34 +0300 Message-ID: <20260929081609.557899-1-omermetekaya0@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bpf_mem_cache_free_rcu() uses this_cpu_ptr() which requires migration to be disabled. All callers of rhtab_delete_elem() disable migration except __rhtab_map_lookup_and_delete_batch(), which calls it under rcu_read_lock() only. On CONFIG_PREEMPT_RCU, rcu_read_lock() does not disable preemption or migration, so the task can migrate between CPUs during the delete loop, causing this_cpu_ptr() to trigger: BUG: using smp_processor_id() in preemptible [00000000] code Fix by wrapping the delete loop in migrate_disable()/migrate_enable() in __rhtab_map_lookup_and_delete_batch(), matching the migration protection that the other callers already provide. Fixes: 818e00848227 ("bpf: Implement iteration ops for resizable hashtab") Reported-by: syzbot+fd7e415d891073b83e1f@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=fd7e415d891073b83e1f Suggested-by: Alexei Starovoitov Signed-off-by: Ă–mer Mete Kaya --- Changes in v2: - Fix root cause in __rhtab_map_lookup_and_delete_batch() with migrate_disable()/migrate_enable() instead of stretching bpf_disable_instrumentation() in rhtab_delete_elem(). - Fix Fixes: tag to 818e00848227. - Fix commit message: migration disabled, not preemption. Tested with syzkaller: - Before the fix: the reported warning was reproduced reliably. - After the fix: the warning was no longer reproducible. kernel/bpf/hashtab.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c index f744a42bb813..2bb9ac7fc73e 100644 --- a/kernel/bpf/hashtab.c +++ b/kernel/bpf/hashtab.c @@ -3369,8 +3369,10 @@ static int __rhtab_map_lookup_and_delete_batch(struct bpf_map *map, } if (do_delete) { + migrate_disable(); for (i = 0; i < total; i++) rhtab_delete_elem(rhtab, del_elems[i], NULL, 0); + migrate_enable(); } rcu_read_unlock(); -- 2.55.0