Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1598347pxj; Wed, 19 May 2021 09:26:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlW6Pjrg0VsuwEgz3iupundejDtrlffqweS26uBv7wZjoWIrYV8jz6EDRQyJcnNAKxN23i X-Received: by 2002:aa7:d455:: with SMTP id q21mr15408033edr.2.1621441567855; Wed, 19 May 2021 09:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621441567; cv=none; d=google.com; s=arc-20160816; b=L7IS/i5D2UlYAN2GE5NBv7ujl849eIqj+2DNyiRa96DLYF2RzajvAsWGFh7cKhZkNx oWPr1C5KU8ELVTSn4UBuiM+gk6McpB21bHnpAc2RjbrJs8P20D7c6DV6pLik8UrPSom1 pbh8WgzWgv6yb8AKwfgcJEIbRRGe6ycEIa4FG7fA4vLJVzIPg/H4Cc7BuHctu5LZ0Rpn QzTY3HUmb+rVRpzaHZDuqf21u5F1mxxR+mDt2ca1kZ868Sf7fCtpQybz3GQKkUTLLU6Z kOh8jZvQ2EqlOpDiYh386awGlXCCMYK3QIdASw6cmRP6KKScF8gWUI7rdJdnLfkBcnqU 8P4g== 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=gnNQM8JHHmfRWd04LwL/bJcm0BMPL6wiVW0KZ9ItLZM=; b=heOt0DL2DVuzSSnYKTmp2cODbg/S4LDSjacBNHdYLC/BxoLYE65x8trBCMF/VznAbD pWu2Sr4DUE/OqIZ0Gjx9D6vtFdCcTUccmrIlRMUZJzRHQTuvo+qdSGuVdt/vnVM2Ta6c c5e3tJQusFrk9SbVJrCb5sRFNMPMmU35i5JPWuIjcAwR6XxNEG/Vr+1WLHXE9Jgc7MGM qINDadFOKzr4HRxqpCpjrRVIh+4RNE9rkmCivblrQX4udBEMux+Dcf4xc59TpZrJyDKO halJlIg2mH8Cw2yToy4DYKSH+5oCAp2gB6gLmserrSRdhaRuzS2vr9xS4GMqfV8n3rJ6 nzeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vK5Vwonk; 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 fi25si137782ejb.552.2021.05.19.09.25.43; Wed, 19 May 2021 09:26:07 -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=vK5Vwonk; 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 S1347261AbhERHrB (ORCPT + 99 others); Tue, 18 May 2021 03:47:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:36974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347262AbhERHqz (ORCPT ); Tue, 18 May 2021 03:46:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0401261354; Tue, 18 May 2021 07:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621323932; bh=Y+V2srtgNnzj+sz2D9W3MzRLHA3Oyb4L5KvaOMTQZcU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=vK5VwonkDkZYGOJp6YPxhRKo6knrgsSkaAV/BX3HDLzqeEaTAA+6V1aM0uWRDthgO GA7xKHvqnbCcxPWVCRWRH2Taf9+f9jqeDMaFKjz1LKAzQsp9D0Hj6SKDK7AgkY9npN sg8FN/TpGhAqh4JO7a2DPGtzS2OTYOEWJSQhvhiGqNSA3PDbQL21zcnKcro361OA2B IBdhXiQuiIN9AqsY8tKloo056FxIXo4X+X7QWU4SkRt/RDz64TQOfPaQL97O5SNST4 pFYGuFPVxLVdQbqr6YF2uL28MgO9SvebKPyOiEI8oWODxf2w2ZWKAf0o1A9GfGxwqA TyrtMikqL9vqQ== Received: by mail-wr1-f54.google.com with SMTP id z17so9025539wrq.7; Tue, 18 May 2021 00:45:31 -0700 (PDT) X-Gm-Message-State: AOAM532pYNhbYCwIOE0jH2gDbkHp51VeR1kuO38iOQE7Ole+hOZYORDt ztX3+qmg43Hb6txnWxnSZ3ni+r0g9qv0ofnKmuQ= X-Received: by 2002:a5d:5404:: with SMTP id g4mr5184734wrv.286.1621323930626; Tue, 18 May 2021 00:45:30 -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 09:44:20 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/4] kexec: simplify compat_sys_kexec_load To: Christoph Hellwig Cc: "Eric W. Biederman" , linux-arch , 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 8:40 AM Christoph Hellwig wrote: > > On Mon, May 17, 2021 at 10:57:24PM -0500, Eric W. Biederman wrote: > > We open ourselves up to bugs whenever we lie to the type system. > > > > Skimming through the code it looks like it should be possible > > to not need the in_compat_syscall and the casts to the wrong > > type by changing the order of the code a little bit. There are obviously other ways of doing the same. The reason for doing it this specific way is so I can eliminate the compat entry point entirely in patch 4/4. > What kind of bug do you expect? We must only copy from user addresses > once anyway. I've never seen bugs due the use of in_compat_syscall, > but plenty due to cruft code trying to avoid it. Right, I've used the same approach of passing a native-typed __user pointer and converting it in a copy_from_user/copy_to_user wrapper in a number of other places, as this tends to produce the most readable version by concentrating the tricky logic in the one place that already has to be careful. Most of the bugs I've seen with compat code are from duplicated code paths that diverge over time when a bugfix for the native version is applied incorrectly or not at all to the compat version. Arnd