From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 841E0263C8F for ; Mon, 3 Nov 2025 22:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762209181; cv=none; b=fFnwVFjkU5DW32A0d0sqZVRaLfUe/yGtph/wjpubBOgEG85doIARjz2UOREmvnAj/py+W9G257uyBUtUdxz1Tq0yO/NPqHa6hcnzFTqsV/sKybAouR2pJd6GvuyWCu3hMCx7IdHa3UniMyoipLz17Ippsjajyt1eeZSkmmie4rQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762209181; c=relaxed/simple; bh=ucVRbf+wTw4gEeS0lYnYs0f0LoZ0+GbkcH9eR8ZB+hk=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lxmCUeVkNJILkdkF6ZCFA1MLGYXzMfQEQhnpf3hZido+ngIjkO8IyKGucDpdigWL9I4IUHiK2N3cYgE6b6wrqUxj5FpDit2/oakTWvIxjsCrypQo+V/PoOgi7xT2+ayJ91IH9giP6bvlnJglV6ESvr4ok7ZMBHyvjAt749ob6Bg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Uzi+TVBb; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Uzi+TVBb" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-477549b3082so1269175e9.0 for ; Mon, 03 Nov 2025 14:32:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762209178; x=1762813978; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=UC87VmjlqhE8ixV0hmOfrgnisqW5ZkS1j7Z41QROyHU=; b=Uzi+TVBbpCgE3AhJGNuPVIfMCXsn4xCegKq0torOYHJjd+zE6IY0u92cFiyeUo4UH8 ubjG9+v0xo0KVvbrcJJ+K2hHeyi9pw/e7MEukLwwIhhf7i0b4cyDsKgZXuj70qCZoKRh hAdKzUWvbngw7Xq76UzQLShwIjZXYIicq2faY1U+FAe88viQooGMRkCpwhG7QB0zSql5 zhtZdc/MBqO1MJhV37yVvUN8nkpubPCWwzpa2DJOOjN8uZ2eroenGr9yuJ517pCJPko0 lpH30OsJnAZIo4rFjSyGqbePPpYXB0McGzZtvZZpyTFQUX1/8MiaIaNcCoC8RmwJVVbh V3Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762209178; x=1762813978; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UC87VmjlqhE8ixV0hmOfrgnisqW5ZkS1j7Z41QROyHU=; b=lye+iXSmO0YTbOK7qpqwkvktc1WwrKUhWiRr7MhhqcDS9iiQcEiriC1yVYwUuOD+i8 0OR8N+6Cj53L47FUo3OzMT6RApvaeQvhFVeNEqoEh3kajDOGBRe5O/SfbNXONnbLcvSr sCscY3Us2Myg0wqApv5VPUY21Sl3woRtkGc/dNV40RmUM6OjG/mtXPZqh7tNXhBdTmSR W6thhWhybomKDh1tXhs2UcJEefVSYoeRfWNubESRaUYuSVxmqx7jAOJ8bLMszXZbxY9S hnp8P/BYG62FFHwxkMGyVZBpuT0CfrQNLv3cCHxL0VNC4XcyyYm1GLlcsK0zjU2puk6K aySQ== X-Forwarded-Encrypted: i=1; AJvYcCWf6xrMQ3acdt0MFR9Q8vkVaW6DyGASl9TGQE1Me0AK16b6A4CFIBOnAh/bAMWE9Y5W3DqS1WEEfJbx@vger.kernel.org X-Gm-Message-State: AOJu0YwTx1/+aFjamwks+r0RHZfDqkEvxv4FIuw0awHr/QVxl53vkR5H HYaywLQn13/vm6iQ/Z4Xllhj93mDQS/vof8EPEa/45UINkIgppBdehoW X-Gm-Gg: ASbGnct2+D0ePKCzsVJQfNYfNPYu/wqex+4v0cgUGiJJvxUC8OUcCtqm8wYgKmZdlDD NYI02fKF2JM5+Q8hcmCHwjHV21rA1mrkBklLwBqs1ABtTRrotgpSRwj3Eb9txO130gE5usi8QMZ 5aZUzE9HbTjCgrBHv3uKqUhBjEu8ot5OB6EXeTpaPYEWxhXH81yoT+7mJALPfd09ULSfi9c55I9 onU3ve47OfdxXHMEsSRvDDflFnheVX2e8HvIdR4CEDFFsKJJfpiq+FaMjvMWd10dCH4Yu6xeirV 79HRYDSkqNWxRkuGnbj2ONR38j7BM5sbwmycy/ZMPAtDZaveJFSb2KRY9dW1ZpcFT1GbTR8Av9m iOnKlziCMHwXKIce7WmjxwZxVDmHT3c1x5vphSYYGZN131N+FjINp4CU5yvYCtw/WAQBc6e+46N kYg/EZpFaXe8rQNidGdS1DIgg98LlSH0s5JVlA/lnUhQ== X-Google-Smtp-Source: AGHT+IFfkjzMjTqHnS48aZjcHtd5R1GU/wOXp/DRSahKGZnuUsfaydy8LykadRRj1SHbjISGDLOeSg== X-Received: by 2002:a5d:5f95:0:b0:429:b7cd:47ff with SMTP id ffacd0b85a97d-429bd6a8e04mr12790816f8f.40.1762209177618; Mon, 03 Nov 2025 14:32:57 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429dc1a8528sm1151043f8f.21.2025.11.03.14.32.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Nov 2025 14:32:57 -0800 (PST) Date: Mon, 3 Nov 2025 22:32:55 +0000 From: David Laight To: Andy Shevchenko Cc: Kuan-Wei Chiu , Guan-Chun Wu <409411716@gms.tku.edu.tw>, Andrew Morton , ebiggers@kernel.org, tytso@mit.edu, jaegeuk@kernel.org, xiubli@redhat.com, idryomov@gmail.com, kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, sagi@grimberg.me, home7438072@gmail.com, linux-nvme@lists.infradead.org, linux-fscrypt@vger.kernel.org, ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 0/6] lib/base64: add generic encoder/decoder, migrate users Message-ID: <20251103223255.3de9f9d7@pumpkin> In-Reply-To: References: <20251029101725.541758-1-409411716@gms.tku.edu.tw> <20251031210947.1d2b028da88ef526aebd890d@linux-foundation.org> <20251103132213.5feb4586@pumpkin> <20251103192908.1d716a7b@pumpkin> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 3 Nov 2025 21:37:17 +0200 Andy Shevchenko wrote: > On Mon, Nov 03, 2025 at 07:29:08PM +0000, David Laight wrote: > > On Mon, 3 Nov 2025 20:16:46 +0200 > > Andy Shevchenko wrote: > > > On Mon, Nov 03, 2025 at 04:41:41PM +0200, Andy Shevchenko wrote: > > > > On Mon, Nov 03, 2025 at 01:22:13PM +0000, David Laight wrote: > > ... > > > > > Pragma will be hated. > > > > They have been used in a few other places. > > and to disable more 'useful' warnings. > > You can go with pragma, but even though it just hides the potential issues. > Not my choice. In this case you really want the version that has '[ 0 .. 255 ] = -1,', everything else is unreadable and difficult to easily verify. > > > > > I believe there is a better way to do what you want. Let me cook a PoC. > > > > > > I tried locally several approaches and the best I can come up with is the pre-generated > > > (via Python script) pieces of C code that we can copy'n'paste instead of that shortened > > > form. So basically having a full 256 tables in the code is my suggestion to fix the build > > > issue. Alternatively we can generate that at run-time (on the first run) in > > > the similar way how prime_numbers.c does. The downside of such an approach is loosing > > > the const specifier, which I consider kinda important. > > > > > > Btw, in the future here might be also the side-channel attack concerns appear, which would > > > require to reconsider the whole algo to get it constant-time execution. > > > > The array lookup version is 'reasonably' time constant. > > The array doesn't fit the cacheline. Ignoring all the error characters it is 2 (64 byte) cache lines (if aligned on a 32 byte boundary). They'll both be resident for any sane input, I doubt an attacker can determine when the second one is loaded. In any case you can load both at the start just to make sure. > > > One option is to offset all the array entries by 1 and subtract 1 after reading the entry. > > Yes, I was thinking of it, but found a bit weird. > > > That means that the 'error' characters have zero in the array (not -1). > > At least the compiler won't error that! > > The extra 'subtract 1' is probably just measurable. > > > But I'd consider raising a bug on gcc :-) > > And clang? :-) clang is probably easier to get fixed. The warning can be disabled for 'old' compilers - only one build 'tool' needs to detect errors. One solution is to disable the warnings in the compilers, but get sparse (which I think is easier to change?) to do a sane check that allows the entire array to default to non-zero while still checking for other errors. > > One of the uses of ranged designated initialisers for arrays is to change the > > default value - as been done here. > > It shouldn't cause a warning. > > This is prone to mistakes when it's not the default rewrite. I fixed already > twice such an issue in drivers/hid in the past few months. I was thinking that if the first initialiser is [ low ... high ] = value then it should be valid to change any value. I'm not sure what you fixed, clearly [ 4 ] = 5, [ 4 ] = 6, is an error, but it might be sane to allow any update of a 'range' initialiser. David