Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp256497rwb; Sun, 25 Sep 2022 20:07:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Jseqaqqc1I0reixMieXjeW1EMgctz445iXaaICrxPBGDII0A+IeGXh7l74yihJ4NUsdaQ X-Received: by 2002:a17:907:25c5:b0:782:978d:c3da with SMTP id ae5-20020a17090725c500b00782978dc3damr11936153ejc.623.1664161632721; Sun, 25 Sep 2022 20:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664161632; cv=none; d=google.com; s=arc-20160816; b=A7c9Q4ut0dLrmzvOwgoFC4tlj1r95Kl9CwBSP6YwLBtbutP5Djwi+Ib6qBTV31h5+X IHMPY0Q6jJMiWu8M3IdP9hDock1kvgNTI6UbOrMNN+J5P2tK8ri7bDvIMNFjhotuCK40 bRksFgm+ZwouRSN+5bEt13khNLl/ewnlPacbO1NG/1e/fks7l09qxd3t2/0RX0sKq20N yFX4QKQmWSuGpbLXH+DubnMxF4ubqtwgg6qC7uYI0zlZd3Tli+qG75leFwkbLOvGMB+e yRDPeLCdoTasfhmNh3jugg1kx0vUG8c/IuOeE+TBmPXYpxwAzWZIkl2XteyOBRf8N60n or3g== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=ymDx1RK1IZPwG4FtzrCjNQCVValjUzUP4YDsHPOQBNw=; b=GyPFRv+1C3Hb3AkNx1kK82qxYT/snb515MGiRhHJ/Kcywx7gMpPCoqSNN8KHSiqD7B M5UQxZ46As8nMbqOdiFheLQ7IzRLT3IFfrPrNdHc2SSJTOwNLLjndlTtcQraiMXsO2ju uKUD2UjQr9wEMP4CMRSa7cMfPohZ12TDhUToLy1Xj10eDTb6PUDMYMJAFGGQxwsz7jyF MdqiXdjBqkgMV4IEo6D5EHONY4KP04yydF5fOWG3Uu0pDwuXBedXXBa23NFuWbd0XsjQ bUrXMDsVdVlj+bZAA/eDvmYl2nYSKznjJh0zkjE4BSgQxV5/A4YPuZ77/FMh3bd3mfOT LVvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NqQCR177; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f11-20020a056402194b00b00456ea7cddbasi6870736edz.114.2022.09.25.20.06.46; Sun, 25 Sep 2022 20:07:12 -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=@chromium.org header.s=google header.b=NqQCR177; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233111AbiIZCw1 (ORCPT + 99 others); Sun, 25 Sep 2022 22:52:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232860AbiIZCwZ (ORCPT ); Sun, 25 Sep 2022 22:52:25 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF950286C2 for ; Sun, 25 Sep 2022 19:52:24 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id iw17so5032818plb.0 for ; Sun, 25 Sep 2022 19:52:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=ymDx1RK1IZPwG4FtzrCjNQCVValjUzUP4YDsHPOQBNw=; b=NqQCR177uun7WuAmSlElKYS/S2MAwbvxqlraXbT3atsMNak+h1X5jIvRn9RvyWsTtI /JsQCsZjLjbGNWflkWIX/2v/cqo0B0dvAoJxFI0rl8hjUPJ5tzO3rmdvCGVz6qBdjdUr TMupY6qwk6T3DBFDCn7qzHXBAqywOTzpEioLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=ymDx1RK1IZPwG4FtzrCjNQCVValjUzUP4YDsHPOQBNw=; b=uwbrEOb15TIIeSaqd3Msh31LR93+5WIeSbXI96M1S5jhF7iweTOigwbEDIHT8Jj+vP uJhqGR/mVUfeYaAIPEFr0k73eMYJYKTuqferSwqXNJ4OOR9PvVHt5het+wVNfOy1pw3l qPcNmUEgdk0QGGqdQa0tvzsaIw+nyELj5vYOGZDNDCh1byFqKRmpRaYQvkPXTP5FXlEg U2zAJxdjoNPDS/T0msA2JRwsqCCUf3TZAt7Lpl6e5l+DBOtd6QoEUFZEbB6d9KvN5tdB IgJbRlm7rwiuvdrUtO3bQbkmSxpaQK8zjBaH9Wjga+ZKYubMdPriTR43KdjZZBSiy+IK lJ0Q== X-Gm-Message-State: ACrzQf0KzUaadHzFiomllE236uApS3LPJmTf2q9/Ws5FFk72bRBB3XKj JTJT1ok8GVyRYmk/ENFuTT9zRA== X-Received: by 2002:a17:903:4ca:b0:179:d21f:f04b with SMTP id jm10-20020a17090304ca00b00179d21ff04bmr7520625plb.7.1664160744246; Sun, 25 Sep 2022 19:52:24 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id j6-20020a170902da8600b00176acc23a73sm9984869plx.281.2022.09.25.19.52.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 19:52:23 -0700 (PDT) Date: Sun, 25 Sep 2022 19:52:22 -0700 From: Kees Cook To: Eric Dumazet Cc: Jamal Hadi Salim , syzbot , David Miller , Jiri Pirko , Jakub Kicinski , LKML , netdev , Paolo Abeni , syzkaller-bugs , Cong Wang , "Gustavo A. R. Silva" Subject: Re: [syzbot] WARNING in u32_change Message-ID: <202209251949.D718072@keescook> References: <000000000000a96c0b05e97f0444@google.com> <202209251935.0469930C@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202209251935.0469930C@keescook> X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 Sun, Sep 25, 2022 at 07:39:23PM -0700, Kees Cook wrote: > On Sun, Sep 25, 2022 at 10:34:37AM -0700, Eric Dumazet wrote: > > Sure, please look at: > > > > commit 54d9469bc515dc5fcbc20eecbe19cea868b70d68 > > Author: Kees Cook > > Date: Thu Jun 24 15:39:26 2021 -0700 > > > > fortify: Add run-time WARN for cross-field memcpy() > > [...] > > Here, we might switch to unsafe_memcpy() instead of memcpy() > > I would tend to agree. Something like: > > diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c > index 4d27300c287c..21e0e6206ecc 100644 > --- a/net/sched/cls_u32.c > +++ b/net/sched/cls_u32.c > @@ -1040,7 +1040,9 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, > } > #endif > > - memcpy(&n->sel, s, sel_size); > + unsafe_memcpy(&n->sel, s, sel_size, > + /* A composite flex-array structure destination, > + * which was correctly sized and allocated above. */); > RCU_INIT_POINTER(n->ht_up, ht); > n->handle = handle; > n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0; Ah, there is another in the same source file, in u32_init_knode(): memcpy(&new->sel, s, struct_size(s, keys, s->nkeys)); (I've been trying to convince Coccinelle to produce a list of all the composite structure targets, but I keep running into weird glitches. That it hadn't found this one let me track down the latest issue, so now I should be able to find more! Whew.) -- Kees Cook