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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 2A006C43469 for ; Sat, 19 Sep 2020 22:22:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E56332311D for ; Sat, 19 Sep 2020 22:22:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=amacapital-net.20150623.gappssmtp.com header.i=@amacapital-net.20150623.gappssmtp.com header.b="EY9RaFhK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726710AbgISWWI (ORCPT ); Sat, 19 Sep 2020 18:22:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726598AbgISWWI (ORCPT ); Sat, 19 Sep 2020 18:22:08 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 416CFC0613CF for ; Sat, 19 Sep 2020 15:22:08 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id k13so4899656plk.3 for ; Sat, 19 Sep 2020 15:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=25gVfK2bGDr534LWfZ/pQ4shMLoyA8XjkGlFCfd9UIQ=; b=EY9RaFhKJvXZJRe9JFZEmj/lrRJqtPj6jNB3uuL8Asw+3z3hL8ojgYDOBxgCTI3nk9 /mXxtqUMYM7Lwl0JgYFAozO/o74Ybc5I1+WhDC3iRbQpOEwdgChJfXvUy9LaiX/RnQRf p/J0xsjYVG4oqNtf24952lDJD0ziSd0wiVT/i0R8ihNenTSwy/mXNvVIx+wshhqobcUy 5EicG48utPjw3drDSP4fcvdYEf263LYbKCqq5wRH96dLaukxQtxTbM+CqP9ZHn/W3xRY 8AFACdo1jBBh0ZpNH8dhEU0zBCFGmtnY/LeHs/0y17jDB1ByiLtkNkIHMFbVGhXPT7kd OVIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=25gVfK2bGDr534LWfZ/pQ4shMLoyA8XjkGlFCfd9UIQ=; b=a87nahKde3FPm1v+Pk5k3c9Dm0VDBQbcH3x5kGOUcQqi9qkaomRuRdCTPyRDF4/F2j 9Gm6Qr5/9zDlpWh7CM1YcsqFSUJlr3nekjJD00uqjYCxARQNMLPNqo3+U0KCDG1RmieH F7QLDgVyfY6jKlWb0xDwoE8bLfOrULByL5ZwV/thC+V2fCkzzfvLKRGfUQTN3DbDtk5k dyOOarYpqjaGrF+rBxYvMr4er+cUSb0STHKYWEWquSnjgIDJZZIiybAxWjDqmUa0izy7 wpOF5wFx8V0ABv7xjhTWxI5i4uAz/eASrsr8BjBDf5HxnYqn4dwlndLwPAsPBceB9ZpO /nsg== X-Gm-Message-State: AOAM530neuiDivvEOt8C4mKjnbyVB0S/PwvPfiv9X+19N/U+Kj38ZgS1 ++MN+40YCysSCyB0TzGAhy8/LQ== X-Google-Smtp-Source: ABdhPJziI+9RTM4Q+0EM9+8+2xFKIE2ZrEYxvbFrrOPerUdpGlrHlMuO11hqWffBHcUb5BpNHvdsyg== X-Received: by 2002:a17:902:ac97:b029:d1:f367:b51a with SMTP id h23-20020a170902ac97b02900d1f367b51amr16629268plr.20.1600554127472; Sat, 19 Sep 2020 15:22:07 -0700 (PDT) Received: from localhost.localdomain ([2601:646:c200:1ef2:e9da:b923:b529:3349]) by smtp.gmail.com with ESMTPSA id p4sm6588471pju.29.2020.09.19.15.22.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 19 Sep 2020 15:22:06 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 1/9] kernel: add a PF_FORCE_COMPAT flag Date: Sat, 19 Sep 2020 15:22:04 -0700 Message-Id: References: Cc: Andy Lutomirski , Christoph Hellwig , Al Viro , Andrew Morton , Jens Axboe , David Howells , linux-arm-kernel , X86 ML , LKML , "open list:MIPS" , Parisc List , linuxppc-dev , linux-s390 , sparclinux , linux-block , Linux SCSI List , Linux FS Devel , linux-aio , io-uring@vger.kernel.org, linux-arch , Linux-MM , Network Development , keyrings@vger.kernel.org, LSM List In-Reply-To: To: Arnd Bergmann X-Mailer: iPhone Mail (18A373) Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org > On Sep 19, 2020, at 2:16 PM, Arnd Bergmann wrote: >=20 > =EF=BB=BFOn Sat, Sep 19, 2020 at 6:21 PM Andy Lutomirski = wrote: >>> On Fri, Sep 18, 2020 at 8:16 AM Christoph Hellwig wrote: >>> On Fri, Sep 18, 2020 at 02:58:22PM +0100, Al Viro wrote: >>>> Said that, why not provide a variant that would take an explicit >>>> "is it compat" argument and use it there? And have the normal >>>> one pass in_compat_syscall() to that... >>>=20 >>> That would help to not introduce a regression with this series yes. >>> But it wouldn't fix existing bugs when io_uring is used to access >>> read or write methods that use in_compat_syscall(). One example that >>> I recently ran into is drivers/scsi/sg.c. >=20 > Ah, so reading /dev/input/event* would suffer from the same issue, > and that one would in fact be broken by your patch in the hypothetical > case that someone tried to use io_uring to read /dev/input/event on x32...= >=20 > For reference, I checked the socket timestamp handling that has a > number of corner cases with time32/time64 formats in compat mode, > but none of those appear to be affected by the problem. >=20 >> Aside from the potentially nasty use of per-task variables, one thing >> I don't like about PF_FORCE_COMPAT is that it's one-way. If we're >> going to have a generic mechanism for this, shouldn't we allow a full >> override of the syscall arch instead of just allowing forcing compat >> so that a compat syscall can do a non-compat operation? >=20 > The only reason it's needed here is that the caller is in a kernel > thread rather than a system call. Are there any possible scenarios > where one would actually need the opposite? >=20 I can certainly imagine needing to force x32 mode from a kernel thread. As for the other direction: what exactly are the desired bitness/arch semant= ics of io_uring? Is the operation bitness chosen by the io_uring creation o= r by the io_uring_enter() bitness?= From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Lutomirski Date: Sat, 19 Sep 2020 22:22:04 +0000 Subject: Re: [PATCH 1/9] kernel: add a PF_FORCE_COMPAT flag Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="ibm852" Content-Transfer-Encoding: base64 List-Id: References: In-Reply-To: To: Arnd Bergmann Cc: Andy Lutomirski , Christoph Hellwig , Al Viro , Andrew Morton , Jens Axboe , David Howells , linux-arm-kernel , X86 ML , LKML , "open list:MIPS" , Parisc List , linuxppc-dev , linux-s390 , sparclinux , linux-block , Linux SCSI List , Linux FS Devel , linux-aio , io-uring@vger.kernel.org, linux-arch , Linux-MM , Network Development , keyrings@vger.kernel.org, LSM List Cj4gT24gU2VwIDE5LCAyMDIwLCBhdCAyOjE2IFBNLCBBcm5kIEJlcmdtYW5uIDxhcm5kQGFybmRi LmRlPiB3cm90ZToKPiAKPiDvu79PbiBTYXQsIFNlcCAxOSwgMjAyMCBhdCA2OjIxIFBNIEFuZHkg THV0b21pcnNraSA8bHV0b0BrZXJuZWwub3JnPiB3cm90ZToKPj4+IE9uIEZyaSwgU2VwIDE4LCAy MDIwIGF0IDg6MTYgQU0gQ2hyaXN0b3B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ocmVhZC4K CkFzIGZvciB0aGUgb3RoZXIgZGlyZWN0aW9uOiB3aGF0IGV4YWN0bHkgYXJlIHRoZSBkZXNpcmVk IGJpdG5lc3MvYXJjaCBzZW1hbnRpY3Mgb2YgaW9fdXJpbmc/ICBJcyB0aGUgb3BlcmF0aW9uIGJp dG5lc3MgY2hvc2VuIGJ5IHRoZSBpb191cmluZyBjcmVhdGlvbiBvciBieSB0aGUgaW9fdXJpbmdf ZW50ZXIoKSBiaXRuZXNzPw== From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Lutomirski Date: Sat, 19 Sep 2020 22:22:04 +0000 Subject: Re: [PATCH 1/9] kernel: add a PF_FORCE_COMPAT flag Message-Id: List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: Arnd Bergmann Cc: Andy Lutomirski , Christoph Hellwig , Al Viro , Andrew Morton , Jens Axboe , David Howells , linux-arm-kernel , X86 ML , LKML , "open list:MIPS" , Parisc List , linuxppc-dev , linux-s390 , sparclinux , linux-block , Linux SCSI List , Linux FS Devel , linux-aio , io-uring@vger.kernel.org, linux-arch , Linux-MM , Network Development , keyrings@vger.kernel.org, LSM List > On Sep 19, 2020, at 2:16 PM, Arnd Bergmann wrote: >=20 > =EF=BB=BFOn Sat, Sep 19, 2020 at 6:21 PM Andy Lutomirski wrote: >>> On Fri, Sep 18, 2020 at 8:16 AM Christoph Hellwig wrote: >>> On Fri, Sep 18, 2020 at 02:58:22PM +0100, Al Viro wrote: >>>> Said that, why not provide a variant that would take an explicit >>>> "is it compat" argument and use it there? And have the normal >>>> one pass in_compat_syscall() to that... >>>=20 >>> That would help to not introduce a regression with this series yes. >>> But it wouldn't fix existing bugs when io_uring is used to access >>> read or write methods that use in_compat_syscall(). One example that >>> I recently ran into is drivers/scsi/sg.c. >=20 > Ah, so reading /dev/input/event* would suffer from the same issue, > and that one would in fact be broken by your patch in the hypothetical > case that someone tried to use io_uring to read /dev/input/event on x32... >=20 > For reference, I checked the socket timestamp handling that has a > number of corner cases with time32/time64 formats in compat mode, > but none of those appear to be affected by the problem. >=20 >> Aside from the potentially nasty use of per-task variables, one thing >> I don't like about PF_FORCE_COMPAT is that it's one-way. If we're >> going to have a generic mechanism for this, shouldn't we allow a full >> override of the syscall arch instead of just allowing forcing compat >> so that a compat syscall can do a non-compat operation? >=20 > The only reason it's needed here is that the caller is in a kernel > thread rather than a system call. Are there any possible scenarios > where one would actually need the opposite? >=20 I can certainly imagine needing to force x32 mode from a kernel thread. As for the other direction: what exactly are the desired bitness/arch seman= tics of io_uring? Is the operation bitness chosen by the io_uring creation= or by the io_uring_enter() bitness? 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=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,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 39BA4C433DB for ; Sat, 19 Sep 2020 22:23:51 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B03721741 for ; Sat, 19 Sep 2020 22:23:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=amacapital-net.20150623.gappssmtp.com header.i=@amacapital-net.20150623.gappssmtp.com header.b="EY9RaFhK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B03721741 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amacapital.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4Bv4wz5bZ0zDqwj for ; Sun, 20 Sep 2020 08:23:47 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=amacapital.net (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=luto@amacapital.net; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=amacapital.net Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=amacapital-net.20150623.gappssmtp.com header.i=@amacapital-net.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=EY9RaFhK; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Bv4vF38Q0zDqXW for ; Sun, 20 Sep 2020 08:22:11 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id y6so4879827plt.9 for ; Sat, 19 Sep 2020 15:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=25gVfK2bGDr534LWfZ/pQ4shMLoyA8XjkGlFCfd9UIQ=; b=EY9RaFhKJvXZJRe9JFZEmj/lrRJqtPj6jNB3uuL8Asw+3z3hL8ojgYDOBxgCTI3nk9 /mXxtqUMYM7Lwl0JgYFAozO/o74Ybc5I1+WhDC3iRbQpOEwdgChJfXvUy9LaiX/RnQRf p/J0xsjYVG4oqNtf24952lDJD0ziSd0wiVT/i0R8ihNenTSwy/mXNvVIx+wshhqobcUy 5EicG48utPjw3drDSP4fcvdYEf263LYbKCqq5wRH96dLaukxQtxTbM+CqP9ZHn/W3xRY 8AFACdo1jBBh0ZpNH8dhEU0zBCFGmtnY/LeHs/0y17jDB1ByiLtkNkIHMFbVGhXPT7kd OVIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=25gVfK2bGDr534LWfZ/pQ4shMLoyA8XjkGlFCfd9UIQ=; b=mP7HZ2a+NsMuJDsVRap5tpG9LDlU1qBk7R4RmU8trAcrHAsJfitwWAtlGbPBl/79rE AYL/bUAwQASjmXIAgbS58pUPCFY3isI1FaWwTST6o2NCCzXXrO6yUhlC4py2xjNAhVbz nP1nJEFiJL7Evlr/IKaZDzUvyBnzvh0BtJVYJgPl55/kEBdzAJNBDnbV38lWo0QErJSy IewyjFYWrVcc6bHAmfdu4QGQF+pXieOd6IosH9lj4eUUN3Kxy0HM4EhJzzWIc8FcRS7t Rhn5xyr2uWcPukPmkmDpz5Wbb6TPuLX5m3BLg9K7GDtEsoI7EeJZbUQYoeEtJm7xHd0S sr2A== X-Gm-Message-State: AOAM533YaVUraomWCwJHTHv/iMBkQcaqlIu5+etV8qyzb3sK+Kg2xgTo Ml/abGUOErddRIGStCZQGWyZmg== X-Google-Smtp-Source: ABdhPJziI+9RTM4Q+0EM9+8+2xFKIE2ZrEYxvbFrrOPerUdpGlrHlMuO11hqWffBHcUb5BpNHvdsyg== X-Received: by 2002:a17:902:ac97:b029:d1:f367:b51a with SMTP id h23-20020a170902ac97b02900d1f367b51amr16629268plr.20.1600554127472; Sat, 19 Sep 2020 15:22:07 -0700 (PDT) Received: from localhost.localdomain ([2601:646:c200:1ef2:e9da:b923:b529:3349]) by smtp.gmail.com with ESMTPSA id p4sm6588471pju.29.2020.09.19.15.22.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 19 Sep 2020 15:22:06 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 1/9] kernel: add a PF_FORCE_COMPAT flag Date: Sat, 19 Sep 2020 15:22:04 -0700 Message-Id: References: In-Reply-To: To: Arnd Bergmann X-Mailer: iPhone Mail (18A373) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aio , "open list:MIPS" , David Howells , Linux-MM , keyrings@vger.kernel.org, sparclinux , Christoph Hellwig , linux-arch , linux-s390 , Linux SCSI List , X86 ML , linux-block , Al Viro , Andy Lutomirski , io-uring@vger.kernel.org, linux-arm-kernel , Jens Axboe , Parisc List , Network Development , LKML , LSM List , Linux FS Devel , Andrew Morton , linuxppc-dev Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" > On Sep 19, 2020, at 2:16 PM, Arnd Bergmann wrote: >=20 > =EF=BB=BFOn Sat, Sep 19, 2020 at 6:21 PM Andy Lutomirski = wrote: >>> On Fri, Sep 18, 2020 at 8:16 AM Christoph Hellwig wrote: >>> On Fri, Sep 18, 2020 at 02:58:22PM +0100, Al Viro wrote: >>>> Said that, why not provide a variant that would take an explicit >>>> "is it compat" argument and use it there? And have the normal >>>> one pass in_compat_syscall() to that... >>>=20 >>> That would help to not introduce a regression with this series yes. >>> But it wouldn't fix existing bugs when io_uring is used to access >>> read or write methods that use in_compat_syscall(). One example that >>> I recently ran into is drivers/scsi/sg.c. >=20 > Ah, so reading /dev/input/event* would suffer from the same issue, > and that one would in fact be broken by your patch in the hypothetical > case that someone tried to use io_uring to read /dev/input/event on x32...= >=20 > For reference, I checked the socket timestamp handling that has a > number of corner cases with time32/time64 formats in compat mode, > but none of those appear to be affected by the problem. >=20 >> Aside from the potentially nasty use of per-task variables, one thing >> I don't like about PF_FORCE_COMPAT is that it's one-way. If we're >> going to have a generic mechanism for this, shouldn't we allow a full >> override of the syscall arch instead of just allowing forcing compat >> so that a compat syscall can do a non-compat operation? >=20 > The only reason it's needed here is that the caller is in a kernel > thread rather than a system call. Are there any possible scenarios > where one would actually need the opposite? >=20 I can certainly imagine needing to force x32 mode from a kernel thread. As for the other direction: what exactly are the desired bitness/arch semant= ics of io_uring? Is the operation bitness chosen by the io_uring creation o= r by the io_uring_enter() bitness?= 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.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 C09F7C43463 for ; Sat, 19 Sep 2020 22:23:50 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 69DCE222BB for ; Sat, 19 Sep 2020 22:23:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KG79Dg+O"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=amacapital-net.20150623.gappssmtp.com header.i=@amacapital-net.20150623.gappssmtp.com header.b="EY9RaFhK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69DCE222BB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amacapital.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:In-Reply-To:References:Message-Id:Date:Subject: Mime-Version:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/bpeU0g/uvBtA2ttzn6evL4IQb6uTQ9uz35uHLXtd5g=; b=KG79Dg+OmEx4KBoPoZKYeV9wm hnGTVfF3XbUTvTZ1mgHo6dtzqe0YA00Nu529zrpeAVLOpPYAC4EIO9t/nP/RmZXWugD9bUvmUEkUr zcD++zS9n5g30PIwLSKzA21h868s7ipfqwEatMD6mvcu3cOWwVLN/WSfzJRawTrwdORrlCIYJILrt lWFwYnmwEq3c/QK9P1BdLGK7v2+aW+nI2eYGmUAyV1OF6CRTXp2ai97CEJIZvZngL96ctBNAjfI/Y thgkfMQ8UnQkBk+lkwPrUxkagb92w9EQRzAK8RCCxqwAIiYqk+LQrI5u5nohx8WVOfBzhSHs8OqVf JVSk6xeTQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJlFF-0003YQ-Ej; Sat, 19 Sep 2020 22:22:13 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJlFB-0003X5-S8 for linux-arm-kernel@lists.infradead.org; Sat, 19 Sep 2020 22:22:10 +0000 Received: by mail-pl1-x641.google.com with SMTP id q12so4872852plr.12 for ; Sat, 19 Sep 2020 15:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=25gVfK2bGDr534LWfZ/pQ4shMLoyA8XjkGlFCfd9UIQ=; b=EY9RaFhKJvXZJRe9JFZEmj/lrRJqtPj6jNB3uuL8Asw+3z3hL8ojgYDOBxgCTI3nk9 /mXxtqUMYM7Lwl0JgYFAozO/o74Ybc5I1+WhDC3iRbQpOEwdgChJfXvUy9LaiX/RnQRf p/J0xsjYVG4oqNtf24952lDJD0ziSd0wiVT/i0R8ihNenTSwy/mXNvVIx+wshhqobcUy 5EicG48utPjw3drDSP4fcvdYEf263LYbKCqq5wRH96dLaukxQtxTbM+CqP9ZHn/W3xRY 8AFACdo1jBBh0ZpNH8dhEU0zBCFGmtnY/LeHs/0y17jDB1ByiLtkNkIHMFbVGhXPT7kd OVIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=25gVfK2bGDr534LWfZ/pQ4shMLoyA8XjkGlFCfd9UIQ=; b=mF+Mt1XY2/tFVKh8IztYG8jwIiPCtJgYVozKhRIK7rsYLn5QBZ58HIi2Eu9Fk7hL4p gKn3tTcmXkgevR319q9fgksaLWD99kQBPoJubKInmWOZD6ATLnpi3eVOIA0tx178oudx kKOKIKNGgD7G7MRkSdXoQ7N++4odky4X3+fZ/XtDfa1DmIL6U8VIyMP3Xh1wIRfUMEsF tJBCe/3GGIyYmVRYM13cG0+E8LruYfGiqrN65fZc5OgwIJqs5lY5ffOgEavQ3YQlpLJp vVIy+uuXXlS2qfXqg3T2icgb5ZvSM6wvlpNlpTeIbOsXB020LB+/aWM0ewXHWGBQXZv5 zxWg== X-Gm-Message-State: AOAM5332qeznsxLN/8avuy4fl1gmWUxB7vIWSY8O/HjknE2/gwjIT3VV Xjfq98Uc3ddSCx4J+BboWmf+wQ== X-Google-Smtp-Source: ABdhPJziI+9RTM4Q+0EM9+8+2xFKIE2ZrEYxvbFrrOPerUdpGlrHlMuO11hqWffBHcUb5BpNHvdsyg== X-Received: by 2002:a17:902:ac97:b029:d1:f367:b51a with SMTP id h23-20020a170902ac97b02900d1f367b51amr16629268plr.20.1600554127472; Sat, 19 Sep 2020 15:22:07 -0700 (PDT) Received: from localhost.localdomain ([2601:646:c200:1ef2:e9da:b923:b529:3349]) by smtp.gmail.com with ESMTPSA id p4sm6588471pju.29.2020.09.19.15.22.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 19 Sep 2020 15:22:06 -0700 (PDT) From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 1/9] kernel: add a PF_FORCE_COMPAT flag Date: Sat, 19 Sep 2020 15:22:04 -0700 Message-Id: References: In-Reply-To: To: Arnd Bergmann X-Mailer: iPhone Mail (18A373) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200919_182209_934256_F45A05BC X-CRM114-Status: GOOD ( 25.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aio , "open list:MIPS" , David Howells , Linux-MM , keyrings@vger.kernel.org, sparclinux , Christoph Hellwig , linux-arch , linux-s390 , Linux SCSI List , X86 ML , linux-block , Al Viro , Andy Lutomirski , io-uring@vger.kernel.org, linux-arm-kernel , Jens Axboe , Parisc List , Network Development , LKML , LSM List , Linux FS Devel , Andrew Morton , linuxppc-dev Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-arm-kern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