Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp89183lqo; Tue, 7 May 2024 13:06:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX8tuZB6UxqTt+MC9iuK8R+67LUeeiHgmjHn4U9ppsF+LQ3eSX+EW4cJDo9bnfFRPH6FSe2cw7mb5kEN6Htjp21fWqZH4TnYCD7/5O+SA== X-Google-Smtp-Source: AGHT+IGVsJgbmxYPGNt/X8TViQ1WoDwsTOtHateoeJtBG3Kk7uBA2hLFHitoLqqLAGSdnAbtBPNr X-Received: by 2002:a05:6358:949d:b0:192:b048:2942 with SMTP id e5c5f4694b2df-192d3585f81mr79901655d.30.1715112384282; Tue, 07 May 2024 13:06:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715112384; cv=pass; d=google.com; s=arc-20160816; b=v2zY0e9Dey2Pg9r86ndyZ/nwZHoK/HD5sNXVIV/JBFteRIs6P3ShkD89w5n6RRcEN2 ij0KhhomraLOmNVAXTQHoidQTLJvaziiqa2pMYTlsAbC8dfzJzB7X/aaBeO2am1uAKhN C8VPC65W66a7F0brbJjbXvSRlSyZoNKwr36UvIlQiW3kEYlySXnsNMUdfTgO9kR252Yx 5D4UPrp9PCZm0sBQ/iRVdglaEmjRJIzPKkg9+TeWXt1+0VWlzOpnrwa3yRGSsqqiPtmt YWRaZuM7gGbPt435Du895FNkPuaseHpPc0GKZeeagaRcq/9ulUtQfDrk1ujwwh5rVmLd C3AA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=qlhwsbkKKVd2ohQ0kuBs8V/ScuJpgv65EhyU0mX2mEQ=; fh=/4J1M7Xrn00llcvK9cbiTcGxwN1QGQEJzIZsOXxokqY=; b=PRXmTvgkGJpbHbIJsXVvXcTy8wlHA3+jtblAYv9HrT2TlPicsMgixDftk32CbenY8T 9CcxGzjXZScfMBD1TIcIeTm9C5lDAOVXXbTP396fu0KVorlVy7HLjPekIh9lSHA9Rt0Z u/0C0nJ4miSbjyCQPO4QfotinRwfDox/88Mio+vzKIAdlojLEQxYyllhSpKl/AunWKGi Fh1fMPixPNUePjKgXkG+/bf17TuumJVJZdDj4RHH9HW3WmkkvcwzuR6o9W0yBGhGaSFR hl4E81mB2ZTbp2/jGTzBNLqRPI0awiN7BqT0Jf16nnPnSjF//J9zbX0NRJkVlDsvsTK9 RdoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=StqMaae6; 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-172115-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172115-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t18-20020a632252000000b006126ff2f264si10927693pgm.472.2024.05.07.13.06.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 13:06:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172115-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=StqMaae6; 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-172115-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172115-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B42CC281A21 for ; Tue, 7 May 2024 20:06:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3BEAE16F0E4; Tue, 7 May 2024 19:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="StqMaae6" 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 85871150999 for ; Tue, 7 May 2024 19:55:18 +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=1715111720; cv=none; b=r0d6xRei+sGzwEWFgIVJMRTForItCC7dfJqfaN5JPRI0XkCtDrLOH7WSkADt4AheIYtV0A+G98/oDCDCfmgyoMkbb3ck+yRtvND9SfY29rOAtDUtTxaqlWkmypu4zrsH8nKp0yiowD/wivIrZ8nz5OT9Y1zITbX3nhWQ1Q/uX84= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715111720; c=relaxed/simple; bh=a0wY0qoFOsxghYv4yN8+yu9MTxt8hu8AS20FIolS/uU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PWpa8Be/S8gewZP2kjdYSIRw0aYpQd8vqyR2WKcmIctau2+9g5g7T1MR1IROdizH0GL3PXEAoaMwDI2IxgDVKHr+ut3GNZFNzvarCfa4mglJOBIMVVPVsbYMw79Y+zD69hLAE6McOOx/7caStP2gzJ3ARsNlg+belcmuA0WMtvU= 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=StqMaae6; 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=1715111717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qlhwsbkKKVd2ohQ0kuBs8V/ScuJpgv65EhyU0mX2mEQ=; b=StqMaae6+PbwCJgrRcOVDDsSVCMyAydrNV7RpbgNvFVXxhyL1PGLDV7Zfb7W+96SKtsUn8 xXts+zIG2XmYPBbvHW07JHGspkhn/qtlzIfbTtegJjLz2DBAD+taF11ejJDB1wRfRTZ/Nd nxc8JLLo/hSF5zZ17HV0gRt+EBZgWc8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-567-BSvfzLQPO9mBz_2vPSWUpg-1; Tue, 07 May 2024 15:55:16 -0400 X-MC-Unique: BSvfzLQPO9mBz_2vPSWUpg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6BBCD1C031BB; Tue, 7 May 2024 19:55:15 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.18.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21C3820B96E0; Tue, 7 May 2024 19:55:15 +0000 (UTC) From: Audra Mitchell To: 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 Subject: [PATCH 1/2] Fix userfaultfd_api to return EINVAL as expected Date: Tue, 7 May 2024 15:55:09 -0400 Message-ID: <20240507195510.283744-1-audra@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 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. 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. 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))) -- 2.44.0