Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2073425rwb; Thu, 27 Jul 2023 01:20:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlHtXkMOHOnW/5Lzqy1bFEk3v5nET3btFrcJIs+D7PPv1UOZZJqa/g/D5b4r1ZSPcCkDLGEp X-Received: by 2002:a05:6a20:3950:b0:137:3224:16c1 with SMTP id r16-20020a056a20395000b00137322416c1mr4451827pzg.45.1690446036024; Thu, 27 Jul 2023 01:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690446036; cv=none; d=google.com; s=arc-20160816; b=mDzeZgIQzLn/vZ9mIUlixKyQOOJV/5IjHxbgLyMiyDsWiOHAmdCGGq1a+X2t9TaFDa AMNqdbrgiiYCTHat20hHblzA9hvrKPasXapzfmEVxKES1vjsVzj6sBrlnWQrS1oZZooW 6QMiwOpmlqald0k47EMc8kYIeHVcatGMxU1aTrbsiqpXmOy4rW6YkvjxlkavibL/+arj YPQBB6RYVJrd7xc7+BQILXl78uwd6xJRg7gNJKPumXjUPalhi+E7WpfwiuOjAn37BwdN umh5HnUN+v1nRHpcJa+R5nZHaio7NSG5hliCf0MLIzSOM8fFfqb6aYd7ihuc+pXWS8hd jJ2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:to:from :subject:message-id:dkim-signature; bh=l/d1hElCRlKYILqamKbhScYXhcTsJFSt0ooe3i9EVAI=; fh=KU+8AumfFylD7eG7X/sacOdOynCO5b+KnvmMUq67a3k=; b=hAgK/JRzXP6EPkcjNwwSjXxr4ZKhR/uy1B8HiwJkmznfHLxHX5pWwNXlSd10XFPUAF X6xnzChBr0FpdSNlvBR2Oj8WN9+UDiMa63FaRep+3x2lCt9xNNUcxvFZuVI4J1CMPj1V oAA+ladbWVQ2CraVL+eXBvOQsby3eKk3sq2WIty8Mgbysy1ojfcED4MxRiCW7LjNVxqu pd48tXF+KYB2Um3hYz0N18bC+kzQg7FPMtyU4qQCak0swB8KHj7ICjinlXdy0+MGYw8L QYd3OgGT4wBBrMo4G97PxaumRZSpxhZwQARIhLuojt7DDRzSMyD0gmscKn9SQAmxhcIb IsVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e5knfw9u; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cn8-20020a056a00340800b00686627e7e9esi1033837pfb.120.2023.07.27.01.20.23; Thu, 27 Jul 2023 01:20:36 -0700 (PDT) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e5knfw9u; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233216AbjG0HmV (ORCPT + 99 others); Thu, 27 Jul 2023 03:42:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233140AbjG0HmB (ORCPT ); Thu, 27 Jul 2023 03:42:01 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0747A59DA for ; Thu, 27 Jul 2023 00:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690443289; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l/d1hElCRlKYILqamKbhScYXhcTsJFSt0ooe3i9EVAI=; b=e5knfw9uMq50UQ0QMsKT2BfVQQt3PAYNR/PpIhjXV9yA/h8IjNz1DIA+fcEuGsFgmsa8Iq GpvmFS0fcCbU43HZ40nc0E1yLgpNeJe1rrlYhsczC2tNRVaZtLvvjd+Te+w/u8V8bbJJYq BZo7NeU6f2qqDsS0jMeifapYG1xCXXA= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-515-cNhoqxBkPsuWeS7mwyIYCg-1; Thu, 27 Jul 2023 03:34:46 -0400 X-MC-Unique: cNhoqxBkPsuWeS7mwyIYCg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-63d2b88325bso1911726d6.1 for ; Thu, 27 Jul 2023 00:34:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690443286; x=1691048086; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=l/d1hElCRlKYILqamKbhScYXhcTsJFSt0ooe3i9EVAI=; b=llJDptGjRDTYmFAhCzEeziEwDaGT1yfphLcCTdZNG9UDQ15YXgxryenPGtFTfWd0Sp ycf/EA9eVgiNJ/jWmr2qU/JgzTkY2MoQH8qQkmlZAikWYQyFJ4DJonJfs/RR+oBpMSoj zHNH5EVAXvg8BZcKuf0O4s6lVZvHrbDOF3E2K6S1c/wzHTshoTVoNu0MGnUKjPMwzq6R +CMYgEELKbHFBk8w2ZBUQzRPlY/SWW7zuhGN3uQfIMSyCE/JYcPtQ4Evi6XOXXySAg+P LiPR5eaE3z0gg6LqWNJF9ib6Mp5TrShaVP41wGr0aKwvgyHA7/Ol9fyhS7rY/hA8+lPv Uh+Q== X-Gm-Message-State: ABy/qLaVJ3Q0O8b/zBVBxvRxjV6ph398B3UyM+ZlHRb8w+uErxFOh1GB 6b0zhtwN+9ONr9zSqR+dIkpsNDa4Mq6k5F0dfenLBVOP+ewmlLSD/v097SOoo54CvArwV9hpFO5 jxmNXgk9tfSVMMJ1+bqKiCyR5 X-Received: by 2002:a05:6214:19e9:b0:63c:7427:e7e9 with SMTP id q9-20020a05621419e900b0063c7427e7e9mr4493703qvc.6.1690443285857; Thu, 27 Jul 2023 00:34:45 -0700 (PDT) X-Received: by 2002:a05:6214:19e9:b0:63c:7427:e7e9 with SMTP id q9-20020a05621419e900b0063c7427e7e9mr4493694qvc.6.1690443285622; Thu, 27 Jul 2023 00:34:45 -0700 (PDT) Received: from gerbillo.redhat.com (146-241-238-55.dyn.eolo.it. [146.241.238.55]) by smtp.gmail.com with ESMTPSA id e16-20020a0caa50000000b0063d3dbf77f8sm106914qvb.51.2023.07.27.00.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 00:34:45 -0700 (PDT) Message-ID: Subject: Re: [PATCH v2] bpf: Add length check for SK_DIAG_BPF_STORAGE_REQ_MAP_FD parsing From: Paolo Abeni To: Lin Ma , davem@davemloft.net, edumazet@google.com, kuba@kernel.org, ast@kernel.org, martin.lau@kernel.org, yhs@fb.com, void@manifault.com, andrii@kernel.org, houtao1@huawei.com, inwardvessel@gmail.com, kuniyu@amazon.com, songliubraving@fb.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Date: Thu, 27 Jul 2023 09:34:41 +0200 In-Reply-To: <20230725023330.422856-1-linma@zju.edu.cn> References: <20230725023330.422856-1-linma@zju.edu.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Tue, 2023-07-25 at 10:33 +0800, Lin Ma wrote: > The nla_for_each_nested parsing in function bpf_sk_storage_diag_alloc > does not check the length of the nested attribute. This can lead to an > out-of-attribute read and allow a malformed nlattr (e.g., length 0) to > be viewed as a 4 byte integer. >=20 > This patch adds an additional check when the nlattr is getting counted. > This makes sure the latter nla_get_u32 can access the attributes with > the correct length. >=20 > Fixes: 1ed4d92458a9 ("bpf: INET_DIAG support in bpf_sk_storage") > Suggested-by: Jakub Kicinski > Signed-off-by: Lin Ma I guess this should go via the ebpf tree, right? Setting the delegate accordingly.=20 Please correct me if I'm wrong. Thanks! /P