From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 22E4E3BA241 for ; Wed, 26 Aug 2026 09:58:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787738318; cv=none; b=t7tVk4+4u682tMGUfuNeaEvqgopIhTkMFY5L1SjFthJW+umbIsKtdhLU33/uh9S1FsZzlKM3ivVxbs2lZQ5T8quy526eXJ+yr9IQwRyWactlEju90Rv7c44Xm3Csbavd0y6Mer0TuLcYQcvJXD8xnBtoMq5os4YURjiqI3NiJKc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787738318; c=relaxed/simple; bh=RDnnCTdjJ6akWeemPqQ3ZjxvzIlCkvD5LwMgsR6vkC4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F+NLbbTKkczhFqCOFe+8d7WWYzvqcv49JFk/dkaqPx7rnk4lv+EPjFu8bk1SVy+Ecok8cMgmkDQS5z2EBAmP839KOm40XkexnQ3QW74yooG5h5THfGHy0aacdpLI7S1E87WweJtn+GPr2XWCtaz9S7yQ7c8mEeIwCKCf+K5goSo= 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=a0uehXIT; arc=none smtp.client-ip=209.85.128.49 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="a0uehXIT" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-49800c6a846so5831955e9.3 for ; Wed, 26 Aug 2026 02:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787738314; x=1788343114; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=UBtoL8qC21Pn7cp31qTduZAok2vQhnrW+dfZVknNCzg=; b=a0uehXITs8eDNL1PzKanYyQIOLfoFriQMhNZ09HukUqYGH8xeQdYsowdkzxPVO1Z5R 5hbEx66RkdaQV/48qGkwlvOWqSDy3io1kklMiRyjn1scFqUAshd86OonWNkKXv/4cWvJ KSI8P+5xa33P58Ant7RZNieOnOpUpYOB7jSwZ7BGrxlogBbN8PV+tYdxb00i2VKpRfDc d5nOQVc7Ixlh/yOnwO2+zHyBCG1OM0lAOzcCdmTnNX30S11l0taVvKKXmu0S6qjnAKeU V1stdRwnim2AG5ydsrIjQlgZIn0uHP5FmPvJue7G+cfH6dicM5CwnXfsT6sMn3qDujVB GRmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787738314; x=1788343114; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=UBtoL8qC21Pn7cp31qTduZAok2vQhnrW+dfZVknNCzg=; b=mr7sMBmSTge0hQiCyLv6YE4dywujFxmispLjqyDOyOCTyu7fgxs/dN3qbcHYPcGaDe bjUXs+pPvBvLsrIsbWYFMcHwiYUezBxP0pjBOU5EaZ1e55mXlobuLS2EnC8NWgnPHPrY f/BkerSiNRdHiM1D3kC5iq3oeYsXLGsnAo7Gka5NjjmnWC7PELb3FdIxzJjWHVyP9Y1H M/9ODWpFj4ro8xN7nuya4R5Bh89poYbKqb7KHnHlaJ/SiEEzo+u9xxCqEplNupqTLHuo K5aiqbJfob3DZpLO5Un9pHnlJDH9ym7O4d1i7jXhY2Z3c08U4JluHYHrbhJXMdAv98yl bEhQ== X-Forwarded-Encrypted: i=1; AHgh+RpQIdwYWEPEIv1ZZU98nibEnD1lJPINTiz9OLq+np/5UPUiXf/Gvj1uc2PyUi5cLIyx55WKiytPSAGRfC0=@vger.kernel.org X-Gm-Message-State: AFuF++mxFrdR+snkUDW3ocTWT+8RXN/osYUtVA4YhsqYw7ZR6pnTu9Ae CqUY2G1HhwEiL2dYVMl58caaCwQtnBhRVxOC54uQ7Hyaqw4cZjMoWmAo X-Gm-Gg: AR+sD12Jb3kG+2RhgLN1K6jPjoLBXCCiaeLRV8nn815b6X+9jZG7umue6kioD/O5hss 3JwU/xkN2wkN8lMR2VZG3u2EeEFRPt9ZJrURjf32cKwlnVeGsh9ZCX6WxfTRnjIKtWhG0YhpUtv E0Uv9kvu6KTsq9njboikDPi3rFrcSsg52oG+D/fJ5u9Dp93OH6tx32KXEcq+Qi4wA1D+Dr8Ll0b TOqs3HSl+aDNUDm0WQnOxLAXIDpG6LOQX/WZun5p0sQ2Bk3GCt3I45xXHnQq4o2zGZ5KnCCQtp5 c1y03RPlEXbpABdQVtv4Uc+tCIPN24FY+Z/G7XCVHZj++eqZF6OPhvBWHmKKDDQWussyYx3OEFq KpHy0r1leoJM7KAn1csUcWzczvwbfnUw0qcbiBWYpy5g9ef+v8gOkVf1Kwoa4dm0tToJ8CUGoN+ wH6SdeSEBtsG8zOeS5Xfg4840IqnzCbZLxTiTMjZW239mn2192ppG+vXicNh1d0gBi5jxFQ+1JT /t5js8Ear0S3THQQ5CF/S90lQ== X-Received: by 2002:a05:600c:c48f:b0:499:dbc0:370d with SMTP id 5b1f17b1804b1-499dc6eaca4mr38562695e9.2.1787738314066; Wed, 26 Aug 2026 02:58:34 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-499dd5721a0sm13428015e9.4.2026.08.26.02.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2026 02:58:33 -0700 (PDT) Date: Wed, 26 Aug 2026 10:58:32 +0100 From: David Laight To: Ricardo Ribalda Cc: Dave Hansen , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Dan Carpenter , rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] x86/uaccess: Fix casting in put_user Message-ID: <20260826105832.7f1a6cc5@pumpkin> In-Reply-To: References: <20260825-unqual-v1-0-7024fb81b4f9@chromium.org> <20260825-unqual-v1-2-7024fb81b4f9@chromium.org> <2a772433-b0b7-44ff-a655-f8c26ee54d0e@intel.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@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 Tue, 25 Aug 2026 23:15:02 +0200 Ricardo Ribalda wrote: > Hi Dave > > On Tue, 25 Aug 2026 at 23:06, Dave Hansen wrote: > > > > On 8/25/26 13:02, Ricardo Ribalda wrote: > > > Recent versions of smatch preserved the address space qualifiers with > > > typeof()[1]. > > > > > > This fix has discovered an invalid casting in put_user. > > > > > > This patch fixes tens of smatch errors like the following: > > > drivers/media/usb/uvc/uvc_v4l2.c:1112:13: warning: incorrect type in argument 2 (different address spaces) > > > drivers/media/usb/uvc/uvc_v4l2.c:1112:13: expected void const *from > > > drivers/media/usb/uvc/uvc_v4l2.c:1112:13: got unsigned int __user * > > > > Could we beef up the changelog here a bit, please? > > > > What _is_ the invalid casting? > > > > What is the fix? > > > > Why does it work? > > Something like this would be better? I will send a v2 if there are no > more comments. > > > Recent versions of smatch preserved the address space qualifiers with > typeof()[1]. > > This fix has discovered an invalid casting in put_user. > > put_user is using a casting with __typeof__(*(ptr)), which keeps the > qualifiers (__user), instead it should use the macro TYPEOF_UNQUAL() > that will use __typeof_unqual__ where the compiler supports it. > __typeof_unqual__ copies the type but not the qualifiers. This is a spares 'bug'. You need to fix it without changing normal compiles. There are enough put_user() calls that is will slow down compiles. David > > > This patch fixes tens of smatch errors like the following: > drivers/media/usb/uvc/uvc_v4l2.c:1112:13: warning: incorrect type in > argument 2 (different address spaces) > drivers/media/usb/uvc/uvc_v4l2.c:1112:13: expected void const *from > drivers/media/usb/uvc/uvc_v4l2.c:1112:13: got unsigned int __user * > > [1] https://github.com/error27/smatch/commit/e53027a4e816a772403baafa83c09e4a94c1cb8f > >