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=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 CFDD8C433B4 for ; Tue, 18 May 2021 14:19:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 586C3611CE for ; Tue, 18 May 2021 14:19:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 586C3611CE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E198F8E0038; Tue, 18 May 2021 10:19:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC9268E002F; Tue, 18 May 2021 10:19:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6C448E0038; Tue, 18 May 2021 10:19:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0081.hostedemail.com [216.40.44.81]) by kanga.kvack.org (Postfix) with ESMTP id 90B498E002F for ; Tue, 18 May 2021 10:19:06 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 33E5A181AEF21 for ; Tue, 18 May 2021 14:19:06 +0000 (UTC) X-FDA: 78154558692.27.C12151B Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf25.hostedemail.com (Postfix) with ESMTP id 20AF36000115 for ; Tue, 18 May 2021 14:19:02 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id C5B52611CE for ; Tue, 18 May 2021 14:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621347544; bh=nrAiIQTKJqiGVWRN+fZiK7vfTpl+mh6GdbMLf8QWU6M=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=uO2nCdiW0NvUD3Oq2cx82BZG1aOLpwqISU2mJf1pn/41gmWeJwtJ3KwTWkPZOSffp qtEeD+G01WQE2a6OLg6viaogVrTcoartVG2vRtYwIcq9FSRcV1egrAvYdgmA/X3tdB m+P5YNb/2zoWb2ENaduSUYHTB0469Qb0Kj+2op5ABqhzmU5gjMCmQF2DbOGijvmPsZ xCjeQ8txdUZYsP5uPuGPMjh0ckotg/LymHT4x6ecHUAo8zYTM6uAVSt2umBf2+GizG +1ADzfu8zRcpU2xe1Of94E5AHIjxvrL1zbXxtiJz14yqM7TivZbQbYGDShT6WINj/N peuu9A0lgQRXg== Received: by mail-wr1-f54.google.com with SMTP id v12so10435595wrq.6 for ; Tue, 18 May 2021 07:19:04 -0700 (PDT) X-Gm-Message-State: AOAM532DycNi38n0xg+GehpkR9DtdOu8wLiM+yhDB/TeYetp2w8xpiZN VDnPwVPYjVZbRauepbqbRd8NL0vadCIVty12+W0= X-Google-Smtp-Source: ABdhPJzFpyp1CPVwvL2JvI3KmHNWPOcV2naQQAKLVgR48kQxz5AWGK/oLA+ez9stiNWkfs+BeuLGyXYYTicjDNU1kEw= X-Received: by 2002:a5d:6dc4:: with SMTP id d4mr7586717wrz.105.1621347543476; Tue, 18 May 2021 07:19:03 -0700 (PDT) MIME-Version: 1.0 References: <20210517203343.3941777-1-arnd@kernel.org> <20210517203343.3941777-2-arnd@kernel.org> In-Reply-To: From: Arnd Bergmann Date: Tue, 18 May 2021 16:17:53 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/4] kexec: simplify compat_sys_kexec_load To: "Eric W. Biederman" Cc: linux-arch , Christoph Hellwig , Alexander Viro , Andrew Morton , Borislav Petkov , Brian Gerst , Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , Linux ARM , Linux Kernel Mailing List , Linux-MM , kexec@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uO2nCdiW; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of arnd@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=arnd@kernel.org X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 20AF36000115 X-Stat-Signature: d84umhg4nptdh7orfpsqo3nq59m7xwy4 X-HE-Tag: 1621347542-177340 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, May 18, 2021 at 4:05 PM Arnd Bergmann wrote: > > On Tue, May 18, 2021 at 3:41 PM Eric W. Biederman wrote: > > > > Arnd Bergmann writes: > > > > > From: Arnd Bergmann KEXEC_ARCH_DEFAULT > > > > > > The compat version of sys_kexec_load() uses compat_alloc_user_space to > > > convert the user-provided arguments into the native format. > > > > > > Move the conversion into the regular implementation with > > > an in_compat_syscall() check to simplify it and avoid the > > > compat_alloc_user_space() call. > > > > > > compat_sys_kexec_load() now behaves the same as sys_kexec_load(). > > > > Nacked-by: "Eric W. Biederman" > >KEXEC_ARCH_DEFAULT > > The patch is wrong. > > > > The logic between the compat entry point and the ordinary entry point > > are by necessity different. This unifies the logic and breaks the compat > > entry point. > > > > The fundamentally necessity is that the code being loaded needs to know > > which mode the kernel is running in so it can safely transition to the > > new kernel. > > > > Given that the two entry points fundamentally need different logic, > > and that difference was not preserved and the goal of this patchset > > was to unify that which fundamentally needs to be different. I don't > > think this patch series makes any sense for kexec. > > Sorry, I'm not following that explanation. Can you clarify what different > modes of the kernel you are referring to here, and how my patch > changes this? I think I figured it out now myself after comparing the two functions: --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -269,7 +269,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, /* Verify we are on the appropriate architecture */ if (((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH) && - ((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH_DEFAULT)) + (in_compat_syscall() || + ((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH_DEFAULT))) return -EINVAL; /* Because we write directly to the reserved memory Not sure if that's the best way of doing it, but it looks like folding this in restores the current behavior. Arnd