Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1601129rdb; Mon, 2 Oct 2023 15:04:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXbnoRxcFlbpX0pMuJmiwZRfLxpvR0ayDnlH7LFLq9qWXKTyV8ON4hdc4YPtle9G5HvMQa X-Received: by 2002:a05:6358:2496:b0:13a:cb52:4837 with SMTP id m22-20020a056358249600b0013acb524837mr12159558rwc.31.1696284268626; Mon, 02 Oct 2023 15:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696284268; cv=none; d=google.com; s=arc-20160816; b=LXKKTjPZJaflh5V27Wp/C/MKMHyXeNE6ooIjm9dgxajniaxCXMo2+9dJrjklqZwhOP w0kf99vBsXpEhLO9DaFdxUSnE5gJ+qaq7dKaayv4gG9/mg5cqDUB62voLRkmdMmVzagM /P3K5eHS9kpHIFhjVQhpRG+FroaX7rcneaqygDd+Is4TD/eYf3YeX57Rc96lun6P82zQ 3oEbJ49nCh0SX4WyfEMqNIJUkddIt4opcWhHq077iSPufjsjDiLNUW31kxLYk1LsEIJh TF9S/ZEQvASO4/l/BaRsCksRuuIS1TswELYTZgnm0NQjLBTFF/3hhx3n8gsV8wMWyQmk fGZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:subject:cc:to:from:date:message-id:dkim-signature; bh=GcfuhtzVzjDNtRj4QA4ePrsnxqf+lMTsaZP4TTaHfSU=; fh=RfP5IxpK8GJ8GgIxTWuOPb0594Q9NtuTl4p08uMYMJY=; b=GmoHPT1yIhN5EdZU5JmoJc3dBP0ZFZc5P+ce6YJ12znkzrRA7vf7tZoSBeC01qMavc Zk1+TdXw9XF1AM+FzDbDdonVPpMYEKAhGM8xDrwJd7VXJBkEtKf8xe14Ox6ZLtRjp/Zv Iyq05mNbnDn9La/dijD22m+tiK/HerBqP122bYSNfmsde8PVrF273BgNfbmALUEK5O60 s/lJaLrMBFhm8Non6MIigRzpV95E/4s9WBaMDP83lSyCg2LisAqHucRIQAtYn8sP8P4M hDQUvo0X4i1yD6E9Ttw2h1dbe1ZHT1IEC0S6dzyxkU9LPd+9llHIPhcW4Zt4Fu6kFX75 XRug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MFEDMVdN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id x23-20020a631717000000b00570a4303746si27497219pgl.560.2023.10.02.15.04.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 15:04:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MFEDMVdN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6744B803336C; Mon, 2 Oct 2023 15:04:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230014AbjJBWDp (ORCPT + 99 others); Mon, 2 Oct 2023 18:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbjJBWDo (ORCPT ); Mon, 2 Oct 2023 18:03:44 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 431CFB0; Mon, 2 Oct 2023 15:03:41 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id 2adb3069b0e04-50481a0eee7so4458956e87.0; Mon, 02 Oct 2023 15:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696284219; x=1696889019; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=GcfuhtzVzjDNtRj4QA4ePrsnxqf+lMTsaZP4TTaHfSU=; b=MFEDMVdNc7YtftIMAShxWK9aeBcfDO8gO8Kjr7+MIK6L5FN8bIafBXUA3FBAGaC03q APElRAvzAv05jIiJNk58lWPQQ97no06OT9R7yhCFlmVLykrOGim6uT2PjP/xVbL0roY/ R4VszKp4/6uRTEGcIWNscsXqnvYqMEcAVBwuHxaGrM4VgpmF+A175leB2j04UXYzkiLp z6GgkdellbB+ckI/aCcToFtXI2Cs5mFmgWaK5HzP8uAy4RHFyLm2INN3FVqP93EZqe0l 0SHzgtFg/zh1qAjb+w7zZpCG8D7yryEU/55Li5Q15iITZ6SMdl0oBa/Au7TAAgZBI93/ i5/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696284219; x=1696889019; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GcfuhtzVzjDNtRj4QA4ePrsnxqf+lMTsaZP4TTaHfSU=; b=HBiH51ysoC4N/oO5c/Sx4XolAUBr7UNBBlur80ByoIHKMCC77JTC1EpVyEC5TOcSgE 9nwDmgWMU41Id1iHa4r2fYV8J+Hw+CDX7pThvef3+IUevToXSyEDhVKmq5HGqaDfMyTu Nq92H6kWx6NaQYTwc/3Zd/5/9YpjgUa1edwI3gqGV524OVAmKds0bs/z7f7/vRBj5POK 9NiOaDGts064qhI8q3YBrs5/QDMDgVcSHNKW6gbPg+w23mpnBll5vQGq6+D8WbijqUIp RNPuOuO9LXRrNBHmMNAog745qUJzx/9fJVxSkBUWBulrio3LPw+8J9qPuDH6x5vSZTN9 FlJw== X-Gm-Message-State: AOJu0Yx6n923aT1f6q3sQXln0Di2bZn7SZyvJ0/rdz3h4Nkn3+by+7a+ 1zVB2Kmyyi/R9Ug4b8CjR2E= X-Received: by 2002:ac2:4577:0:b0:4fe:4896:b6ab with SMTP id k23-20020ac24577000000b004fe4896b6abmr708500lfm.15.1696284219160; Mon, 02 Oct 2023 15:03:39 -0700 (PDT) Received: from akanner-r14. ([77.222.24.78]) by smtp.gmail.com with ESMTPSA id w9-20020ac25989000000b005057781cee2sm1212429lfn.264.2023.10.02.15.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 15:03:38 -0700 (PDT) Message-ID: <651b3e3a.c20a0220.a0ffe.58a3@mx.google.com> X-Google-Original-Message-ID: Date: Tue, 3 Oct 2023 01:03:35 +0300 From: Andrew Kanner To: Alexander Lobakin Cc: bjorn@kernel.org, magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, jonathan.lemon@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, xuanzhuo@linux.alibaba.com, linux-kernel-mentees@lists.linuxfoundation.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+fae676d3cf469331fc89@syzkaller.appspotmail.com Subject: Re: [PATCH net-next v1] net/xdp: fix zero-size allocation warning in xskq_create() References: <000000000000c84b4705fb31741e@google.com> <20230928204440.543-1-andrew.kanner@gmail.com> <2165e4a3-a717-f715-f7c3-e520d45ec21c@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2165e4a3-a717-f715-f7c3-e520d45ec21c@intel.com> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 02 Oct 2023 15:04:26 -0700 (PDT) On Mon, Oct 02, 2023 at 03:52:44PM +0200, Alexander Lobakin wrote: > From: Andrew Kanner > Date: Thu, 28 Sep 2023 23:44:40 +0300 > > > Syzkaller reported the following issue: > > [...] > > > PS: the initial number of entries is 0x20000000 in syzkaller repro: > > syscall(__NR_setsockopt, (intptr_t)r[0], 0x11b, 3, 0x20000040, 0x20); > > > > Link: https://syzkaller.appspot.com/text?tag=ReproC&x=10910f18280000 > > > > net/xdp/xsk_queue.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/net/xdp/xsk_queue.c b/net/xdp/xsk_queue.c > > index f8905400ee07..1bc7fb1f14ae 100644 > > --- a/net/xdp/xsk_queue.c > > +++ b/net/xdp/xsk_queue.c > > @@ -34,6 +34,9 @@ struct xsk_queue *xskq_create(u32 nentries, bool umem_queue) > > q->ring_mask = nentries - 1; > > > > size = xskq_get_ring_size(q, umem_queue); > > + if (size == SIZE_MAX) > > unlikely(). > > > + return NULL; > > + > > size = PAGE_ALIGN(size); > > > > q->ring = vmalloc_user(size); > > Thanks, > Olek Thanks, Olek. That is a reasonable optimization, I'll add it in v2. -- pw-bot: cr Andrew Kanner