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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 DEA77C43331 for ; Mon, 11 Jan 2021 14:07:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B43C0224B8 for ; Mon, 11 Jan 2021 14:07:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388329AbhAKOHp (ORCPT ); Mon, 11 Jan 2021 09:07:45 -0500 Received: from www62.your-server.de ([213.133.104.62]:40704 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730144AbhAKOHo (ORCPT ); Mon, 11 Jan 2021 09:07:44 -0500 Received: from sslproxy02.your-server.de ([78.47.166.47]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1kyxqW-000Fxo-Tv; Mon, 11 Jan 2021 15:07:00 +0100 Received: from [85.7.101.30] (helo=pc-9.home) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kyxqW-0009t5-My; Mon, 11 Jan 2021 15:07:00 +0100 Subject: Re: [PATCH bpf] bpf: local storage helpers should check nullness of owner ptr passed To: KP Singh , Andrii Nakryiko Cc: bpf , Gilad Reti , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau References: <20210107173729.2667975-1-kpsingh@kernel.org> From: Daniel Borkmann Message-ID: <281d55ae-984d-5a40-e0be-3a3480564379@iogearbox.net> Date: Mon, 11 Jan 2021 15:06:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.4/26046/Mon Jan 11 13:34:14 2021) Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 1/7/21 9:25 PM, KP Singh wrote: > On Thu, Jan 7, 2021 at 8:15 PM Andrii Nakryiko > wrote: >> On Thu, Jan 7, 2021 at 11:07 AM Andrii Nakryiko >> wrote: >>> On Thu, Jan 7, 2021 at 9:37 AM KP Singh wrote: >>>> >>>> The verifier allows ARG_PTR_TO_BTF_ID helper arguments to be NULL, so >>>> helper implementations need to check this before dereferencing them. >>>> This was already fixed for the socket storage helpers but not for task >>>> and inode. >>>> >>>> The issue can be reproduced by attaching an LSM program to >>>> inode_rename hook (called when moving files) which tries to get the >>>> inode of the new file without checking for its nullness and then trying >>>> to move an existing file to a new path: >>>> >>>> mv existing_file new_file_does_not_exist >>> >>> Seems like it's simple to write a selftest for this then? > > Sure, I will send in a separate patch for selftest and also for the typo. If it's small or trivial to add a selftest for the fix, I'd suggest to add it as part of this series for 'ease of logistics' as it would otherwise be a bit odd to i) either have a stand-alone patch against bpf tree with just a selftest or ii) having to wait until bpf syncs into bpf-next and then send one against bpf-next where for the latter there's risk that it gets forgotten in meantime as it might take a while. Thanks, Daniel