Received: by 2002:aa6:cad3:0:b0:147:287a:cb84 with SMTP id e19csp776981lky; Mon, 27 Sep 2021 02:43:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4qIpgcYGTT5k7NRidaJu8apZ9qw77/OeStVl36u5PRhhYe0SmNRfQhhi/DGzdnzmFWR+b X-Received: by 2002:a17:906:c251:: with SMTP id bl17mr25669573ejb.219.1632735809284; Mon, 27 Sep 2021 02:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632735809; cv=none; d=google.com; s=arc-20160816; b=PaXG4vv9fkb2gd/+rgM3/jEHuL2uQbyq6qSACRgouGXpFCApF30JeU6b7rBycb9Jfe 1mCkKHfym1qQH++lqHYeUmtXJqT1j6pdejBDwaQnex9aIMEdVEtrl17a0nINBfbs97wz rQovisnqHO7gEJxLu0Ajg8kT3sJTNL3dLdfp9f7SUcxRdsmHyG01maLMcdpBa07L1OXC MstJGw7iWS1n/yazogfpV72mVeAiu3CqZ6Cd63RJ+02Tqigw+rGxiVkeMytx04IUlR3+ v48pu2mc6r+umAg8yTaq7lutYS54RAN3sCsIwsBunkPeqDEglC1WAbYvhz870rL3CtsL qN6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SioEFG2nXJQuc0jPSfaiAIuU+IZMKSaskcalW6mdlyA=; b=w7kkHoQDhZeZSNyA4o8wZEZV9eTLFaSMPupiVErJvuIdFi9CCURhcNmr5w1jMZxV1y lQC7ffid51eArZbLM3VaUq48kz8+Th+vPJwgkeEtJ5FHETgNdruLBYIXI/HUOlq+eUF/ Xjyye1+O+o08KMcOzaztzUG7/F0XfDQp2sua9IlPVV/ZuitLagnZaNfgTyLNzccO11sR +4Dq9h8UiW0VWhjt/uWxdci+iStjuDB0ZxGTUCVg1xx4dpkjt3PfxxsWaIVIMobWkE/r 2rRnp9p4aotSbL4RjJ047o4lzIBsrE2TAzTCpyW+lZ92M1AbWEfgOTPGrDWzz4klVHcs IuEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=do7Grx6Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ka17si17945524ejc.609.2021.09.27.02.43.05; Mon, 27 Sep 2021 02:43:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=do7Grx6Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233712AbhI0JnG (ORCPT + 99 others); Mon, 27 Sep 2021 05:43:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:47530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233682AbhI0JnF (ORCPT ); Mon, 27 Sep 2021 05:43:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 79C2460F70; Mon, 27 Sep 2021 09:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632735688; bh=9hhtJVsGexG0XVk3k/pwBPZOJmTujKncE9iL0HXJp30=; h=From:To:Cc:Subject:Date:From; b=do7Grx6Q2G3z3JCOdoY72cgg/pNHi9Hw4uOyOAIVymjxJtguRuFrBjo+9Uc/xi6QH bJG7HYtl+c5EFp2DGkIbb3dLU/HZHp/7hdFk3G674B5sgxMTKEJRZOHHAEWhp4UHqa 45pSzv4j8v3wGo1ookpJs9YjLnph54fHfZK14pI9JwhCItVPyG5WOf+A5mVxqxeMwb HYPsFht2GVeWKjRPDo9AnotnrPrk2EfBviwluHIfbx3c2UHM55s6sFAI89uZtZrOxK XjDiLaINnWPg70jpFsYcIGt+cnKNKw/6T61fCSBXAP1sDkP+6WtS6K9ueqZ7sl2dip RGZyku3YMepOg== From: Arnd Bergmann To: Hans de Goede , Nathan Chancellor , Nick Desaulniers , Al Viro Cc: Arnd Bergmann , Dan Carpenter , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] vboxsf: fix old signature detection Date: Mon, 27 Sep 2021 11:40:58 +0200 Message-Id: <20210927094123.576521-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann The constant-out-of-range check in clang found an actual bug in vboxsf, which leads to the detection of old mount signatures always failing: fs/vboxsf/super.c:394:21: error: result of comparison of constant -3 with expression of type 'unsigned char' is always false [-Werror,-Wtautological-constant-out-of-range-compare] options[3] == VBSF_MOUNT_SIGNATURE_BYTE_3) { ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/vboxsf/super.c:393:21: error: result of comparison of constant -2 with expression of type 'unsigned char' is always false [-Werror,-Wtautological-constant-out-of-range-compare] options[2] == VBSF_MOUNT_SIGNATURE_BYTE_2 && ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/vboxsf/super.c:392:21: error: result of comparison of constant -1 with expression of type 'unsigned char' is always false [-Werror,-Wtautological-constant-out-of-range-compare] options[1] == VBSF_MOUNT_SIGNATURE_BYTE_1 && ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ The problem is that the pointer is of type 'unsigned char' but the constant is a 'char'. My first idea was to change the type of the pointer to 'char *', but I noticed that this was the original code and it got changed after 'smatch' complained about this. I don't know if there is a bug in smatch here, but it sounds to me that clang's warning is correct. Forcing the constants to an unsigned type should make the code behave consistently and avoid the warning on both. Fixes: 9d682ea6bcc7 ("vboxsf: Fix the check for the old binary mount-arguments struct") Cc: Dan Carpenter Signed-off-by: Arnd Bergmann --- fs/vboxsf/super.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/vboxsf/super.c b/fs/vboxsf/super.c index 4f5e59f06284..84e2236021de 100644 --- a/fs/vboxsf/super.c +++ b/fs/vboxsf/super.c @@ -21,10 +21,10 @@ #define VBOXSF_SUPER_MAGIC 0x786f4256 /* 'VBox' little endian */ -#define VBSF_MOUNT_SIGNATURE_BYTE_0 ('\000') -#define VBSF_MOUNT_SIGNATURE_BYTE_1 ('\377') -#define VBSF_MOUNT_SIGNATURE_BYTE_2 ('\376') -#define VBSF_MOUNT_SIGNATURE_BYTE_3 ('\375') +#define VBSF_MOUNT_SIGNATURE_BYTE_0 (u8)('\000') +#define VBSF_MOUNT_SIGNATURE_BYTE_1 (u8)('\377') +#define VBSF_MOUNT_SIGNATURE_BYTE_2 (u8)('\376') +#define VBSF_MOUNT_SIGNATURE_BYTE_3 (u8)('\375') static int follow_symlinks; module_param(follow_symlinks, int, 0444); -- 2.29.2