Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1678377pxj; Wed, 19 May 2021 11:16:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU1hfwo2BzpDun4LJQ0lAIEjzmMQCygZU8DuWGafhf1lyal4ssnqpHVgKjMbqG3657kDml X-Received: by 2002:a05:6602:14c8:: with SMTP id b8mr757745iow.209.1621448160254; Wed, 19 May 2021 11:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621448160; cv=none; d=google.com; s=arc-20160816; b=DG72P2BXIAfLUPZiDIjELKATPaPWU/BZQqEJNiSoqbXQOVTACOUQvGEf1uySqwSdDa fPXoCvGLe7PgyefPGnl9dP5ViqYXiP2tg8sCew85U0mAxwHi9eZySepWBWYludjtPeN/ FBQRqLgoEVssYOio29gYhet+dP73crmU4TxvR+F7y0FYRe5vAYyxnIMAW1ffH3tUGraY AWqKI6a0JwbTtMiygC5vfw6MLA4lIhpcSjOAuKN+C4bwmB8YZ2wONWxzfjqVvFI6SitM BfGidmgB4NA2b5zwiL63DMePx77lnCJXxA27bDlBMTxks2OXsfRakP0xRZqfrgnftF1c fJ9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=AS2wcknP2BrtIZszYf9e+6x75C1Et0AM5k4dyrQ49vM=; b=b7t2jNAtrM1vo9pYLOEPG0O4k9ThDy1y13PDiIw/kqxct5/YVfgI8Osa7p1BioHgYD +ACCsqjuhqeq+oDkosh+BOyZAsoYQLzi1aWdVoaX0KGyh/TE+/QixT8f3+h56beLn40T SHdLz6L8AHxWWIJbnPl5TeiFI/2+d6QRQ7nl6xPYnQ6oA4ZbyjOAhV3dNrbhHoCkV2TO 3dLK6+JcZaQk9f8XpTsDPc99tzziF6OnTsAva8DKgSgJCoDlV/VuVsCJk5n8BSKugIF0 swREFQRCf6IL1vr/+7qIb1Lw60JorRaXoUnSYTbHVMuYXEUYAVT1QgCOkqOn73jRo7t8 D9CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uO2nCdiW; 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 h11si258714ila.129.2021.05.19.11.15.47; Wed, 19 May 2021 11:16:00 -0700 (PDT) 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=k20201202 header.b=uO2nCdiW; 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 S1349931AbhEROUX (ORCPT + 99 others); Tue, 18 May 2021 10:20:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:55694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243610AbhEROUW (ORCPT ); Tue, 18 May 2021 10:20:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CA31661261; 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-f44.google.com with SMTP id j14so8694518wrq.5; Tue, 18 May 2021 07:19:04 -0700 (PDT) X-Gm-Message-State: AOAM533iH7VBzIlnOuNZh8KObkGowvuqg209qCpHSe1GYY10O9Ap2071 YIwemHu4gzeOIo+zwLND8bzHA526So8jSfafqg8= 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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