Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp332667lqo; Wed, 8 May 2024 00:39:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5GAzbJ9H16NyX8K49SXMiajUZhP07OC7WOB/nebCQ2s9wpuVdTFBMd8R79YD4yGsmW47Ny9fIQe7E3yA8uc/XaWaxVy9MiFYX9Tz56Q== X-Google-Smtp-Source: AGHT+IGGZi+FvIt9xwN7tTDl2meAPZO460tk/NlPqz0XAtxN8fVg934PmmOTt7fFHisiqUtbNCRZ X-Received: by 2002:a17:906:b794:b0:a59:9e02:68fc with SMTP id a640c23a62f3a-a59fb969a4amr95431066b.44.1715153994011; Wed, 08 May 2024 00:39:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715153993; cv=pass; d=google.com; s=arc-20160816; b=N+67UyLohHbqzF97DsjHGLRLBDxx3fDsDZRMf1cLmj/XBnOtRlrKPfGr+JV0uszpsp se6f9fR280MuoXnBblXbM7I9LN74amhzqIXia0y4QeP95BRzCbuDA6Ro7AXWYsPoHYhC d1QnKWKTxe64cVoOZxOjALaIrDRyw537226S7t9QyHNxBqmty1ERQqJ+qUDkgzTyjWqr ntLgqkMwRL0EPsKsuki5JVcu6CRVXqzwGPP8WFB9aKUdV92gCq/tXmor3lczyEZvI5/s kV+n5m9NV/lMvXxuuCY0FVFj9+cc1xFt2UaYzrAPSMqoEp0wFUneg1AbE8TvtN7/4d8S fn0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=FVpdoIP5MsYXu7rCIo+E46n/SCgmwnPBP9uox/R7iyQ=; fh=ZtWWWSFSXMbQjAC9jZoJIqB8StskBaLzr8zJcjZfKuI=; b=zsOnslLPt/5T5OJpwT9KztF1mm6ngoxv39CyX7sBqFKFnI45R1l1u/2DLFXwoJ9iNt dt3duBiE/qHwc5w7VhTfj4TArlW2U5GK8H3bQN/lDUIhf/IuHZ34UEwREJ6QP3/y4QS4 xqlAGha5Ha9aEqKjn3IeukHU86kF1UH8TCtJ4JH7/xx1sYgLkdpxNIWT8yB3p6zvtyAM 3sqjzzQaR0N+uRRvf3mLGnH4iG7yz15wso5oNO9Iy8oiDF+JMALHShSkHmtOApo6ttvZ fiMPSrSYPAG2LoVzUSVNLvVu3pREaJgW8Nb5pEmYsFXd+QGtt7FzUjTDc3u9Ai9C5wgc tePQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CetLzvWV; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-172826-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172826-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s12-20020a1709060c0c00b00a524ddbb30esi6560761ejf.977.2024.05.08.00.39.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 00:39:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172826-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CetLzvWV; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-172826-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172826-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 923081F2158C for ; Wed, 8 May 2024 07:39:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D298E3F8D6; Wed, 8 May 2024 07:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CetLzvWV" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3796A3E493 for ; Wed, 8 May 2024 07:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715153958; cv=none; b=V4yb865k7x5EPYySBUoDMzBVUnYuYcCQXbdq2fxyYY6a0C0NubXERfCBunFxF7vBQS/SqEDySlRIAt/vwZ0BGlWZsjG/lx+6cSFiFxrE2HbUxPKOGl+F3+0n2SkuJ0QWuMix5YU/vpDnPpP/DzMa4F8Lqac8EW3nmZ1sImDN2Do= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715153958; c=relaxed/simple; bh=0Y+cdAgVJ5Wzm/Bku8fZNhaN9C0JgQPsf4IAnxXoyhg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NqMLhHBpcrAYZJR2EEcvKlqt3lLTEaW3aWvW6a7JzAu1E4XmbgpzuJz6pVXWBT54X88HWbOpdhIt5OyrMERW9eofDtJSmBT2ilr0UB8PlGxsIoTLHf+6SPoZHUW2E30nTKSsdYp8zpQAtT+k167xW2gQt6SkEIj4lgjqSdSQIgo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CetLzvWV; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715153955; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=FVpdoIP5MsYXu7rCIo+E46n/SCgmwnPBP9uox/R7iyQ=; b=CetLzvWVVdgP3y8/0UBS7cjydgDjZ3BQihZu1oY80/0j1kH9VlpykYYXe++28vNuUT/Nr+ nZflPywS64PZPUPpJS/3vZsxZY6Qm8zqKke6zxkSr1BId4cOoAsDXOttg99M4X0nnpYSmN 5hPU87+8AluwvPbfnvFIAUy3bESzEag= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-449-_6AkJaxtOEWhMxrFNssiDQ-1; Wed, 08 May 2024 03:39:13 -0400 X-MC-Unique: _6AkJaxtOEWhMxrFNssiDQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-34dc6410028so2104108f8f.0 for ; Wed, 08 May 2024 00:39:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715153952; x=1715758752; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=FVpdoIP5MsYXu7rCIo+E46n/SCgmwnPBP9uox/R7iyQ=; b=kcCQHswPoDODNYdtt5Xr4D502N26mGCNrEpdWzaeang+sPMeJQa5MLsj+pNZxllmqo ftBcXH7nL4BInpNlkRF7GiPZEzGFJ03iRu+xo0gUKLCl+ZOhkWiYQ/hNF3E8m4X/AokX 8fDemet9qEu6GCbIh3XHsDC33++xPhOsgXRpeYMwC04k7qUKcLk/TDkzyEPW/THZg3et FcrmlP+m4CUZq3k0KNAv3R2W++/GOeeBTEkPQsTKJ3tVuU/p02T7RkU0QN47qG4eeKPX TXEjjxgnIQcsQEvQMCi1A6+SkE4O/0ZVJH/2QBb5tRodDPApd+vKevCue/gztGNn55tO P0Ww== X-Forwarded-Encrypted: i=1; AJvYcCVDt0sZRTTy7m4pJlfuGJG8HGrzh65gd9AvWMOYF5jPXP2hNg1bsCNFU0wJpSI+SF5RRHWPM26C2kY2hOUzFOPOvqdr3KebJsq3V/7W X-Gm-Message-State: AOJu0Yw358J6F3uEgMMtyUURK1JHD7WQdGZNsZ4Gv0Aod5XCjjXN+A/T pUEtIQARSoQ2osXh4AfhtRzveZc6Wlg4Dc1pZiabSKRC+1KwB/nYj3yKVBH8f4xkNlNaHJ+dROm KfxcXrfMoRtuzOLvKlgA8xUxNMqJbCS708/Hjm1A07/jbGjkOS5Gtbja167GpDQ== X-Received: by 2002:a05:6000:4599:b0:34a:5d79:dfe2 with SMTP id ffacd0b85a97d-34fca054a97mr1258204f8f.13.1715153952355; Wed, 08 May 2024 00:39:12 -0700 (PDT) X-Received: by 2002:a05:6000:4599:b0:34a:5d79:dfe2 with SMTP id ffacd0b85a97d-34fca054a97mr1258175f8f.13.1715153951852; Wed, 08 May 2024 00:39:11 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:3100:35c3:fc4b:669f:9ff9? (p200300cbc707310035c3fc4b669f9ff9.dip0.t-ipconnect.de. [2003:cb:c707:3100:35c3:fc4b:669f:9ff9]) by smtp.gmail.com with ESMTPSA id f6-20020a5d58e6000000b0034dd063e8dasm14604835wrd.86.2024.05.08.00.39.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 May 2024 00:39:11 -0700 (PDT) Message-ID: <939a16f2-7b66-45a6-a043-4821bd3c71dc@redhat.com> Date: Wed, 8 May 2024 09:39:10 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] Fix userfaultfd_api to return EINVAL as expected To: Audra Mitchell , viro@zeniv.linux.org.uk Cc: brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, raquini@redhat.com, Peter Xu References: <20240507195510.283744-1-audra@redhat.com> From: David Hildenbrand Content-Language: en-US Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGc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e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20240507195510.283744-1-audra@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 07.05.24 21:55, Audra Mitchell wrote: > Currently if we request a feature that is not set in the Kernel > config we fail silently and return the available features. However, the > documentation indicates we should return an EINVAL. I assume you are referencing "EINVAL The API version requested in the api field is not supported by this kernel, or the features field passed to the kernel includes feature bits that are not supported by the current kernel version." and "To enable userfaultfd features the application should set a bit corresponding to each feature it wants to enable in the features field. If the kernel supports all the requested features it will enable them. Otherwise it will zero out the returned uffdio_api structure and return EINVAL. " in which case I agree. > > We need to fix this issue since we can end up with a Kernel warning > should a program request the feature UFFD_FEATURE_WP_UNPOPULATED on > a kernel with the config not set with this feature. Can you mention which exact one? Is it a WARN* or a pr_warn() ? Likely we want "Fixes:" here. > > Signed-off-by: Audra Mitchell > --- > fs/userfaultfd.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c > index 60dcfafdc11a..17210558de79 100644 > --- a/fs/userfaultfd.c > +++ b/fs/userfaultfd.c > @@ -2073,6 +2073,11 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx, > uffdio_api.features &= ~UFFD_FEATURE_WP_UNPOPULATED; > uffdio_api.features &= ~UFFD_FEATURE_WP_ASYNC; > #endif > + > + ret = -EINVAL; > + if (features & ~uffdio_api.features) > + goto err_out; > + > uffdio_api.ioctls = UFFD_API_IOCTLS; > ret = -EFAULT; > if (copy_to_user(buf, &uffdio_api, sizeof(uffdio_api))) CCing Peter. -- Cheers, David / dhildenb