Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3931387imm; Mon, 4 Jun 2018 11:40:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKwQyAUfuFCWTfEHBjS5d8RNNt78anHzuTI5IoHsfD13Fgi0ASMe6LVnY0uxUuKqR0IxSem X-Received: by 2002:a17:902:b683:: with SMTP id c3-v6mr22978687pls.158.1528137641123; Mon, 04 Jun 2018 11:40:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528137641; cv=none; d=google.com; s=arc-20160816; b=ZWnr2zCqlQntP46TpyZrH8aJ37+34lcNP1uUjn4l/ZJp7Iz/kSQnOie/VOhYL6KeZH 19eh1FO06j3clqM4Kk07FXiEEyjxeH4P5vjJWVlK+O/RrSqCvkwsXTxc1O6YPE0gJ0fs 2ZZSaZjCXBSf3KxrecZY6PkSv5e1mZeV1Vj6K5VueYWNVc6S53cIssgk0ZVLm9h1eeC7 EQDfBp6iKcs9VH5pBMPNRGgwQoQ6KYQfUy2tDVFTqvrIIKwyJNLxTaKRyUfpAKCyClQB BPy3N2UgtGveB0G4rBHrOao2OqblUSk+1KLnXnqXCRJNQqZRCeFfj1lzKohAOwmRg9vX V2Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=ZjXIxLDUNyxLpxTroyZNwkU1ZQvC0rbILo5Yq9bMBbQ=; b=rTJEIEFvF4woP2yQ5K04AwNd2uc2OqZQJk0WgZbYZj0CPWFiKVHzC/hLg9FtPvx/PC h8RWDP8GK+cJV7z1sc9GMo7DNOd742+Hpylsq+tCxqvy7xBglO4E5ptiEqtJ6EEDdNk/ FBOC7PF1XVRU1XP3tWMLzyDalrtKArGBS6gqcNCzayLubJBt2iMu9Ssw9e54I1mA7OZb Y2wDFtlu97QOkSTevaKL32hJFmQBAvb1PABdqVSO4oWV/oqNNS5bK+iKncJv1PlkRzN1 hKOPvjwsfsrbd7sZzzz9wWMiAVuatWXVXeZ6Swxzhrr/Kp2V5a3dgR2wy4EWf5q0hGfM NJ+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=StMe89eX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14-v6si21028111pgw.478.2018.06.04.11.40.26; Mon, 04 Jun 2018 11:40:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=StMe89eX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751230AbeFDSjx (ORCPT + 99 others); Mon, 4 Jun 2018 14:39:53 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:35140 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751086AbeFDSjw (ORCPT ); Mon, 4 Jun 2018 14:39:52 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w54IaW5X030199; Mon, 4 Jun 2018 18:39:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=ZjXIxLDUNyxLpxTroyZNwkU1ZQvC0rbILo5Yq9bMBbQ=; b=StMe89eX3Ra9RBPIgF6eVZ7Dp0yvVRBi+zJAdvGBxHhORO8dFoMua9VZdlm7Q0uedxAN 9BaTClpSJhZhlQW0R1x8qE8jyIedBxsW3HDP1rIwdLDDVxIGHYNmUwAQjaq05b5wiJVl o8O9/tVzhpX0T/N0x5laQ8AQ/BVVUblDYvJa89avgZTPpQL7JTHZfavoMxoEQAq5kC+B A9V0g8Y35y88nMULBxQiSVwRoeauqXiMhCPLu7xvCznEmkPWXWxmdH/IjhNewTK6/lDB SzfTvRcgTuYHD8HeitHwCYg1eTRSjxwGX07z5xmhQTIXpkNusvhKqnK83PBddUyv6JqV Og== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2jbvynvsd9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Jun 2018 18:39:39 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w54IddIj028880 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 Jun 2018 18:39:39 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w54IdcLp003637; Mon, 4 Jun 2018 18:39:38 GMT Received: from [192.168.1.93] (/99.156.91.244) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 04 Jun 2018 11:39:38 -0700 Subject: Re: Slab out of bounds in setxattr To: shankarapailoor Cc: jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <2f2047ca-a96f-91da-c746-530c7b8d1bbf@oracle.com> From: Dave Kleikamp Openpgp: preference=signencrypt Message-ID: Date: Mon, 4 Jun 2018 13:39:37 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8914 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=924 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806040214 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/04/2018 01:30 PM, shankarapailoor wrote: > Hi Dave, > > Attached is my proposed patch. It solves the problem as you suggest > and I don't see the KASAN complaint. That looks good to me. Add a description and a Signed-off-by: and I'll get it pushed upstream. Thanks for finding this. Shaggy > > Regards, > Shankara > > On Mon, Jun 4, 2018 at 11:24 AM, Dave Kleikamp wrote: >> On 06/01/2018 11:06 PM, shankarapailoor wrote: >>> Hi, >>> >>> Looking at the crash some more, it seems that if value_len > PAGE_SIZE >>> then e_buf->max_size is rounded up nearest page size [1]. If a new >>> attribute is added with value_len < e_buf->max_size - EA_SIZE(ea) then >>> no new space is allocated for the attiribute list [2] and this >>> triggers the KASAN slab out of bounds error. This is the case in the C >>> repro I provided. >> >> I see the problem. It looks like we should be calculating max_size >> earlier and using that to call kmalloc(). (xattr.c#496) >> >> Shaggy >>> >>> >>> 1. https://elixir.bootlin.com/linux/v4.17-rc7/source/fs/jfs/xattr.c#L501 >>> 2. https://elixir.bootlin.com/linux/v4.17-rc7/source/fs/jfs/xattr.c#L723 >>> >>> On Fri, Jun 1, 2018 at 1:52 PM, shankarapailoor >>> wrote: >>>> Hi Dave et al, >>>> >>>> I have been fuzzing linux 4.17-rc4 with JFS using Syzkaller KASAN: >>>> slab-out-of-bounds in jfs_xattr. >>>> >>>> Attached are my kernel configs and a C reproducer. In the first >>>> setxattr call it appears that length is much larger than the name. In >>>> __jfs_setxattr, I don't see where the length is checked against the >>>> actual value length. >>>> >>>> Regards, >>>> Shankara Pailoor