Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp42520rdb; Wed, 18 Oct 2023 17:32:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9/arbSlDjPNrytcPqp6X2M3L1fr8dfBbkV1tKHYLH0+vI6Eik3+jA1od5a/J4h6GUVcgb X-Received: by 2002:a05:6358:5114:b0:13c:dd43:f741 with SMTP id 20-20020a056358511400b0013cdd43f741mr463209rwi.24.1697675579226; Wed, 18 Oct 2023 17:32:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697675579; cv=none; d=google.com; s=arc-20160816; b=lF4QwC2BBtW/hbC9ilLrOIr5ct9MT+EGDbn9eE2IlECCub+61jilbDEKa0Mb83YU0z N8F8zip0D1DvqteCTUJ+IYGVAlMiIZ8+DAhVPOO6THewzVmV9Nj1ZCJKMIaFzGYg4lx6 zcnPU3/dD/nCJxnmetd51bC3zLNJ9IVlcPhC6S/4cZyMa22UgJbPSSXQJ/zs3ZO+yaKD FMO3Z/+pxYsyoMKyrfR3UNKOV04Rj0CNDsYs3PuRlQzdPfs/SrX/NSiE372V3uVLfQj/ PWQUTk0DfeJnsymfVtH48DU6UsVFYs0jf/zI9tQ6qzGQ6cPFQoHPET+k9luGYIAKrupW qn5A== 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:dkim-signature:date; bh=hwS7/DcUtHPt4kJq4hSNEacDz1a7ECv/zqs7i4aI0Eg=; fh=iV5oZSBAobDF9z4179jgPjHbqgMPVeFdpzyMTF2Q9qs=; b=cNgvJvNF/EuZRIzuetcRJpeynwDs3Ne4ZX7pi6ygwv5z8ljqb4GRwDYqa6d77jAvQa CKrWV/HyabtTbC2PG/qY6gxP+eCQeW6mNoyJe0YZIHbkxw4tumBdNcYrORolQadHoa6e Pl2ds4QpNLJUWTM4yUGAD74nfBW9LMuaVUZ/WjxbvddftkG0NukI4WvXP1bpDoH9uqis bnUGuqE0rQJY3kIcpFG4wR95Ds2wwxFCnLCKx9aBUmYD3EuI2dB+w3BrPidzV6djmFbT Qm4CFiUzGBwCSHIUuvijGS/ZSmUyGhkTv5Qt4B29omsUM1qYVSzZaXxQU9VV/0XuO9on se7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="EnOF/bKt"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id by31-20020a056a02059f00b00578c3b7af9fsi3753568pgb.184.2023.10.18.17.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 17:32:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="EnOF/bKt"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 35BEE80DFA60; Wed, 18 Oct 2023 17:32:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231341AbjJSAck (ORCPT + 99 others); Wed, 18 Oct 2023 20:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjJSAcj (ORCPT ); Wed, 18 Oct 2023 20:32:39 -0400 Received: from out-197.mta1.migadu.com (out-197.mta1.migadu.com [95.215.58.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9402111D; Wed, 18 Oct 2023 17:32:37 -0700 (PDT) Date: Wed, 18 Oct 2023 20:32:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1697675555; 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: in-reply-to:in-reply-to:references:references; bh=hwS7/DcUtHPt4kJq4hSNEacDz1a7ECv/zqs7i4aI0Eg=; b=EnOF/bKtp+QW7N3HS2qa+3qrbx+KqloGAi0gphqa7ayhh+LjdKDLCnEhls/ElClHD6wMYw Y8oaqaEJrneKjjqeYz5ZUWTInl6kNnkeYYpK6Fo0QaKzV9VIC7+4hiKvsinpxOM32psro6 YdGflUMi+/JeK4oGK29uqBksKWyQUqQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Kees Cook Cc: Brian Foster , linux-bcachefs@vger.kernel.org, kernel test robot , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v3] bcachefs: Refactor memcpy into direct assignment Message-ID: <20231019003232.5uwphr7de7nybsra@moria.home.lan> References: <20231018230728.make.202-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231018230728.make.202-kees@kernel.org> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 groat.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 (groat.vger.email [0.0.0.0]); Wed, 18 Oct 2023 17:32:54 -0700 (PDT) On Wed, Oct 18, 2023 at 04:07:32PM -0700, Kees Cook wrote: > The memcpy() in bch2_bkey_append_ptr() is operating on an embedded fake > flexible array which looks to the compiler like it has 0 size. This > causes W=1 builds to emit warnings due to -Wstringop-overflow: > > In file included from include/linux/string.h:254, > from include/linux/bitmap.h:11, > from include/linux/cpumask.h:12, > from include/linux/smp.h:13, > from include/linux/lockdep.h:14, > from include/linux/radix-tree.h:14, > from include/linux/backing-dev-defs.h:6, > from fs/bcachefs/bcachefs.h:182: > fs/bcachefs/extents.c: In function 'bch2_bkey_append_ptr': > include/linux/fortify-string.h:57:33: warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=] > 57 | #define __underlying_memcpy __builtin_memcpy > | ^ > include/linux/fortify-string.h:648:9: note: in expansion of macro '__underlying_memcpy' > 648 | __underlying_##op(p, q, __fortify_size); \ > | ^~~~~~~~~~~~~ > include/linux/fortify-string.h:693:26: note: in expansion of macro '__fortify_memcpy_chk' > 693 | #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ > | ^~~~~~~~~~~~~~~~~~~~ > fs/bcachefs/extents.c:235:17: note: in expansion of macro 'memcpy' > 235 | memcpy((void *) &k->v + bkey_val_bytes(&k->k), > | ^~~~~~ > fs/bcachefs/bcachefs_format.h:287:33: note: destination object 'v' of size 0 > 287 | struct bch_val v; > | ^ > > Avoid making any structure changes and just replace the u64 copy into a > direct assignment, side-stepping the entire problem. This does make me wonder about the usefulness of the fortify source stuff if it can be sidestepped this way, but hey, I'll take it :) Pulled it into the testing branch, https://evilpiepirate.org/~testdashboard/ci?branch=bcachefs-testing