From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512409; b=lVTe2ydFCINBlGf3IGEhIR7YoDz+WPhj56ieWJ5JinoH8VmNqdnLtABfP/nov3HLdliL 8SwiX76X2KuReUpM/6Wp4w4hmRahrOVNHal6PPhF7cncN6mBNniWT8YsIQpUWIjm6tbyV DXiUiktVm1ZfHiOMrkSzqLCQkV8103Hm8Q9VGaaFjCf9k7LfqhHJ1sip93V4paVnESzJU Q3wp10lllnr+DoPq5YcktNy/lD/HMnhxX6TVYPN/CzRyubVwd6LJIq+8mByhnWIcewZtd SuJpCfu9EuiOav2j1r7fGRTKROXkZZ81D10C5hriZKYZXsMAfe1bScr+BqWleV8c5zQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512409; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=0gEJVlaWrP0ZAJwgYyEcUUwWufmMAiWbvBe5hH/b8GI=; b=OnSfVE1rqQmjJ0Lc6/q6E7lwofM9ydtTLxW+zZH/o37K4SuIgD57ZpZzp9HSa9X3om46 t1mbsnelO+U5YeR70S/2sNNC3U5rgcrQq2jfp6Znb5Ro0XNiNbipkGWUmfXXRJd1EM7oL m6XoeYNAmz0Xl9NeROVWTnOG2Sr47ZTw8mHygGkqYZEPUcgmJCG0KOnw4LIl/g1kegf0s 35GFA7C7I6GQZXH383swA1IqXqUrNmtjS4tLsmF0yfautqeoUW3/2KXxiZscbITf61ODC jlp/aPlFkjprYktupkmhBuhgUqyFikNh9SPxvHbl9ZsafKR2RhyJ9tqYc+1iH2g+1pQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass header.d=kernel.dk header.i=@kernel.dk header.a=rsa-sha256 header.s=google header.b=qaR6pUNn; arc=none smtp.remote-ip=209.85.210.42 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46886606A31F for ; Sat, 5 Dec 2026 23:13:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 46886606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.dk header.i=@kernel.dk header.a=rsa-sha256 header.s=google header.b=qaR6pUNn Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-862b98b2e47so948753a34.2 for ; Sat, 05 Dec 2026 15:13:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512408; x=1797117208; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0gEJVlaWrP0ZAJwgYyEcUUwWufmMAiWbvBe5hH/b8GI=; b=qaR6pUNn6Rftd9rWqEsmNEu4FXXXA+N9Tp/cb6l36OqMvmo1akgbAFQV1z7IPw/4zy qNoXz1pUVE9oMFB93qYYDpKPI1MbE7MJ7OMGKSA0r25K9Oo8bSez/mpC7Hi6JfcSFhBD Ltymhg1OX1GYAFnvccugd48IR/Ne2QXFQcnoPTqCXhZUoNs7INE5KBTw007skvccsZ3z i/r4TKUGYoxi43Th3QCsNN4SFHk8YLI0piyp9nxxVNkm6m6dfWvqtINXkux18OMTu5km lLLUg6fbTf2CfHyeQLL1EJ3qrbco11M8MTpaJBAxZE2AAW+yBhMb9QNQ9h4HkpRO9XtD YtUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512408; x=1797117208; h=content-transfer-encoding:mime-version:references:in-reply-to :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=0gEJVlaWrP0ZAJwgYyEcUUwWufmMAiWbvBe5hH/b8GI=; b=gUiBfdbKHgrww9tZCqqyorc6TO6WNtb2YOSCmqjePICMIzvdnfsgq4zLKRRCpELL/+ XppLExF1nxCGO2fhAn5+Q3nVJehx9N38d7O4EjHh2FG7+zTIyAcJKegdvAGKEYL42WVw 4rXdf/c0XHh3PnDNgGUQM6kdH0bc+8lfjlr0tOHRJ2nLNM0IkEdbD3FeO891E5VoDYhA x2hQBl7/gfguxYBr6WlQfg67nTLRZwqSCMcFZQySoJrdwh9gNxeod4jT/DK9axX0Stci rQIPJIiscleY28RhZxjdv15BMSJGQdVDjFD0TOe3y0hlLBEd2vEDlQR75o4LOYgmo6HO XUeQ== X-Gm-Message-State: APuU4Z82qifpTm/49dVHT5NT+V+wfh34CIQbQjdELoQhZxKTBy+D/8h3 LCfuPPI7A98PAC1WQ10Zx9VFPDC+FoM1jkc9ZpUCLtIybvCUcHJH6QhVJIn9hxOYRmNvUn6zhjY xIgBVPis= X-Gm-Gg: AZFdTZcmp6sgFjNPCh58LOseimoR5NhPDNEeYapP0RxUALetYFK16p/n/YlCkDdM4sU zisIRYDwuLuBnyRf+r0LgzzGgwzMSs4V7HpxbNfJtCfJU314yLBie4hnWnLYoJEcgCgZo/u5TAt 6PhqDE1hZjfw9u/9tNo8JaGOyxMlYziImIH4gz5nZPvGU4WXCuCWhLZzOjiJqQkWG56su+miRJW ns4p+/g3unwWroRA4FM6hRS1okVmvWK/TDHJ5Ot5n145RoKpKCx8Wtkh9EXMeeZ3cS/v25fCDwv LqMotBwI08bbzcl7nrNRngHzutLZU41UwuoQTCwnaArJf3ZHk+Yta6P4DNe0yWyOG+Z72CLIsCf rLaxgPb67HrO9l355i/6Zp16ftGrs1djkXq8BAUuy5J/bG4O9kkl2F0K0c/ur9XdDREgmr1uk1U W+1J5PNFjSFj/iF8CuxQTXRlYwc7g3djUcfCsmnkxf500z10PaXsEm7opmd9cdO0cU8zMWuBFUm iZYU8wDJiTXPWZAR3+aqjwHk1d42QMyR43uAjeCf5JngjamIEn2cJglrLrmsDU/0JptUal/jti4 +reFOTKgyCBHl0Js3cBKItP5nOXzKexYHc1ILUkSRHIVnv+p5dS7Zy29BiuVyhndulAsQTcTULe fl0qAUanurgMA8YRGh1hqPFcCJ/bLzC63eRmt X-Received: by 2002:a05:6830:6412:b0:861:5c3d:4a97 with SMTP id 46e09a7af769-863f89c36c9mr6434713a34.19.1796512408354; Sat, 05 Dec 2026 15:13:28 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863f8331ff6sm6269737a34.22.2026.12.05.15.13.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:13:27 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 7.3.y 11/15] io_uring/bpf-ops: validate loop_step before registration Date: Sat, 5 Dec 2026 23:13:01 +0000 Message-ID: <20261205231305.4158103-12-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231305.4158103-1-axboe@kernel.dk> References: <20261205231305.4158103-1-axboe@kernel.dk> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Sechang Lim Commit ba0084f1402bdf2946282290a3fb0af8f3544759 upstream. A struct_ops map with only ring_fd set leaves loop_step NULL. The struct_ops update path skips a zero program fd, and bpf_ring_ops does not validate the completed value. Without BPF_F_LINK, the update then calls bpf_io_reg(), where io_install_bpf() triggers a kernel warning before returning -EINVAL. With BPF_F_LINK, the warning occurs when the link is created. Validate loop_step before either registration path. Reject an incomplete value with -EINVAL so malformed userspace input cannot trigger the warning. Fixes: 98f37634b12b ("io_uring/bpf-ops: implement bpf ops registration") Signed-off-by: Sechang Lim Reviewed-by: Pavel Begunkov Link: https://patch.msgid.link/20261119115942.3613868-1-rhkrqnwk98@gmail.com Signed-off-by: Jens Axboe --- io_uring/bpf-ops.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/io_uring/bpf-ops.c b/io_uring/bpf-ops.c index 6c2a587fb1bf..dfa93144b090 100644 --- a/io_uring/bpf-ops.c +++ b/io_uring/bpf-ops.c @@ -157,6 +157,13 @@ static int bpf_io_check_member(const struct btf_type *t, return 0; } +static int bpf_io_validate(void *kdata) +{ + const struct io_uring_bpf_ops *ops = kdata; + + return ops->loop_step ? 0 : -EINVAL; +} + static int bpf_io_init_member(const struct btf_type *t, const struct btf_member *member, void *kdata, const void *udata) @@ -269,6 +276,7 @@ static struct bpf_struct_ops bpf_ring_ops = { .check_member = bpf_io_check_member, .init_member = bpf_io_init_member, .init = bpf_io_init, + .validate = bpf_io_validate, .cfi_stubs = &io_bpf_ops_stubs, .name = "io_uring_bpf_ops", .owner = THIS_MODULE, -- 2.55.0