From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5495EC433DB for ; Thu, 28 Jan 2021 01:47:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25F8464DD1 for ; Thu, 28 Jan 2021 01:47:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231136AbhA1BrK (ORCPT ); Wed, 27 Jan 2021 20:47:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231137AbhA1BrG (ORCPT ); Wed, 27 Jan 2021 20:47:06 -0500 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09398C061574 for ; Wed, 27 Jan 2021 17:46:26 -0800 (PST) Received: by mail-yb1-xb2f.google.com with SMTP id y128so3937514ybf.10 for ; Wed, 27 Jan 2021 17:46:26 -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:content-transfer-encoding; bh=shCJg6LSx/ErJstFNURWZk0h4jbY1bIKw8OLMF7mzBY=; b=Hr4LDg/A1JnUsmUck6IiazeIE/QBInF0+ixwcsYG1+tKKiWAsyGlXzmGslaXJZd90D YeBf9udwBCpS4DvNlM61CiwepwMDfmk+oFWLASb+Vs01RYNFL3cYadaqs6dkqribR1H0 9Ry0qAEGk6inDqTFIV+sgQF7833+brGlchte2LquzK1wurJJbqy9TU5ZGhJolv4HEGgN rrxD64gR6oVrhfhW2qlsnXOKDq9Ul9DfMR628j8U0TUOAUFDjc/Ae0TJX3pl56in9ZD6 HPShwI9CzgC4cHHTzIzLnijap24pht7pq4rX03FbelmI5YDwat5mBizroUd05/XC9aaC AAtw== 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:content-transfer-encoding; bh=shCJg6LSx/ErJstFNURWZk0h4jbY1bIKw8OLMF7mzBY=; b=pq6lXi+IoRk0wD6uV9/5ABPlt/8+DxNFsp6jGhRocsZH93hhS630yn+R7yZWm+67LZ iQr23UjT5CkUdHaMmf81a6Cz5QQnSXv1QrrBhUKsE+4V2a+z5WC49EiDC0QVOB5kJw// C3ZwSgGu6jghjIFG8MBZd1kclYQdheqouRtwQFYZTYG19FP0Teu96jHVNPV5rjAS921n nWGyoMVYxhXBLKhML8YceWGRD6J4l1T9BG24v75ZdcbWvY9PGHoGksBOMAkZyGTBAUjB 5yvilRS5vt7OMbWcmC4YAStVy05MkW4d98+K+5TdlGna8n27s1PLG1Ta66uJZYLYS9/n 7oFg== X-Gm-Message-State: AOAM531s/97kdZvAwDla7nAfpV0CHAZdgKKvY9/ZMk28xP+owJ1ZdjZG osThqydDKb5AlDpVcfm1M1pnxlC+4eRoSGtvUqY= X-Google-Smtp-Source: ABdhPJw3d9EMLAKGfCxnN5+yCPdPikKYnV/o6ARusSmPJs0ImlvoLyRJe5Lwdh8LMzh+fgscMawD9Wl0E83JLiUTCPM= X-Received: by 2002:a25:b195:: with SMTP id h21mr20319844ybj.347.1611798385375; Wed, 27 Jan 2021 17:46:25 -0800 (PST) MIME-Version: 1.0 References: <20210112075525.256820-1-kpsingh@kernel.org> <20210112075525.256820-2-kpsingh@kernel.org> In-Reply-To: <20210112075525.256820-2-kpsingh@kernel.org> From: Andrii Nakryiko Date: Wed, 27 Jan 2021 17:46:14 -0800 Message-ID: Subject: Re: [PATCH bpf v3 1/3] bpf: update local storage test to check handling of null ptrs To: KP Singh Cc: bpf , Gilad Reti , Yonghong Song , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Mon, Jan 11, 2021 at 11:55 PM KP Singh wrote: > > It was found in [1] that bpf_inode_storage_get helper did not check > the nullness of the passed owner ptr which caused an oops when > dereferenced. This change incorporates the example suggested in [1] into > the local storage selftest. > > The test is updated to create a temporary directory instead of just > using a tempfile. In order to replicate the issue this copied rm binary > is renamed tiggering the inode_rename with a null pointer for the > new_inode. The logic to verify the setting and deletion of the inode > local storage of the old inode is also moved to this LSM hook. > > The change also removes the copy_rm function and simply shells out > to copy files and recursively delete directories and consolidates the > logic of setting the initial inode storage to the bprm_committed_creds > hook and removes the file_open hook. > > [1]: https://lore.kernel.org/bpf/CANaYP3HWkH91SN=3DwTNO9FL_2ztHfqcXKX38SS= E-JJ2voh+vssw@mail.gmail.com > > Suggested-by: Gilad Reti > Acked-by: Yonghong Song > Signed-off-by: KP Singh > --- Hi KP, I'm getting a compilation warning when building selftests. Can you please take a look and send a fix? Thanks! /data/users/andriin/linux/tools/testing/selftests/bpf/prog_tests/test_local= _storage.c: In function =E2=80=98test_test_local_storage=E2=80=99: /data/users/andriin/linux/tools/testing/selftests/bpf/prog_tests/test_local= _storage.c:143:52: warning: =E2=80=98/copy_of_rm=E2=80=99 directive output may be truncated wr= iting 11 bytes into a region of size between 1 and 64 [-Wformat-truncation=3D] 143 | snprintf(tmp_exec_path, sizeof(tmp_exec_path), "%s/copy_of_rm", | ^~~~~~~~~~~ /data/users/andriin/linux/tools/testing/selftests/bpf/prog_tests/test_local= _storage.c:143:2: note: =E2=80=98snprintf=E2=80=99 output between 12 and 75 bytes into a dest= ination of size 64 143 | snprintf(tmp_exec_path, sizeof(tmp_exec_path), "%s/copy_of_rm", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 144 | tmp_dir_path); | ~~~~~~~~~~~~~ > .../bpf/prog_tests/test_local_storage.c | 96 +++++-------------- > .../selftests/bpf/progs/local_storage.c | 62 ++++++------ > 2 files changed, 61 insertions(+), 97 deletions(-) > [...]