Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1099717pxb; Wed, 6 Apr 2022 08:42:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxqo5FTV1lpJjgpKEOuqoGJv0c3JiWcP4/BPH1uk9ks6IwqW5qBc7b+/yerCcwVlhLwynv X-Received: by 2002:a17:902:a60f:b0:155:efbf:1291 with SMTP id u15-20020a170902a60f00b00155efbf1291mr9120502plq.152.1649259758945; Wed, 06 Apr 2022 08:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649259758; cv=none; d=google.com; s=arc-20160816; b=XNZneto6H/BQDwfBNv/e4SztC8JqiVswZsUeoqj8PSr65kwGvvopnLQNH2d/iiCm1h RcfwzIGzEAiGNt+khjK2JekGDRPIGFjdqkyXDoRW0xnelrMa/wlDnk9LcbnsSEYf5icb EQhyK+sGlxxyci8ryTUTiKKYrRUwFXXEvYs4bfuwj17nO6OZMLJqxO41cfAAnExBAf07 KVyoJWExFbe/6dJ7gHj9moVk3nBvWaL64cDT4U3y6VHKDxrLX2mVdIhu8cqKz6hHOzpd CBsEaYDHG5qdiKc6KB2YCKxGNd7Whz/lYxrEXYxXrjnl6VFiZj4VJU8vS5mFh13cWP4y XV4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=AcjzWGcdu18BMqkfmj4vFQYOWEOKNr12Idy3vAbhIVw=; b=N4fsKkIpoTk3IApPyB0+vPSlM+LLvCzOjnXDVj05niWX0QW8YXEjZnW1sMAOVRaP8g QmWMydolmnJ54bwDUDSt5BFWEY3IsZ6uO8+u7a7Ug3azEqvUn4E5072a/wsKluHWLYPc Nb+RdRAFN/F2CNglDJVfCLD/OfthTAcEmZ18cJwtSiA4hIIUnCQxHYrSgr0lnFV5QBIL 7qMgIefIaYD5KaxnrRRy+/MbwvBsD88Cihf/ona755Uvu5mZ8Xlm63ORiCvGbUwQBL55 im60B1kpO2flu+f+0uzixlvzOt8j80hxa4FG9u4xJKs5LHTSQO5GXs6hrXBRJT/t/Fw1 xmrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FabKE2qt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f4-20020a6547c4000000b0039910e47e5bsi10698939pgs.528.2022.04.06.08.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 08:42:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FabKE2qt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 93268299F0B; Wed, 6 Apr 2022 08:05:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235709AbiDFPHY (ORCPT + 99 others); Wed, 6 Apr 2022 11:07:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235613AbiDFPHI (ORCPT ); Wed, 6 Apr 2022 11:07:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EA2D71BE10A for ; Wed, 6 Apr 2022 05:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649246140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=AcjzWGcdu18BMqkfmj4vFQYOWEOKNr12Idy3vAbhIVw=; b=FabKE2qtVtaeuYCqImD47zLRflpoUocZUB8PIeRq0yXZt3hI38eMxyvJE4FR0+WUQVmQ47 6EXAYp38llV9I/uJviHfcnvuqDkBrt+EghEAAhi4neM1rZ5wxDkYIoADWEqOr+RaX+Y3t7 Zo8hK7OSLMzsxEiChjeXGraM6CY2seI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-502-Bbd3XBGAPq2BPBjOc-j5Dg-1; Wed, 06 Apr 2022 07:55:37 -0400 X-MC-Unique: Bbd3XBGAPq2BPBjOc-j5Dg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4375F824072; Wed, 6 Apr 2022 11:55:37 +0000 (UTC) Received: from asgard.redhat.com (unknown [10.36.110.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0219140CF905; Wed, 6 Apr 2022 11:55:35 +0000 (UTC) Date: Wed, 6 Apr 2022 13:55:33 +0200 From: Eugene Syromiatnikov To: Jens Axboe , Pavel Begunkov Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, Artem Savkov Subject: [PATCH] io_uring: implement compat handling for IORING_REGISTER_IOWQ_AFF Message-ID: <20220406115533.GA5165@asgard.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similarly to the way it is done im mbind syscall. Cc: stable@vger.kernel.org # 5.14 Fixes: fe76421d1da1dcdb ("io_uring: allow user configurable IO thread CPU affinity") Signed-off-by: Eugene Syromiatnikov --- fs/io_uring.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index de9c9de..83e194f 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -10803,7 +10803,15 @@ static __cold int io_register_iowq_aff(struct io_ring_ctx *ctx, if (len > cpumask_size()) len = cpumask_size(); - if (copy_from_user(new_mask, arg, len)) { + if (in_compat_syscall()) { + ret = compat_get_bitmap(cpumask_bits(new_mask), + (const compat_ulong_t __user *)arg, + len * 8 /* CHAR_BIT */); + } else { + ret = copy_from_user(new_mask, arg, len); + } + + if (ret) { free_cpumask_var(new_mask); return -EFAULT; } -- 2.1.4