Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp279704pxu; Tue, 1 Dec 2020 11:04:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5RaHO9ur6UbY4kRSgnF3kfKxTImL5sjcgHs5K+g6fehpuXlUYwPggdt9m/QjL0qMr5vqu X-Received: by 2002:a50:fa92:: with SMTP id w18mr4521231edr.44.1606849440406; Tue, 01 Dec 2020 11:04:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606849440; cv=none; d=google.com; s=arc-20160816; b=BNy/D/ToijRoz4d1sfCa4w5lXS/lsfgj096aVswQRQnx2Hcjy5mR3RcNGH++GtA8QR +6Rv9YrYRd8s495J40HD4QfInVyYsG5xUhkoSdnWftn2sy2Md930eO3gMhnB+Vk7eCvP J1oZuOEL1nSaUBJOKMGGju6eH+R49FtXElDNqfV9Mv0b0HxB16o6C5JOjXtbbFn6+P1L ZG5dq7EthzPZvc0Pfnapptup5gUyQqHRVy015JYpFAaTjYcVrjzT7mxdj+tTCBIMaA4y 4pv99hntThIEOh3i3fguA/DQeRhk6RiZlajVvlkux0cg4pxL0hpM0pKIUQc1iCwXmadW Hsiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=UiehYIIztWiOA5x7rcOwJG5vM5C5mv49+njdt1W94Ak=; b=ZPhsnthEmJ3YxqGiBd1/qt7cUvgryQZZgsOxLULqwaQKzLW1GxGsl4N292Ym6orP3v OGMeLe+Jf+N0459C5Gj7tg0tX6JhYDfR3fZaUW7vykIN5kjc+bYR8JFqk9kmuxbcsmAa 9/rY3fO+TOV9rO608wWaG+Pb/tpTyW2/y77HYPeyAl9TPKPTawpWYbujx0Syk/1HVksd Q3le/G0LXqtVxdtCb+wwN9jFUiFmPylvuS292he0YV+m80lDYYuB2Hy/2pf51gKEDICn zrjmeuywCMHAFs4L4iZgegVUy3W0FucW1X1v0eUKU0zIztzlU3UGYg8rfGAUgOkVifOJ 5jMg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z14si496318ejp.692.2020.12.01.11.03.36; Tue, 01 Dec 2020 11:04:00 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730118AbgLATBj (ORCPT + 99 others); Tue, 1 Dec 2020 14:01:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:44494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbgLATBj (ORCPT ); Tue, 1 Dec 2020 14:01:39 -0500 Received: from gaia (unknown [95.146.230.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AD93720643; Tue, 1 Dec 2020 19:00:54 +0000 (UTC) Date: Tue, 1 Dec 2020 19:00:52 +0000 From: Catalin Marinas To: Andy Lutomirski Cc: linux-arch , Brian Gerst , LKML , X86 ML , Borislav Petkov , Thomas Gleixner , Jan Kara , =?utf-8?B?UGF3ZcWC?= Jasiak , Russell King Subject: Re: [PATCH] fanotify: Fix sys_fanotify_mark() on native x86-32 Message-ID: <20201201190051.GB2502@gaia> References: <20201130223059.101286-1-brgerst@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 01, 2020 at 09:34:32AM -0800, Andy Lutomirski wrote: > On Tue, Dec 1, 2020 at 9:23 AM Andy Lutomirski wrote: > > On Mon, Nov 30, 2020 at 2:31 PM Brian Gerst wrote: > > > Commit 121b32a58a3a converted native x86-32 which take 64-bit arguments to > > > use the compat handlers to allow conversion to passing args via pt_regs. > > > sys_fanotify_mark() was however missed, as it has a general compat handler. > > > Add a config option that will use the syscall wrapper that takes the split > > > args for native 32-bit. > > > > > > Reported-by: Paweł Jasiak > > > Fixes: 121b32a58a3a ("x86/entry/32: Use IA32-specific wrappers for syscalls taking 64-bit arguments") > > > Signed-off-by: Brian Gerst > > > --- > > > arch/Kconfig | 6 ++++++ > > > arch/x86/Kconfig | 1 + > > > fs/notify/fanotify/fanotify_user.c | 17 +++++++---------- > > > include/linux/syscalls.h | 24 ++++++++++++++++++++++++ > > > 4 files changed, 38 insertions(+), 10 deletions(-) > > > > > > diff --git a/arch/Kconfig b/arch/Kconfig > > > index 090ef3566c56..452cc127c285 100644 > > > --- a/arch/Kconfig > > > +++ b/arch/Kconfig > > > @@ -1045,6 +1045,12 @@ config HAVE_STATIC_CALL_INLINE > > > bool > > > depends on HAVE_STATIC_CALL > > > > > > +config ARCH_SPLIT_ARG64 > > > + bool > > > + help > > > + If a 32-bit architecture requires 64-bit arguments to be split into > > > + pairs of 32-bit arguemtns, select this option. > > > > You misspelled arguments. You might also want to clarify that, for > > 64-bit arches, this means that compat syscalls split their arguments. > > No, that's backwards. Maybe it should be depends !64BIT instead. > > But I'm really quite confused about something: what's special about > x86 here? Are there really Linux arches (compat or 32-bit native) > that *don't* split arguments like this? Sure, some arches probably > work the same way that x86 used to in which the compiler did the > splitting by magic for us, but that was always a bit of a kludge. On arm32 we rely on the compiler splitting a 64-bit argument in two consecutive registers. But I wouldn't say it's a kludge (well, mostly) as that's part of the arm procedure calling standard. Currently arm32 doesn't pass the syscall arguments through a read from pt_regs, so all is handled transparently. On arm64 compat, we need to re-assemble the arguments with some wrappers explicitly (arch/arm64/kernel/sys32.c) or call the generic wrapper like in the compat_sys_fanotify_mark() case. > Could this change maybe be made unconditional? I think it's fine in this particular case. I don't think it's valid in general because of the arm (and maybe others) requirement that the first register of a 64-bit argument is an even number (IIRC, Russell should know better). If the u64 mask was an argument before or after the current position, the compiler would have introduced a pad register but not if the arg is split in two u32. -- Catalin