Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp82829imm; Mon, 4 Jun 2018 13:26:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLguSpvYkDnqtD3SFnjS6bSOIvpn/Qs1pNDF2n+uFbcwbla0c51/gi5NbZN0u/70F8HZ8kW X-Received: by 2002:a65:47c8:: with SMTP id f8-v6mr18356665pgs.430.1528144016936; Mon, 04 Jun 2018 13:26:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528144016; cv=none; d=google.com; s=arc-20160816; b=Cl8dCOJuvYlCSQkLygZtzBsBIkMp/t8dXNyE9mb+cIM9M2w56XL7e2vl6dAX9NuIg6 cYyuj9rSh2WKAe7g7MOKLNROn0Ck4OroEXSJYbSIQumqv5fsgI2XOmT3qAsAlhQOviGd CniB1mnlj8Ath/TpHar11eAzD6Xjof1q0L6z3KFPOLZ3Q6McdkbUSK20BkRntea3hiC9 V/XfvEHJNc+RSKup7QG1Gj34A4aZ0+PHeLU9/ZC0VteF8r2I3t423kJzfMlIOqnZEA+I Ieawo5IflCccQHRbLYR6DgDKH+2X4i9K2B4Tajaq6SN20iUNNrsUAvJpUcEyVwfNn7aJ 4z8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=bJj6xtkCrzDa2RJMInON2zClAc+1kflPFUeRI/oimg0=; b=YIQWwV1n/XWqtKIq+ds3OCbZ5wds5gIut7UI7JW6/0RYFyqSmDU/pV88diO7eHizRz x65q+vC8Jh9TsmPKzOGyA9LEUTHzfXcqce79wj8tkw66OuKAJUBHNXtjWq6xoF9RNraC dZgGjtnTnaM20CGB1RH45JDqLOwYVSjD/AHj8rXFeyN0TRZQ6TIYwGxA5aStGq1Dw4JT e2E5Zu1w9iQHJssFWI0UqgL6DHDgI6FMwPR8+NLGFDv1Aj9x5MaT+RzTjphloaqA2pId BZj++oQj+zpdoe7svHOBT7cA2WlDYTsIYc+V1DV8VQzx1G4qZ1NlkAzLTPHAyV6ZdzzA 0l0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KsYV3R16; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1-v6si38009162pgr.681.2018.06.04.13.26.41; Mon, 04 Jun 2018 13:26:56 -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=@gmail.com header.s=20161025 header.b=KsYV3R16; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751305AbeFDUZK (ORCPT + 99 others); Mon, 4 Jun 2018 16:25:10 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:37678 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751203AbeFDUZI (ORCPT ); Mon, 4 Jun 2018 16:25:08 -0400 Received: by mail-lf0-f68.google.com with SMTP id r2-v6so27233820lff.4 for ; Mon, 04 Jun 2018 13:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=bJj6xtkCrzDa2RJMInON2zClAc+1kflPFUeRI/oimg0=; b=KsYV3R16/ZGW+96mV+qtmzp+X94IADhrzyoI3jm7LjnZfrMugwUmrzxpIMzVj1II1F ShCwXYE3R03Ztg4phXHf2hcx0tx1zwJBhgHxn4oBW+g6fvAcIxRWazbeR50JLx7Jny0h lGLpUIyEpNiWgsLvLQmS5pFD4WnBXYtHhjW8vVTT3XJJWxxTJF8B7ylawb1nf3cCbkjP IwmazgS33m7TuyhHoRUp7ZbVGzVs9Ai6uywouB6j+nJRb7VIK434xEi9shTkZi5YVo1Q vjrR4rDqqNH8vtD2kCgXAvG8ESIc/QAQrliL7ib+dklq6s0WX4uNmfTDw9MpziVOvnpJ PebA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=bJj6xtkCrzDa2RJMInON2zClAc+1kflPFUeRI/oimg0=; b=lkEuIOsuPl4gh+xVhxd7+f20TobCZammFPGwClH6PcgR6N/WfXZYO4YQ0nnpoTXyYk j38c4LhwUCpeFZtOTcUjvqvcLTN27HRcFrHaaxtsOEpGei7HWclq0dsKittydH/SJMIx JTjtKHd03We67OQ/c2hlfI4iCV1XH4SqZqR6Qttd3F4dr0Bs378hPr2/NpYbk4XP4UbF j4XyPpP5zs5OSFdwU1sTDBZb6UXsjHZN2U5vXwjmcEecBVe582Thh6sJNeKCkD6wX85T +JMVNWE2U7SeCgrAQN3zMKtkOAn6mgfBkhYK27jEpe75h8f7eBzNhMfc/Pp+ElTOd4OT J/sA== X-Gm-Message-State: ALKqPwfhvJZoU9zlf/wijXDYnHnFaC50hfHWKffVSzpBlDk/6BpmmZPA cpU8YIBxni7NmjXbfTCGZRO61oAm90mCONrmfAI= X-Received: by 2002:a2e:163:: with SMTP id 96-v6mr9976404ljb.8.1528143907278; Mon, 04 Jun 2018 13:25:07 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:5119:0:0:0:0:0 with HTTP; Mon, 4 Jun 2018 13:25:06 -0700 (PDT) In-Reply-To: References: <2f2047ca-a96f-91da-c746-530c7b8d1bbf@oracle.com> From: shankarapailoor Date: Mon, 4 Jun 2018 13:25:06 -0700 Message-ID: Subject: Re: Slab out of bounds in setxattr To: Dave Kleikamp Cc: jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org Content-Type: multipart/mixed; boundary="000000000000c27431056dd6ba80" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000c27431056dd6ba80 Content-Type: text/plain; charset="UTF-8" Sorry, Sent the same thing twice. Here is the updated one. On Mon, Jun 4, 2018 at 1:22 PM, shankarapailoor wrote: > Hi Dave, > > I've updated the patch accordingly. > > Regards, > Shankara > > On Mon, Jun 4, 2018 at 11:39 AM, Dave Kleikamp wrote: >> 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 > > > > -- > Regards, > Shankara Pailoor -- Regards, Shankara Pailoor --000000000000c27431056dd6ba80 Content-Type: application/octet-stream; name=jfspatch Content-Disposition: attachment; filename=jfspatch Content-Transfer-Encoding: base64 X-Attachment-Id: f_ji0pf7181 RnJvbSAzOGQyZmM3Y2I4ZjRiMzNmYmE0OTJjYTk1NmMxYjJiZThhNzk2YTg1IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBTaGFua2FyYSBQYWlsb29yIDxzaGFua2FyYXBhaWxvb3JAZ21h aWwuY29tPgpEYXRlOiBNb24sIDQgSnVuIDIwMTggMTk6NTc6MTUgKzAwMDAKU3ViamVjdDogW1BB VENIXSBfX2pmc19zZXR4YXR0cjogY2hhbmdlIGVhX2dldCB0byBhbGxvY2F0ZSBlYV9idWYtPnhh dHRyIHdpdGggdGhlIHNhbWUgc2l6ZSBhcyBlYV9idWYtPm1heF9zaXplClNpZ25lZC1vZmYtYnk6 IFNoYW5rYXJhIFBhaWxvb3IgPHNoYW5rYXJhcGFpbG9vckBnbWFpbC5jb20+Ci0tLQogZnMvamZz L3hhdHRyLmMgfCA4ICsrKystLS0tCiAxIGZpbGUgY2hhbmdlZCwgNCBpbnNlcnRpb25zKCspLCA0 IGRlbGV0aW9ucygtKQpkaWZmIC0tZ2l0IGEvZnMvamZzL3hhdHRyLmMgYi9mcy9qZnMveGF0dHIu YwppbmRleCBjNjBmM2QzLi45NmI5MzU1IDEwMDY0NAotLS0gYS9mcy9qZnMveGF0dHIuYworKysg Yi9mcy9qZnMveGF0dHIuYwpAQCAtNDkzLDE0ICs0OTMsMTQgQEAgc3RhdGljIGludCBlYV9nZXQo c3RydWN0IGlub2RlICppbm9kZSwgc3RydWN0IGVhX2J1ZmZlciAqZWFfYnVmLCBpbnQgbWluX3Np emUpCiAgICAgICAgICAgICAgICAgKiBUbyBrZWVwIHRoZSByZXN0IG9mIHRoZSBjb2RlIHNpbXBs ZS4gIEFsbG9jYXRlIGEKICAgICAgICAgICAgICAgICAqIGNvbnRpZ3VvdXMgYnVmZmVyIHRvIHdv cmsgd2l0aAogICAgICAgICAgICAgICAgICovCi0gICAgICAgICAgICAgICBlYV9idWYtPnhhdHRy ID0ga21hbGxvYyhzaXplLCBHRlBfS0VSTkVMKTsKLSAgICAgICAgICAgICAgIGlmIChlYV9idWYt PnhhdHRyID09IE5VTEwpCi0gICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAtRU5PTUVNOwot CiAgICAgICAgICAgICAgICBlYV9idWYtPmZsYWcgPSBFQV9NQUxMT0M7CiAgICAgICAgICAgICAg ICBlYV9idWYtPm1heF9zaXplID0gKHNpemUgKyBzYi0+c19ibG9ja3NpemUgLSAxKSAmCiAgICAg ICAgICAgICAgICAgICAgfihzYi0+c19ibG9ja3NpemUgLSAxKTsKKyAgICAgICAgICAgICAgIGVh X2J1Zi0+eGF0dHIgPSBrbWFsbG9jKGVhX2J1Zi0+bWF4X3NpemUsIEdGUF9LRVJORUwpOworICAg ICAgICAgICAgICAgaWYgKGVhX2J1Zi0+eGF0dHIgPT0gTlVMTCkKKyAgICAgICAgICAgICAgICAg ICAgICAgcmV0dXJuIC1FTk9NRU07CisKICAgICAgICAgICAgICAgIGlmIChlYV9zaXplID09IDAp CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAwOwo= --000000000000c27431056dd6ba80--