Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1825572ybn; Thu, 26 Sep 2019 02:49:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmoB2u8EFd/9KbDORL8QvFdpgRfPD36VN2QOOO73Kt4GF/OvyM1g1osXAzfaUKpa79d6N8 X-Received: by 2002:a50:fa9a:: with SMTP id w26mr2492140edr.227.1569491341170; Thu, 26 Sep 2019 02:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569491341; cv=none; d=google.com; s=arc-20160816; b=g6PI+KcU0Hik8D4agEJr5o0NytOUxpCI9NUHP63LV9LPrpk+e2Q59GLhJPQc1Swb+D c/GAGPj9UiY29TYQvedDEhlTeT7XHpFF7z8awcTRqvLSZO/uab7/rPYKsld5pjxk1y1W SSEEmfbpVvK8D+OriQFEWZB9JM3zllbkKi1mLfOZlJ6WYLzBEGX9eGt1zHuKW3/BOspU 9ehwbg8oduhWb0uJ5e7RfrvZG+VVad68QjU9Qb3tYP4YX7lV6FX9hbK/9olfnCbzaPQh aJG5m6H6VSAVVO6KvH5s97ZqVW+w+tWZn0ikh9r+sqRzjkK9B9spIxFjwUtYoDxLXrl2 Sn/g== 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:dkim-signature; bh=m/M6vs2MEAeMbwXL6x+MUmS0dJpTwUZl6jDdxP7DrDw=; b=vbghPLLCw4R6hg0umUv+xFmOV0o7CCqxbslInTjhij8YEQovNe/Nx6+EAnhXZvgTyb qHErjN0qGEkPWwQ5IMvV4OXDwcmVdrjOyhn6bS72JLsOpqGWFTwKqMWZKPojDeqQMDW5 jh/z2TJu/VnVl2gyCNvjfLbqcPIKlYH4jVhghCBN+EvpJL9eQ1ccrYxz7HX6biqroxSB 8ygtDVmi6PnExisnRfjL840CnaPgOD0xpJKF/hjc9+R/Txd6ISylpRIGLN4tTCTpi4NX DDsl1SXoVHhjh6Kdk0IAHo9FsLVSL1ErSfRQOwZ6hJ/Xqqx9g3NJd0yA0TNRYRhQdZK4 Hhtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=QRNmKsS7; 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 gz26si754879ejb.65.2019.09.26.02.48.38; Thu, 26 Sep 2019 02:49:01 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=QRNmKsS7; 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 S2440178AbfIYRK7 (ORCPT + 99 others); Wed, 25 Sep 2019 13:10:59 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:46282 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437796AbfIYRK7 (ORCPT ); Wed, 25 Sep 2019 13:10:59 -0400 Received: by mail-lj1-f193.google.com with SMTP id e17so6457164ljf.13 for ; Wed, 25 Sep 2019 10:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=m/M6vs2MEAeMbwXL6x+MUmS0dJpTwUZl6jDdxP7DrDw=; b=QRNmKsS7UFvM5WS2hJvF/DKx2du7B20JglJZah0r/OncwmJDy/25GvjHNsK/+d8dtK 1WVfiK+mnfI6/+EgrVxBfTTDFs9f/7e4VvW4hVap03eHhSSrdUZWnKE5p4p2VDg0GTRe al6XiM4ArkVPwy1MSvvlYIiUCokXZoc/Us5KU= 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=m/M6vs2MEAeMbwXL6x+MUmS0dJpTwUZl6jDdxP7DrDw=; b=jGJYL9JZMba9qt5muSQIp3/ayk2hbwpKZp7E4oymxQrURFjLT8Cni9ips2yAj6VVZi JdOlXqRSE0UaHdj1tyftNJvp9To5bzrl7up00lyJaJZp8BasC0LgnJjWc8OWuLIyz5jE //XQgLenTqDAsIG0jf45sNbzR8XtPTd9g4XbS/EFhpQc3u+B5FZd4azzlP6gcthLSaw/ Gn+R1c8KF4evE4Zeic9eTlfosVndlyuLZzqmv2cmofF1c/EkSnAK8gTB35AKKhpNGexQ rt27thT2gzEKaFp06XfeZwl19w7bG7ecBFo/CMtTDW1BEpc8Bvy5+S1oHnP/6ztEHkDh HEdg== X-Gm-Message-State: APjAAAVFvm0ptuTlHl0d3e+0PYMUzP4mpiPwMkIDbnGD8p11mpIvXCgy jpIbvsshQVT8ccomSIAGeSieD7PeNzg= X-Received: by 2002:a2e:9d16:: with SMTP id t22mr6457567lji.207.1569431455134; Wed, 25 Sep 2019 10:10:55 -0700 (PDT) Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com. [209.85.208.175]) by smtp.gmail.com with ESMTPSA id q13sm1269180lfk.51.2019.09.25.10.10.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Sep 2019 10:10:54 -0700 (PDT) Received: by mail-lj1-f175.google.com with SMTP id e17so6456997ljf.13 for ; Wed, 25 Sep 2019 10:10:54 -0700 (PDT) X-Received: by 2002:a2e:2c02:: with SMTP id s2mr7454790ljs.156.1569431453769; Wed, 25 Sep 2019 10:10:53 -0700 (PDT) MIME-Version: 1.0 References: <20190925165915.8135-1-cyphar@cyphar.com> <20190925165915.8135-2-cyphar@cyphar.com> In-Reply-To: <20190925165915.8135-2-cyphar@cyphar.com> From: Linus Torvalds Date: Wed, 25 Sep 2019 10:10:37 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 1/4] lib: introduce copy_struct_from_user() helper To: Aleksa Sarai Cc: Ingo Molnar , Peter Zijlstra , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Christian Brauner , Rasmus Villemoes , Al Viro , GNU C Library , Linux API , 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 Wed, Sep 25, 2019 at 10:00 AM Aleksa Sarai wrote: > > +int is_zeroed_user(const void __user *from, size_t size) I like how you've done this, but it's buggy and only works on 64-bit. All the "u64" and "8" cases need to be "unsigned long" and "sizeof(unsigned long)". Part of that requirement is: > + unsafe_get_user(val, (u64 __user *) from, err_fault); This part works fine - although 64-bit accesses migth be much more expensive and the win of unrolling might not be sufficient - but: > + if (align) { > + /* @from is unaligned. */ > + val &= ~aligned_byte_mask(align); > + align = 0; > + } This part fundamentally only works on 'unsigned long'. Linus