From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23D94C3E8C5 for ; Sat, 28 Nov 2020 00:38:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6AB72223F for ; Sat, 28 Nov 2020 00:38:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="PgCGztmP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729459AbgK1Ahg (ORCPT ); Fri, 27 Nov 2020 19:37:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:47496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730166AbgK1Ag6 (ORCPT ); Fri, 27 Nov 2020 19:36:58 -0500 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 D213922252 for ; Sat, 28 Nov 2020 00:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606523800; bh=rlndTyZ07ltlrWHTqYBWYToR6dBHNbYRn2Phd8hj/mU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=PgCGztmP82ygA1ZsSzxJ9a1GMWL3KxVVbaqgVpZRu4UprXuSXgSBiPfJQ5y5bvyI7 F6LsIl5VQzjrVSGbaCyzWfq47gwl3WwPPbHzBXigJnwqnw+855mvFGIGjZ0ubDAJFT AYFDu+IPGTUGjMykmu4T5mxs3enNs2QrcoU08Lck= Received: by mail-wr1-f43.google.com with SMTP id m6so7203821wrg.7 for ; Fri, 27 Nov 2020 16:36:39 -0800 (PST) X-Gm-Message-State: AOAM531Xk69Ag6gp3Iym3T5xyynDDDhHHP413dLRGxtGWzRcrLzsmjjw ku01MiLJd04JFss0ojYWmcFieSsjW/hbZdt37HHpwA== X-Google-Smtp-Source: ABdhPJyHzaToMneHQIlE/CQuox4gGtAV1aibN/c+MmVJ3U1vZACyFpmgVNo/aQXl4esq+dTc1TYGAfgXUmiUr2S50zM= X-Received: by 2002:a5d:5482:: with SMTP id h2mr13958810wrv.18.1606523798379; Fri, 27 Nov 2020 16:36:38 -0800 (PST) MIME-Version: 1.0 References: <20201126155246.25961-1-jack@suse.cz> In-Reply-To: From: Andy Lutomirski Date: Fri, 27 Nov 2020 16:36:24 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] fanotify: Fix fanotify_mark() on 32-bit x86 To: Brian Gerst Cc: Andy Lutomirski , Jan Kara , linux-arch , Christoph Hellwig , Al Viro , Will Deacon , Catalin Marinas , Linux FS Devel , X86 ML , Borislav Petkov , Thomas Gleixner , stable Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On Fri, Nov 27, 2020 at 2:30 PM Brian Gerst wrote: > > On Fri, Nov 27, 2020 at 1:13 PM Andy Lutomirski wrote: > > > > On Thu, Nov 26, 2020 at 7:52 AM Jan Kara wrote: > > > > > > Commit converting syscalls taking 64-bit arguments to new scheme of compat > > > handlers omitted converting fanotify_mark(2) which then broke the > > > syscall for 32-bit x86 builds. Add missed conversion. It is somewhat > > > cumbersome since we need to keep the original compat handler for all the > > > other 32-bit archs. > > > > > > > This is stupendously ugly. I'm not really sure how this is supposed > > to work on any 32-bit arch. I'm also not sure whether we should > > expect the SYSCALL_DEFINE macros to figure this out by themselves. > > It works on 32-bit arches because the compiler implicitly uses > consecutive input registers or stack slots for 64-bit arguments, and > some arches have alignment requirements that result in hidden padding. > x86-32 is different now because parameters are passed in via pt_regs, > and the 64-bit value has to explicitly be reassembled from the high > and low 32-bit values, just like in the compat case. > That was my guess. > I think the simplest way to handle this is add a wrapper in > arch/x86/kernel/sys_ia32.c with the other fs syscalls that need 64-bit > args. That keeps this mess out of general code. Want to send a patch? I also wonder if there's a straightforward way to statically check this. Maybe the syscall wrapper macros could be rigged up to avoid emitting the ia32 stubs if there is a u64 or s64 arg, so the build would fail if someone tries to stick one in the syscall tables. I tried to do this, but I got a bit lost in the macro maze and my attempt didn't work. --Andy