From patchwork Wed Jun 19 02:06:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13703336 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 96B7ECA40 for ; Wed, 19 Jun 2024 02:06:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718762798; cv=none; b=IigEQ/W6PA6JlQU+H/TiY/8JEzmy/DSR8/AeA9mC8m/xBCWfl3qAS3pK5r+M5rvlFm4FYHsbOVhR5iaeeAjSKCBKJobiyopM5nkVtHeY+m/f3bYQsohZlXDBYVYM4O64duZKduQbr2AxPY7a+dIf2u6VrXxD5usBEKTpqHFLR7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718762798; c=relaxed/simple; bh=aQxfgo7l61+0/Nb248t7mAlh51V/LztIBsh+9nxLYYw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XWCBnaYjGDBgL2dFAG7+VlpFbiSkOz/oFtPRtfmpbp6aeY0McB56kkf9FZEqh+yRpWvVq58YQnhD053QpBSGYd9HnjjsFKyWeeKKTogiR6EzHZvljhN2gCruxwODUo+DiPzzgAWpQucT5dj/nMiVth7Na4SDrluvbPYFnFRCWfA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=ZE5ogQEv; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=uqKA9iV2; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=ZE5ogQEv; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=uqKA9iV2; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="ZE5ogQEv"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="uqKA9iV2"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="ZE5ogQEv"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="uqKA9iV2" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AD4042198D; Wed, 19 Jun 2024 02:06:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718762794; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w+duwK6gh2vWHbc5cyD6xb9g9g9wIY5+tyLnsCB2khA=; b=ZE5ogQEv+8A0ufZXJjpLCckFBIVz3CnAwu+t3NgL1f5lm6P0c3MyG1hJWmX99M/rQ5hiUY ZvZ6dUnvz8WaA6pbo9qRkBt65Hx0gTiopTZxNL7tEALvywtXS+ND9OvtRaBCN+cwgIDi6f YjPnHgzx4/hnGUInU9qaJgo4wE92E7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718762794; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w+duwK6gh2vWHbc5cyD6xb9g9g9wIY5+tyLnsCB2khA=; b=uqKA9iV2toN9eEV/TGg1AK9sKoPbM8zj+6+wxSXt23GiomGp6AKa+SeOUxUzx2FDzGwLs+ PBTlSJPgt4GVE5CA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718762794; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w+duwK6gh2vWHbc5cyD6xb9g9g9wIY5+tyLnsCB2khA=; b=ZE5ogQEv+8A0ufZXJjpLCckFBIVz3CnAwu+t3NgL1f5lm6P0c3MyG1hJWmX99M/rQ5hiUY ZvZ6dUnvz8WaA6pbo9qRkBt65Hx0gTiopTZxNL7tEALvywtXS+ND9OvtRaBCN+cwgIDi6f YjPnHgzx4/hnGUInU9qaJgo4wE92E7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718762794; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w+duwK6gh2vWHbc5cyD6xb9g9g9wIY5+tyLnsCB2khA=; b=uqKA9iV2toN9eEV/TGg1AK9sKoPbM8zj+6+wxSXt23GiomGp6AKa+SeOUxUzx2FDzGwLs+ PBTlSJPgt4GVE5CA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6462513AAA; Wed, 19 Jun 2024 02:06:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id lYC9ESo9cmYYNgAAD6G6ig (envelope-from ); Wed, 19 Jun 2024 02:06:34 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH 1/3] io_uring: Fix probe of disabled operations Date: Tue, 18 Jun 2024 22:06:18 -0400 Message-ID: <20240619020620.5301-2-krisman@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240619020620.5301-1-krisman@suse.de> References: <20240619020620.5301-1-krisman@suse.de> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Score: -2.80 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; RCVD_TLS_ALL(0.00)[] io_probe checks io_issue_def->not_supported, but we never really set that field, as we mark non-supported functions through a specific ->prep handler. This means we end up returning IO_URING_OP_SUPPORTED, even for disabled operations. Fix it by just checking the prep handler itself. Fixes: 66f4af93da57 ("io_uring: add support for probing opcodes") Signed-off-by: Gabriel Krisman Bertazi --- io_uring/opdef.c | 8 ++++++++ io_uring/opdef.h | 4 ++-- io_uring/register.c | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/io_uring/opdef.c b/io_uring/opdef.c index 7d5c51fb8e6e..f3af2126fc7d 100644 --- a/io_uring/opdef.c +++ b/io_uring/opdef.c @@ -746,6 +746,14 @@ const char *io_uring_get_opcode(u8 opcode) return "INVALID"; } +bool io_uring_op_supported(u8 opcode) +{ + if (opcode < IORING_OP_LAST && + io_issue_defs[opcode].prep != io_eopnotsupp_prep) + return true; + return false; +} + void __init io_uring_optable_init(void) { int i; diff --git a/io_uring/opdef.h b/io_uring/opdef.h index 7ee6f5aa90aa..14456436ff74 100644 --- a/io_uring/opdef.h +++ b/io_uring/opdef.h @@ -17,8 +17,6 @@ struct io_issue_def { unsigned poll_exclusive : 1; /* op supports buffer selection */ unsigned buffer_select : 1; - /* opcode is not supported by this kernel */ - unsigned not_supported : 1; /* skip auditing */ unsigned audit_skip : 1; /* supports ioprio */ @@ -47,5 +45,7 @@ struct io_cold_def { extern const struct io_issue_def io_issue_defs[]; extern const struct io_cold_def io_cold_defs[]; +bool io_uring_op_supported(u8 opcode); + void io_uring_optable_init(void); #endif diff --git a/io_uring/register.c b/io_uring/register.c index 50e9cbf85f7d..75f8e85cf0b0 100644 --- a/io_uring/register.c +++ b/io_uring/register.c @@ -59,7 +59,7 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg, for (i = 0; i < nr_args; i++) { p->ops[i].op = i; - if (!io_issue_defs[i].not_supported) + if (io_uring_op_supported(i)) p->ops[i].flags = IO_URING_OP_SUPPORTED; } p->ops_len = i; From patchwork Wed Jun 19 02:06:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13703337 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 3AF871097B for ; Wed, 19 Jun 2024 02:06:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718762800; cv=none; b=Oty+IbZVI6QWj0YNIMNMMBBMA+Tuyp6SXw9l4XExXP+UjYcEhvVPkRNBePy+q1AI3hg6xKnQzzPtYwUTPDrFbzpjw7wBfj0pFope6kvnPAaoKJiVEX74hr2ZiwuI2+qL5QVjBOW86HvDBLb1BKWy1GMaZLQCVkKpXXx2MYwyz5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718762800; c=relaxed/simple; bh=EJbb1It10VgxHc+Zxv9g/aRFmGamoyfSMEdbUJxxEhg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G77BWWG2MhYOPvNmk7k3VckycGwBuqWGb/BkhYuSiSg5oWQtPIBH7BgZasx97ZmBYSSXiMGfZ5op6GzrL/d4iUJPOq/V2iuOO7R2G2oeEUHyEFJLHDb1LjZ+nyyNQQJPpLHh+bWfCPGawHdnqCFyUXkMp7Qqb6RhO+W33pnuATk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=bNqCpRrT; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=UFqDHGpX; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=bNqCpRrT; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=UFqDHGpX; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bNqCpRrT"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="UFqDHGpX"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bNqCpRrT"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="UFqDHGpX" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 567142198B; Wed, 19 Jun 2024 02:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718762796; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j9+jdUADYt52dtFQ3q/Db7cHZ/Wb0fZqcEyf9oJ8Pyk=; b=bNqCpRrTT8GItqMjMTZ4kGbFCwG1oQdak9ms7NEJDOq8tASBEnK5QWPlvyz+CiwNu3mamk 7YUwIj8QPexFnKizadRqMjR9wFBZUzeIzaIUJn2YWJZllJsECEmcbE/aWWg9KBgs4CgoF1 +3goYeLj+wJCQ0qTd7KUnKuwI80LB6c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718762796; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j9+jdUADYt52dtFQ3q/Db7cHZ/Wb0fZqcEyf9oJ8Pyk=; b=UFqDHGpXP7fB10nW4i6yhEJd3JJvaKI0HGtf+Oks7agndxSZLHqry4oo6OkQSoxG9E831e LfVnHAKp/DwHE/Bg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718762796; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j9+jdUADYt52dtFQ3q/Db7cHZ/Wb0fZqcEyf9oJ8Pyk=; b=bNqCpRrTT8GItqMjMTZ4kGbFCwG1oQdak9ms7NEJDOq8tASBEnK5QWPlvyz+CiwNu3mamk 7YUwIj8QPexFnKizadRqMjR9wFBZUzeIzaIUJn2YWJZllJsECEmcbE/aWWg9KBgs4CgoF1 +3goYeLj+wJCQ0qTd7KUnKuwI80LB6c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718762796; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j9+jdUADYt52dtFQ3q/Db7cHZ/Wb0fZqcEyf9oJ8Pyk=; b=UFqDHGpXP7fB10nW4i6yhEJd3JJvaKI0HGtf+Oks7agndxSZLHqry4oo6OkQSoxG9E831e LfVnHAKp/DwHE/Bg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1901F13AAA; Wed, 19 Jun 2024 02:06:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id K4UkOys9cmYoNgAAD6G6ig (envelope-from ); Wed, 19 Jun 2024 02:06:35 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH 2/3] io_uring: Allocate only necessary memory in io_probe Date: Tue, 18 Jun 2024 22:06:19 -0400 Message-ID: <20240619020620.5301-3-krisman@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240619020620.5301-1-krisman@suse.de> References: <20240619020620.5301-1-krisman@suse.de> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spam-Level: We write at most IORING_OP_LAST entries in the probe buffer, so we don't need to allocate temporary space for more than that. As a side effect, we no longer can overflow "size". Signed-off-by: Gabriel Krisman Bertazi --- io_uring/register.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/io_uring/register.c b/io_uring/register.c index 75f8e85cf0b0..8409fc80c1cb 100644 --- a/io_uring/register.c +++ b/io_uring/register.c @@ -39,9 +39,10 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg, size_t size; int i, ret; + if (nr_args > IORING_OP_LAST) + nr_args = IORING_OP_LAST; + size = struct_size(p, ops, nr_args); - if (size == SIZE_MAX) - return -EOVERFLOW; p = kzalloc(size, GFP_KERNEL); if (!p) return -ENOMEM; @@ -54,8 +55,6 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg, goto out; p->last_op = IORING_OP_LAST - 1; - if (nr_args > IORING_OP_LAST) - nr_args = IORING_OP_LAST; for (i = 0; i < nr_args; i++) { p->ops[i].op = i; From patchwork Wed Jun 19 02:06:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13703338 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 9D332CA40 for ; Wed, 19 Jun 2024 02:06:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718762805; cv=none; b=YcG33XIefzlLN6xaSQj9viyxhiGgp4rVM61vNDM5eCF/ii8K+W3RQUtNFZ/0ybw/8c8+fXDCfIjvNZ4ZGpsv/pXF4WRy9bgg0u+EFF9zgNVSB91QK5YUnDs1NAMVEViiGxu/rNuF8lhWKEUv/7YeMScmW8N0yV3MeKH86e36cBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718762805; c=relaxed/simple; bh=o4HqAZPzczMh59IJz77XoJm7PSdxWj2yYn75kUrEur8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kH9AXrahhSUem9hozyKceIP0/Cd7MOZPCjYgliqfRi/QsI18iiTS3z0Vfb6gbWs6E8Z0Y+DaRQiGUWzC8NgIG025oJty9L2uKSBn4q2pOKPqLKkLeJbnZGlAihuI6oQK6rNpEzQdmkTynyPTt29u3ySQAN2Np0SR1UP3os8LRZ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=e3RHyTlw; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=xPkKGoUv; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=FDfVsnSp; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=jCB1ezqR; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="e3RHyTlw"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="xPkKGoUv"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="FDfVsnSp"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="jCB1ezqR" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EEB761F7B0; Wed, 19 Jun 2024 02:06:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718762802; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hKtaoBU+L32HhmXj5EEXm8XaqoQoKrrwsHq7dBzGL+4=; b=e3RHyTlwLWWbkj9GEvPIL7NkEuYdf2HOIPHXCNMiQx5iD2vC9ktdHIar9vJTnDyck3B20N F0vun/nzW9zvdE/Qvy0ju7d7v5wq1TQcEYxfXM4kL2TPJaMCQbgx0o5b2GEFXkCcLFdg1D 9P0MaVYGhbqVilAHra9gukwrHZ3TOUI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718762802; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hKtaoBU+L32HhmXj5EEXm8XaqoQoKrrwsHq7dBzGL+4=; b=xPkKGoUvbV5izAouMjT2jEICNrm8e9OvnB+uTRUM0R+QAkarKmFhUJrKkRVsJS0u3CmxKE U3XzXCFU0Tcbe5Cg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=FDfVsnSp; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=jCB1ezqR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718762801; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hKtaoBU+L32HhmXj5EEXm8XaqoQoKrrwsHq7dBzGL+4=; b=FDfVsnSpB+MHLoN2BJWSrotjLs6SYmrytXtAWkPnFi4CO0CDsZER70HsS+CdN1VCNCB039 HkUxOapD/MXuQ8eozYt0w1jwZgCEQyoFG4px+YH3/MBVBFaA974oAsbHXElbmyLyJkWPPA KVoffgtjvH7aEP1/Z63x0DCxTNzYEPs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718762801; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hKtaoBU+L32HhmXj5EEXm8XaqoQoKrrwsHq7dBzGL+4=; b=jCB1ezqRVHiIbJRGoYcuq2A5YQiLOhXINF1td7cZUA2DwykLLC2I2fJASIS/XAYGni1FnA 4MQSE5KY9xmSPNBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B481113AAA; Wed, 19 Jun 2024 02:06:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id NOyPJTE9cmYtNgAAD6G6ig (envelope-from ); Wed, 19 Jun 2024 02:06:41 +0000 From: Gabriel Krisman Bertazi To: axboe@kernel.dk Cc: io-uring@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH 3/3] io_uring: Don't read userspace data in io_probe Date: Tue, 18 Jun 2024 22:06:20 -0400 Message-ID: <20240619020620.5301-4-krisman@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240619020620.5301-1-krisman@suse.de> References: <20240619020620.5301-1-krisman@suse.de> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: EEB761F7B0 X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: We don't need to read the userspace buffer, and the kernel side is expected to write over it anyway. Perhaps this was meant to allow expansion of the interface for future parameters? If we ever need to do it, perhaps it should be done as a new io_uring opcode. Signed-off-by: Gabriel Krisman Bertazi --- io_uring/register.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/io_uring/register.c b/io_uring/register.c index 8409fc80c1cb..a60eba22141a 100644 --- a/io_uring/register.c +++ b/io_uring/register.c @@ -37,7 +37,7 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg, { struct io_uring_probe *p; size_t size; - int i, ret; + int i, ret = 0; if (nr_args > IORING_OP_LAST) nr_args = IORING_OP_LAST; @@ -47,13 +47,6 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg, if (!p) return -ENOMEM; - ret = -EFAULT; - if (copy_from_user(p, arg, size)) - goto out; - ret = -EINVAL; - if (memchr_inv(p, 0, size)) - goto out; - p->last_op = IORING_OP_LAST - 1; for (i = 0; i < nr_args; i++) { @@ -63,10 +56,8 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg, } p->ops_len = i; - ret = 0; if (copy_to_user(arg, p, size)) ret = -EFAULT; -out: kfree(p); return ret; }