Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4042095img; Tue, 26 Mar 2019 01:38:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwW7cWmE1tfzRt68bdIgvIZjJAWV1cEjmOti4TMH7yHq8fdMEr5Hxzqpt3BP1fO+Th2Ukif X-Received: by 2002:aa7:8d49:: with SMTP id s9mr27553636pfe.248.1553589485841; Tue, 26 Mar 2019 01:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553589485; cv=none; d=google.com; s=arc-20160816; b=KOMcZ2MAi3yapCJdf5dlbV1uJBCRKNiPvqX4SyzRcEuWsBTIiCFKSGkUxQrg+jNQuV MydXe5U7imlWYwRnGkp0wgHc5u9hKu99NFNYtNv9hEmkHPuHR37qpu/AAx1KHBlIQ0mH 6Pch70+j15RDescVUbsAP/q3kHYol09VK/QwXB5Z1ct35x36qd0Ufeu7IpxuPsi2SuwN giov/BfdsUGU1TYpgSn/0Go3lpUdMNu9GhTeAhe5qNqWx1nmHnPcJp58Sq4zPrWZ1B3a QishiqRbAEVwqQktxn8VfVleUmJfsRLvV6WTR8ZytpHBCs3XilYQUNVOKrNFtNzMrKgS X0PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=O8CWQ0vlfEM02bfYSXusQ3OXqqxb3sLKb5Y+G7wWTrg=; b=E3dSyeo+M889zti9VVyPAqABhdUEEVQhUVnN7hVO9KLx66BACdud8FYtdxKmWckx64 uUeGwqcEaSLHtehiVP2qWFIB1j3i2rkb4aObViDxaHTGURHTZFT6cDZmKS4VmtV6UCBh zWi/gGqeYl53p1oWth1U0iip0uVG9O4DtBHLeDaRak0vxxC3IAQrWzd8DHMW/cjzWdWt KtyXUB1UVtCG5+TEExc+BiGllBrSZsX6iUFU4qotYCOM3JH3n9ov3Mai3yT19XwAeS/E 1ILUZIj28BSGbVaSFCIJOtRSsvdomSJXRq027ILKdR0rsjgki2Ru6lMYwWuR2ZoGTe2B Vyug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k22si15330079pfa.215.2019.03.26.01.37.50; Tue, 26 Mar 2019 01:38:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731235AbfCZIfv (ORCPT + 99 others); Tue, 26 Mar 2019 04:35:51 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:37010 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730827AbfCZIfv (ORCPT ); Tue, 26 Mar 2019 04:35:51 -0400 Received: by mail-qt1-f193.google.com with SMTP id z16so13583787qtn.4; Tue, 26 Mar 2019 01:35:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=O8CWQ0vlfEM02bfYSXusQ3OXqqxb3sLKb5Y+G7wWTrg=; b=BULgRyAcnpnyg3CWtI3nmTweD6Gj2/r+ImMIKdzkqwuJ0ClcpteXLQqPFaTWuxl2Up DAanMgRnEoPs9AogAt3IdBBv/WdB2nCxyWpTGJiKR//TTxeau/I8ori5vw2xamm483sC Y8yJptsyME0wLrtfiNmB9/rJoYV7N92ZddOSDPFsIB97yO0p4JHdfvGVS4VCo2My5RJ1 og7zZvHXLGWxTU1Xtcaggc/IMhCC/wgqzhpbYJNrtqTOH+/2Spm6ZXQ4sGLdgzH8PRI9 IU3Bt74DJCQzGJQ9NBE0ACqPtFpMLhNuc33dVEPePg3bBNCbmkYtl3x0ZUegUipLbe8C oNxA== X-Gm-Message-State: APjAAAXxrqpL9QRRt3dwN8wIBvdCM9uIf8wywZ+VoLn/45vQOjzD9oq6 DLx79xKShzzIqPyhcCz1gmOxAOq1b0oJAqFZ/+I= X-Received: by 2002:ac8:276b:: with SMTP id h40mr24477221qth.319.1553589350138; Tue, 26 Mar 2019 01:35:50 -0700 (PDT) MIME-Version: 1.0 References: <20190325143521.34928-1-arnd@arndb.de> <1553530766.2955.51.camel@HansenPartnership.com> <1553559185.2929.20.camel@HansenPartnership.com> In-Reply-To: <1553559185.2929.20.camel@HansenPartnership.com> From: Arnd Bergmann Date: Tue, 26 Mar 2019 09:35:33 +0100 Message-ID: Subject: Re: [PATCH 1/2] io_uring: fix big-endian compat signal mask handling To: James Bottomley Cc: Andrew Morton , Jens Axboe , Alexander Viro , Hannes Reinecke , Matthew Wilcox , David Hildenbrand , Nikolay Borisov , linux-block , Linux FS-devel Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 26, 2019 at 1:13 AM James Bottomley wrote: > On Mon, 2019-03-25 at 17:24 +0100, Arnd Bergmann wrote: > > On Mon, Mar 25, 2019 at 5:19 PM James Bottomley > > wrote: > > > This looks a bit suboptimal: shouldn't in_compat_syscall() be hard > > > coded to return 0 if CONFIG_COMPAT isn't defined? That way the > > > compiler can do the correct optimization and we don't have to > > > litter #ifdefs and worry about undefined variables and other > > > things. > > > > The check can be outside of the #ifdef, but set_compat_user_sigmask > > is not declared then. > > Right, but shouldn't it be declared? I thought BUILD_BUG_ON had nice > magic that allowed it to work here (meaning if the compiler doesn't > eliminate the branch we get a build bug). My y2038 series originally went in that direction by allowing much more of the compat code to be compiled and then discarded without the #ifdefs (and combine it with the 32-bit time_t handling on 32-bit architectures). I went away from that after Christoph and others found the reuse of the compat interfaces too confusing. The current state now is that most compat_* interfaces cannot be compiled unless CONFIG_COMPAT is set, and making that work in general is a lot of work, so I followed the usual precedent here and used that #ifdef. This also matches what is done elsewhere in the same file (see io_import_iovec). > > I think for the future we can consider just moving the compat logic > > into set_user_sigmask(), which would simplify most of the callers, > > but that seemed to invasive as a bugfix for 5.1. > > Well, that too. I've just been on a recent bender to stop #ifdefs > after I saw what some people were doing with them. I absolutely agree in general, and have sent many patches to remove #ifdefs in other code when there was a good alternative and the #ifdefs are wrong (which they are at least 30% of the time in my experience). The problems for doing this in general for compat code are - some structures have a conditional compat_ioctl() callback pointer, and need an #ifdef around the assignment until we change the struct as well. - Most compat handlers require the use of the compat_ptr() wrapper, I have a patch to move this to common code, but that was rejected previously - many compat handlers rely on types from asm/compat.h that does not exist on architectures without compat support. In this specific case, compat_sigset_t is required for declaring set_compat_user_sigmask(), and the former is not easy to define on non-compat architectures. I still think that the best way forward here is to move it into set_user_sigmask() next merge window, rather than doing a larger scale rewrite of linux/compat.h to get this bug fixed now. Arnd