Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4104477rwb; Mon, 21 Nov 2022 03:53:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf406/wAZKyJE8jw4U5ew4HWmJ5V8Hr5s10KABZq4tw82pgWj7R6k2REKU6Q/2fyb9k6XIYd X-Received: by 2002:aa7:cc12:0:b0:462:79ec:55eb with SMTP id q18-20020aa7cc12000000b0046279ec55ebmr15723710edt.151.1669031632346; Mon, 21 Nov 2022 03:53:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669031632; cv=none; d=google.com; s=arc-20160816; b=Lh+HGfdstgoNQac0eQjv3SPs+oQ3GKO7eizvPyCoxFaLVwBdZ2p+I4bJcBV+5RaELg QyexzgFdaL4bwOV98iHjW2CBN+uH4NnjIrduvX/r3r5g3HLWzty2NX2P1U5z/meHfWsP XV1J0fZHUoSxvM4s1YaIWML6uG4/9IQxMcQc9C66DynX2fh0gX8I/O2o5k5ljylwqgWd o5CkMea2chAak+AHX4SZ8wabGAKg6AofNbTjjWoUJUPXHkXGk5Ik/EyRoYv27crXAL8x ByrMW4gc+TPBGBef2AImLZ0nvJf7dwlz7de849gwOtERwGFaWl1Z9Aw5hdwfXRyUwtRm 5SCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id; bh=xzgZ8Rha6kXTURAtuHACiSZ1zgexQgAMzOKTZUv6vAc=; b=QRUAxdpLB/3Ad4i0j657ZE1qfAlvDlTUWlaQI1DL5h0W8EljJ7X85aJFp91HVoiFoX woRHlv8cdwsNrrmXGlAfb/x+Oed8o1UtLiYSioOkfvamd0p0djvj5TLmlwOZWKKzMwm9 1OMBf55fpnFsWyeTpkPhjhZiJHKYQwFhLvRFztOLiJnx6MXMsrxa4fkt/KGguzF2Kp3z scLTuVrKRbO7shH+KT16PWQXWO8pK8ctD16Iw6ga2/YRIIEasbd7/gqhtKJYR/VnF4Vj n5u9WzI6/qAc2IzvumdL2LhsMOuPHlr/Qpzi+pGVzmSThy1fFXqxInFMWcn3Ku3YJ+rL a7qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji22-20020a170907981600b007adf16570c3si4902346ejc.17.2022.11.21.03.53.26; Mon, 21 Nov 2022 03:53:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230507AbiKULfJ (ORCPT + 92 others); Mon, 21 Nov 2022 06:35:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231296AbiKULeq (ORCPT ); Mon, 21 Nov 2022 06:34:46 -0500 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89858B4838; Mon, 21 Nov 2022 03:30:13 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4NG4tl3Tynz4f3l2F; Mon, 21 Nov 2022 19:30:07 +0800 (CST) Received: from [10.67.111.192] (unknown [10.67.111.192]) by APP3 (Coremail) with SMTP id _Ch0CgBXZqJBYXtj6fFRAw--.52286S2; Mon, 21 Nov 2022 19:30:10 +0800 (CST) Message-ID: Date: Mon, 21 Nov 2022 19:30:09 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH bpf 1/2] bpf: Do not copy spin lock field from user in bpf_selem_alloc Content-Language: en-US From: Xu Kuohai To: Alexei Starovoitov Cc: bpf , LKML , "open list:KERNEL SELFTEST FRAMEWORK" , Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Kumar Kartikeya Dwivedi , Mykola Lysenko , Shuah Khan References: <20221114134720.1057939-1-xukuohai@huawei.com> <20221114134720.1057939-2-xukuohai@huawei.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: _Ch0CgBXZqJBYXtj6fFRAw--.52286S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Xw15Xw17Ww15GF4fWF15urg_yoW8JrWxpr 93Aas8tFW7Xw1rua9Iqr4xAFy09w43G3WDWan8JFWrGrZ3ZF9Igr1Dta1UCa4Syw4aq3Wv vF1Yqas8C34DAaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvIb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7Mxk0xIA0c2IE e2xFo4CEbIxvr21l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxV Aqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a 6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6x kF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE 14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf 9x07UZ18PUUUUU= X-CM-SenderInfo: 50xn30hkdlqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/16/2022 4:07 PM, Xu Kuohai wrote: > On 11/16/2022 1:27 PM, Alexei Starovoitov wrote: >> On Mon, Nov 14, 2022 at 5:31 AM Xu Kuohai wrote: >>> >>> bpf_selem_alloc function is used by inode_storage, sk_storage and >>> task_storage maps to set map value, for these map types, there may >>> be a spin lock in the map value, so if we use memcpy to copy the whole >>> map value from user, the spin lock field may be initialized incorrectly. >>> >>> Since the spin lock field is zeroed by kzalloc, call copy_map_value >>> instead of memcpy to skip copying the spin lock field to fix it. >>> >>> Fixes: 6ac99e8f23d4 ("bpf: Introduce bpf sk local storage") >> >> The tag is wrong. When local storage was introduced it was not >> possible to use spin_locks there. >> Pls resubmit. >> . > > No, spin_lock was introduced by d83525ca62cf ("bpf: introduce bpf_spin_lock"), > before 6ac99e8f23d4 ("bpf: Introduce bpf sk local storage"). > > To confirm this, I built a kernel image on comit 6ac99e8f23d4 ("bpf: Introduce bpf sk local storage") > and run test case posted in patch 2, a softlockup was triggered. Then I picked > this patch and tried again, nothing failed. Hello, am I right? Or could you please give the correct fix-tag? Thanks.