Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp335898pxb; Thu, 5 Nov 2020 01:01:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6JH4rqbtokUz3PjY2Uan7iBCoRFPQip3P0r0wEu7OOHrzeDrEj0SjFoEn/3qtxkVj8uG3 X-Received: by 2002:a17:906:c352:: with SMTP id ci18mr1380575ejb.182.1604566915321; Thu, 05 Nov 2020 01:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604566915; cv=none; d=google.com; s=arc-20160816; b=ec6qBrIVSQqggRtzbipcAEByWOSoPZ/D84W+wacnS5ec3FNxHLJrJ8+lChgrQyt4ib NrNdBWv8/CZ0xU1+Q2lMk7c/lgwNMrD1S80WyS1c4oA0k4FBnmjYsaXb6KxMMLiseA++ Tu4BFvg5L2kY10GS9by3HvMWozixiE4Qh7xb3GZvfFrfEsL8XefQ4Q8c5nWOnfaF5gFd 7nAuHA3ijiNWJz1IRPSamF6xXV478BbPbysZmf4tTwHoYu0csXzpElgLndJxgWKqUiHw EbO9Q/JIt8yazAtdJ3/l9oF25F7FjDq+QWhXGsz31ZO6IFej2mZfiIwKwElS7BkagKAS DPMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=iMJ7D9bU9uTMZMaTx6oqjpTFJhcqALM26T/AVDqd3ZI=; b=wE+9OUx3A4SkXXcfuMlG76zcGCXi3AguOy/0VnC9VLhhzXmE+60bS6BkxZDVtcp6gv O7hse03m8YQohYRyo4lAz7CLydJoeJjo2z7Dy2SMkI29K41GIvUv/F7ku9VqX6sIUZCb zFfopBHk+uEflhDjiqsZYPytpFU8B8qvMIacM11M2M1ZuBASTfezi6K4FYbZum3hBeKx 34xSRBKGcIzjb3kdfn5OSsdM0A8VKzAW76YbtJ13izbnQPZ5JrTgcFszkmGdhdizBJJi KG+PuPfnwQ++19WZxmAXZetK5nsO06U8vRXDC+xAma2OwTKkXoMpYxOib/Amg+TQLEaI I2rQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t14si668523ejy.440.2020.11.05.01.01.32; Thu, 05 Nov 2020 01:01:55 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730209AbgKEJAG convert rfc822-to-8bit (ORCPT + 99 others); Thu, 5 Nov 2020 04:00:06 -0500 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:47325 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729263AbgKEJAG (ORCPT ); Thu, 5 Nov 2020 04:00:06 -0500 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-231-8UX6HNYcNJS69Go7Z9G_5w-1; Thu, 05 Nov 2020 09:00:01 +0000 X-MC-Unique: 8UX6HNYcNJS69Go7Z9G_5w-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 5 Nov 2020 09:00:00 +0000 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 5 Nov 2020 09:00:00 +0000 From: David Laight To: 'Daniel Xu' , "bpf@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "ast@kernel.org" , "daniel@iogearbox.net" CC: "kernel-team@fb.com" Subject: RE: [PATCH bpf v2 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator Thread-Topic: [PATCH bpf v2 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator Thread-Index: AQHWsxsIE6fPG3mijk+FzhsUr3fzDam5OvTg Date: Thu, 5 Nov 2020 09:00:00 +0000 Message-ID: References: <487a07aa911b4e822a0b931f7b33a4f67fedb6bd.1604542786.git.dxu@dxuuu.xyz> In-Reply-To: <487a07aa911b4e822a0b931f7b33a4f67fedb6bd.1604542786.git.dxu@dxuuu.xyz> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Xu > Sent: 05 November 2020 02:26 ... > --- a/lib/strncpy_from_user.c > +++ b/lib/strncpy_from_user.c > @@ -35,17 +35,22 @@ static inline long do_strncpy_from_user(char *dst, const char __user *src, > goto byte_at_a_time; > > while (max >= sizeof(unsigned long)) { > - unsigned long c, data; > + unsigned long c, data, mask, *out; > > /* Fall back to byte-at-a-time if we get a page fault */ > unsafe_get_user(c, (unsigned long __user *)(src+res), byte_at_a_time); It's not related to this change, but since both addresses are aligned (checked earlier) a page fault on the word read is fatal. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)