Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3634331ybp; Sun, 6 Oct 2019 16:37:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCcz4LKKnZdp48ee0Hu+ZAYhHdG1XCQc29NlvoI+s3N28xaCCf2LjQ7noHWeFmcr1tt4fm X-Received: by 2002:a17:906:7499:: with SMTP id e25mr13615860ejl.326.1570405048200; Sun, 06 Oct 2019 16:37:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570405048; cv=none; d=google.com; s=arc-20160816; b=EKbR5qpuSC4el1mRt9G2WLu0JQU1gGHzzVINfeJgt0aWBD8Dd1pe5Wc8KjTJBhoQvj ucBAfqoa2EgU6dnXMKCkUYdHUZ2/HLcRMo8VAtpszDcFxolozCNtygKIMpDjdmWf4AUn QqP6c1hbkRZXdEAHX0NRY2j0969LwyxrB2OEknAqPh/cuRX965SwbikZQUkxscZN0i8i pzl2JpoTuXPkCUBTBmS1VuRT4YteK24BZkjiq95R4L9jnR3H3+ZN0xNoRzcb2yD3ebus 2UC7wgpFmtJRckirIVu/35Yh5OiYz80It+rwafs+6Mdkj53tN/ZIEU0lZYPT04ckqDEk Arzw== 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=I541VyUsc39FvItvzf+6+a8hUNrsqYjkEIi3jp2fNe8=; b=0sUonblHUUXlar+RIqq3wxHOQDUVQss6NumoHevWxwuVziVfVgNSuF8GTvdFWr1GDi mVr9kyfI0C6Pht/OKw+35Rq4uwiGnnOcG7PpPnQVL0rn3Z+iyeMTIxdLvA+8ubMgeVyg ZHibOTP+Jkc+8GpGO9INYq1jFO9LGBtkfpUq9s+zlN27vlh1yxkk9zdlRVzBakECMNyN MsC5bFqffTkQ5gsO8EumRbQgXyzZDBjAnOcSqZPsYpGlWJzWG9og/zrRR9LPW/HMx1fO CG5cmxUetAbbzhgDF6juUoOe0+K3otR5Imdf9nH1fpWL8EnaIlWLWQ3JMAozjJLnvrpf 4TnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=dRuQMA2y; 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 d25si7389417eds.40.2019.10.06.16.36.30; Sun, 06 Oct 2019 16:37:28 -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=dRuQMA2y; 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 S1726559AbfJFXfg (ORCPT + 99 others); Sun, 6 Oct 2019 19:35:36 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:36488 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbfJFXfg (ORCPT ); Sun, 6 Oct 2019 19:35:36 -0400 Received: by mail-lj1-f193.google.com with SMTP id v24so11692746ljj.3 for ; Sun, 06 Oct 2019 16:35:35 -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=I541VyUsc39FvItvzf+6+a8hUNrsqYjkEIi3jp2fNe8=; b=dRuQMA2y2wlK980QrRzfH0xEaPdZmaKsiQQCv/qmq93BayrBgQjq03QgE6EdBHRoQT OZoizuluLCjMPp4szPv9UOuBbzVUypw+Zjz0wmmFn+xCOXWv842CfUdkcpf4pCVrIbHh frveB/6637/WgVUn6pMqJQpqOxNxMkXf3rQ+k= 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=I541VyUsc39FvItvzf+6+a8hUNrsqYjkEIi3jp2fNe8=; b=FrS7NYvq4K116sXVOUwcA1yeKX8sd/gKs4xos05fJAS9ZfvP33h6YtPXYiSOMPtOkv JO70oYKuNX/JQnIs8bARkcG51fALCmGjkVi8BKZocxnQgWSNXHtnHIkeGpZqYDjQf7r2 cjGwsncaJEEPDK9oP6BvNXKLSjuRNO579N+rkuMUrMfhMowoRwRbXUx/WTBt14o15xtx PaFuQzB+JnWoCYLYGVtWQbxLFBLBixWbZUv8epFtg0sm3rxCnBPDWj4ZBpr5KHckKNhw ln96OyN/A68LWwGVC2RrLFlmE1tP4CGetnkheOtwxQM3/VnSvkQRFj1wvv77DNWdFcmc QZFA== X-Gm-Message-State: APjAAAVJry6z0PbX3Y9J5SzkwcwmGQzLV5l59NyZBO5dKY3n3YXVdq+S WLzFmYejMPLPtBxOnfSfy3PE9x0WEsA= X-Received: by 2002:a2e:1b56:: with SMTP id b83mr16244093ljb.107.1570404933940; Sun, 06 Oct 2019 16:35:33 -0700 (PDT) Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com. [209.85.167.54]) by smtp.gmail.com with ESMTPSA id l3sm2355501lfc.31.2019.10.06.16.35.32 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Oct 2019 16:35:32 -0700 (PDT) Received: by mail-lf1-f54.google.com with SMTP id w67so7951736lff.4 for ; Sun, 06 Oct 2019 16:35:32 -0700 (PDT) X-Received: by 2002:ac2:5c11:: with SMTP id r17mr15047822lfp.61.1570404932088; Sun, 06 Oct 2019 16:35:32 -0700 (PDT) MIME-Version: 1.0 References: <20191006222046.GA18027@roeck-us.net> In-Reply-To: From: Linus Torvalds Date: Sun, 6 Oct 2019 16:35:14 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] Convert filldir[64]() from __put_user() to unsafe_put_user() To: Guenter Roeck Cc: Linux Kernel Mailing List , Alexander Viro , linux-fsdevel Content-Type: multipart/mixed; boundary="000000000000219e680594466412" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000219e680594466412 Content-Type: text/plain; charset="UTF-8" On Sun, Oct 6, 2019 at 4:06 PM Linus Torvalds wrote: > > Ho humm. I've run variations of that patch over a few years on x86, > but obviously not on alpha/sparc. Oooh. I wonder... This may be the name string copy loop. And it's special in that the result may not be aligned. Now, a "__put_user()" with an unaligned address _should_ work - it's very easy to trigger that from user space by just giving an unaligned address to any system call that then writes a single word. But alpha does #define __put_user_32(x, addr) \ __asm__ __volatile__("1: stl %r2,%1\n" \ "2:\n" \ EXC(1b,2b,$31,%0) \ : "=r"(__pu_err) \ : "m"(__m(addr)), "rJ"(x), "0"(__pu_err)) iow it implements that 32-bit __put_user() as a 'stl'. Which will trap if it's not aligned. And I wonder how much testing that has ever gotten. Nobody really does unaigned accesses on alpha. We need to do that memcpy unrolling on x86, because x86 actually uses "user_access_begin()" and we have magic rules about what is inside that region. But on alpha (and sparc) it might be better to just do "__copy_to_user()". Anyway, this does look like a possible latent bug where the alpha unaligned trap doesn't then handle the case of exceptions. I know it _tries_, but I doubt it's gotten a whole lot of testing. Anyway, let me think about this, but just for testing, does the attached patch make any difference? It's not the right thing in general (and most definitely not on x86), but for testing whether this is about unaligned accesses it might work. It's entirely untested, and in fact on x86 it should cause objtool to complain about a function call with AC set. But I think that on alpha and sparc, using __copy_to_user() for the name copy should work, and would work around the unaligned issue. That said, if it *is* the unaligned issue, then that just means that we have a serious bug elsewhere in the alpha port. Maybe nobody cares. Linus --000000000000219e680594466412 Content-Type: text/x-patch; charset="US-ASCII"; name="patch.diff" Content-Disposition: attachment; filename="patch.diff" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k1fmjafm0 IGZzL3JlYWRkaXIuYyB8IDkgKysrKysrKysrCiAxIGZpbGUgY2hhbmdlZCwgOSBpbnNlcnRpb25z KCspCgpkaWZmIC0tZ2l0IGEvZnMvcmVhZGRpci5jIGIvZnMvcmVhZGRpci5jCmluZGV4IDE5YmVh NTkxYzNmMS4uZDQ5YzRlMmM2NmE4IDEwMDY0NAotLS0gYS9mcy9yZWFkZGlyLmMKKysrIGIvZnMv cmVhZGRpci5jCkBAIC03Niw2ICs3NiwxNSBAQAogCXVuc2FmZV9wdXRfdXNlcigwLCBkc3QsIGxh YmVsKTsJCQkJXAogfSB3aGlsZSAoMCkKIAorLyogQWxwaGEgKGFuZCBzcGFyYz8pIHRlc3QgcGF0 Y2ghICovCisjdW5kZWYgdW5zYWZlX2NvcHlfZGlyZW50X25hbWUKKyNkZWZpbmUgdW5zYWZlX2Nv cHlfZGlyZW50X25hbWUoX2RzdCwgX3NyYywgX2xlbiwgbGFiZWwpIGRvIHsJXAorCWNoYXIgX191 c2VyICpkc3QgPSAoX2RzdCk7CQkJCVwKKwljb25zdCBjaGFyICpzcmMgPSAoX3NyYyk7CQkJCVwK KwlzaXplX3QgbGVuID0gKF9sZW4pOwkJCQkJXAorCWlmIChfX2NvcHlfdG9fdXNlcihkc3QsIHNy YywgbGVuKSkgZ290byBsYWJlbDsJCVwKKwl1bnNhZmVfcHV0X3VzZXIoMCwgZHN0K2xlbiwgbGFi ZWwpOwkJCVwKK30gd2hpbGUgKDApCiAKIGludCBpdGVyYXRlX2RpcihzdHJ1Y3QgZmlsZSAqZmls ZSwgc3RydWN0IGRpcl9jb250ZXh0ICpjdHgpCiB7Cg== --000000000000219e680594466412--