Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp287441pxu; Tue, 1 Dec 2020 11:14:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeW2BEyhaLMcdhxFg3hzLR5wyHvIn8ZHVLyIOC1R70C6Qmc2OvltblfgEVMXjAmVQZD2sJ X-Received: by 2002:a05:6402:d09:: with SMTP id eb9mr4529879edb.71.1606850084408; Tue, 01 Dec 2020 11:14:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606850084; cv=none; d=google.com; s=arc-20160816; b=x+VEH0ffaZ42BZLBPxykz0JgFO89TsOKptuMayRsJ4S4XorkeKX9xKKHrj/+aa8pr2 KaRGFspWykSu+BUXNeqdB098UeVm75IynwkF+ulQLgoBEnZC1G0Pks6Yv8xQO1GzL/6D AftmjYvI2v26UgZVEKhi2cj2hfsu1xw1amYAO9hcYuNyEbJ39tQ5kujOOuDhAQ6Dgp2J J23vvtqChQNPEHhEas/xsAyfBsKxJzePlW7GFbdHqOMrN0JR3fJ1m3in3pfCVCTTXmtW qC8j/pIPZkTLaqummYgMhcFDLtYJY7Ch4f9ksahhbe5eygBl5kt5WTBXPds762GuB6o0 +k7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=pG2p2S2mBS9XTH89p2yj0/Xioobklbo7PAS6TKKgAZM=; b=ZrkMvhA5w8Fvrad6z0cYK63j+1seeyW1y8eBrtLPJEipabzfqSUt0G2gcc/328LLNt ASdr8+/8PJQU4O1Cw6ZoyrCC5BjLwnpiWqeSq4DyL+o74hoZ7sL2ON/sFJqI6H2YtBJS QQdcz6xmzyGN3rsiKmRYqLU1aaMH/JZIcu/yniCMK2Lemo+1CiYv33Kqeg8DwinO5zB4 r+2NTduT/sWfWarKLBHTpRXdkbM2iBpNCPeiWYqT9bZV/QHcEezNySd2tx1igB+RMyGz 7hCvcwLaFPZk8i4A6t2O6lmu9GfKwHpPI26jmMc+mrtH6xpcwCyun61FfgEzC9/wDvmC NJRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iqHTGKxF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si501197ejo.364.2020.12.01.11.14.20; Tue, 01 Dec 2020 11:14:44 -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=@kernel.org header.s=default header.b=iqHTGKxF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731286AbgLATLr (ORCPT + 99 others); Tue, 1 Dec 2020 14:11:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:46458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730070AbgLATLq (ORCPT ); Tue, 1 Dec 2020 14:11:46 -0500 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7DB2820639 for ; Tue, 1 Dec 2020 19:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606849865; bh=JqwaoK4HBPCT+/h+D8qURvwc3oM0DqI5/EEkWIzSOGk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=iqHTGKxFX8str4vKF7dqTHknZh4uChxGxcH981c5983+DfHyXmb6SeLnou4HZpqBD APnFX8IZ06nyHB3cIF9o3PvWokhbytT3fX4gmQ/P5VcO217SyltUv/oKdS4ccc0cl0 IOkKjamdGTtpMvdwxkjMLkWEtH7PR6YdKSswYYro= Received: by mail-wm1-f45.google.com with SMTP id d3so5935122wmb.4 for ; Tue, 01 Dec 2020 11:11:05 -0800 (PST) X-Gm-Message-State: AOAM532+XhMZGc6MjE7NwkoXJQTfizAQd4JuQmmO8Vn6xapHU823uQ5Y Nx0ndz/PnoV4VJawOVHOQlU0PfuBE7pc1bpLMnioJg== X-Received: by 2002:a1c:1d85:: with SMTP id d127mr4261484wmd.49.1606849862284; Tue, 01 Dec 2020 11:11:02 -0800 (PST) MIME-Version: 1.0 References: <20201130223059.101286-1-brgerst@gmail.com> <20201201190051.GB2502@gaia> In-Reply-To: <20201201190051.GB2502@gaia> From: Andy Lutomirski Date: Tue, 1 Dec 2020 11:10:48 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] fanotify: Fix sys_fanotify_mark() on native x86-32 To: Catalin Marinas Cc: Andy Lutomirski , linux-arch , Brian Gerst , LKML , X86 ML , Borislav Petkov , Thomas Gleixner , Jan Kara , =?UTF-8?Q?Pawe=C5=82_Jasiak?= , Russell King Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 1, 2020 at 11:00 AM Catalin Marinas w= rote: > > 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 argum= ents 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 th= e split > > > > args for native 32-bit. > > > > > > > > Reported-by: Pawe=C5=82 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. > So I guess Brian's macro is more like "this is a 32-bit arch that needs to split 64-bit syscall args but naively splitting them is correct", which is true on x86_32 but not necessarily on arm. Should we consider having a real program that runs as part of the build generate the syscall wrappers? The logic involved is pushing the bounds of C macro magic and human comprehension. --Andy