From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C673BC61DA4 for ; Thu, 2 Feb 2023 19:53:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2617F6B0072; Thu, 2 Feb 2023 14:53:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2119D6B0073; Thu, 2 Feb 2023 14:53:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B30B6B0074; Thu, 2 Feb 2023 14:53:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F1E266B0072 for ; Thu, 2 Feb 2023 14:53:11 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 877DF1407A2 for ; Thu, 2 Feb 2023 19:53:11 +0000 (UTC) X-FDA: 80423400582.16.CA66789 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf22.hostedemail.com (Postfix) with ESMTP id 6FE7CC000B for ; Thu, 2 Feb 2023 19:53:09 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=YN5MfCYS; spf=pass (imf22.hostedemail.com: domain of keescook@chromium.org designates 209.85.214.179 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675367589; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lTJ0ccmZsF7Gg5dE4Vjs5n4bqhK7TAIoBM6qr3Xy8w4=; b=Z8oPqQHPWcsICpXgY6NICCVBGPClBxyBzYI7Jhyn6aWsip9G5kS9HphrwteV+zhmVwGKPZ YvQ9tU/La0ub5Olv8sQ2krjfpeBCgo11XcOxXtbbryNrmJjAMPp3Lcwa+cx6o/mO+Epl1D QZJ40s7Z34RkdvC8Ui45c/uI1dnfjs0= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=YN5MfCYS; spf=pass (imf22.hostedemail.com: domain of keescook@chromium.org designates 209.85.214.179 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675367589; a=rsa-sha256; cv=none; b=SgciU18oZsBBwYCcF/HEEM7UWmyojWD2W02IXkBG8GqIOxF5p+MRARSS+/KzxQ+t5L/OfP E5ClWnCkeId5ECuOd8cJ32ICBAnRVSg1S44MtlRZVKehcwuDmEk+M+g9N5CyLFGvNGeEsV v6vi+6+qqINWakoM2rJjFamsIbBO2pE= Received: by mail-pl1-f179.google.com with SMTP id z1so2990070plg.6 for ; Thu, 02 Feb 2023 11:53:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=lTJ0ccmZsF7Gg5dE4Vjs5n4bqhK7TAIoBM6qr3Xy8w4=; b=YN5MfCYS9gxj2QhBXI5KZocZd2/htBFUyHiPsf05F0lToYbpyrMYoG9TWZEgiRbSVv SMFgP8p2olPX8yxJClMKUUp7onRh5Gw6s/YAO554whyR4NC5QTERa5Kfz0h0vSalaFFg bvcKN3nThGyybsFOl+wAqARj7RXbivXFmP2+E= 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:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lTJ0ccmZsF7Gg5dE4Vjs5n4bqhK7TAIoBM6qr3Xy8w4=; b=5pySAFI8ZWQ7JSj/Nb3BlNMvHE+wR3Rumx+fUXM+gG8zkVp9LU/kbka+Pj9LB0WItW cfxyKOTZ+3V0W99O3fFPMwtRBaGrBInYy2ZRgN8lKzHghLzhUwXZBs/thHT4wi94Z8V4 +xSgslo/2Zq5vrzCn/cN1aB8DqCsQ890Q7jxO1YcJAB0h9/JFxrXYzFx8Um2Typ9ryB+ IURRFZIQSmJempa3txdA+ppL96MsZLp69akhcH15RC1rsXBXWKOhBJU/Z5ZAAiQFRtKp ibYRt8tKCvnjKYlc6wtxkUS1sOmw3u+hiFYuyV2Qsiy8n8/DCvQEO5QJceB94XDlDEfg 1A0A== X-Gm-Message-State: AO0yUKUXir8SaV/q5FCspMN3N8OVvv1TDf0ZIrxsaRmvWWsytDebtY5v PQ5dQ6V+oI0a4Or1x23wGosaYQ== X-Google-Smtp-Source: AK7set8zRQbILHV+ugTiEd3WSZDmH7kswxREZghs4AgHCKTSZ4UsdVx2ugsfHod8HCyxVOJB0iJYzw== X-Received: by 2002:a17:902:f38c:b0:192:b43e:272 with SMTP id f12-20020a170902f38c00b00192b43e0272mr5651044ple.53.1675367588277; Thu, 02 Feb 2023 11:53:08 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id v16-20020a17090331d000b001948cc9c2fbsm52725ple.133.2023.02.02.11.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 11:53:06 -0800 (PST) Message-ID: <63dc14a2.170a0220.beb2a.0275@mx.google.com> X-Google-Original-Message-ID: <202302021952.@keescook> Date: Thu, 2 Feb 2023 19:53:06 +0000 From: Kees Cook To: Sami Tolvanen Cc: Nick Desaulniers , Ard Biesheuvel , John Stultz , Yongqin Liu , Vlastimil Babka , Greg Kroah-Hartman , Rasmus Villemoes , Thomas Gleixner , Jason Gunthorpe , Nishanth Menon , Michael Kelley , Dan Williams , Won Chung , David Gow , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Guenter Roeck , Andy Shevchenko , Paolo Abeni , Geert Uytterhoeven , Nathan Chancellor , Tom Rix , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev, Sumit Semwal Subject: Re: [PATCH 5/6] driver core: Add __alloc_size hint to devm allocators References: <20221101222520.never.109-kees@kernel.org> <20221101223321.1326815-5-keescook@chromium.org> <63dbf04a.630a0220.2608a.0149@mx.google.com> <63dc0a89.170a0220.49507.0091@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 6FE7CC000B X-Stat-Signature: 86pafa6wb8kdjgk77f3ffj3x9qngjtc1 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1675367589-316339 X-HE-Meta: U2FsdGVkX1/Ogyp9zpUbOjw/1kFMr1JmQGN6qlyJQX/UMKCKrcSBkkisWp9CORCPI1eum9txXce3Nnkuw37Cin6p/9TIQchs9fdz2EW9xSMi/FJlgJKsNXyBLD385sZI2QK57Y1FTiq7aa4Lx3fG1uEKBlBLzMoA5LSIxPrVGV3swUqtM6ZH+fl14tZmGHmh0DlsuSsAE9ONO30E7mqw4jkK7u5g0zubd+hi0/uAQkGm3tZ2FQpLJkKyRxqNRqDhwAn9fyU96YIgg20vrk2tnR9DDC4tv/882P2bu09YZuorMmB8haZZ11rDpGzfU23WfBIN46MFLlmPFEKaLDcGxHyjDN/vNxG8Nfz0ClcU7p5bPswh6LPk9EalbX7CLPhjqkn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fhy8/YQd1vGnfzk4MYO9VzAz6pQhnnPJNkjOnBPmUhE3Op57ay+DdKZ799LcgTDUXZ3kwBn1wKij+TrXZEWTmNQRY7kiMIfnWhQLb3PZL4AuGgdfGSM1vWr8w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Feb 02, 2023 at 11:49:42AM -0800, Sami Tolvanen wrote: > On Thu, Feb 2, 2023 at 11:31 AM Nick Desaulniers > wrote: > > > > On Thu, Feb 2, 2023 at 11:20 AM Ard Biesheuvel wrote: > > > > > > On Thu, 2 Feb 2023 at 20:10, Kees Cook wrote: > > > > > > > > On Thu, Feb 02, 2023 at 10:56:29AM -0800, John Stultz wrote: > > > > > That said, making sense of the error message isn't completely trivial > > > > > either. I've been seeing a few cases recently of some of the new > > > > > compiler tooling (I pinged you earlier on a CFI one) causing errors > > > > > that developers aren't really sure how to address. I know sometimes > > > > > it's not easy to surface the errors with context to what was wrong, > > > > > but at the risk of intense bike shedding, is there some way to provide > > > > > something like "Likely array bounds error" instead of just "BRK > > > > > handler: Fatal exception"? > > > > > > > > Yeah, this is a result of the size trade-off that resulted in config > > > > CONFIG_UBSAN_TRAP -- there ends up being no message about what went > > > > wrong. I'd really like to have cleaner handling of this -- perhaps what > > > > was done for KCFI could be applied to UBSAN as well, though this is an > > > > area I don't know well myself. (i.e. encoding "this was a UBSAN trap" > > > > in the trap itself.) > > > > > > > > Sami or Ard, is this something that could be improved for arm64? > > > > > > > > > > -ENOCONTEXT, so I am going to assume this is about runtime > > > instrumentation that needs some kind of 'panic' function which it will > > > invoke if some condition is met that should never occur? > > > > > > We already use brk with different immediate values in the opcode, so > > > the arch layer already has what we need. Is this a limitation in the > > > compiler, perhaps, where it always emits the same brk opcode? > > > > Yeah, we'd need to update both the compiler to produce the encoding, > > and the kernel to recognize the encoding and do something special. > > A quick look at Clang's source code suggests that Intrinsic::ubsantrap > already accepts the handler ID (from the SanitizerHandler enum) as an > argument and the arm64 LLVM back-end appears to encode the value as an > immediate for the brk instruction. I didn't confirm that this actually > works, but perhaps we just need to teach the kernel about the possible > values? Oh excellent. Yeah, if that's all that's needed here that would be great. What are the values? -- Kees Cook