Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp983726pxb; Thu, 5 Nov 2020 19:55:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWbCXP3XVuDdZYIX5pyTrhP9vSJBdIVF/gi6SdNEAMp7mUA6THYtCTMvuTd6pqcbNpc1Af X-Received: by 2002:a17:906:4a98:: with SMTP id x24mr119695eju.304.1604634923682; Thu, 05 Nov 2020 19:55:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604634923; cv=none; d=google.com; s=arc-20160816; b=YWA3dfrrDzuix2XgbuLUbp3J9+eMxpZXwLhYnlcICVbrgkv1KFdfVeUGtc4+ynVqk4 Jqe3IGvTN7Fit9EewXsXc+twiTBLI1nYeoTmqoRVmWf1WvcSj5I0h3nEbV8IvmsGruPc xkMlFzkm9Tns220Og0b7In5vK91PvMsaDrPpfqW3Fz63LOJmyrWDtwFcQtMzW44EE3dg 3p6nnBklfyh+41atOWMgA32UOuMURLK3C+RlkYNyMxejecVTSw772zuIat0cqbI8+Sc2 tHMN/Tk7cyB9xfLmi5tkrw+XH1ONE4XFAx52Ig1B5YNG/UxvEKLj9vwvKBh4e4JZGakw Jong== 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=S2AIiVxkOnwPyftxYL1/j7Dy6SZMLtDsVFSo2M4HZ00=; b=cvghb1VSa1vHX9tNpfubCxZz+ixx0NKBn1w6KUcRsJLLxDDzLvrGn/7/sjxI4eLoXJ Nrs/enjZKYYiseGSNDE5b7XnFCpVCQk3OHhOnZtFojZtf9M33+Zf0BisXvwDEhqmq7WE /h17At+Bpx5w1Uhm8fBODqEs6j+XqvRfjmRLNvtooaVkvj/Wv2wUM6UmWx04NANvBo6R jvq+PEYz8M76Oec+tKHQfvRTYV2wroPlge0GSz+3xbiavTZv5brD0LPxhdhDt7kStsHV URcuybzsKlFf9+i3QSQ4rXIPZEqVb91dDtGoPjlEiGzWg+IfrDQgUhmS2m+7g9PsDHsA SZ9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TH+8jr1O; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x37si57783ede.385.2020.11.05.19.55.00; Thu, 05 Nov 2020 19:55:23 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=TH+8jr1O; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725837AbgKFDxS (ORCPT + 99 others); Thu, 5 Nov 2020 22:53:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725616AbgKFDxR (ORCPT ); Thu, 5 Nov 2020 22:53:17 -0500 Received: from mail-yb1-xb43.google.com (mail-yb1-xb43.google.com [IPv6:2607:f8b0:4864:20::b43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE668C0613CF; Thu, 5 Nov 2020 19:53:16 -0800 (PST) Received: by mail-yb1-xb43.google.com with SMTP id f6so2587ybr.0; Thu, 05 Nov 2020 19:53:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=S2AIiVxkOnwPyftxYL1/j7Dy6SZMLtDsVFSo2M4HZ00=; b=TH+8jr1O5vLPDH4dbuO2Dz6p1Yd/QzZehL7b5uRnz1ilNH26KAyT2Xa3p+tCJbzw9C iZshgXOQHIENIB544P5LFmvJZV7d8a0h9fs1G76RIwsWCEhyC1sfm9/a0UGkJAI4wnXg MPBg7RiQtiIo4yU1xnJhMtj3vGIDKb1IiEIuvK6FrSW5+ERVJedXP6VLAPP0gEw6mpwJ w419HoAwpzPExfLsu1MFjkoEhcI3hge+qxaILaPFXeiMrqg3z7h7FHyBjt2Xd39jZMC8 t1VGPs6I9hLODV0jG5jrmQDqyRGSnrZYc0C3bxjId4DWRzHMi02fyT/XukzwNYceAMGJ UzUQ== 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=S2AIiVxkOnwPyftxYL1/j7Dy6SZMLtDsVFSo2M4HZ00=; b=ZKisKfrSPOMp7gLo1gO/Dt005VZFOpulBTApNeiAnz48YGe8mKs8cM6GJrNbTS8Vt7 1+3WoDN0YlExPUQ9tT46P/nx20lQRQ/uzlOcLGM62l114UiasjVr0Ate2CAtGj98pqiU FV1BcEkR2c+j/ugflUx/4CZUcRvYvxXktmjQOMEMvrOhYW8hAbY5gdtBdfzle9NMjqhW M7XLsjSGeOz6Kwc7GWLh5ONK4hV8O2e2YlgoYCJQVD94qgvi0SQfAkIkeRks6j4RbCM5 mrMkZUMKFenPOvyU5khqdSuG1EaGbqcDdvk0l6ZJ9ChjPAryCc2bQ64say0JXE2u23Zx 3TbQ== X-Gm-Message-State: AOAM533c5zjN5eeenwl6WUyzrEwKL2C3Nz0UXPG6rgn3pNTdXjX+aa06 CTUxhSejh/h7HPLxtZi+ZXUY5kS4mWwH7mIM1QI= X-Received: by 2002:a25:da4e:: with SMTP id n75mr241475ybf.425.1604634796022; Thu, 05 Nov 2020 19:53:16 -0800 (PST) MIME-Version: 1.0 References: <8b8c8f51aff8fabac4425da9b0054b4c976c944b.1604620776.git.dxu@dxuuu.xyz> In-Reply-To: <8b8c8f51aff8fabac4425da9b0054b4c976c944b.1604620776.git.dxu@dxuuu.xyz> From: Andrii Nakryiko Date: Thu, 5 Nov 2020 19:53:05 -0800 Message-ID: Subject: Re: [PATCH bpf v4 2/2] selftest/bpf: Test bpf_probe_read_user_str() strips trailing bytes after NUL To: Daniel Xu Cc: bpf , open list , Alexei Starovoitov , Daniel Borkmann , Song Liu , Kernel Team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 5, 2020 at 4:06 PM Daniel Xu wrote: > > Previously, bpf_probe_read_user_str() could potentially overcopy the > trailing bytes after the NUL due to how do_strncpy_from_user() does the > copy in long-sized strides. The issue has been fixed in the previous > commit. > > This commit adds a selftest that ensures we don't regress > bpf_probe_read_user_str() again. > > Signed-off-by: Daniel Xu > --- Acked-by: Andrii Nakryiko > .../bpf/prog_tests/probe_read_user_str.c | 71 +++++++++++++++++++ > .../bpf/progs/test_probe_read_user_str.c | 25 +++++++ > 2 files changed, 96 insertions(+) > create mode 100644 tools/testing/selftests/bpf/prog_tests/probe_read_user_str.c > create mode 100644 tools/testing/selftests/bpf/progs/test_probe_read_user_str.c > [...]