From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 3BF4F33B946 for ; Fri, 6 Mar 2026 09:25:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772789112; cv=none; b=uyqxKoDDEi1PW6mKsxM2VshQJjjtJ6Qpd49gR7/WIIpxqS8AOZZA2OIWOPA5YjrilRyaXmKReLZdorjaOBqcF/xVN7vhOQ23mS1Kbt/hmGrxG5ojXn6EfmPkvhFRrvUinZql14ihD9ZSdqBXKsSY97gArtRCJRYWRcPUNvkNi9k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772789112; c=relaxed/simple; bh=qc/wfNv2DTKb76yxe5ZyszbHya3/TD9RtaoQuu2WRgc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NSFTPBKqdN0DjxqvmcgD7flZ1xyn0YF6/MuoeJSNZqtHSm6kVsXtqnHXHK3eTyPXl+xs5nJDyoNjsnSpdYZ9XUW2Xd08cZSYbveHDjnF23nBTpicaIBFMfVVLeur+lsy4u2ieiTpYyBckUfvyvUjJBEra0MIqkza0oN7dfXJWh8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=CcUSvrXF; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="CcUSvrXF" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-439a89b6fd0so5660594f8f.2 for ; Fri, 06 Mar 2026 01:25:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1772789109; x=1773393909; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=XpDTsDoV5+2uhsQojcrRuu4Kg/PPqTfqWkMZuczO8W4=; b=CcUSvrXFAK7HclA7+jXVf4Fcublxbzw4DdOxl5IR9RDNTPsDk5EAexqoHyBwS18UUi 0XuerHZ1CcL4KAih76xzpG1TG/C8LHRYhrms/dKV5WimrlNVoDmJiOsYksC2rlWr5tT+ P38Af9uW8msgZtCdndaX64p39fLyjL+5cITU91MAT4/mT3n7XfS5LCm6iZABIh2Q5RD6 40S8WJYMgiRNSEfzCg+MUSa1jLyzVkPTDDi5IHT5/tUrhLTAlHYoHKgWzBIkG+mIvlc8 UMrJbriMBGG6O9kxVM2hfvxIQEYMsxoz1Fr81xh7bcDQpCeauWODafJlBjyjVlWFsfp8 EEXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772789109; x=1773393909; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XpDTsDoV5+2uhsQojcrRuu4Kg/PPqTfqWkMZuczO8W4=; b=VCYTDZwZksRi4cAyrragCfDf5fgTvT9lHbldDic09zdu2/8caI3d+xXEecj+hrUsdz MadVx9LArJMoFvlvFIAZb+GAM4TH0BEaDmAfc+Umg83Lh52E9FQeFelejhnfTSwHLp8u +Cpv5AJW0UaeEfUdUmnh/dIyS5UkWgJlHbknxUN1HHEVgdAqaBJ3O5jS/1reQQKRKJ3+ mc/VlEFsOovvspkeI3ZGuDw3fh0T7Yb348kwUCHpaQcuJMOeuAX4YMSMEBA/Ouk/tCo/ X0N3i4novKhm0F9hqkk+2Oz2knvOu6Ium9XGooQRdTswLAeCtJzcHZtcWE4dZW7/Uj9k jUoQ== X-Forwarded-Encrypted: i=1; AJvYcCUCxvpValIc9zZj5y3G/8EZwCU4AY1Ln+IMm5bxemXPduFR8sUj0QfqvYcS7naE/bvBt4pyoU2nfiLJXpw=@vger.kernel.org X-Gm-Message-State: AOJu0YwJ5+FUV02BV2jLERKg3kP1CqtqxZcjNy+Jy4xfBLVX4Db7gpzg Q37bzfnjKb0A3vOaWlvYQcQNyS8qCXW/HJMcs/Uoji0jrr0pL4BiNZbzG+Sv9kbEBo4= X-Gm-Gg: ATEYQzyCEAhfjjBHv80ORy+i7Jcc1TAgw8rQkRkgJjq0PfISBFeVgQr1G0aD96zvwhW NePqngY6F5KOfkfCy1nNI+mu43wPLLTv9/dDbhaODk2msTP4wBDBwji+38O3PVY+UhwkES+IFzl nn02+KF/gi7tVuzDuUTb/C+zpGkzSAw0doQIMKAyNdT0h5q4MVISsJD3G4eDABKc4xCbd/hkBiG 6DCtd2FghQav4u4E8p+5Dbkk32IY3qaXYZsX4FIj1j4g/sELBKdP8s7MuFts4VX408d8VvMt8NI j7Njcmoa0414NlfcbNSVXWth9EGYifpHAyA6CkLsQtbi7vW+mNL9lH+czDmHYE2WfODqjAB1ivs t2usLvKj1YVSCI6+6Bwd1CfNA+rb0HIoQmbJNc9jXjEJfSy4+ByVTO9pgc+vzQRBiXtUGI3x1+G gSJv6uKdG6MeaQLLEOFugr7y2qTSo4/p4nGtt7zYBHFTOiRsp9LD6F2hKKvoGQrqgX X-Received: by 2002:a05:6000:1846:b0:439:ccd7:cdfb with SMTP id ffacd0b85a97d-439da89f0b4mr2343398f8f.53.1772789109493; Fri, 06 Mar 2026 01:25:09 -0800 (PST) Received: from ?IPV6:2001:a61:1372:501:2753:2852:68b3:61d5? ([2001:a61:1372:501:2753:2852:68b3:61d5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dad8da01sm2796386f8f.1.2026.03.06.01.25.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Mar 2026 01:25:09 -0800 (PST) Message-ID: <6c70210c-e437-420e-a1ee-fab44622aea3@suse.com> Date: Fri, 6 Mar 2026 10:25:07 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [BUG] usb: cdc-wdm: Missing barriers in ad-hoc lockless buffer To: Gui-Dong Han Cc: Greg KH , robert.hodaszi@digi.com, kees@kernel.org, linux-usb@vger.kernel.org, LKML , Jia-Ju Bai References: <678e1fc6-356d-426a-aec0-f0bf46c7d3af@suse.com> Content-Language: en-US From: Oliver Neukum In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 05.03.26 14:26, Gui-Dong Han wrote: Hi, > Based on my shallow understanding, reordering issues typically happen > between different memory addresses, not within the same one. Nevertheless, you've found the issue, hence I will ask you :-) Is that something we can depend on or is that just how it works on the architectures we are currently running on? If I go to the effort of checking for reordering effects, I want to do it right in all cases. > The real danger of weak memory architectures lies in accessing > associated variables. For instance, if we write 1 to int a and then 2 > to int b, another CPU might observe b == 2 before a == 1. This is > exactly the situation I pointed out in my original report regarding > the lack of barriers between desc->ubuf and desc->length. Yes. Hence I was looking. The results of a completed IO can be a) data b) an error c) a buffer overflow thus there must be ordering between recording any of these results and changing WDM_READ, right? > Honestly, lockless algorithm design is incredibly hard, which is why > drivers should probably just rely on well-tested libraries instead of > rolling their own. I am definitely no expert in this dark art, just > know enough to be dangerous :) I agree. The issue is that lockless IO is also error handling, not just the buffer. Regards Oliver