Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3983400rdg; Wed, 18 Oct 2023 11:14:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7z1jgIJIsNaHHljYv5jPf3blmnl+tGN2F+1HISghXVWV6i1feiY/GJp6nXE4/hyASFRDE X-Received: by 2002:a05:6a20:2450:b0:14c:c393:692 with SMTP id t16-20020a056a20245000b0014cc3930692mr6929337pzc.7.1697652878096; Wed, 18 Oct 2023 11:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697652878; cv=none; d=google.com; s=arc-20160816; b=Q40f3Ijdrsm8o5UbtwCJnc2QoCyDZeBjjZbZ+BkPWseIpzPOqyk9vE4gwt1XODoo9b ndKSDQz9xFYhE3tZk2+xqeamRdjQJA6ei1UGT0ztpysa8PoWFHnTjNKBNhN2tqo+wdEs xoi9kEauVHO3BjX319xvWb52btSCx2xKDEqECycEnvlCIxcGY4F/qgyoXSpmCDbLROpu aq1v+gA8/QVghZUGCeYfCSv/0UXY7YOgIP/iuO+RZW4HX2WqsjvT7b+zgYccrSLJQqR+ MDWUkz1ALy1invD2RHiClMsKNKoJMuIvuJbbf1fljcH8H0ykzddenMqwfCrRX96nbPA3 hDOA== 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=b5ifuSh3pAXhwmN6aI2xPo6Qr4r8ZyUW95PzWHa09WA=; fh=+pFTWEulc2j/oZEFOG/w3eTLo4BI0Bp7BK8yuNG0uLQ=; b=IZhZuso6B2JxTNfPPMJ0U6w6hRd45RLQNew8Jlz48PSIcgJMkX6ax42mn93INDMV+u XfrgOYjdF8PHf2zUrJ6DI5FWf1JLx9dCimUBMp7az2ojzukSjN/gW5mv9kAodAibkN6l eTiJvdlUkAJVMxsyVycGz8ur8OelUqe5+DMj8bIObEXVLWKzh959oEDAMy0FiRnur6nT 3nu5uaf6mr6NFX2OpWDGU4MlDgCo4UOYvh+dyCpjlWr7E+Mr5Xec6L/d7m8Wnd6EOsxB zzfoGZcZWMRpHyPfqDWbj863v9l+sugrvn7Ai1u6JM1shXJhJk89so9VVG/CM7hKZb/e kdBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZCiACGeQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id j185-20020a638bc2000000b0055391572218si2577008pge.26.2023.10.18.11.14.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 11:14:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZCiACGeQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id EE6CE80BB5E9; Wed, 18 Oct 2023 11:14:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232333AbjJRSO1 (ORCPT + 99 others); Wed, 18 Oct 2023 14:14:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231307AbjJRSO0 (ORCPT ); Wed, 18 Oct 2023 14:14:26 -0400 Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53631111 for ; Wed, 18 Oct 2023 11:14:24 -0700 (PDT) Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-5832ea25c7eso203589eaf.3 for ; Wed, 18 Oct 2023 11:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1697652863; x=1698257663; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=b5ifuSh3pAXhwmN6aI2xPo6Qr4r8ZyUW95PzWHa09WA=; b=ZCiACGeQoi4k9Uczo7sPdo5KrSXFyTY/eKKYP/9yyDJHLOgwgs5M0Dj7+t9a/k2sGl 3GYP5PAWFfBheXCANJwQ7L2mqNvQuT3CzfFE8hF6KSks3b85N2++rfuzK0LWd1cMh7lN U0H2wrhwvUw5yVZ0Pls8y3UBf3MGAWwMh228g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697652863; x=1698257663; 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 :message-id:reply-to; bh=b5ifuSh3pAXhwmN6aI2xPo6Qr4r8ZyUW95PzWHa09WA=; b=XsMD8XP9TYF38XYMa9VX2K8gwLszAUViyK9MEWEjYNOUT5j9AHAxunzgr/Hvlnr4WF qDIjWMMxnKqvNWbOx5QN909oFVQUM7ot6MJT2eJVLSICn4U/v4fAwlSTEmTIzyubM+La J3IC27YuiNgizRnaNKcy81ohL+VAmDkYDfubXT/1p3BSbHylaYn9ky2VhTxsVAEiOMG3 MVzo0m9m+gWow9JXhYiRqDHYIAjeDNcz3cUjE9+h0Y8AiDolRyiV6G/wmjjosfhP01j3 W4pM3tq0NAPWpurj5o9xFcuHALhWJot4b264lA2hzxtflZnsMhmX4L6rRCh0egQTayKY i7Zg== X-Gm-Message-State: AOJu0YzKmfRNOV9RlVAvQutY479oqQjTvE2PNuBxyTUR39i42NOcQ2nG C5ZvutT0AWoiRXZTU3q7ep0vUw== X-Received: by 2002:a05:6358:3a0f:b0:166:f348:a8b3 with SMTP id g15-20020a0563583a0f00b00166f348a8b3mr2010476rwe.28.1697652863564; Wed, 18 Oct 2023 11:14:23 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id h26-20020aa796da000000b006bae6eea9d0sm3657643pfq.49.2023.10.18.11.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 11:14:23 -0700 (PDT) Date: Wed, 18 Oct 2023 11:14:22 -0700 From: Kees Cook To: Nathan Chancellor Cc: rostedt@goodmis.org, mhiramat@kernel.org, ndesaulniers@google.com, trix@redhat.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev Subject: Re: [PATCH] eventfs: Use ERR_CAST() in eventfs_create_events_dir() Message-ID: <202310181114.55457CFE@keescook> References: <20231018-ftrace-fix-clang-randstruct-v1-1-338cb214abfb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231018-ftrace-fix-clang-randstruct-v1-1-338cb214abfb@kernel.org> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 morse.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 (morse.vger.email [0.0.0.0]); Wed, 18 Oct 2023 11:14:34 -0700 (PDT) On Wed, Oct 18, 2023 at 11:10:31AM -0700, Nathan Chancellor wrote: > When building with clang and CONFIG_RANDSTRUCT_FULL=y, there is an error > due to a cast in eventfs_create_events_dir(): > > fs/tracefs/event_inode.c:734:10: error: casting from randomized structure pointer type 'struct dentry *' to 'struct eventfs_inode *' > 734 | return (struct eventfs_inode *)dentry; > | ^ > 1 error generated. > > Use the ERR_CAST() function to resolve the error, as it was designed for > this exact situation (casting an error pointer to another type). > > Closes: https://github.com/ClangBuiltLinux/linux/issues/1947 > Fixes: 5790b1fb3d67 ("eventfs: Remove eventfs_file and just use eventfs_inode") > Signed-off-by: Nathan Chancellor Yes, please. That's the correct method to do such casts. Thanks! Reviewed-by: Kees Cook -- Kees Cook