From patchwork Wed Dec 28 14:36:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 13083027 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5B59C3DA7A for ; Wed, 28 Dec 2022 16:10:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233113AbiL1QKj (ORCPT ); Wed, 28 Dec 2022 11:10:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234562AbiL1QKG (ORCPT ); Wed, 28 Dec 2022 11:10:06 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F339819C1D; Wed, 28 Dec 2022 08:08:53 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 03210B8188A; Wed, 28 Dec 2022 16:08:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5067DC433D2; Wed, 28 Dec 2022 16:08:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672243728; bh=89yh0HvrDlc+OVz/weFWInUj5yVz0H0HLe1LttMG5lc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JqT5BKJh2uuotPvxil3PCVnzn32nnNl0OO7uFb16aIY0LRdcqGNMz6ztC++EBbBxS QLAM8Sw1XuPhdDV7P/T13kpg5V1TiUadZBHav2TcJvL0oHcYEvGF1w7sqe7CFYf+sf ynPIIHngr1B/IWrCGWoo5BDXmQurQkIqo+FEMOko= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Linus Torvalds , linux-hardening@vger.kernel.org, Kees Cook , Sasha Levin Subject: [PATCH 6.0 0578/1073] fortify: Do not cast to "unsigned char" Date: Wed, 28 Dec 2022 15:36:06 +0100 Message-Id: <20221228144343.750024317@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144328.162723588@linuxfoundation.org> References: <20221228144328.162723588@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org From: Kees Cook [ Upstream commit e9a40e1585d792751d3a122392695e5a53032809 ] Do not cast to "unsigned char", as this needlessly creates type problems when attempting builds without -Wno-pointer-sign[1]. The intent of the cast is to drop possible "const" types. [1] https://lore.kernel.org/lkml/CAHk-=wgz3Uba8w7kdXhsqR1qvfemYL+OFQdefJnkeqXG8qZ_pA@mail.gmail.com/ Suggested-by: Linus Torvalds Fixes: 3009f891bb9f ("fortify: Allow strlen() and strnlen() to pass compile-time known lengths") Cc: linux-hardening@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: Sasha Levin --- include/linux/fortify-string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/fortify-string.h b/include/linux/fortify-string.h index ae076aae9e66..c26160fe2e34 100644 --- a/include/linux/fortify-string.h +++ b/include/linux/fortify-string.h @@ -17,7 +17,7 @@ void __write_overflow_field(size_t avail, size_t wanted) __compiletime_warning(" #define __compiletime_strlen(p) \ ({ \ - unsigned char *__p = (unsigned char *)(p); \ + char *__p = (char *)(p); \ size_t __ret = SIZE_MAX; \ size_t __p_size = __builtin_object_size(p, 1); \ if (__p_size != SIZE_MAX && \