Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1196652pxb; Sat, 17 Apr 2021 09:28:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeAeTGxo4kY8b8I+qhqVT5KPL83+vj5dbr/0URy3bHbwq3O2GK86231jxMGX1t3TdYiQPR X-Received: by 2002:a05:6402:c:: with SMTP id d12mr16041195edu.100.1618676932255; Sat, 17 Apr 2021 09:28:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618676932; cv=none; d=google.com; s=arc-20160816; b=My4n+M+4J1MZPynE2Z5eKyRafTI1L6Vqb81wuPE18q7YMZGrhPhCYWIbStfOEDIvVO kx9k2xMsJ/KGPTkS0M88cdbQJG136Qbcr6PG16J7JOFo8wLJ4Gk6IUQpkqvkcDeWc4dC RyzUVcpYNL7l7pfWweyOhmzYQMZaZqWwZ3bSM3RzDSPHdO9geb54/G8NcgkC2yia+KsR SuIHtWgOMMXpdGkld+9++XGwz/XFZIROPyWdLzcYbD2E+6KRkKXmWr8uce2D3iV9eGtd c6dc4Qtng+Ie0Po+dSleoBjBJV+m7ODvYXF4b6s01ZMSpILkIDdXLiDdXN3F/tfxSlXH 0c6g== 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=PJwvm5Q5+ockDf6u3DaRu4ljbIeOieaqkufPDQnk1AU=; b=0AHgTcmYoL32eBr74mf0eMXImmpQ9oiVEfsnY4puNHT8yzAD8A917hQOP1P8biKkvi knMsVPIwcqbfP41BiNRspHOEQWmhSPo/IJOSDggEpr7HA6Av9jIvXOCzx+f3eaCZKhF4 Gbyd7/3bH8ixITOTlYaJx4fSLy7oFCJxk2QtzLBOWjbEaxzNI1TojinixYhWOAlei3eX yd9HSosdUdADQW4yrtyvD+fA74p+OH5HPhUlIl2kfEbWSWYHX3twROzW4H6Of8pQRtXh ueyvlNxU8nYpLGfw4CNNjghbD+Thn9QeUKP0O89//dXd3Zt3l6h+h7MdfGFeRcdqvHxw Klxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=MD7JEdg9; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n5si7285373eji.73.2021.04.17.09.28.29; Sat, 17 Apr 2021 09:28:52 -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=@linux-foundation.org header.s=google header.b=MD7JEdg9; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236590AbhDQQ1u (ORCPT + 99 others); Sat, 17 Apr 2021 12:27:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236535AbhDQQ1t (ORCPT ); Sat, 17 Apr 2021 12:27:49 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30888C061574 for ; Sat, 17 Apr 2021 09:27:23 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id o16so34465572ljp.3 for ; Sat, 17 Apr 2021 09:27:23 -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=PJwvm5Q5+ockDf6u3DaRu4ljbIeOieaqkufPDQnk1AU=; b=MD7JEdg9LjVjs5eRuO9c1Qio1fzn1ZVgzjEx88mcuMlS75Ytl95hCLewS19zxPGgBK QJaIxm686i3EboowyTIt0msSjEDRYa6AvTTGt3wBYLz3++yVPWv0HOBQGBFduTK4AuhM m+epdptG3VQoZ8uKJw2YUUzCeEf7jFbZi0GMM= 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=PJwvm5Q5+ockDf6u3DaRu4ljbIeOieaqkufPDQnk1AU=; b=o8kYm703MOXqv4gwEIjs8DqBmKJjN8pTL3j9EihdVNR0oGWivsAbo6aNiHmEGGV8Dl gpA1Pe2JYeF3W/MJpt2qK1uV6rUT4oGOTiioRA/ibtomhE34681AMozUG9p1goqaM6HL JXsZR5IpEi1OOajIlWyvozcBT1kkdTTdyv8o5gD9kQ+AWlrbcT6z7XLRNGd2GCVc8wPM vCL/p/SWxy9XYGJU+0Crqa/1gdTmRzHQhQ78l2xIoYwgXpCqfCIMXB24/Nl/IRXgY60x TiJ+YLafgSAcoFiDCtkbFUvOfu9zmBa6ivBWczpkFf+k6WnyhH1Fn4cBAhKBICOSP7Rt arRQ== X-Gm-Message-State: AOAM531uHnAeuv7sDOKY+SqweMXEuSVNVXxYEDKFsxDiAnY44u/b40ug qUOevMIxPgks4CmlhuX7XUO86HJAKpIUJPZv X-Received: by 2002:a2e:87c9:: with SMTP id v9mr5904448ljj.321.1618676841285; Sat, 17 Apr 2021 09:27:21 -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 x23sm804127lff.162.2021.04.17.09.27.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 17 Apr 2021 09:27:20 -0700 (PDT) Received: by mail-lf1-f54.google.com with SMTP id i10so13564964lfe.11 for ; Sat, 17 Apr 2021 09:27:20 -0700 (PDT) X-Received: by 2002:a05:6512:1192:: with SMTP id g18mr6439868lfr.421.1618676840422; Sat, 17 Apr 2021 09:27:20 -0700 (PDT) MIME-Version: 1.0 References: <20210416192413.1514419-1-eric.dumazet@gmail.com> In-Reply-To: From: Linus Torvalds Date: Sat, 17 Apr 2021 09:27:04 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86/uaccess: small optimization in unsafe_copy_to_user() To: Eric Dumazet , Al Viro Cc: Thomas Gleixner , linux-kernel , Eric Dumazet Content-Type: multipart/mixed; boundary="00000000000014ade305c02d9269" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --00000000000014ade305c02d9269 Content-Type: text/plain; charset="UTF-8" On Sat, Apr 17, 2021 at 9:08 AM Linus Torvalds wrote: > > Side note: I'm, looking at the readdir cases that I wrote, and I have > to just say that is broken too. So "stones and glass houses" etc, and > I'll have to fix that too. In particular, the very very old OLD_READDIR interface that only fills in one dirent at a time didn't call verify_dirent_name(). Same for the compat version. This requires a corrupt filesystem to be an issue (and even then, most/all would have the length of a directory entry in an 'unsigned char', so even corrupt filesystems would generally never have a negative name length). So I don't think it's an issue in _practice_, but at the same time it is very much an example of the same issue that put_cmsg() has in net-next: unsafe user copies should be fully guarded and not have some "but this would never happen because callers would never do anything bad". Al - fairly trivial patch applied, comments? Linus --00000000000014ade305c02d9269 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_knlybvem0 IGZzL3JlYWRkaXIuYyB8IDYgKysrKysrCiAxIGZpbGUgY2hhbmdlZCwgNiBpbnNlcnRpb25zKCsp CgpkaWZmIC0tZ2l0IGEvZnMvcmVhZGRpci5jIGIvZnMvcmVhZGRpci5jCmluZGV4IDE5NDM0YjNj OTgyYy4uMDllOGVkN2Q0MTYxIDEwMDY0NAotLS0gYS9mcy9yZWFkZGlyLmMKKysrIGIvZnMvcmVh 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