Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp2875549pxx; Sun, 1 Nov 2020 13:29:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0ptmYZFcZJivTgCl6IhtGpEIHsEsNGuaZKeB+4Bs1APP5P2ZIpC2koUl9NzMV+88cq35V X-Received: by 2002:aa7:cd90:: with SMTP id x16mr13248162edv.302.1604266177648; Sun, 01 Nov 2020 13:29:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604266177; cv=none; d=google.com; s=arc-20160816; b=gOMe4UqExAB2UPlx46vJWGU6X6/qy+1ZPXON9VspxvEPDsviOHFwbwoYOn60IYgZf3 m3QGiIXcZOiMYWe4n44nS54c7NsVdhztewgF68R9OCRIm5Zc/vlu7jh0TaojP4aC0ndT tCY2H7sMRAvh4r38WSlybnMu0wT+XT4oUYErbsH/VIMymNpbMmjpEGoQhX63BG5n9Sse Pz2i+VzMX3qN4zmh16DJmCZUEjX9QIwiq9Ww27dkRBe2g9NyNHnIKs3BtlviuRsrUG+g Y98XuQFaS7TzX49zimR5wVJIXU4oIC4FqGb4O5lbXTeLaEzXL+lTt0euVRaT2GzTD1Xa AiPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=IUm+02MidsojlW5fyhf8cyxyEKcWd8Rt8ToY5UOJ6+c=; b=aBvZHDZN6KUriT6zFMR+hVmurloN7XLN2+Ac8hxLQ2n9wJnF6JJTeNi9nxQEUL+lYO pB9Mz0cfRQ42+s9sVQMQ6tqgDU29Usx+vFhW7/t/9uAdLcKht9XLUsCOhXIiToHMX7um dqFmBOa7n+vvcAsfTcMltz26AeX7+p3iTbQGcdHNqlMP5uy++y9EK3/Sc2q0/BMJxJIA +3EaHJ4gKhtRijLtmpyGm0WITmYe423YejXrtULfgxoN+vAwZ013aNIEVY7z/Y5J3A/J GaGfRaICeZX3Ncvo7xUcp68AhS+9EdkvgBXQV8znmTx3Xwh/z/Aj4geucyTgL5lcFvuM 07Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jasiak-xyz.20150623.gappssmtp.com header.s=20150623 header.b="r/6jxWRT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si2945947edq.105.2020.11.01.13.29.15; Sun, 01 Nov 2020 13:29:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@jasiak-xyz.20150623.gappssmtp.com header.s=20150623 header.b="r/6jxWRT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727052AbgKAV1v (ORCPT + 99 others); Sun, 1 Nov 2020 16:27:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727048AbgKAV1t (ORCPT ); Sun, 1 Nov 2020 16:27:49 -0500 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44FD2C0617A6 for ; Sun, 1 Nov 2020 13:27:43 -0800 (PST) Received: by mail-lj1-x234.google.com with SMTP id d24so12802684ljg.10 for ; Sun, 01 Nov 2020 13:27:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jasiak-xyz.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=IUm+02MidsojlW5fyhf8cyxyEKcWd8Rt8ToY5UOJ6+c=; b=r/6jxWRTfzY9FsqcnXJQy77Mw37FtnqSARc80Oobr0rtdIVwtgVg75l9ciELrr/LAt jUo/l/eofutem8pjSyUxCJdGEHkMjF6+tAzpG4rkYg0xpM1YUwfVpc4d4w5iiQNXq5Cl VmYCqtVQoOOGzGqox79vueHBsBu+2Vi4zPGfGD34xkJnuM1Z8SpLGfyLfsignymSVGk5 CdxH+YhXMuDcbbfRlbn5pIHIKHouQmwvrcE6ilwMKo0PwXCbHb7AiIib2DzxC/RYcP+F 8nXgy8SGw5U61oxJopexk2Gl0YjnwC0XFlL1Mc6MuXO3Ke81Z9AVJDO5TASv7DTjSOXZ TsqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=IUm+02MidsojlW5fyhf8cyxyEKcWd8Rt8ToY5UOJ6+c=; b=Bnq1qSU/r3ROCO/vZswBHh5LvDNgwv96+1iwBWpAWWSbWn0lqY9hkV2SognZ6N2PZe IJ1LsthGtGBoPBPFeAGB39IclolhZq7AXgQoEOqToOzaxjVQiDfxlrkApS9PcovkUf0k uUewx1w/ERwYfzJV6AoDPnAbNOjOHW5649rcHrozeBWhNVgHTkstyt9JiLOGQt0ETFjc vBd6wg0Gy1mXMj/s/DLfzkEejVi8Y6nYpC1rRUW1oU9G12mfF8trlXtuRu26o+VJ45b0 5R0QHobe2kxYL3kX9d+2TGY+WqvDeLIo45K4iYZyd8THICz9Lf4Llxi9uCUzkLXfVxff k5dQ== X-Gm-Message-State: AOAM531rxRYMfnBQ7BE8rUW0Ed32gKKd+IihNGYVS2bJTYpqTUgCXbmH BqjwzvAgU6vv5iCoerdCfmARZOpwxmgzQg== X-Received: by 2002:a2e:7d0e:: with SMTP id y14mr4936139ljc.90.1604266061480; Sun, 01 Nov 2020 13:27:41 -0800 (PST) Received: from gmail.com (wireless-nat-78.ip4.greenlan.pl. [185.56.211.78]) by smtp.gmail.com with ESMTPSA id k2sm1545519lfm.13.2020.11.01.13.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 13:27:40 -0800 (PST) Date: Sun, 1 Nov 2020 22:27:38 +0100 From: =?utf-8?B?UGF3ZcWC?= Jasiak To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, jack@suse.cz Subject: PROBLEM: fanotify_mark EFAULT on x86 Message-ID: <20201101212738.GA16924@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="x+6KMIRAuhnl3hBn" Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --x+6KMIRAuhnl3hBn Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I am trying to run examples from man fanotify.7 but fanotify_mark always fail with errno =3D EFAULT. fanotify_mark declaration is SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags, __u64, mask, int, dfd, const char __user *, pathname) When=20 fanotify_mark(4, FAN_MARK_ADD | FAN_MARK_ONLYDIR, FAN_CREATE | FAN_ONDIR, AT_FDCWD, 0xdeadc0de) is called on kernel side I can see in do_syscall_32_irqs_on that CPU context is bx =3D 0x4 =3D 4 cx =3D 0x9 =3D FAN_MARK_ADD | FAN_MARK_ONLYDIR, dx =3D 0x40000100 =3D FAN_CREATE | FAN_ONDIR si =3D 0x0 di =3D 0xffffff9c =3D AT_FDCWD bp =3D 0xdeadc0de ax =3D 0xffffffda orix_ax =3D 0x153 I am not sure if it is ok because third argument is uint64_t so if I understand correctly mask should be divided into two registers (dx and si). But in fanotify_mark we get fanotify_fd =3D 4 =3D bx flags =3D 0x9 =3D cx mask =3D 0x40000100 =3D dx dfd =3D 0 =3D si pathname =3D 0xffffff9c =3D di I believe that correct order is fanotify_fd =3D 4 =3D bx flags =3D 0x9 =3D cx mask =3D 0x40000100 =3D (si << 32) | dx dfd =3D 0xffffff9c =3D di pathname =3D 0xdeadc0de =3D bp I think that we should call COMPAT version of fanotify_mark here COMPAT_SYSCALL_DEFINE6(fanotify_mark, int, fanotify_fd, unsigned int, flags, __u32, mask0, __u32, mask1, int, dfd, const char __user *, pathname) or something wrong is with 64-bits arguments. I am running Linux 5.9.2 i686 on Pentium III (Coppermine). For tests I am using Debian sid on qemu with 5.9.2 and default kernel =66rom repositories. Everything works fine on 5.5 and 5.4. --=20 Pawe=C5=82 Jasiak --x+6KMIRAuhnl3hBn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEENIqkLxDcCMlLMdi0FzfmQudzVTgFAl+fKEYACgkQFzfmQudz VTiEgQ//aiyjua4unpQBiXkKTTNgv1ICPmPSvR1YO26NKiF5oIW/EZDf1aKOdd4h zCUR+rt74wtxbKlwIwMYokS9PJveh1H8WgWie+hmGCxR8shPZhKR3YthtuzTR6TO t6PR2IWUA6S7gPxdh0aWrq6cQMTLJEQ5fO8W9lCBpwE5FAZH4phki5a5/K1a9YGN uT4o++BUha1txqsnd7syKpT3o0buY2/92U2lQJQJt3Vyu1FRjif1qXIr2cyzaWPe EmbQP9+9I8k92JycO6trj4Yd9NbtUZk+/215p9255r6yuQ4RLSkBRehfBRzPTEbp FvKEeVQZX0tYM1B3WO+A5xqaGHKFItQOmsBJ8Bc7052ljZe4jk2GdaFc4EShUMd/ 5QJpH8O+GCxbeZX5vY7ieftyRBxWIcWVPaevngpv6OV7sY3NY3ZmbIfcbbHoZkBL PzFfvEsfEqabaL9qHV0+ZQowNxO+RFtwEwPlXCdeYBNibP16disvzzLZ81tHf8xj 6sJKUwS/aAQ3vLnk1/2b04/QVCu81wvi8GgOd/tQxHWHimjvl0i6ukC8iQlO94bU jsZPuVtVFYbREwimgqGtI9R5vd37gGeS9Bd0o6Kyz0+PdYlo33K/GoV987djeG2P HAPCyn5SDD7lV24x+O3/3WdxwSnsZyGqw3kXuqFPMU5OvUmHgwc= =9KzB -----END PGP SIGNATURE----- --x+6KMIRAuhnl3hBn--