From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 439AE3FE47 for ; Fri, 15 Mar 2024 20:55:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710536147; cv=none; b=deqhNXoeKufn2EM6ZjvV0x90Cx77hAl7r1X7OqJFd0QaByljJVhRfuSHWjxVWGOrOW7vO/laE9U5WOt/mBrfrJZwOJD2nkGipx7Q2AkUXJk2X7ORVrg/9B+RpGv3tf00hEG9ojvrCzBvmI8aYJih3mG2nL7xsZY1NQ3rvKU/xYc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710536147; c=relaxed/simple; bh=vFIp47eyFRkJebC1ZTewSggLavBg2Uy67QVKRb0Dbew=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=b2CkULNeyUboH6KtSTceu6KKE8ja9vyx8J5bWHJQ/Ep9Fd7ge6UfIMiJnEtt5kA2b4ey0R6ijPAWMPasvYQzxtAtcLDsEQ+oMZMjL3erKW8iKUy48Km3X8gRlw7GutzlWl8MP5Am5plhm4JG7np+mHXd8AadOxh36Bm9VEbT/AM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=J3jUyH26; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="J3jUyH26" Message-ID: <55151dc9-8edf-4c75-b1d0-1cc0437816c3@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1710536142; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cyzThqt9i5s0vy//kTuZWuEk52yZJ8/vTj4lH/P0htw=; b=J3jUyH265uaTN1J5HV2QzzZ3Rc1/Hjngokhg0IU25RHmZHGDyVwRGMMQnlVv8ZANumhzVa 0NB+qBe4kRS47x9Ms5CL3oLceFevwb3SKk+AGKiHIJJWsSvU26s6L5e7sV/mV49JiSoRhn 2dlDTGf87BNLs1yv4vzFs6kYkW2h6Zw= Date: Fri, 15 Mar 2024 13:55:28 -0700 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v3 2/2] bpf: Check return from set_memory_rox() Content-Language: en-US To: Christophe Leroy Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Zi Shen Lim , Catalin Marinas , Will Deacon , "David S. Miller" , David Ahern , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Kui-Feng Lee , Eric Dumazet , Jakub Kicinski , Paolo Abeni , bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Kees Cook References: <2b9fdb119ef73cfa4516572026ba4936e86aedca.1710522112.git.christophe.leroy@csgroup.eu> <4d7cc25e937403ac61ae61be06f998f27e631a65.1710522112.git.christophe.leroy@csgroup.eu> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: <4d7cc25e937403ac61ae61be06f998f27e631a65.1710522112.git.christophe.leroy@csgroup.eu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 3/15/24 10:06 AM, Christophe Leroy wrote: > diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c > index 43356faaa057..ca1d9b87c475 100644 > --- a/kernel/bpf/bpf_struct_ops.c > +++ b/kernel/bpf/bpf_struct_ops.c > @@ -742,8 +742,11 @@ static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key, > if (err) > goto reset_unlock; > } > - for (i = 0; i < st_map->image_pages_cnt; i++) > - arch_protect_bpf_trampoline(st_map->image_pages[i], PAGE_SIZE); > + for (i = 0; i < st_map->image_pages_cnt && !err; i++) > + err = arch_protect_bpf_trampoline(st_map->image_pages[i], PAGE_SIZE); > + > + if (err) > + goto reset_unlock; This part does not look right. The "if (err)" check should be inside the for loop. pw-bot: cr 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 21BE1C54E58 for ; Fri, 15 Mar 2024 20:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=I5fFMNatSfISXUEeUJbPT0BGAGvk7LWxK8OiUkgui7w=; b=4dOst6F8r3xPl4 ZJ1K/xZVPSLLrfjFuwvd56h1v4UDwPLMekYoNpk0atANZ/dDqipy/j0LSUfZI4XRmYFYOcjEiOrLq 3BSamescLxk3gpU4HJ9g1C3/K8XQ+0Og+cyI3lbK4WyzsnNlB4o6k+6T0AFlF0d2AKFVdt1ssRh6r 6bWBcSJEI6F4mY8Ka72rPxLibY/I8/3GWCdzC/fL6uRsKebbfX0SR2WsCruexEW8uLBUqls+y5AXL jMLp8BXZZgJX83XxA3xhRWtkq9VWIfd/TiYVrRDWKYSjbMHhJ+28xMBEM8Fd20MJI/7LN5nR3AylQ +I8QLqlAsk466g0eL/0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rlEao-00000001ZDR-0Qlo; Fri, 15 Mar 2024 20:55:54 +0000 Received: from out-175.mta0.migadu.com ([91.218.175.175]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rlEag-00000001ZAT-2thZ for linux-arm-kernel@lists.infradead.org; Fri, 15 Mar 2024 20:55:51 +0000 Message-ID: <55151dc9-8edf-4c75-b1d0-1cc0437816c3@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1710536142; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cyzThqt9i5s0vy//kTuZWuEk52yZJ8/vTj4lH/P0htw=; b=J3jUyH265uaTN1J5HV2QzzZ3Rc1/Hjngokhg0IU25RHmZHGDyVwRGMMQnlVv8ZANumhzVa 0NB+qBe4kRS47x9Ms5CL3oLceFevwb3SKk+AGKiHIJJWsSvU26s6L5e7sV/mV49JiSoRhn 2dlDTGf87BNLs1yv4vzFs6kYkW2h6Zw= Date: Fri, 15 Mar 2024 13:55:28 -0700 MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v3 2/2] bpf: Check return from set_memory_rox() Content-Language: en-US To: Christophe Leroy Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Zi Shen Lim , Catalin Marinas , Will Deacon , "David S. Miller" , David Ahern , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Kui-Feng Lee , Eric Dumazet , Jakub Kicinski , Paolo Abeni , bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Kees Cook References: <2b9fdb119ef73cfa4516572026ba4936e86aedca.1710522112.git.christophe.leroy@csgroup.eu> <4d7cc25e937403ac61ae61be06f998f27e631a65.1710522112.git.christophe.leroy@csgroup.eu> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: <4d7cc25e937403ac61ae61be06f998f27e631a65.1710522112.git.christophe.leroy@csgroup.eu> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240315_135547_228293_1CB3857A X-CRM114-Status: GOOD ( 12.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 3/15/24 10:06 AM, Christophe Leroy wrote: > diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c > index 43356faaa057..ca1d9b87c475 100644 > --- a/kernel/bpf/bpf_struct_ops.c > +++ b/kernel/bpf/bpf_struct_ops.c > @@ -742,8 +742,11 @@ static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key, > if (err) > goto reset_unlock; > } > - for (i = 0; i < st_map->image_pages_cnt; i++) > - arch_protect_bpf_trampoline(st_map->image_pages[i], PAGE_SIZE); > + for (i = 0; i < st_map->image_pages_cnt && !err; i++) > + err = arch_protect_bpf_trampoline(st_map->image_pages[i], PAGE_SIZE); > + > + if (err) > + goto reset_unlock; This part does not look right. The "if (err)" check should be inside the for loop. pw-bot: cr _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel